Mercurial > mplayer.hg
annotate libmpdemux/cdda.c @ 15366:d2180f62e0e8
explains what ARa is and a tries to improve the readability of the
paragraph about X and Y resolution
author | gpoirier |
---|---|
date | Sun, 08 May 2005 14:30:53 +0000 |
parents | b846d0a788c1 |
children | 83d101e1bedb |
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" |
9801 | 6 #include "../m_option.h" |
7 #include "../m_struct.h" | |
11652 | 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 |
10591 | 16 extern char *cdrom_device; |
17 | |
9801 | 18 static struct cdda_params { |
19 int speed; | |
20 int paranoia_mode; | |
21 char* generic_dev; | |
22 int sector_size; | |
23 int search_overlap; | |
24 int toc_bias; | |
25 int toc_offset; | |
26 int no_skip; | |
27 char* device; | |
28 m_span_t span; | |
29 } cdda_dflts = { | |
30 -1, | |
31 1, | |
32 NULL, | |
33 0, | |
34 -1, | |
35 0, | |
36 0, | |
37 0, | |
10591 | 38 NULL, |
9801 | 39 { 0, 0 } |
40 }; | |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
41 |
9801 | 42 #define ST_OFF(f) M_ST_OFF(struct cdda_params,f) |
43 m_option_t cdda_params_fields[] = { | |
44 { "speed", ST_OFF(speed), CONF_TYPE_INT, M_OPT_RANGE,1,100, NULL }, | |
45 { "paranoia", ST_OFF(paranoia_mode), CONF_TYPE_INT,M_OPT_RANGE, 0, 2, NULL }, | |
46 { "generic-dev", ST_OFF(generic_dev), CONF_TYPE_STRING, 0, 0, 0, NULL }, | |
47 { "sector-size", ST_OFF(sector_size), CONF_TYPE_INT, M_OPT_RANGE,1,100, NULL }, | |
48 { "overlap", ST_OFF(search_overlap), CONF_TYPE_INT, M_OPT_RANGE,0,75, NULL }, | |
49 { "toc-bias", ST_OFF(toc_bias), CONF_TYPE_INT, 0, 0, 0, NULL }, | |
50 { "toc-offset", ST_OFF(toc_offset), CONF_TYPE_INT, 0, 0, 0, NULL }, | |
51 { "noskip", ST_OFF(no_skip), CONF_TYPE_FLAG, 0 , 0, 1, NULL }, | |
52 { "skip", ST_OFF(no_skip), CONF_TYPE_FLAG, 0 , 1, 0, NULL }, | |
53 { "device", ST_OFF(device), CONF_TYPE_STRING, 0, 0, 0, NULL }, | |
54 { "span", ST_OFF(span), CONF_TYPE_OBJ_PARAMS, 0, 0, 0, &m_span_params_def }, | |
55 /// For url parsing | |
56 { "hostname", ST_OFF(span), CONF_TYPE_OBJ_PARAMS, 0, 0, 0, &m_span_params_def }, | |
57 { "port", ST_OFF(speed), CONF_TYPE_INT, M_OPT_RANGE,1,100, NULL }, | |
58 { "filename", ST_OFF(device), CONF_TYPE_STRING, 0, 0, 0, NULL }, | |
59 {NULL, NULL, 0, 0, 0, 0, NULL} | |
60 }; | |
61 static struct m_struct_st stream_opts = { | |
62 "cdda", | |
63 sizeof(struct cdda_params), | |
64 &cdda_dflts, | |
65 cdda_params_fields | |
66 }; | |
67 | |
68 /// We keep these options but now they set the defaults | |
69 m_option_t cdda_opts[] = { | |
70 { "speed", &cdda_dflts.speed, CONF_TYPE_INT, M_OPT_RANGE,1,100, NULL }, | |
71 { "paranoia", &cdda_dflts.paranoia_mode, CONF_TYPE_INT,M_OPT_RANGE, 0, 2, NULL }, | |
72 { "generic-dev", &cdda_dflts.generic_dev, CONF_TYPE_STRING, 0, 0, 0, NULL }, | |
73 { "sector-size", &cdda_dflts.sector_size, CONF_TYPE_INT, M_OPT_RANGE,1,100, NULL }, | |
74 { "overlap", &cdda_dflts.search_overlap, CONF_TYPE_INT, M_OPT_RANGE,0,75, NULL }, | |
75 { "toc-bias", &cdda_dflts.toc_bias, CONF_TYPE_INT, 0, 0, 0, NULL }, | |
76 { "toc-offset", &cdda_dflts.toc_offset, CONF_TYPE_INT, 0, 0, 0, NULL }, | |
77 { "noskip", &cdda_dflts.no_skip, CONF_TYPE_FLAG, 0 , 0, 1, NULL }, | |
78 { "skip", &cdda_dflts.no_skip, CONF_TYPE_FLAG, 0 , 1, 0, NULL }, | |
79 { "device", &cdda_dflts.device, CONF_TYPE_STRING, 0, 0, 0, NULL }, | |
80 { "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
|
81 {NULL, NULL, 0, 0, 0, 0, NULL} |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
82 }; |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
83 |
9801 | 84 extern int cddb_resolve(const char *dev, char **xmcd_file); |
85 extern cd_info_t* cddb_parse_xmcd(char *xmcd_file); | |
86 | |
87 static int seek(stream_t* s,off_t pos); | |
88 static int fill_buffer(stream_t* s, char* buffer, int max_len); | |
89 static void close(stream_t* s); | |
90 | |
91 static int open_cdda(stream_t *st,int m, void* opts, int* file_format) { | |
92 struct cdda_params* p = (struct cdda_params*)opts; | |
93 int mode = p->paranoia_mode; | |
94 int offset = p->toc_offset; | |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
95 cdrom_drive* cdd = NULL; |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
96 cdda_priv* priv; |
9801 | 97 cd_info_t *cd_info,*cddb_info = NULL; |
6696 | 98 unsigned int audiolen=0; |
99 int i; | |
9801 | 100 char *xmcd_file = NULL; |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
101 |
9801 | 102 if(m != STREAM_READ) { |
103 m_struct_free(&stream_opts,opts); | |
104 return STREAM_UNSUPORTED; | |
105 } | |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
106 |
10591 | 107 if(!p->device) { |
108 if (cdrom_device) | |
109 p->device = strdup(cdrom_device); | |
110 else | |
111 p->device = strdup(DEFAULT_CDROM_DEVICE); | |
112 } | |
113 | |
10121
d42177a0da2a
Changed the STREAMING defines to MPLAYER_NETWORK to avoid name definition clash.
bertrand
parents:
9801
diff
changeset
|
114 #ifdef MPLAYER_NETWORK |
9801 | 115 if(strncmp(st->url,"cddb",4) == 0) { |
116 i = cddb_resolve(p->device, &xmcd_file); | |
117 if(i == 0) { | |
118 cddb_info = cddb_parse_xmcd(xmcd_file); | |
119 free(xmcd_file); | |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
120 } |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
121 } |
9801 | 122 #endif |
123 | |
124 if(p->generic_dev) | |
125 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
|
126 else |
8958
56bf90cefb10
Removed the hardcoded /dev/cdrom for NetBSD and added an work around
bertrand
parents:
8609
diff
changeset
|
127 #if defined(__NetBSD__) |
9801 | 128 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
|
129 #else |
9801 | 130 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
|
131 #endif |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
132 |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
133 if(!cdd) { |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
134 mp_msg(MSGT_OPEN,MSGL_ERR,"Can't open cdda device\n"); |
9801 | 135 m_struct_free(&stream_opts,opts); |
136 return STREAM_ERROR; | |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
137 } |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
138 |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
139 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
|
140 |
9801 | 141 if(p->sector_size) { |
142 cdd->nsectors = p->sector_size; | |
143 cdd->bigbuff = p->sector_size * CD_FRAMESIZE_RAW; | |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
144 } |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
145 |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
146 if(cdda_open(cdd) != 0) { |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
147 mp_msg(MSGT_OPEN,MSGL_ERR,"Can't open disc\n"); |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
148 cdda_close(cdd); |
9801 | 149 m_struct_free(&stream_opts,opts); |
150 return STREAM_ERROR; | |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
151 } |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
152 |
6696 | 153 cd_info = cd_info_new(); |
154 mp_msg(MSGT_OPEN,MSGL_INFO,"Found Audio CD with %d tracks\n",cdda_tracks(cdd)); | |
155 for(i=0;i<cdd->tracks;i++) { | |
156 char track_name[80]; | |
157 long sec=cdda_track_firstsector(cdd,i+1); | |
158 long off=cdda_track_lastsector(cdd,i+1)-sec+1; | |
159 | |
160 sprintf(track_name, "Track %d", i+1); | |
161 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 ); | |
162 audiolen += off; | |
163 } | |
164 cd_info->min = (unsigned int)(audiolen/(60*75)); | |
165 cd_info->sec = (unsigned int)((audiolen/75)%60); | |
166 cd_info->msec = (unsigned int)(audiolen%75); | |
167 | |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
168 priv = (cdda_priv*)malloc(sizeof(cdda_priv)); |
6696 | 169 memset(priv, 0, sizeof(cdda_priv)); |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
170 priv->cd = cdd; |
6696 | 171 priv->cd_info = cd_info; |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
172 |
9801 | 173 if(p->toc_bias) |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
174 offset -= cdda_track_firstsector(cdd,1); |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
175 |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
176 if(offset) { |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
177 int i; |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
178 for(i = 0 ; i < cdd->tracks + 1 ; i++) |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
179 cdd->disc_toc[i].dwStartSector += offset; |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
180 } |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
181 |
9801 | 182 if(p->speed) |
183 cdda_speed_set(cdd,p->speed); | |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
184 |
9801 | 185 if(p->span.start) |
186 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
|
187 else |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
188 priv->start_sector = cdda_disc_firstsector(cdd); |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
189 |
9801 | 190 if(p->span.end) { |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
191 int last = cdda_tracks(cdd); |
9801 | 192 if(p->span.end > last) p->span.end = last; |
193 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
|
194 } else |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
195 priv->end_sector = cdda_disc_lastsector(cdd); |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
196 |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
197 priv->cdp = paranoia_init(cdd); |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
198 if(priv->cdp == NULL) { |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
199 cdda_close(cdd); |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
200 free(priv); |
9801 | 201 cd_info_free(cd_info); |
202 m_struct_free(&stream_opts,opts); | |
203 return STREAM_ERROR; | |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
204 } |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
205 |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
206 if(mode == 0) |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
207 mode = PARANOIA_MODE_DISABLE; |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
208 else if(mode == 1) |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
209 mode = PARANOIA_MODE_OVERLAP; |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
210 else |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
211 mode = PARANOIA_MODE_FULL; |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
212 |
9801 | 213 if(p->no_skip) |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
214 mode |= PARANOIA_MODE_NEVERSKIP; |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
215 |
9801 | 216 if(p->search_overlap >= 0) |
217 paranoia_overlapset(cdd,p->search_overlap); | |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
218 |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
219 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
|
220 priv->sector = priv->start_sector; |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
221 |
10121
d42177a0da2a
Changed the STREAMING defines to MPLAYER_NETWORK to avoid name definition clash.
bertrand
parents:
9801
diff
changeset
|
222 #ifdef MPLAYER_NETWORK |
9801 | 223 if(cddb_info) { |
224 cd_info_free(cd_info); | |
225 priv->cd_info = cddb_info; | |
226 cd_info_debug( cddb_info ); | |
227 } | |
228 #endif | |
229 | |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
230 st->priv = priv; |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
231 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
|
232 st->end_pos = priv->end_sector*CD_FRAMESIZE_RAW; |
9801 | 233 st->type = STREAMTYPE_CDDA; |
234 st->sector_size = CD_FRAMESIZE_RAW; | |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
235 |
9801 | 236 st->fill_buffer = fill_buffer; |
237 st->seek = seek; | |
238 st->close = close; | |
239 | |
240 *file_format = DEMUXER_TYPE_RAWAUDIO; | |
241 | |
242 m_struct_free(&stream_opts,opts); | |
243 | |
244 return STREAM_OK; | |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
245 } |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
246 |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
247 static void cdparanoia_callback(long inpos, int function) { |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
248 } |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
249 |
9801 | 250 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
|
251 cdda_priv* p = (cdda_priv*)s->priv; |
6696 | 252 cd_track_t *cd_track; |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
253 int16_t * buf; |
9801 | 254 int i; |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
255 |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
256 buf = paranoia_read(p->cdp,cdparanoia_callback); |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
257 |
11652 | 258 #ifdef WORDS_BIGENDIAN |
259 for(i=0;i<CD_FRAMESIZE_RAW/2;i++) | |
260 buf[i]=le2me_16(buf[i]); | |
261 #endif | |
262 | |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
263 p->sector++; |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
264 s->pos = p->sector*CD_FRAMESIZE_RAW; |
9801 | 265 memcpy(buffer,buf,CD_FRAMESIZE_RAW); |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
266 |
9656
ef5ae9f9c6e6
fixed trivial seeking bugs, patch by Krister Lagerstrom <krister@kmlager.com>
alex
parents:
8958
diff
changeset
|
267 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
|
268 s->eof = 1; |
9656
ef5ae9f9c6e6
fixed trivial seeking bugs, patch by Krister Lagerstrom <krister@kmlager.com>
alex
parents:
8958
diff
changeset
|
269 return 0; |
ef5ae9f9c6e6
fixed trivial seeking bugs, patch by Krister Lagerstrom <krister@kmlager.com>
alex
parents:
8958
diff
changeset
|
270 } |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
271 |
6696 | 272 for(i=0;i<p->cd->tracks;i++){ |
273 if(p->cd->disc_toc[i].dwStartSector==p->sector-1) { | |
274 cd_track = cd_info_get_track(p->cd_info, i+1); | |
275 //printf("Track %d, sector=%d\n", i, p->sector-1); | |
276 if( cd_track!=NULL ) { | |
8558 | 277 printf("\n%s\n", cd_track->name ); |
6696 | 278 } |
279 break; | |
280 } | |
281 } | |
282 | |
283 | |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
284 return CD_FRAMESIZE_RAW; |
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 seek(stream_t* s,off_t newpos) { |
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; |
290 int sec; | |
291 int current_track=0, seeked_track=0; | |
292 int i; | |
9656
ef5ae9f9c6e6
fixed trivial seeking bugs, patch by Krister Lagerstrom <krister@kmlager.com>
alex
parents:
8958
diff
changeset
|
293 |
9801 | 294 s->pos = newpos; |
9656
ef5ae9f9c6e6
fixed trivial seeking bugs, patch by Krister Lagerstrom <krister@kmlager.com>
alex
parents:
8958
diff
changeset
|
295 if(s->pos < 0) { |
ef5ae9f9c6e6
fixed trivial seeking bugs, patch by Krister Lagerstrom <krister@kmlager.com>
alex
parents:
8958
diff
changeset
|
296 s->eof = 1; |
9801 | 297 return 0; |
9656
ef5ae9f9c6e6
fixed trivial seeking bugs, patch by Krister Lagerstrom <krister@kmlager.com>
alex
parents:
8958
diff
changeset
|
298 } |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
299 |
6696 | 300 sec = s->pos/CD_FRAMESIZE_RAW; |
8524 | 301 //printf("pos: %d, sec: %d ## %d\n", (int)s->pos, (int)sec, CD_FRAMESIZE_RAW); |
302 //printf("sector: %d new: %d\n", p->sector, sec ); | |
6696 | 303 |
304 for(i=0;i<p->cd->tracks;i++){ | |
8559 | 305 // printf("trk #%d: %d .. %d\n",i,p->cd->disc_toc[i].dwStartSector,p->cd->disc_toc[i+1].dwStartSector); |
8524 | 306 if( p->sector>=p->cd->disc_toc[i].dwStartSector && p->sector<p->cd->disc_toc[i+1].dwStartSector ) { |
6696 | 307 current_track = i; |
308 } | |
8524 | 309 if( sec>=p->cd->disc_toc[i].dwStartSector && sec<p->cd->disc_toc[i+1].dwStartSector ) { |
6696 | 310 seeked_track = i; |
311 } | |
312 } | |
313 //printf("current: %d, seeked: %d\n", current_track, seeked_track); | |
314 if( current_track!=seeked_track ) { | |
315 //printf("Track %d, sector=%d\n", seeked_track, sec); | |
316 cd_track = cd_info_get_track(p->cd_info, seeked_track+1); | |
317 if( cd_track!=NULL ) { | |
8558 | 318 printf("\n%s\n", cd_track->name ); |
6696 | 319 } |
320 | |
321 } | |
8524 | 322 #if 0 |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
323 if(sec < p->start_sector) |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
324 sec = p->start_sector; |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
325 else if(sec > p->end_sector) |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
326 sec = p->end_sector; |
8524 | 327 #endif |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
328 |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
329 p->sector = sec; |
6696 | 330 // s->pos = sec*CD_FRAMESIZE_RAW; |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
331 |
8524 | 332 //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
|
333 paranoia_seek(p->cdp,sec,SEEK_SET); |
9801 | 334 return 1; |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
335 } |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
336 |
9801 | 337 static void close(stream_t* s) { |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
338 cdda_priv* p = (cdda_priv*)s->priv; |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
339 paranoia_free(p->cdp); |
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
340 cdda_close(p->cd); |
9801 | 341 cd_info_free(p->cd_info); |
342 free(p); | |
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 |
9801 | 345 stream_info_t stream_info_cdda = { |
346 "CDDA", | |
347 "cdda", | |
348 "Albeu", | |
349 "", | |
350 open_cdda, | |
351 { "cdda", "cddb", NULL }, | |
352 &stream_opts, | |
353 1 // Urls are an option string | |
354 }; | |
355 | |
6384
f0b933918a22
Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff
changeset
|
356 #endif |