Mercurial > mplayer.hg
annotate libmpdemux/cdda.c @ 18540:fb07cde79487
only include sys/mman.h if HAVE_SYS_MMAN_H is defined
author | ivo |
---|---|
date | Thu, 18 May 2006 09:21:45 +0000 |
parents | 4231482179b6 |
children | d2d9d011203f |
rev | line source |
---|---|
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
1 #include "config.h" |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
2 |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
3 #ifdef HAVE_CDDA |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
4 |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
5 #include "stream.h" |
17012 | 6 #include "m_option.h" |
7 #include "m_struct.h" | |
8 #include "bswap.h" | |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
9 |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
10 #include <stdio.h> |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
11 #include <stdlib.h> |
9801 | 12 #include "demuxer.h" |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
13 |
6696 | 14 #include "cdd.h" |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
15 |
16967
32e2c59c8e86
[TRIVIAL] More translatables to help_mp and printfs to mp_msg on libmpdemux
reynaldo
parents:
16940
diff
changeset
|
16 #include "mp_msg.h" |
32e2c59c8e86
[TRIVIAL] More translatables to help_mp and printfs to mp_msg on libmpdemux
reynaldo
parents:
16940
diff
changeset
|
17 #include "help_mp.h" |
32e2c59c8e86
[TRIVIAL] More translatables to help_mp and printfs to mp_msg on libmpdemux
reynaldo
parents:
16940
diff
changeset
|
18 |
16940 | 19 #ifndef CD_FRAMESIZE_RAW |
20 #define CD_FRAMESIZE_RAW CDIO_CD_FRAMESIZE_RAW | |
21 #endif | |
22 | |
23 | |
10591 | 24 extern char *cdrom_device; |
25 | |
9801 | 26 static struct cdda_params { |
27 int speed; | |
28 int paranoia_mode; | |
29 char* generic_dev; | |
30 int sector_size; | |
31 int search_overlap; | |
32 int toc_bias; | |
33 int toc_offset; | |
34 int no_skip; | |
35 char* device; | |
36 m_span_t span; | |
37 } cdda_dflts = { | |
38 -1, | |
16914
701af802aee7
set cdda paranoia default to 0 since e.g. cdda://2 breaks otherwise.
reimar
parents:
16635
diff
changeset
|
39 0, |
9801 | 40 NULL, |
41 0, | |
42 -1, | |
43 0, | |
44 0, | |
45 0, | |
10591 | 46 NULL, |
9801 | 47 { 0, 0 } |
48 }; | |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
49 |
9801 | 50 #define ST_OFF(f) M_ST_OFF(struct cdda_params,f) |
51 m_option_t cdda_params_fields[] = { | |
52 { "speed", ST_OFF(speed), CONF_TYPE_INT, M_OPT_RANGE,1,100, NULL }, | |
53 { "paranoia", ST_OFF(paranoia_mode), CONF_TYPE_INT,M_OPT_RANGE, 0, 2, NULL }, | |
54 { "generic-dev", ST_OFF(generic_dev), CONF_TYPE_STRING, 0, 0, 0, NULL }, | |
55 { "sector-size", ST_OFF(sector_size), CONF_TYPE_INT, M_OPT_RANGE,1,100, NULL }, | |
56 { "overlap", ST_OFF(search_overlap), CONF_TYPE_INT, M_OPT_RANGE,0,75, NULL }, | |
57 { "toc-bias", ST_OFF(toc_bias), CONF_TYPE_INT, 0, 0, 0, NULL }, | |
58 { "toc-offset", ST_OFF(toc_offset), CONF_TYPE_INT, 0, 0, 0, NULL }, | |
59 { "noskip", ST_OFF(no_skip), CONF_TYPE_FLAG, 0 , 0, 1, NULL }, | |
60 { "skip", ST_OFF(no_skip), CONF_TYPE_FLAG, 0 , 1, 0, NULL }, | |
61 { "device", ST_OFF(device), CONF_TYPE_STRING, 0, 0, 0, NULL }, | |
62 { "span", ST_OFF(span), CONF_TYPE_OBJ_PARAMS, 0, 0, 0, &m_span_params_def }, | |
63 /// For url parsing | |
64 { "hostname", ST_OFF(span), CONF_TYPE_OBJ_PARAMS, 0, 0, 0, &m_span_params_def }, | |
65 { "port", ST_OFF(speed), CONF_TYPE_INT, M_OPT_RANGE,1,100, NULL }, | |
66 { "filename", ST_OFF(device), CONF_TYPE_STRING, 0, 0, 0, NULL }, | |
67 {NULL, NULL, 0, 0, 0, 0, NULL} | |
68 }; | |
69 static struct m_struct_st stream_opts = { | |
70 "cdda", | |
71 sizeof(struct cdda_params), | |
72 &cdda_dflts, | |
73 cdda_params_fields | |
74 }; | |
75 | |
76 /// We keep these options but now they set the defaults | |
77 m_option_t cdda_opts[] = { | |
78 { "speed", &cdda_dflts.speed, CONF_TYPE_INT, M_OPT_RANGE,1,100, NULL }, | |
79 { "paranoia", &cdda_dflts.paranoia_mode, CONF_TYPE_INT,M_OPT_RANGE, 0, 2, NULL }, | |
80 { "generic-dev", &cdda_dflts.generic_dev, CONF_TYPE_STRING, 0, 0, 0, NULL }, | |
81 { "sector-size", &cdda_dflts.sector_size, CONF_TYPE_INT, M_OPT_RANGE,1,100, NULL }, | |
82 { "overlap", &cdda_dflts.search_overlap, CONF_TYPE_INT, M_OPT_RANGE,0,75, NULL }, | |
83 { "toc-bias", &cdda_dflts.toc_bias, CONF_TYPE_INT, 0, 0, 0, NULL }, | |
84 { "toc-offset", &cdda_dflts.toc_offset, CONF_TYPE_INT, 0, 0, 0, NULL }, | |
85 { "noskip", &cdda_dflts.no_skip, CONF_TYPE_FLAG, 0 , 0, 1, NULL }, | |
86 { "skip", &cdda_dflts.no_skip, CONF_TYPE_FLAG, 0 , 1, 0, NULL }, | |
87 { "device", &cdda_dflts.device, CONF_TYPE_STRING, 0, 0, 0, NULL }, | |
88 { "span", &cdda_dflts.span, CONF_TYPE_OBJ_PARAMS, 0, 0, 0, &m_span_params_def }, | |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
89 {NULL, NULL, 0, 0, 0, 0, NULL} |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
90 }; |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
91 |
16524
83d101e1bedb
Prints the number of tracks and MSF length for each track of an audio CD,
gpoirier
parents:
11652
diff
changeset
|
92 extern int cdd_identify(const char *dev); |
9801 | 93 extern int cddb_resolve(const char *dev, char **xmcd_file); |
94 extern cd_info_t* cddb_parse_xmcd(char *xmcd_file); | |
95 | |
96 static int seek(stream_t* s,off_t pos); | |
97 static int fill_buffer(stream_t* s, char* buffer, int max_len); | |
16935
60bd6aeed405
make it optionally possible to compile MPlayer with libcdio instead of libcdparanoia
faust3
parents:
16926
diff
changeset
|
98 static void close_cdda(stream_t* s); |
9801 | 99 |
100 static int open_cdda(stream_t *st,int m, void* opts, int* file_format) { | |
101 struct cdda_params* p = (struct cdda_params*)opts; | |
102 int mode = p->paranoia_mode; | |
103 int offset = p->toc_offset; | |
16935
60bd6aeed405
make it optionally possible to compile MPlayer with libcdio instead of libcdparanoia
faust3
parents:
16926
diff
changeset
|
104 #ifndef HAVE_LIBCDIO |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
105 cdrom_drive* cdd = NULL; |
16935
60bd6aeed405
make it optionally possible to compile MPlayer with libcdio instead of libcdparanoia
faust3
parents:
16926
diff
changeset
|
106 #else |
60bd6aeed405
make it optionally possible to compile MPlayer with libcdio instead of libcdparanoia
faust3
parents:
16926
diff
changeset
|
107 cdrom_drive_t* cdd = NULL; |
60bd6aeed405
make it optionally possible to compile MPlayer with libcdio instead of libcdparanoia
faust3
parents:
16926
diff
changeset
|
108 #endif |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
109 cdda_priv* priv; |
9801 | 110 cd_info_t *cd_info,*cddb_info = NULL; |
6696 | 111 unsigned int audiolen=0; |
16926
24c52f2c3aa9
fix cdda://n syntax: do not hang when n > nr_tracks and play only track n,
reimar
parents:
16914
diff
changeset
|
112 int last_track; |
6696 | 113 int i; |
9801 | 114 char *xmcd_file = NULL; |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
115 |
9801 | 116 if(m != STREAM_READ) { |
117 m_struct_free(&stream_opts,opts); | |
118 return STREAM_UNSUPORTED; | |
119 } | |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
120 |
10591 | 121 if(!p->device) { |
122 if (cdrom_device) | |
123 p->device = strdup(cdrom_device); | |
124 else | |
125 p->device = strdup(DEFAULT_CDROM_DEVICE); | |
126 } | |
127 | |
10121
d42177a0da2a
Changed the STREAMING defines to MPLAYER_NETWORK to avoid name definition clash.
bertrand
parents:
9801
diff
changeset
|
128 #ifdef MPLAYER_NETWORK |
16524
83d101e1bedb
Prints the number of tracks and MSF length for each track of an audio CD,
gpoirier
parents:
11652
diff
changeset
|
129 // cdd_identify returns -1 if it cannot read the TOC, |
83d101e1bedb
Prints the number of tracks and MSF length for each track of an audio CD,
gpoirier
parents:
11652
diff
changeset
|
130 // in which case there is no point in calling cddb_resolve |
83d101e1bedb
Prints the number of tracks and MSF length for each track of an audio CD,
gpoirier
parents:
11652
diff
changeset
|
131 if(cdd_identify(p->device) >= 0 && strncmp(st->url,"cddb",4) == 0) { |
9801 | 132 i = cddb_resolve(p->device, &xmcd_file); |
133 if(i == 0) { | |
134 cddb_info = cddb_parse_xmcd(xmcd_file); | |
135 free(xmcd_file); | |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
136 } |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
137 } |
9801 | 138 #endif |
139 | |
16935
60bd6aeed405
make it optionally possible to compile MPlayer with libcdio instead of libcdparanoia
faust3
parents:
16926
diff
changeset
|
140 #ifndef HAVE_LIBCDIO |
9801 | 141 if(p->generic_dev) |
142 cdd = cdda_identify_scsi(p->generic_dev,p->device,0,NULL); | |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
143 else |
16935
60bd6aeed405
make it optionally possible to compile MPlayer with libcdio instead of libcdparanoia
faust3
parents:
16926
diff
changeset
|
144 #endif |
8958
56bf90cefb10
Removed the hardcoded /dev/cdrom for NetBSD and added an work around
bertrand
parents:
8609
diff
changeset
|
145 #if defined(__NetBSD__) |
9801 | 146 cdd = cdda_identify_scsi(p->device,p->device,0,NULL); |
8958
56bf90cefb10
Removed the hardcoded /dev/cdrom for NetBSD and added an work around
bertrand
parents:
8609
diff
changeset
|
147 #else |
9801 | 148 cdd = cdda_identify(p->device,0,NULL); |
8958
56bf90cefb10
Removed the hardcoded /dev/cdrom for NetBSD and added an work around
bertrand
parents:
8609
diff
changeset
|
149 #endif |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
150 |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
151 if(!cdd) { |
16967
32e2c59c8e86
[TRIVIAL] More translatables to help_mp and printfs to mp_msg on libmpdemux
reynaldo
parents:
16940
diff
changeset
|
152 mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_MPDEMUX_CDDA_CantOpenCDDADevice); |
9801 | 153 m_struct_free(&stream_opts,opts); |
18225 | 154 free(cddb_info); |
9801 | 155 return STREAM_ERROR; |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
156 } |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
157 |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
158 cdda_verbose_set(cdd, CDDA_MESSAGE_FORGETIT, CDDA_MESSAGE_FORGETIT); |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
159 |
9801 | 160 if(p->sector_size) { |
161 cdd->nsectors = p->sector_size; | |
16935
60bd6aeed405
make it optionally possible to compile MPlayer with libcdio instead of libcdparanoia
faust3
parents:
16926
diff
changeset
|
162 #ifndef HAVE_LIBCDIO |
9801 | 163 cdd->bigbuff = p->sector_size * CD_FRAMESIZE_RAW; |
16935
60bd6aeed405
make it optionally possible to compile MPlayer with libcdio instead of libcdparanoia
faust3
parents:
16926
diff
changeset
|
164 #endif |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
165 } |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
166 |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
167 if(cdda_open(cdd) != 0) { |
16967
32e2c59c8e86
[TRIVIAL] More translatables to help_mp and printfs to mp_msg on libmpdemux
reynaldo
parents:
16940
diff
changeset
|
168 mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_MPDEMUX_CDDA_CantOpenDisc); |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
169 cdda_close(cdd); |
9801 | 170 m_struct_free(&stream_opts,opts); |
18225 | 171 free(cddb_info); |
9801 | 172 return STREAM_ERROR; |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
173 } |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
174 |
6696 | 175 cd_info = cd_info_new(); |
16967
32e2c59c8e86
[TRIVIAL] More translatables to help_mp and printfs to mp_msg on libmpdemux
reynaldo
parents:
16940
diff
changeset
|
176 mp_msg(MSGT_OPEN,MSGL_INFO,MSGTR_MPDEMUX_CDDA_AudioCDFoundWithNTracks,cdda_tracks(cdd)); |
6696 | 177 for(i=0;i<cdd->tracks;i++) { |
178 char track_name[80]; | |
179 long sec=cdda_track_firstsector(cdd,i+1); | |
180 long off=cdda_track_lastsector(cdd,i+1)-sec+1; | |
181 | |
182 sprintf(track_name, "Track %d", i+1); | |
183 cd_info_add_track(cd_info, track_name, i+1, (unsigned int)(off/(60*75)), (unsigned int)((off/75)%60), (unsigned int)(off%75), sec, off ); | |
184 audiolen += off; | |
185 } | |
186 cd_info->min = (unsigned int)(audiolen/(60*75)); | |
187 cd_info->sec = (unsigned int)((audiolen/75)%60); | |
188 cd_info->msec = (unsigned int)(audiolen%75); | |
189 | |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
190 priv = (cdda_priv*)malloc(sizeof(cdda_priv)); |
6696 | 191 memset(priv, 0, sizeof(cdda_priv)); |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
192 priv->cd = cdd; |
6696 | 193 priv->cd_info = cd_info; |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
194 |
9801 | 195 if(p->toc_bias) |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
196 offset -= cdda_track_firstsector(cdd,1); |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
197 |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
198 if(offset) { |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
199 int i; |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
200 for(i = 0 ; i < cdd->tracks + 1 ; i++) |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
201 cdd->disc_toc[i].dwStartSector += offset; |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
202 } |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
203 |
9801 | 204 if(p->speed) |
205 cdda_speed_set(cdd,p->speed); | |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
206 |
16926
24c52f2c3aa9
fix cdda://n syntax: do not hang when n > nr_tracks and play only track n,
reimar
parents:
16914
diff
changeset
|
207 last_track = cdda_tracks(cdd); |
24c52f2c3aa9
fix cdda://n syntax: do not hang when n > nr_tracks and play only track n,
reimar
parents:
16914
diff
changeset
|
208 if (p->span.start > last_track) p->span.start = last_track; |
24c52f2c3aa9
fix cdda://n syntax: do not hang when n > nr_tracks and play only track n,
reimar
parents:
16914
diff
changeset
|
209 if (p->span.end < p->span.start) p->span.end = p->span.start; |
24c52f2c3aa9
fix cdda://n syntax: do not hang when n > nr_tracks and play only track n,
reimar
parents:
16914
diff
changeset
|
210 if (p->span.end > last_track) p->span.end = last_track; |
9801 | 211 if(p->span.start) |
212 priv->start_sector = cdda_track_firstsector(cdd,p->span.start); | |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
213 else |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
214 priv->start_sector = cdda_disc_firstsector(cdd); |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
215 |
9801 | 216 if(p->span.end) { |
217 priv->end_sector = cdda_track_lastsector(cdd,p->span.end); | |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
218 } else |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
219 priv->end_sector = cdda_disc_lastsector(cdd); |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
220 |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
221 priv->cdp = paranoia_init(cdd); |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
222 if(priv->cdp == NULL) { |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
223 cdda_close(cdd); |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
224 free(priv); |
9801 | 225 cd_info_free(cd_info); |
226 m_struct_free(&stream_opts,opts); | |
18225 | 227 free(cddb_info); |
9801 | 228 return STREAM_ERROR; |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
229 } |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
230 |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
231 if(mode == 0) |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
232 mode = PARANOIA_MODE_DISABLE; |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
233 else if(mode == 1) |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
234 mode = PARANOIA_MODE_OVERLAP; |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
235 else |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
236 mode = PARANOIA_MODE_FULL; |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
237 |
9801 | 238 if(p->no_skip) |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
239 mode |= PARANOIA_MODE_NEVERSKIP; |
16935
60bd6aeed405
make it optionally possible to compile MPlayer with libcdio instead of libcdparanoia
faust3
parents:
16926
diff
changeset
|
240 #ifndef HAVE_LIBCDIO |
16635
8fd80915d2a2
10l, forgotten call to paranoia_modeset to actually set the desired mode.
reimar
parents:
16524
diff
changeset
|
241 paranoia_modeset(cdd, mode); |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
242 |
9801 | 243 if(p->search_overlap >= 0) |
244 paranoia_overlapset(cdd,p->search_overlap); | |
16935
60bd6aeed405
make it optionally possible to compile MPlayer with libcdio instead of libcdparanoia
faust3
parents:
16926
diff
changeset
|
245 #else |
60bd6aeed405
make it optionally possible to compile MPlayer with libcdio instead of libcdparanoia
faust3
parents:
16926
diff
changeset
|
246 paranoia_modeset(priv->cdp, mode); |
60bd6aeed405
make it optionally possible to compile MPlayer with libcdio instead of libcdparanoia
faust3
parents:
16926
diff
changeset
|
247 |
60bd6aeed405
make it optionally possible to compile MPlayer with libcdio instead of libcdparanoia
faust3
parents:
16926
diff
changeset
|
248 if(p->search_overlap >= 0) |
60bd6aeed405
make it optionally possible to compile MPlayer with libcdio instead of libcdparanoia
faust3
parents:
16926
diff
changeset
|
249 paranoia_overlapset(priv->cdp,p->search_overlap); |
60bd6aeed405
make it optionally possible to compile MPlayer with libcdio instead of libcdparanoia
faust3
parents:
16926
diff
changeset
|
250 #endif |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
251 |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
252 paranoia_seek(priv->cdp,priv->start_sector,SEEK_SET); |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
253 priv->sector = priv->start_sector; |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
254 |
10121
d42177a0da2a
Changed the STREAMING defines to MPLAYER_NETWORK to avoid name definition clash.
bertrand
parents:
9801
diff
changeset
|
255 #ifdef MPLAYER_NETWORK |
9801 | 256 if(cddb_info) { |
257 cd_info_free(cd_info); | |
258 priv->cd_info = cddb_info; | |
259 cd_info_debug( cddb_info ); | |
260 } | |
261 #endif | |
262 | |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
263 st->priv = priv; |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
264 st->start_pos = priv->start_sector*CD_FRAMESIZE_RAW; |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
265 st->end_pos = priv->end_sector*CD_FRAMESIZE_RAW; |
9801 | 266 st->type = STREAMTYPE_CDDA; |
267 st->sector_size = CD_FRAMESIZE_RAW; | |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
268 |
9801 | 269 st->fill_buffer = fill_buffer; |
270 st->seek = seek; | |
16935
60bd6aeed405
make it optionally possible to compile MPlayer with libcdio instead of libcdparanoia
faust3
parents:
16926
diff
changeset
|
271 st->close = close_cdda; |
9801 | 272 |
273 *file_format = DEMUXER_TYPE_RAWAUDIO; | |
274 | |
275 m_struct_free(&stream_opts,opts); | |
276 | |
277 return STREAM_OK; | |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
278 } |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
279 |
16935
60bd6aeed405
make it optionally possible to compile MPlayer with libcdio instead of libcdparanoia
faust3
parents:
16926
diff
changeset
|
280 #ifndef HAVE_LIBCDIO |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
281 static void cdparanoia_callback(long inpos, int function) { |
16935
60bd6aeed405
make it optionally possible to compile MPlayer with libcdio instead of libcdparanoia
faust3
parents:
16926
diff
changeset
|
282 #else |
60bd6aeed405
make it optionally possible to compile MPlayer with libcdio instead of libcdparanoia
faust3
parents:
16926
diff
changeset
|
283 static void cdparanoia_callback(long int inpos, paranoia_cb_mode_t function) { |
60bd6aeed405
make it optionally possible to compile MPlayer with libcdio instead of libcdparanoia
faust3
parents:
16926
diff
changeset
|
284 #endif |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
285 } |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
286 |
9801 | 287 static int fill_buffer(stream_t* s, char* buffer, int max_len) { |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
288 cdda_priv* p = (cdda_priv*)s->priv; |
6696 | 289 cd_track_t *cd_track; |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
290 int16_t * buf; |
9801 | 291 int i; |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
292 |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
293 buf = paranoia_read(p->cdp,cdparanoia_callback); |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
294 |
11652 | 295 #ifdef WORDS_BIGENDIAN |
296 for(i=0;i<CD_FRAMESIZE_RAW/2;i++) | |
297 buf[i]=le2me_16(buf[i]); | |
298 #endif | |
299 | |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
300 p->sector++; |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
301 s->pos = p->sector*CD_FRAMESIZE_RAW; |
9801 | 302 memcpy(buffer,buf,CD_FRAMESIZE_RAW); |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
303 |
9656
ef5ae9f9c6e6
fixed trivial seeking bugs, patch by Krister Lagerstrom <krister@kmlager.com>
alex
parents:
8958
diff
changeset
|
304 if((p->sector < p->start_sector) || (p->sector >= p->end_sector)) { |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
305 s->eof = 1; |
9656
ef5ae9f9c6e6
fixed trivial seeking bugs, patch by Krister Lagerstrom <krister@kmlager.com>
alex
parents:
8958
diff
changeset
|
306 return 0; |
ef5ae9f9c6e6
fixed trivial seeking bugs, patch by Krister Lagerstrom <krister@kmlager.com>
alex
parents:
8958
diff
changeset
|
307 } |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
308 |
6696 | 309 for(i=0;i<p->cd->tracks;i++){ |
310 if(p->cd->disc_toc[i].dwStartSector==p->sector-1) { | |
311 cd_track = cd_info_get_track(p->cd_info, i+1); | |
312 //printf("Track %d, sector=%d\n", i, p->sector-1); | |
313 if( cd_track!=NULL ) { | |
16524
83d101e1bedb
Prints the number of tracks and MSF length for each track of an audio CD,
gpoirier
parents:
11652
diff
changeset
|
314 mp_msg(MSGT_SEEK, MSGL_INFO, "\n%s\n", cd_track->name); |
18237
4231482179b6
Get ride of the several if(identify) messy lines and rearangment of some of the output, both patches by Kiriuja mplayer-patches AT en-directo_net, his changes are barely unrelated, nevertheless Im commiting them thogeter just for the sake of my mental healt, I had both patches already applied on my local three
reynaldo
parents:
18225
diff
changeset
|
315 mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_CDDA_TRACK=%d\n", cd_track->track_nb); |
6696 | 316 } |
317 break; | |
318 } | |
319 } | |
320 | |
321 | |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
322 return CD_FRAMESIZE_RAW; |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
323 } |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
324 |
9801 | 325 static int seek(stream_t* s,off_t newpos) { |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
326 cdda_priv* p = (cdda_priv*)s->priv; |
6696 | 327 cd_track_t *cd_track; |
328 int sec; | |
329 int current_track=0, seeked_track=0; | |
330 int i; | |
9656
ef5ae9f9c6e6
fixed trivial seeking bugs, patch by Krister Lagerstrom <krister@kmlager.com>
alex
parents:
8958
diff
changeset
|
331 |
9801 | 332 s->pos = newpos; |
9656
ef5ae9f9c6e6
fixed trivial seeking bugs, patch by Krister Lagerstrom <krister@kmlager.com>
alex
parents:
8958
diff
changeset
|
333 if(s->pos < 0) { |
ef5ae9f9c6e6
fixed trivial seeking bugs, patch by Krister Lagerstrom <krister@kmlager.com>
alex
parents:
8958
diff
changeset
|
334 s->eof = 1; |
9801 | 335 return 0; |
9656
ef5ae9f9c6e6
fixed trivial seeking bugs, patch by Krister Lagerstrom <krister@kmlager.com>
alex
parents:
8958
diff
changeset
|
336 } |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
337 |
6696 | 338 sec = s->pos/CD_FRAMESIZE_RAW; |
8524 | 339 //printf("pos: %d, sec: %d ## %d\n", (int)s->pos, (int)sec, CD_FRAMESIZE_RAW); |
340 //printf("sector: %d new: %d\n", p->sector, sec ); | |
6696 | 341 |
342 for(i=0;i<p->cd->tracks;i++){ | |
8559 | 343 // printf("trk #%d: %d .. %d\n",i,p->cd->disc_toc[i].dwStartSector,p->cd->disc_toc[i+1].dwStartSector); |
8524 | 344 if( p->sector>=p->cd->disc_toc[i].dwStartSector && p->sector<p->cd->disc_toc[i+1].dwStartSector ) { |
6696 | 345 current_track = i; |
346 } | |
8524 | 347 if( sec>=p->cd->disc_toc[i].dwStartSector && sec<p->cd->disc_toc[i+1].dwStartSector ) { |
6696 | 348 seeked_track = i; |
349 } | |
350 } | |
351 //printf("current: %d, seeked: %d\n", current_track, seeked_track); | |
352 if( current_track!=seeked_track ) { | |
353 //printf("Track %d, sector=%d\n", seeked_track, sec); | |
354 cd_track = cd_info_get_track(p->cd_info, seeked_track+1); | |
355 if( cd_track!=NULL ) { | |
16524
83d101e1bedb
Prints the number of tracks and MSF length for each track of an audio CD,
gpoirier
parents:
11652
diff
changeset
|
356 mp_msg(MSGT_SEEK, MSGL_INFO, "\n%s\n", cd_track->name); |
18237
4231482179b6
Get ride of the several if(identify) messy lines and rearangment of some of the output, both patches by Kiriuja mplayer-patches AT en-directo_net, his changes are barely unrelated, nevertheless Im commiting them thogeter just for the sake of my mental healt, I had both patches already applied on my local three
reynaldo
parents:
18225
diff
changeset
|
357 mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_CDDA_TRACK=%d\n", cd_track->track_nb); |
6696 | 358 } |
359 | |
360 } | |
8524 | 361 #if 0 |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
362 if(sec < p->start_sector) |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
363 sec = p->start_sector; |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
364 else if(sec > p->end_sector) |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
365 sec = p->end_sector; |
8524 | 366 #endif |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
367 |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
368 p->sector = sec; |
6696 | 369 // s->pos = sec*CD_FRAMESIZE_RAW; |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
370 |
8524 | 371 //printf("seek: %d, sec: %d\n", (int)s->pos, sec); |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
372 paranoia_seek(p->cdp,sec,SEEK_SET); |
9801 | 373 return 1; |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
374 } |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
375 |
16935
60bd6aeed405
make it optionally possible to compile MPlayer with libcdio instead of libcdparanoia
faust3
parents:
16926
diff
changeset
|
376 static void close_cdda(stream_t* s) { |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
377 cdda_priv* p = (cdda_priv*)s->priv; |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
378 paranoia_free(p->cdp); |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
379 cdda_close(p->cd); |
9801 | 380 cd_info_free(p->cd_info); |
381 free(p); | |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
382 } |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
383 |
9801 | 384 stream_info_t stream_info_cdda = { |
385 "CDDA", | |
386 "cdda", | |
387 "Albeu", | |
388 "", | |
389 open_cdda, | |
390 { "cdda", "cddb", NULL }, | |
391 &stream_opts, | |
392 1 // Urls are an option string | |
393 }; | |
394 | |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
395 #endif |