Mercurial > mplayer.hg
annotate stream/stream_cdda.c @ 31342:996166ae509d
Remove unnecessary get_path() declaration.
author | diego |
---|---|
date | Mon, 14 Jun 2010 11:39:22 +0000 |
parents | ce0122361a39 |
children | 045110c125c6 |
rev | line source |
---|---|
30426
ce0122361a39
Add license header to all files missing it in the stream subdirectory.
diego
parents:
29401
diff
changeset
|
1 /* |
ce0122361a39
Add license header to all files missing it in the stream subdirectory.
diego
parents:
29401
diff
changeset
|
2 * This file is part of MPlayer. |
ce0122361a39
Add license header to all files missing it in the stream subdirectory.
diego
parents:
29401
diff
changeset
|
3 * |
ce0122361a39
Add license header to all files missing it in the stream subdirectory.
diego
parents:
29401
diff
changeset
|
4 * MPlayer is free software; you can redistribute it and/or modify |
ce0122361a39
Add license header to all files missing it in the stream subdirectory.
diego
parents:
29401
diff
changeset
|
5 * it under the terms of the GNU General Public License as published by |
ce0122361a39
Add license header to all files missing it in the stream subdirectory.
diego
parents:
29401
diff
changeset
|
6 * the Free Software Foundation; either version 2 of the License, or |
ce0122361a39
Add license header to all files missing it in the stream subdirectory.
diego
parents:
29401
diff
changeset
|
7 * (at your option) any later version. |
ce0122361a39
Add license header to all files missing it in the stream subdirectory.
diego
parents:
29401
diff
changeset
|
8 * |
ce0122361a39
Add license header to all files missing it in the stream subdirectory.
diego
parents:
29401
diff
changeset
|
9 * MPlayer is distributed in the hope that it will be useful, |
ce0122361a39
Add license header to all files missing it in the stream subdirectory.
diego
parents:
29401
diff
changeset
|
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
ce0122361a39
Add license header to all files missing it in the stream subdirectory.
diego
parents:
29401
diff
changeset
|
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
ce0122361a39
Add license header to all files missing it in the stream subdirectory.
diego
parents:
29401
diff
changeset
|
12 * GNU General Public License for more details. |
ce0122361a39
Add license header to all files missing it in the stream subdirectory.
diego
parents:
29401
diff
changeset
|
13 * |
ce0122361a39
Add license header to all files missing it in the stream subdirectory.
diego
parents:
29401
diff
changeset
|
14 * You should have received a copy of the GNU General Public License along |
ce0122361a39
Add license header to all files missing it in the stream subdirectory.
diego
parents:
29401
diff
changeset
|
15 * with MPlayer; if not, write to the Free Software Foundation, Inc., |
ce0122361a39
Add license header to all files missing it in the stream subdirectory.
diego
parents:
29401
diff
changeset
|
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
ce0122361a39
Add license header to all files missing it in the stream subdirectory.
diego
parents:
29401
diff
changeset
|
17 */ |
ce0122361a39
Add license header to all files missing it in the stream subdirectory.
diego
parents:
29401
diff
changeset
|
18 |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
19 #include "config.h" |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
20 |
21418
cc5b0c53b263
Move system headers before libavutil headers to work around build issues on
diego
parents:
21372
diff
changeset
|
21 #include <stdio.h> |
cc5b0c53b263
Move system headers before libavutil headers to work around build issues on
diego
parents:
21372
diff
changeset
|
22 #include <stdlib.h> |
cc5b0c53b263
Move system headers before libavutil headers to work around build issues on
diego
parents:
21372
diff
changeset
|
23 |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
24 #include "stream.h" |
17012 | 25 #include "m_option.h" |
26 #include "m_struct.h" | |
21372 | 27 #include "libavutil/common.h" |
21507
fa99b3d31d13
Hack around libavutil/bswap.h compilation problems due to always_inline undefined.
reimar
parents:
21479
diff
changeset
|
28 #include "mpbswap.h" |
19312
ab8d6b6deb63
proper inclusion of demuxer.h (including libmpdemux in Makefile only was to make previous split easier)
ben
parents:
19272
diff
changeset
|
29 #include "libmpdemux/demuxer.h" |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
30 |
6696 | 31 #include "cdd.h" |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
32 |
16967
32e2c59c8e86
[TRIVIAL] More translatables to help_mp and printfs to mp_msg on libmpdemux
reynaldo
parents:
16940
diff
changeset
|
33 #include "mp_msg.h" |
32e2c59c8e86
[TRIVIAL] More translatables to help_mp and printfs to mp_msg on libmpdemux
reynaldo
parents:
16940
diff
changeset
|
34 #include "help_mp.h" |
32e2c59c8e86
[TRIVIAL] More translatables to help_mp and printfs to mp_msg on libmpdemux
reynaldo
parents:
16940
diff
changeset
|
35 |
16940 | 36 #ifndef CD_FRAMESIZE_RAW |
37 #define CD_FRAMESIZE_RAW CDIO_CD_FRAMESIZE_RAW | |
38 #endif | |
39 | |
40 | |
10591 | 41 extern char *cdrom_device; |
42 | |
9801 | 43 static struct cdda_params { |
44 int speed; | |
45 int paranoia_mode; | |
46 char* generic_dev; | |
47 int sector_size; | |
48 int search_overlap; | |
49 int toc_bias; | |
50 int toc_offset; | |
51 int no_skip; | |
52 char* device; | |
53 m_span_t span; | |
54 } cdda_dflts = { | |
55 -1, | |
16914
701af802aee7
set cdda paranoia default to 0 since e.g. cdda://2 breaks otherwise.
reimar
parents:
16635
diff
changeset
|
56 0, |
9801 | 57 NULL, |
58 0, | |
59 -1, | |
60 0, | |
61 0, | |
62 0, | |
10591 | 63 NULL, |
9801 | 64 { 0, 0 } |
65 }; | |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
66 |
9801 | 67 #define ST_OFF(f) M_ST_OFF(struct cdda_params,f) |
25242 | 68 static const m_option_t cdda_params_fields[] = { |
9801 | 69 { "speed", ST_OFF(speed), CONF_TYPE_INT, M_OPT_RANGE,1,100, NULL }, |
70 { "paranoia", ST_OFF(paranoia_mode), CONF_TYPE_INT,M_OPT_RANGE, 0, 2, NULL }, | |
71 { "generic-dev", ST_OFF(generic_dev), CONF_TYPE_STRING, 0, 0, 0, NULL }, | |
72 { "sector-size", ST_OFF(sector_size), CONF_TYPE_INT, M_OPT_RANGE,1,100, NULL }, | |
73 { "overlap", ST_OFF(search_overlap), CONF_TYPE_INT, M_OPT_RANGE,0,75, NULL }, | |
74 { "toc-bias", ST_OFF(toc_bias), CONF_TYPE_INT, 0, 0, 0, NULL }, | |
75 { "toc-offset", ST_OFF(toc_offset), CONF_TYPE_INT, 0, 0, 0, NULL }, | |
76 { "noskip", ST_OFF(no_skip), CONF_TYPE_FLAG, 0 , 0, 1, NULL }, | |
77 { "skip", ST_OFF(no_skip), CONF_TYPE_FLAG, 0 , 1, 0, NULL }, | |
78 { "device", ST_OFF(device), CONF_TYPE_STRING, 0, 0, 0, NULL }, | |
79 { "span", ST_OFF(span), CONF_TYPE_OBJ_PARAMS, 0, 0, 0, &m_span_params_def }, | |
80 /// For url parsing | |
81 { "hostname", ST_OFF(span), CONF_TYPE_OBJ_PARAMS, 0, 0, 0, &m_span_params_def }, | |
82 { "port", ST_OFF(speed), CONF_TYPE_INT, M_OPT_RANGE,1,100, NULL }, | |
83 { "filename", ST_OFF(device), CONF_TYPE_STRING, 0, 0, 0, NULL }, | |
84 {NULL, NULL, 0, 0, 0, 0, NULL} | |
85 }; | |
25691 | 86 static const struct m_struct_st stream_opts = { |
9801 | 87 "cdda", |
88 sizeof(struct cdda_params), | |
89 &cdda_dflts, | |
90 cdda_params_fields | |
91 }; | |
92 | |
93 /// We keep these options but now they set the defaults | |
25241
bb7c65f2a289
Make m_option_t arrays referenced by cfg-common.h const
reimar
parents:
25211
diff
changeset
|
94 const m_option_t cdda_opts[] = { |
9801 | 95 { "speed", &cdda_dflts.speed, CONF_TYPE_INT, M_OPT_RANGE,1,100, NULL }, |
96 { "paranoia", &cdda_dflts.paranoia_mode, CONF_TYPE_INT,M_OPT_RANGE, 0, 2, NULL }, | |
97 { "generic-dev", &cdda_dflts.generic_dev, CONF_TYPE_STRING, 0, 0, 0, NULL }, | |
98 { "sector-size", &cdda_dflts.sector_size, CONF_TYPE_INT, M_OPT_RANGE,1,100, NULL }, | |
99 { "overlap", &cdda_dflts.search_overlap, CONF_TYPE_INT, M_OPT_RANGE,0,75, NULL }, | |
100 { "toc-bias", &cdda_dflts.toc_bias, CONF_TYPE_INT, 0, 0, 0, NULL }, | |
101 { "toc-offset", &cdda_dflts.toc_offset, CONF_TYPE_INT, 0, 0, 0, NULL }, | |
102 { "noskip", &cdda_dflts.no_skip, CONF_TYPE_FLAG, 0 , 0, 1, NULL }, | |
103 { "skip", &cdda_dflts.no_skip, CONF_TYPE_FLAG, 0 , 1, 0, NULL }, | |
104 { "device", &cdda_dflts.device, CONF_TYPE_STRING, 0, 0, 0, NULL }, | |
105 { "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
|
106 {NULL, NULL, 0, 0, 0, 0, NULL} |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
107 }; |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
108 |
28051 | 109 int cdd_identify(const char *dev); |
110 int cddb_resolve(const char *dev, char **xmcd_file); | |
111 cd_info_t* cddb_parse_xmcd(char *xmcd_file); | |
9801 | 112 |
113 static int seek(stream_t* s,off_t pos); | |
114 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
|
115 static void close_cdda(stream_t* s); |
9801 | 116 |
25410 | 117 static int get_track_by_sector(cdda_priv *p, unsigned int sector) { |
118 int i; | |
119 for (i = p->cd->tracks; i >= 0 ; --i) | |
120 if (p->cd->disc_toc[i].dwStartSector <= sector) | |
121 break; | |
122 return i; | |
123 } | |
124 | |
125 static int control(stream_t *stream, int cmd, void *arg) { | |
126 cdda_priv* p = stream->priv; | |
127 switch(cmd) { | |
128 case STREAM_CTRL_GET_NUM_CHAPTERS: | |
129 { | |
130 int start_track = get_track_by_sector(p, p->start_sector); | |
131 int end_track = get_track_by_sector(p, p->end_sector); | |
132 *(unsigned int *)arg = end_track + 1 - start_track; | |
133 return STREAM_OK; | |
134 } | |
135 case STREAM_CTRL_SEEK_TO_CHAPTER: | |
136 { | |
137 int r; | |
138 unsigned int track = *(unsigned int *)arg; | |
139 int start_track = get_track_by_sector(p, p->start_sector); | |
140 int seek_sector; | |
141 track += start_track; | |
142 if (track >= p->cd->tracks) { | |
143 stream->eof = 1; | |
144 return STREAM_ERROR; | |
145 } | |
146 seek_sector = track <= 0 ? p->start_sector | |
147 : p->cd->disc_toc[track].dwStartSector; | |
148 r = seek(stream, seek_sector * CD_FRAMESIZE_RAW); | |
149 if (r) | |
150 return STREAM_OK; | |
151 break; | |
152 } | |
153 case STREAM_CTRL_GET_CURRENT_CHAPTER: | |
154 { | |
155 int start_track = get_track_by_sector(p, p->start_sector); | |
156 int cur_track = get_track_by_sector(p, p->sector); | |
157 *(unsigned int *)arg = cur_track - start_track; | |
158 return STREAM_OK; | |
159 } | |
160 } | |
161 return STREAM_UNSUPPORTED; | |
162 } | |
163 | |
9801 | 164 static int open_cdda(stream_t *st,int m, void* opts, int* file_format) { |
165 struct cdda_params* p = (struct cdda_params*)opts; | |
166 int mode = p->paranoia_mode; | |
167 int offset = p->toc_offset; | |
27391
1d2faa1020fb
Rename a bunch of miscellaneous preprocessor directives.
diego
parents:
25691
diff
changeset
|
168 #ifndef CONFIG_LIBCDIO |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
169 cdrom_drive* cdd = NULL; |
16935
60bd6aeed405
make it optionally possible to compile MPlayer with libcdio instead of libcdparanoia
faust3
parents:
16926
diff
changeset
|
170 #else |
60bd6aeed405
make it optionally possible to compile MPlayer with libcdio instead of libcdparanoia
faust3
parents:
16926
diff
changeset
|
171 cdrom_drive_t* cdd = NULL; |
60bd6aeed405
make it optionally possible to compile MPlayer with libcdio instead of libcdparanoia
faust3
parents:
16926
diff
changeset
|
172 #endif |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
173 cdda_priv* priv; |
9801 | 174 cd_info_t *cd_info,*cddb_info = NULL; |
6696 | 175 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
|
176 int last_track; |
6696 | 177 int i; |
9801 | 178 char *xmcd_file = NULL; |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
179 |
9801 | 180 if(m != STREAM_READ) { |
181 m_struct_free(&stream_opts,opts); | |
24257 | 182 return STREAM_UNSUPPORTED; |
9801 | 183 } |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
184 |
10591 | 185 if(!p->device) { |
186 if (cdrom_device) | |
187 p->device = strdup(cdrom_device); | |
188 else | |
189 p->device = strdup(DEFAULT_CDROM_DEVICE); | |
190 } | |
191 | |
27391
1d2faa1020fb
Rename a bunch of miscellaneous preprocessor directives.
diego
parents:
25691
diff
changeset
|
192 #ifdef CONFIG_CDDB |
16524
83d101e1bedb
Prints the number of tracks and MSF length for each track of an audio CD,
gpoirier
parents:
11652
diff
changeset
|
193 // 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
|
194 // 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
|
195 if(cdd_identify(p->device) >= 0 && strncmp(st->url,"cddb",4) == 0) { |
9801 | 196 i = cddb_resolve(p->device, &xmcd_file); |
197 if(i == 0) { | |
198 cddb_info = cddb_parse_xmcd(xmcd_file); | |
199 free(xmcd_file); | |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
200 } |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
201 } |
9801 | 202 #endif |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28051
diff
changeset
|
203 |
27391
1d2faa1020fb
Rename a bunch of miscellaneous preprocessor directives.
diego
parents:
25691
diff
changeset
|
204 #ifndef CONFIG_LIBCDIO |
9801 | 205 if(p->generic_dev) |
206 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
|
207 else |
16935
60bd6aeed405
make it optionally possible to compile MPlayer with libcdio instead of libcdparanoia
faust3
parents:
16926
diff
changeset
|
208 #endif |
8958
56bf90cefb10
Removed the hardcoded /dev/cdrom for NetBSD and added an work around
bertrand
parents:
8609
diff
changeset
|
209 #if defined(__NetBSD__) |
9801 | 210 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
|
211 #else |
9801 | 212 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
|
213 #endif |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
214 |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
215 if(!cdd) { |
16967
32e2c59c8e86
[TRIVIAL] More translatables to help_mp and printfs to mp_msg on libmpdemux
reynaldo
parents:
16940
diff
changeset
|
216 mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_MPDEMUX_CDDA_CantOpenCDDADevice); |
9801 | 217 m_struct_free(&stream_opts,opts); |
18225 | 218 free(cddb_info); |
9801 | 219 return STREAM_ERROR; |
6384
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 |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
222 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
|
223 |
9801 | 224 if(p->sector_size) { |
225 cdd->nsectors = p->sector_size; | |
27391
1d2faa1020fb
Rename a bunch of miscellaneous preprocessor directives.
diego
parents:
25691
diff
changeset
|
226 #ifndef CONFIG_LIBCDIO |
9801 | 227 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
|
228 #endif |
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(cdda_open(cdd) != 0) { |
16967
32e2c59c8e86
[TRIVIAL] More translatables to help_mp and printfs to mp_msg on libmpdemux
reynaldo
parents:
16940
diff
changeset
|
232 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
|
233 cdda_close(cdd); |
9801 | 234 m_struct_free(&stream_opts,opts); |
18225 | 235 free(cddb_info); |
9801 | 236 return STREAM_ERROR; |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
237 } |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
238 |
6696 | 239 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
|
240 mp_msg(MSGT_OPEN,MSGL_INFO,MSGTR_MPDEMUX_CDDA_AudioCDFoundWithNTracks,cdda_tracks(cdd)); |
6696 | 241 for(i=0;i<cdd->tracks;i++) { |
242 char track_name[80]; | |
243 long sec=cdda_track_firstsector(cdd,i+1); | |
244 long off=cdda_track_lastsector(cdd,i+1)-sec+1; | |
245 | |
246 sprintf(track_name, "Track %d", i+1); | |
247 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 ); | |
248 audiolen += off; | |
249 } | |
250 cd_info->min = (unsigned int)(audiolen/(60*75)); | |
251 cd_info->sec = (unsigned int)((audiolen/75)%60); | |
252 cd_info->msec = (unsigned int)(audiolen%75); | |
253 | |
19062
83c3afeab35d
drops casts from void * on malloc/calloc from libmpdemux code
reynaldo
parents:
18922
diff
changeset
|
254 priv = malloc(sizeof(cdda_priv)); |
6696 | 255 memset(priv, 0, sizeof(cdda_priv)); |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
256 priv->cd = cdd; |
6696 | 257 priv->cd_info = cd_info; |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
258 |
9801 | 259 if(p->toc_bias) |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
260 offset -= cdda_track_firstsector(cdd,1); |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
261 |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
262 if(offset) { |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
263 int i; |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
264 for(i = 0 ; i < cdd->tracks + 1 ; i++) |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
265 cdd->disc_toc[i].dwStartSector += offset; |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
266 } |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
267 |
9801 | 268 if(p->speed) |
269 cdda_speed_set(cdd,p->speed); | |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
270 |
16926
24c52f2c3aa9
fix cdda://n syntax: do not hang when n > nr_tracks and play only track n,
reimar
parents:
16914
diff
changeset
|
271 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
|
272 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
|
273 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
|
274 if (p->span.end > last_track) p->span.end = last_track; |
9801 | 275 if(p->span.start) |
276 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
|
277 else |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
278 priv->start_sector = cdda_disc_firstsector(cdd); |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
279 |
9801 | 280 if(p->span.end) { |
281 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
|
282 } else |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
283 priv->end_sector = cdda_disc_lastsector(cdd); |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
284 |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
285 priv->cdp = paranoia_init(cdd); |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
286 if(priv->cdp == NULL) { |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
287 cdda_close(cdd); |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
288 free(priv); |
9801 | 289 cd_info_free(cd_info); |
290 m_struct_free(&stream_opts,opts); | |
18225 | 291 free(cddb_info); |
9801 | 292 return STREAM_ERROR; |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
293 } |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
294 |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
295 if(mode == 0) |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
296 mode = PARANOIA_MODE_DISABLE; |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
297 else if(mode == 1) |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
298 mode = PARANOIA_MODE_OVERLAP; |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
299 else |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
300 mode = PARANOIA_MODE_FULL; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28051
diff
changeset
|
301 |
9801 | 302 if(p->no_skip) |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
303 mode |= PARANOIA_MODE_NEVERSKIP; |
27391
1d2faa1020fb
Rename a bunch of miscellaneous preprocessor directives.
diego
parents:
25691
diff
changeset
|
304 #ifndef CONFIG_LIBCDIO |
16635
8fd80915d2a2
10l, forgotten call to paranoia_modeset to actually set the desired mode.
reimar
parents:
16524
diff
changeset
|
305 paranoia_modeset(cdd, mode); |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
306 |
9801 | 307 if(p->search_overlap >= 0) |
308 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
|
309 #else |
60bd6aeed405
make it optionally possible to compile MPlayer with libcdio instead of libcdparanoia
faust3
parents:
16926
diff
changeset
|
310 paranoia_modeset(priv->cdp, mode); |
60bd6aeed405
make it optionally possible to compile MPlayer with libcdio instead of libcdparanoia
faust3
parents:
16926
diff
changeset
|
311 |
60bd6aeed405
make it optionally possible to compile MPlayer with libcdio instead of libcdparanoia
faust3
parents:
16926
diff
changeset
|
312 if(p->search_overlap >= 0) |
60bd6aeed405
make it optionally possible to compile MPlayer with libcdio instead of libcdparanoia
faust3
parents:
16926
diff
changeset
|
313 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
|
314 #endif |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
315 |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
316 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
|
317 priv->sector = priv->start_sector; |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
318 |
27391
1d2faa1020fb
Rename a bunch of miscellaneous preprocessor directives.
diego
parents:
25691
diff
changeset
|
319 #ifdef CONFIG_CDDB |
9801 | 320 if(cddb_info) { |
321 cd_info_free(cd_info); | |
322 priv->cd_info = cddb_info; | |
323 cd_info_debug( cddb_info ); | |
324 } | |
325 #endif | |
326 | |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
327 st->priv = priv; |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
328 st->start_pos = priv->start_sector*CD_FRAMESIZE_RAW; |
25382 | 329 st->end_pos = (priv->end_sector + 1) * CD_FRAMESIZE_RAW; |
9801 | 330 st->type = STREAMTYPE_CDDA; |
331 st->sector_size = CD_FRAMESIZE_RAW; | |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
332 |
9801 | 333 st->fill_buffer = fill_buffer; |
334 st->seek = seek; | |
25410 | 335 st->control = control; |
16935
60bd6aeed405
make it optionally possible to compile MPlayer with libcdio instead of libcdparanoia
faust3
parents:
16926
diff
changeset
|
336 st->close = close_cdda; |
9801 | 337 |
338 *file_format = DEMUXER_TYPE_RAWAUDIO; | |
339 | |
340 m_struct_free(&stream_opts,opts); | |
341 | |
342 return STREAM_OK; | |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
343 } |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
344 |
27391
1d2faa1020fb
Rename a bunch of miscellaneous preprocessor directives.
diego
parents:
25691
diff
changeset
|
345 #ifndef CONFIG_LIBCDIO |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
346 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
|
347 #else |
60bd6aeed405
make it optionally possible to compile MPlayer with libcdio instead of libcdparanoia
faust3
parents:
16926
diff
changeset
|
348 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
|
349 #endif |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
350 } |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
351 |
9801 | 352 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
|
353 cdda_priv* p = (cdda_priv*)s->priv; |
6696 | 354 cd_track_t *cd_track; |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
355 int16_t * buf; |
9801 | 356 int i; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28051
diff
changeset
|
357 |
25382 | 358 if((p->sector < p->start_sector) || (p->sector > p->end_sector)) { |
359 s->eof = 1; | |
360 return 0; | |
361 } | |
362 | |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
363 buf = paranoia_read(p->cdp,cdparanoia_callback); |
20195 | 364 if (!buf) |
365 return 0; | |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
366 |
29401
f01023c524c3
Replace WORDS_BIGENDIAN by HAVE_BIGENDIAN in all internal code.
diego
parents:
29263
diff
changeset
|
367 #if HAVE_BIGENDIAN |
11652 | 368 for(i=0;i<CD_FRAMESIZE_RAW/2;i++) |
369 buf[i]=le2me_16(buf[i]); | |
370 #endif | |
371 | |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
372 p->sector++; |
9801 | 373 memcpy(buffer,buf,CD_FRAMESIZE_RAW); |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
374 |
6696 | 375 for(i=0;i<p->cd->tracks;i++){ |
376 if(p->cd->disc_toc[i].dwStartSector==p->sector-1) { | |
377 cd_track = cd_info_get_track(p->cd_info, i+1); | |
378 //printf("Track %d, sector=%d\n", i, p->sector-1); | |
379 if( cd_track!=NULL ) { | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28051
diff
changeset
|
380 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
|
381 mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_CDDA_TRACK=%d\n", cd_track->track_nb); |
6696 | 382 } |
383 break; | |
384 } | |
385 } | |
386 | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28051
diff
changeset
|
387 |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
388 return CD_FRAMESIZE_RAW; |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
389 } |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
390 |
9801 | 391 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
|
392 cdda_priv* p = (cdda_priv*)s->priv; |
6696 | 393 cd_track_t *cd_track; |
394 int sec; | |
395 int current_track=0, seeked_track=0; | |
25365
b57179296e5a
Only print one track info when exactly seeking to the beginning of a track.
ulion
parents:
25362
diff
changeset
|
396 int seek_to_track = 0; |
6696 | 397 int i; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28051
diff
changeset
|
398 |
9801 | 399 s->pos = newpos; |
25362
74fbb5173956
Fix stream cdda seeks to CD's end and hangs forever bug.
ulion
parents:
25242
diff
changeset
|
400 sec = s->pos/CD_FRAMESIZE_RAW; |
25382 | 401 if (s->pos < 0 || sec > p->end_sector) { |
9656
ef5ae9f9c6e6
fixed trivial seeking bugs, patch by Krister Lagerstrom <krister@kmlager.com>
alex
parents:
8958
diff
changeset
|
402 s->eof = 1; |
9801 | 403 return 0; |
9656
ef5ae9f9c6e6
fixed trivial seeking bugs, patch by Krister Lagerstrom <krister@kmlager.com>
alex
parents:
8958
diff
changeset
|
404 } |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
405 |
8524 | 406 //printf("pos: %d, sec: %d ## %d\n", (int)s->pos, (int)sec, CD_FRAMESIZE_RAW); |
407 //printf("sector: %d new: %d\n", p->sector, sec ); | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28051
diff
changeset
|
408 |
6696 | 409 for(i=0;i<p->cd->tracks;i++){ |
8559 | 410 // printf("trk #%d: %d .. %d\n",i,p->cd->disc_toc[i].dwStartSector,p->cd->disc_toc[i+1].dwStartSector); |
8524 | 411 if( p->sector>=p->cd->disc_toc[i].dwStartSector && p->sector<p->cd->disc_toc[i+1].dwStartSector ) { |
6696 | 412 current_track = i; |
413 } | |
8524 | 414 if( sec>=p->cd->disc_toc[i].dwStartSector && sec<p->cd->disc_toc[i+1].dwStartSector ) { |
6696 | 415 seeked_track = i; |
25365
b57179296e5a
Only print one track info when exactly seeking to the beginning of a track.
ulion
parents:
25362
diff
changeset
|
416 seek_to_track = sec == p->cd->disc_toc[i].dwStartSector; |
6696 | 417 } |
418 } | |
419 //printf("current: %d, seeked: %d\n", current_track, seeked_track); | |
25365
b57179296e5a
Only print one track info when exactly seeking to the beginning of a track.
ulion
parents:
25362
diff
changeset
|
420 if (current_track != seeked_track && !seek_to_track) { |
6696 | 421 //printf("Track %d, sector=%d\n", seeked_track, sec); |
422 cd_track = cd_info_get_track(p->cd_info, seeked_track+1); | |
423 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
|
424 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
|
425 mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_CDDA_TRACK=%d\n", cd_track->track_nb); |
6696 | 426 } |
427 | |
428 } | |
8524 | 429 #if 0 |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
430 if(sec < p->start_sector) |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
431 sec = p->start_sector; |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
432 else if(sec > p->end_sector) |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
433 sec = p->end_sector; |
8524 | 434 #endif |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
435 |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
436 p->sector = sec; |
6696 | 437 // s->pos = sec*CD_FRAMESIZE_RAW; |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
438 |
8524 | 439 //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
|
440 paranoia_seek(p->cdp,sec,SEEK_SET); |
9801 | 441 return 1; |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
442 } |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
443 |
16935
60bd6aeed405
make it optionally possible to compile MPlayer with libcdio instead of libcdparanoia
faust3
parents:
16926
diff
changeset
|
444 static void close_cdda(stream_t* s) { |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
445 cdda_priv* p = (cdda_priv*)s->priv; |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
446 paranoia_free(p->cdp); |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
447 cdda_close(p->cd); |
9801 | 448 cd_info_free(p->cd_info); |
449 free(p); | |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
450 } |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
451 |
25211 | 452 const stream_info_t stream_info_cdda = { |
9801 | 453 "CDDA", |
454 "cdda", | |
455 "Albeu", | |
456 "", | |
457 open_cdda, | |
21479 | 458 { "cdda", |
27391
1d2faa1020fb
Rename a bunch of miscellaneous preprocessor directives.
diego
parents:
25691
diff
changeset
|
459 #ifdef CONFIG_CDDB |
21479 | 460 "cddb", |
461 #endif | |
462 NULL }, | |
9801 | 463 &stream_opts, |
464 1 // Urls are an option string | |
465 }; |