annotate libmpdemux/cdda.c @ 8193:83d3125cb382

A bit more sane range.
author rguyom
date Thu, 14 Nov 2002 21:57:34 +0000
parents 3dc0b71630ff
children fe542f0201ea
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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"
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
6 #include "../cfgparser.h"
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
7
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
8 #include <stdio.h>
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
9 #include <stdlib.h>
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
10
6696
030e3fa9cf4a Build a fake list of track name.
bertrand
parents: 6384
diff changeset
11 #include "cdd.h"
6384
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
12
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
13 static int speed = -1;
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
14 static int paranoia_mode = 1;
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
15 static char* generic_dev = NULL;
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
16 static int sector_size = 0;
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
17 static int search_overlap = -1;
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
18 static int toc_bias = 0;
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
19 static int toc_offset = 0;
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
20 static int no_skip = 0;
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
21
7867
3dc0b71630ff cleanup config option handling in libmpdemux.
arpi
parents: 6696
diff changeset
22 config_t cdda_opts[] = {
6384
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
23 { "speed", &speed, CONF_TYPE_INT, CONF_RANGE,1,100, NULL },
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
24 { "paranoia", &paranoia_mode, CONF_TYPE_INT,CONF_RANGE, 0, 2, NULL },
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
25 { "generic-dev", &generic_dev, CONF_TYPE_STRING, 0, 0, 0, NULL },
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
26 { "sector-size", &sector_size, CONF_TYPE_INT, CONF_RANGE,1,100, NULL },
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
27 { "overlap", &search_overlap, CONF_TYPE_INT, CONF_RANGE,0,75, NULL },
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
28 { "toc-bias", &toc_bias, CONF_TYPE_INT, 0, 0, 0, NULL },
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
29 { "toc-offset", &toc_offset, CONF_TYPE_INT, 0, 0, 0, NULL },
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
30 { "noskip", &no_skip, CONF_TYPE_FLAG, 0 , 0, 1, NULL },
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
31 { "skip", &no_skip, CONF_TYPE_FLAG, 0 , 1, 0, NULL },
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
32 {NULL, NULL, 0, 0, 0, 0, NULL}
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
33 };
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
34
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
35 stream_t* open_cdda(char* dev,char* track) {
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
36 stream_t* st;
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
37 int start_track = 0;
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
38 int end_track = 0;
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
39 int mode = paranoia_mode;
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
40 int offset = toc_offset;
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
41 cdrom_drive* cdd = NULL;
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
42 cdda_priv* priv;
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
43 char* end = strchr(track,'-');
6696
030e3fa9cf4a Build a fake list of track name.
bertrand
parents: 6384
diff changeset
44 cd_info_t *cd_info;
030e3fa9cf4a Build a fake list of track name.
bertrand
parents: 6384
diff changeset
45 unsigned int audiolen=0;
030e3fa9cf4a Build a fake list of track name.
bertrand
parents: 6384
diff changeset
46 int i;
6384
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
47
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
48 if(!end)
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
49 start_track = end_track = atoi(track);
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
50 else {
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
51 int st_len = end - track;
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
52 int ed_len = strlen(track) - 1 - st_len;
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
53
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
54 if(st_len) {
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
55 char st[st_len + 1];
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
56 strncpy(st,track,st_len);
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
57 st[st_len] = '\0';
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
58 start_track = atoi(st);
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
59 }
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
60 if(ed_len) {
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
61 char ed[ed_len + 1];
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
62 strncpy(ed,end+1,ed_len);
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
63 ed[ed_len] = '\0';
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
64 end_track = atoi(ed);
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
65 }
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
66 }
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
67
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
68 if(generic_dev)
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
69 cdd = cdda_identify_scsi(generic_dev,dev,0,NULL);
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
70 else
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
71 cdd = cdda_identify(dev,0,NULL);
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
72
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
73 if(!cdd) {
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
74 mp_msg(MSGT_OPEN,MSGL_ERR,"Can't open cdda device\n");
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
75 return NULL;
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
76 }
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
77
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
78 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
79
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
80 if(sector_size) {
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
81 cdd->nsectors = sector_size;
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
82 cdd->bigbuff = sector_size * CD_FRAMESIZE_RAW;
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
83 }
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
84
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
85 if(cdda_open(cdd) != 0) {
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
86 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
87 cdda_close(cdd);
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
88 return NULL;
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
89 }
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
90
6696
030e3fa9cf4a Build a fake list of track name.
bertrand
parents: 6384
diff changeset
91 cd_info = cd_info_new();
030e3fa9cf4a Build a fake list of track name.
bertrand
parents: 6384
diff changeset
92 mp_msg(MSGT_OPEN,MSGL_INFO,"Found Audio CD with %d tracks\n",cdda_tracks(cdd));
030e3fa9cf4a Build a fake list of track name.
bertrand
parents: 6384
diff changeset
93 for(i=0;i<cdd->tracks;i++) {
030e3fa9cf4a Build a fake list of track name.
bertrand
parents: 6384
diff changeset
94 char track_name[80];
030e3fa9cf4a Build a fake list of track name.
bertrand
parents: 6384
diff changeset
95 long sec=cdda_track_firstsector(cdd,i+1);
030e3fa9cf4a Build a fake list of track name.
bertrand
parents: 6384
diff changeset
96 long off=cdda_track_lastsector(cdd,i+1)-sec+1;
030e3fa9cf4a Build a fake list of track name.
bertrand
parents: 6384
diff changeset
97
030e3fa9cf4a Build a fake list of track name.
bertrand
parents: 6384
diff changeset
98 sprintf(track_name, "Track %d", i+1);
030e3fa9cf4a Build a fake list of track name.
bertrand
parents: 6384
diff changeset
99 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 );
030e3fa9cf4a Build a fake list of track name.
bertrand
parents: 6384
diff changeset
100 audiolen += off;
030e3fa9cf4a Build a fake list of track name.
bertrand
parents: 6384
diff changeset
101 }
030e3fa9cf4a Build a fake list of track name.
bertrand
parents: 6384
diff changeset
102 cd_info->min = (unsigned int)(audiolen/(60*75));
030e3fa9cf4a Build a fake list of track name.
bertrand
parents: 6384
diff changeset
103 cd_info->sec = (unsigned int)((audiolen/75)%60);
030e3fa9cf4a Build a fake list of track name.
bertrand
parents: 6384
diff changeset
104 cd_info->msec = (unsigned int)(audiolen%75);
030e3fa9cf4a Build a fake list of track name.
bertrand
parents: 6384
diff changeset
105
6384
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
106 priv = (cdda_priv*)malloc(sizeof(cdda_priv));
6696
030e3fa9cf4a Build a fake list of track name.
bertrand
parents: 6384
diff changeset
107 memset(priv, 0, sizeof(cdda_priv));
6384
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
108 priv->cd = cdd;
6696
030e3fa9cf4a Build a fake list of track name.
bertrand
parents: 6384
diff changeset
109 priv->cd_info = cd_info;
6384
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
110
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
111 if(toc_bias)
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
112 offset -= cdda_track_firstsector(cdd,1);
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
113
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
114 if(offset) {
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
115 int i;
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
116 for(i = 0 ; i < cdd->tracks + 1 ; i++)
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
117 cdd->disc_toc[i].dwStartSector += offset;
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
118 }
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 if(speed)
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
121 cdda_speed_set(cdd,speed);
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
122
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
123 if(start_track)
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
124 priv->start_sector = cdda_track_firstsector(cdd,start_track);
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
125 else
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
126 priv->start_sector = cdda_disc_firstsector(cdd);
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
127
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
128 if(end_track) {
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
129 int last = cdda_tracks(cdd);
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
130 if(end_track > last) end_track = last;
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
131 priv->end_sector = cdda_track_lastsector(cdd,end_track);
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
132 } else
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
133 priv->end_sector = cdda_disc_lastsector(cdd);
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
134
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
135 priv->cdp = paranoia_init(cdd);
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
136 if(priv->cdp == NULL) {
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
137 cdda_close(cdd);
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
138 free(priv);
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
139 return NULL;
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
140 }
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
141
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
142 if(mode == 0)
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
143 mode = PARANOIA_MODE_DISABLE;
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
144 else if(mode == 1)
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
145 mode = PARANOIA_MODE_OVERLAP;
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
146 else
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
147 mode = PARANOIA_MODE_FULL;
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
148
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
149 if(no_skip)
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
150 mode |= PARANOIA_MODE_NEVERSKIP;
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 if(search_overlap >= 0)
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
153 paranoia_overlapset(cdd,search_overlap);
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
154
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
155 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
156 priv->sector = priv->start_sector;
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 st = new_stream(-1,STREAMTYPE_CDDA);
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
159 st->priv = priv;
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
160 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
161 st->end_pos = priv->end_sector*CD_FRAMESIZE_RAW;
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
162
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
163 return st;
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
164 }
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 static void cdparanoia_callback(long inpos, int function) {
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
167 }
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
168
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
169 int read_cdda(stream_t* s) {
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
170 cdda_priv* p = (cdda_priv*)s->priv;
6696
030e3fa9cf4a Build a fake list of track name.
bertrand
parents: 6384
diff changeset
171 cd_track_t *cd_track;
6384
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
172 int16_t * buf;
6696
030e3fa9cf4a Build a fake list of track name.
bertrand
parents: 6384
diff changeset
173 unsigned int i;
6384
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 buf = paranoia_read(p->cdp,cdparanoia_callback);
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
176
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
177 p->sector++;
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
178 s->pos = p->sector*CD_FRAMESIZE_RAW;
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
179 memcpy(s->buffer,buf,CD_FRAMESIZE_RAW);
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 if(p->sector == p->end_sector)
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
182 s->eof = 1;
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
183
6696
030e3fa9cf4a Build a fake list of track name.
bertrand
parents: 6384
diff changeset
184 for(i=0;i<p->cd->tracks;i++){
030e3fa9cf4a Build a fake list of track name.
bertrand
parents: 6384
diff changeset
185 if(p->cd->disc_toc[i].dwStartSector==p->sector-1) {
030e3fa9cf4a Build a fake list of track name.
bertrand
parents: 6384
diff changeset
186 cd_track = cd_info_get_track(p->cd_info, i+1);
030e3fa9cf4a Build a fake list of track name.
bertrand
parents: 6384
diff changeset
187 //printf("Track %d, sector=%d\n", i, p->sector-1);
030e3fa9cf4a Build a fake list of track name.
bertrand
parents: 6384
diff changeset
188 if( cd_track!=NULL ) {
030e3fa9cf4a Build a fake list of track name.
bertrand
parents: 6384
diff changeset
189 printf("%s\n", cd_track->name );
030e3fa9cf4a Build a fake list of track name.
bertrand
parents: 6384
diff changeset
190 }
030e3fa9cf4a Build a fake list of track name.
bertrand
parents: 6384
diff changeset
191 break;
030e3fa9cf4a Build a fake list of track name.
bertrand
parents: 6384
diff changeset
192 }
030e3fa9cf4a Build a fake list of track name.
bertrand
parents: 6384
diff changeset
193 }
030e3fa9cf4a Build a fake list of track name.
bertrand
parents: 6384
diff changeset
194
030e3fa9cf4a Build a fake list of track name.
bertrand
parents: 6384
diff changeset
195
6384
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
196 return CD_FRAMESIZE_RAW;
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
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
199 void seek_cdda(stream_t* s) {
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
200 cdda_priv* p = (cdda_priv*)s->priv;
6696
030e3fa9cf4a Build a fake list of track name.
bertrand
parents: 6384
diff changeset
201 cd_track_t *cd_track;
030e3fa9cf4a Build a fake list of track name.
bertrand
parents: 6384
diff changeset
202 int sec;
030e3fa9cf4a Build a fake list of track name.
bertrand
parents: 6384
diff changeset
203 int current_track=0, seeked_track=0;
030e3fa9cf4a Build a fake list of track name.
bertrand
parents: 6384
diff changeset
204 int i;
6384
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
205
6696
030e3fa9cf4a Build a fake list of track name.
bertrand
parents: 6384
diff changeset
206 sec = s->pos/CD_FRAMESIZE_RAW;
030e3fa9cf4a Build a fake list of track name.
bertrand
parents: 6384
diff changeset
207 //printf("pos: %d, sec: %d ## %d\n", s->pos, sec, s->pos/CD_FRAMESIZE_RAW);
030e3fa9cf4a Build a fake list of track name.
bertrand
parents: 6384
diff changeset
208 //printf("sector: %d\n", p->sector );
030e3fa9cf4a Build a fake list of track name.
bertrand
parents: 6384
diff changeset
209
030e3fa9cf4a Build a fake list of track name.
bertrand
parents: 6384
diff changeset
210 for(i=0;i<p->cd->tracks;i++){
030e3fa9cf4a Build a fake list of track name.
bertrand
parents: 6384
diff changeset
211 if( p->sector>p->cd->disc_toc[i].dwStartSector && p->sector<p->cd->disc_toc[i+1].dwStartSector ) {
030e3fa9cf4a Build a fake list of track name.
bertrand
parents: 6384
diff changeset
212 current_track = i;
030e3fa9cf4a Build a fake list of track name.
bertrand
parents: 6384
diff changeset
213 }
030e3fa9cf4a Build a fake list of track name.
bertrand
parents: 6384
diff changeset
214 if( sec>p->cd->disc_toc[i].dwStartSector && sec<p->cd->disc_toc[i+1].dwStartSector ) {
030e3fa9cf4a Build a fake list of track name.
bertrand
parents: 6384
diff changeset
215 seeked_track = i;
030e3fa9cf4a Build a fake list of track name.
bertrand
parents: 6384
diff changeset
216 }
030e3fa9cf4a Build a fake list of track name.
bertrand
parents: 6384
diff changeset
217 }
030e3fa9cf4a Build a fake list of track name.
bertrand
parents: 6384
diff changeset
218 //printf("current: %d, seeked: %d\n", current_track, seeked_track);
030e3fa9cf4a Build a fake list of track name.
bertrand
parents: 6384
diff changeset
219 if( current_track!=seeked_track ) {
030e3fa9cf4a Build a fake list of track name.
bertrand
parents: 6384
diff changeset
220 //printf("Track %d, sector=%d\n", seeked_track, sec);
030e3fa9cf4a Build a fake list of track name.
bertrand
parents: 6384
diff changeset
221 cd_track = cd_info_get_track(p->cd_info, seeked_track+1);
030e3fa9cf4a Build a fake list of track name.
bertrand
parents: 6384
diff changeset
222 if( cd_track!=NULL ) {
030e3fa9cf4a Build a fake list of track name.
bertrand
parents: 6384
diff changeset
223 printf("%s\n", cd_track->name );
030e3fa9cf4a Build a fake list of track name.
bertrand
parents: 6384
diff changeset
224 }
030e3fa9cf4a Build a fake list of track name.
bertrand
parents: 6384
diff changeset
225
030e3fa9cf4a Build a fake list of track name.
bertrand
parents: 6384
diff changeset
226 }
030e3fa9cf4a Build a fake list of track name.
bertrand
parents: 6384
diff changeset
227
6384
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
228 if(sec < p->start_sector)
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
229 sec = p->start_sector;
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
230 else if(sec > p->end_sector)
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
231 sec = p->end_sector;
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
232
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
233 p->sector = sec;
6696
030e3fa9cf4a Build a fake list of track name.
bertrand
parents: 6384
diff changeset
234 // s->pos = sec*CD_FRAMESIZE_RAW;
6384
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
235
6696
030e3fa9cf4a Build a fake list of track name.
bertrand
parents: 6384
diff changeset
236 //printf("seek: %d, sec: %d\n", s->pos, sec);
6384
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
237 paranoia_seek(p->cdp,sec,SEEK_SET);
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
238
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
239 }
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
240
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
241 void close_cdda(stream_t* s) {
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
242 cdda_priv* p = (cdda_priv*)s->priv;
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
243 paranoia_free(p->cdp);
f0b933918a22 Support for playing audio cds using cdparanoia. Include a raw audio
albeu
parents:
diff changeset
244 cdda_close(p->cd);
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 #endif