annotate stream/stream_cdda.c @ 19846:bcc792bfa431

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