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