1 /*****************************************************************************
2 * cdda.c : CD digital audio input module for vlc
3 *****************************************************************************
4 * Copyright (C) 2000, 2003-2006, 2008-2009 VLC authors and VideoLAN
5 * $Id: 6f7ae19cc5f29fc0ba5793c8d2c297537bc4c4c6 $
6 *
7 * Authors: Laurent Aimar <fenrir@via.ecp.fr>
8 * Gildas Bazin <gbazin@netcourrier.com>
9 *
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU Lesser General Public License as published by
12 * the Free Software Foundation; either version 2.1 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License for more details.
19 *
20 * You should have received a copy of the GNU Lesser General Public License
21 * along with this program; if not, write to the Free Software Foundation,
22 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23 *****************************************************************************/
24
25 /**
26 * Todo:
27 * - Improve CDDB support (non-blocking, ...)
28 * - Fix tracknumber in MRL
29 */
30
31 /*****************************************************************************
32 * Preamble
33 *****************************************************************************/
34
35 #ifdef HAVE_CONFIG_H
36 # include "config.h"
37 #endif
38
39 #include <assert.h>
40 #include <math.h>
41 #include <stdlib.h>
42 #include <string.h>
43
44 #include <vlc_common.h>
45 #include <vlc_demux.h>
46 #include <vlc_plugin.h>
47 #include <vlc_input.h>
48 #include <vlc_access.h>
49 #include <vlc_meta.h>
50 #include <vlc_charset.h> /* ToLocaleDup */
51 #include <vlc_url.h>
52
53 #include "disc_helper.h"
54 #include "vcd/cdrom.h" /* For CDDA_DATA_SIZE */
55
56
57 #ifdef HAVE_LIBCDDB
58 #include <cddb/cddb.h>
59 #include <errno.h>
60 #endif
61
DiscOpen(vlc_object_t * obj,const char * location,const char * path,unsigned * restrict trackp)62 static vcddev_t *DiscOpen(vlc_object_t *obj, const char *location,
63 const char *path, unsigned *restrict trackp)
64 {
65 char *devpath;
66
67 *trackp = var_InheritInteger(obj, "cdda-track");
68
69 if (path != NULL)
70 devpath = ToLocaleDup(path);
71 else if (location[0] != '\0')
72 {
73 #if (DIR_SEP_CHAR == '/')
74 char *dec = vlc_uri_decode_duplicate(location);
75 if (dec == NULL)
76 return NULL;
77
78 /* GNOME CDDA syntax */
79 const char *sl = strrchr(dec, '/');
80 if (sl != NULL)
81 {
82 if (sscanf(sl, "/Track %2u", trackp) == 1)
83 dec[sl - dec] = '\0';
84 else
85 *trackp = 0;
86 }
87
88 if (unlikely(asprintf(&devpath, "/dev/%s", dec) == -1))
89 devpath = NULL;
90 free(dec);
91 #else
92 (void) location;
93 return NULL;
94 #endif
95 }
96 else
97 devpath = var_InheritString(obj, "cd-audio");
98
99 if (devpath == NULL)
100 return NULL;
101
102 #if defined (_WIN32) || defined (__OS2__)
103 /* Trim backslash after drive letter */
104 if (devpath[0] != '\0' && !strcmp(&devpath[1], ":" DIR_SEP))
105 devpath[2] = '\0';
106 #endif
107
108 if (DiscProbeMacOSPermission(obj, devpath) != VLC_SUCCESS) {
109 free(devpath);
110 return NULL;
111 }
112
113 /* Open CDDA */
114 vcddev_t *dev = ioctl_Open(obj, devpath);
115 if (dev == NULL)
116 msg_Warn(obj, "cannot open disc %s", devpath);
117 free(devpath);
118
119 return dev;
120 }
121
122 /* how many blocks Demux() will read in each iteration */
123 #define CDDA_BLOCKS_ONCE 20
124
125 struct demux_sys_t
126 {
127 vcddev_t *vcddev; /* vcd device descriptor */
128 es_out_id_t *es;
129 date_t pts;
130
131 unsigned start; /**< Track first sector */
132 unsigned length; /**< Track total sectors */
133 unsigned position; /**< Current offset within track sectors */
134 };
135
Demux(demux_t * demux)136 static int Demux(demux_t *demux)
137 {
138 demux_sys_t *sys = demux->p_sys;
139 unsigned count = CDDA_BLOCKS_ONCE;
140
141 if (sys->position >= sys->length)
142 return VLC_DEMUXER_EOF;
143
144 if (sys->position + count >= sys->length)
145 count = sys->length - sys->position;
146
147 block_t *block = block_Alloc(count * CDDA_DATA_SIZE);
148 if (unlikely(block == NULL))
149 return VLC_DEMUXER_EOF;
150
151 if (ioctl_ReadSectors(VLC_OBJECT(demux), sys->vcddev,
152 sys->start + sys->position,
153 block->p_buffer, count, CDDA_TYPE) < 0)
154 {
155 msg_Err(demux, "cannot read sector %u", sys->position);
156 block_Release(block);
157
158 /* Skip potentially bad sector */
159 sys->position++;
160 return VLC_DEMUXER_SUCCESS;
161 }
162
163 sys->position += count;
164
165 block->i_nb_samples = block->i_buffer / 4;
166 block->i_dts = block->i_pts = VLC_TS_0 + date_Get(&sys->pts);
167 date_Increment(&sys->pts, block->i_nb_samples);
168
169 es_out_Send(demux->out, sys->es, block);
170 es_out_SetPCR(demux->out, VLC_TS_0 + date_Get(&sys->pts));
171 return VLC_DEMUXER_SUCCESS;
172 }
173
DemuxControl(demux_t * demux,int query,va_list args)174 static int DemuxControl(demux_t *demux, int query, va_list args)
175 {
176 demux_sys_t *sys = demux->p_sys;
177
178 /* One sector is 40000/3 µs */
179 static_assert (CDDA_DATA_SIZE * CLOCK_FREQ * 3 ==
180 4 * 44100 * INT64_C(40000), "Wrong time/sector ratio");
181
182 switch (query)
183 {
184 case DEMUX_CAN_SEEK:
185 case DEMUX_CAN_PAUSE:
186 case DEMUX_CAN_CONTROL_PACE:
187 *va_arg(args, bool*) = true;
188 break;
189 case DEMUX_GET_PTS_DELAY:
190 *va_arg(args, int64_t *) =
191 INT64_C(1000) * var_InheritInteger(demux, "disc-caching");
192 break;
193
194 case DEMUX_SET_PAUSE_STATE:
195 break;
196
197 case DEMUX_GET_POSITION:
198 *va_arg(args, double *) = (double)(sys->position)
199 / (double)(sys->length);
200 break;
201
202 case DEMUX_SET_POSITION:
203 sys->position = lround(va_arg(args, double) * sys->length);
204 break;
205
206 case DEMUX_GET_LENGTH:
207 *va_arg(args, mtime_t *) = (INT64_C(40000) * sys->length) / 3;
208 break;
209 case DEMUX_GET_TIME:
210 *va_arg(args, mtime_t *) = (INT64_C(40000) * sys->position) / 3;
211 break;
212 case DEMUX_SET_TIME:
213 sys->position = (va_arg(args, mtime_t) * 3) / INT64_C(40000);
214 break;
215
216 default:
217 return VLC_EGENERIC;
218 }
219 return VLC_SUCCESS;
220 }
221
DemuxOpen(vlc_object_t * obj)222 static int DemuxOpen(vlc_object_t *obj)
223 {
224 demux_t *demux = (demux_t *)obj;
225 unsigned track;
226
227 vcddev_t *dev = DiscOpen(obj, demux->psz_location, demux->psz_file,
228 &track);
229 if (dev == NULL)
230 return VLC_EGENERIC;
231
232 if (track == 0 /* Whole disc -> use access plugin */)
233 goto error;
234
235 demux_sys_t *sys = vlc_obj_malloc(obj, sizeof (*sys));
236 if (unlikely(sys == NULL))
237 goto error;
238
239 demux->p_sys = sys;
240 sys->vcddev = dev;
241 sys->start = var_InheritInteger(obj, "cdda-first-sector");
242 sys->length = var_InheritInteger(obj, "cdda-last-sector") - sys->start;
243
244 /* Track number in input item */
245 if (sys->start == (unsigned)-1 || sys->length == (unsigned)-1)
246 {
247 int *sectors = NULL; /* Track sectors */
248 unsigned titles = ioctl_GetTracksMap(obj, dev, §ors);
249
250 if (track > titles)
251 {
252 msg_Err(obj, "invalid track number: %u/%u", track, titles);
253 free(sectors);
254 goto error;
255 }
256
257 sys->start = sectors[track - 1];
258 sys->length = sectors[track] - sys->start;
259 free(sectors);
260 }
261
262 es_format_t fmt;
263
264 es_format_Init(&fmt, AUDIO_ES, VLC_CODEC_S16L);
265 fmt.audio.i_rate = 44100;
266 fmt.audio.i_channels = 2;
267 sys->es = es_out_Add(demux->out, &fmt);
268
269 date_Init(&sys->pts, 44100, 1);
270 date_Set(&sys->pts, 0);
271
272 sys->position = 0;
273 demux->pf_demux = Demux;
274 demux->pf_control = DemuxControl;
275 return VLC_SUCCESS;
276
277 error:
278 ioctl_Close(obj, dev);
279 return VLC_EGENERIC;
280 }
281
DemuxClose(vlc_object_t * obj)282 static void DemuxClose(vlc_object_t *obj)
283 {
284 demux_t *demux = (demux_t *)obj;
285 demux_sys_t *sys = demux->p_sys;
286
287 ioctl_Close(obj, sys->vcddev);
288 }
289
290 /*****************************************************************************
291 * Access: local prototypes
292 *****************************************************************************/
293 struct access_sys_t
294 {
295 vcddev_t *vcddev; /* vcd device descriptor */
296 int *p_sectors; /* Track sectors */
297 int titles;
298 int cdtextc;
299 vlc_meta_t **cdtextv;
300 #ifdef HAVE_LIBCDDB
301 cddb_disc_t *cddb;
302 #endif
303 };
304
305 #ifdef HAVE_LIBCDDB
GetCDDBInfo(vlc_object_t * obj,int i_titles,int * p_sectors)306 static cddb_disc_t *GetCDDBInfo( vlc_object_t *obj, int i_titles, int *p_sectors )
307 {
308 if( !var_InheritBool( obj, "metadata-network-access" ) )
309 {
310 msg_Dbg( obj, "album art policy set to manual: not fetching" );
311 return NULL;
312 }
313
314 /* */
315 cddb_conn_t *p_cddb = cddb_new();
316 if( !p_cddb )
317 {
318 msg_Warn( obj, "unable to use CDDB" );
319 return NULL;
320 }
321
322 /* */
323
324 cddb_http_enable( p_cddb );
325
326 char *psz_tmp = var_InheritString( obj, "cddb-server" );
327 if( psz_tmp )
328 {
329 cddb_set_server_name( p_cddb, psz_tmp );
330 free( psz_tmp );
331 }
332
333 cddb_set_server_port( p_cddb, var_InheritInteger( obj, "cddb-port" ) );
334
335 cddb_set_email_address( p_cddb, "vlc@videolan.org" );
336
337 cddb_set_http_path_query( p_cddb, "/~cddb/cddb.cgi" );
338 cddb_set_http_path_submit( p_cddb, "/~cddb/submit.cgi" );
339
340
341 char *psz_cachedir;
342 char *psz_temp = config_GetUserDir( VLC_CACHE_DIR );
343
344 if( asprintf( &psz_cachedir, "%s" DIR_SEP "cddb", psz_temp ) > 0 ) {
345 cddb_cache_enable( p_cddb );
346 cddb_cache_set_dir( p_cddb, psz_cachedir );
347 free( psz_cachedir );
348 }
349 free( psz_temp );
350
351 cddb_set_timeout( p_cddb, 10 );
352
353 /* */
354 cddb_disc_t *p_disc = cddb_disc_new();
355 if( !p_disc )
356 {
357 msg_Err( obj, "unable to create CDDB disc structure." );
358 goto error;
359 }
360
361 int64_t i_length = 2000000; /* PreGap */
362 for( int i = 0; i < i_titles; i++ )
363 {
364 cddb_track_t *t = cddb_track_new();
365 cddb_track_set_frame_offset( t, p_sectors[i] + 150 ); /* Pregap offset */
366
367 cddb_disc_add_track( p_disc, t );
368 const int64_t i_size = ( p_sectors[i+1] - p_sectors[i] ) *
369 (int64_t)CDDA_DATA_SIZE;
370 i_length += INT64_C(1000000) * i_size / 44100 / 4 ;
371
372 msg_Dbg( obj, "Track %i offset: %i", i, p_sectors[i] + 150 );
373 }
374
375 msg_Dbg( obj, "Total length: %i", (int)(i_length/1000000) );
376 cddb_disc_set_length( p_disc, (int)(i_length/1000000) );
377
378 if( !cddb_disc_calc_discid( p_disc ) )
379 {
380 msg_Err( obj, "CDDB disc ID calculation failed" );
381 goto error;
382 }
383
384 const int i_matches = cddb_query( p_cddb, p_disc );
385 if( i_matches < 0 )
386 {
387 msg_Warn( obj, "CDDB error: %s", cddb_error_str(errno) );
388 goto error;
389 }
390 else if( i_matches == 0 )
391 {
392 msg_Dbg( obj, "Couldn't find any matches in CDDB." );
393 goto error;
394 }
395 else if( i_matches > 1 )
396 msg_Warn( obj, "found %d matches in CDDB. Using first one.", i_matches );
397
398 cddb_read( p_cddb, p_disc );
399
400 cddb_destroy( p_cddb);
401 return p_disc;
402
403 error:
404 if( p_disc )
405 cddb_disc_destroy( p_disc );
406 cddb_destroy( p_cddb );
407 return NULL;
408 }
409 #endif /* HAVE_LIBCDDB */
410
AccessGetMeta(stream_t * access,vlc_meta_t * meta)411 static void AccessGetMeta(stream_t *access, vlc_meta_t *meta)
412 {
413 access_sys_t *sys = access->p_sys;
414
415 vlc_meta_SetTitle(meta, "Audio CD");
416
417 /* Retrieve CD-TEXT information */
418 if (sys->cdtextc > 0 && sys->cdtextv[0] != NULL)
419 vlc_meta_Merge(meta, sys->cdtextv[0]);
420
421 /* Return true if the given string is not NULL and not empty */
422 #define NONEMPTY( psz ) ( (psz) && *(psz) )
423 /* If the given string is NULL or empty, fill it by the return value of 'code' */
424 #define ON_EMPTY( psz, code ) do { if( !NONEMPTY( psz) ) { (psz) = code; } } while(0)
425
426 /* Retrieve CDDB information (preferred over CD-TEXT) */
427 #ifdef HAVE_LIBCDDB
428 if (sys->cddb != NULL)
429 {
430 const char *str = cddb_disc_get_title(sys->cddb);
431 if (NONEMPTY(str))
432 vlc_meta_SetTitle(meta, str);
433
434 str = cddb_disc_get_genre(sys->cddb);
435 if (NONEMPTY(str))
436 vlc_meta_SetGenre(meta, str);
437
438 const unsigned year = cddb_disc_get_year(sys->cddb);
439 if (year != 0)
440 {
441 char yearbuf[5];
442
443 snprintf(yearbuf, sizeof (yearbuf), "%u", year);
444 vlc_meta_SetDate(meta, yearbuf);
445 }
446
447 /* Set artist only if identical across tracks */
448 str = cddb_disc_get_artist(sys->cddb);
449 if (NONEMPTY(str))
450 {
451 for (int i = 0; i < sys->titles; i++)
452 {
453 cddb_track_t *t = cddb_disc_get_track(sys->cddb, i);
454 if (t == NULL)
455 continue;
456
457 const char *track_artist = cddb_track_get_artist(t);
458 if (NONEMPTY(track_artist))
459 {
460 if (str == NULL)
461 str = track_artist;
462 else
463 if (strcmp(str, track_artist))
464 {
465 str = NULL;
466 break;
467 }
468 }
469 }
470 }
471 }
472 #endif
473 }
474
ReadDir(stream_t * access,input_item_node_t * node)475 static int ReadDir(stream_t *access, input_item_node_t *node)
476 {
477 access_sys_t *sys = access->p_sys;
478
479 /* Build title table */
480 for (int i = 0; i < sys->titles; i++)
481 {
482 msg_Dbg(access, "track[%d] start=%d", i, sys->p_sectors[i]);
483
484 /* Initial/default name */
485 char *name;
486
487 if (unlikely(asprintf(&name, _("Audio CD - Track %02i"), i + 1) == -1))
488 name = NULL;
489
490 /* Create playlist items */
491 const mtime_t duration =
492 (mtime_t)(sys->p_sectors[i + 1] - sys->p_sectors[i])
493 * CDDA_DATA_SIZE * CLOCK_FREQ / 44100 / 2 / 2;
494
495 input_item_t *item = input_item_NewDisc(access->psz_url,
496 (name != NULL) ? name :
497 access->psz_url, duration);
498 free(name);
499
500 if (unlikely(item == NULL))
501 continue;
502
503 char *opt;
504 if (likely(asprintf(&opt, "cdda-track=%i", i + 1) != -1))
505 {
506 input_item_AddOption(item, opt, VLC_INPUT_OPTION_TRUSTED);
507 free(opt);
508 }
509
510 if (likely(asprintf(&opt, "cdda-first-sector=%i",
511 sys->p_sectors[i]) != -1))
512 {
513 input_item_AddOption(item, opt, VLC_INPUT_OPTION_TRUSTED);
514 free(opt);
515 }
516
517 if (likely(asprintf(&opt, "cdda-last-sector=%i",
518 sys->p_sectors[i + 1]) != -1))
519 {
520 input_item_AddOption(item, opt, VLC_INPUT_OPTION_TRUSTED);
521 free(opt);
522 }
523
524 const char *title = NULL;
525 const char *artist = NULL;
526 const char *album = NULL;
527 const char *genre = NULL;
528 const char *description = NULL;
529 int year = 0;
530
531 #ifdef HAVE_LIBCDDB
532 if (sys->cddb != NULL)
533 {
534 cddb_track_t *t = cddb_disc_get_track(sys->cddb, i);
535 if (t != NULL)
536 {
537 title = cddb_track_get_title(t);
538 artist = cddb_track_get_artist(t);
539 }
540
541 ON_EMPTY(artist, cddb_disc_get_artist(sys->cddb));
542 album = cddb_disc_get_title(sys->cddb);
543 genre = cddb_disc_get_genre(sys->cddb);
544 year = cddb_disc_get_year(sys->cddb);
545 }
546 #endif
547 const vlc_meta_t *m;
548
549 if (sys->cdtextc > 0 && (m = sys->cdtextv[0]) != NULL)
550 {
551 ON_EMPTY(artist, vlc_meta_Get(m, vlc_meta_Artist));
552 ON_EMPTY(album, vlc_meta_Get(m, vlc_meta_Album));
553 ON_EMPTY(genre, vlc_meta_Get(m, vlc_meta_Genre));
554 description = vlc_meta_Get(m, vlc_meta_Description);
555 }
556
557 if (i + 1 < sys->cdtextc && (m = sys->cdtextv[i + 1]) != NULL)
558 {
559 ON_EMPTY(title, vlc_meta_Get(m, vlc_meta_Title));
560 ON_EMPTY(artist, vlc_meta_Get(m, vlc_meta_Artist));
561 ON_EMPTY(genre, vlc_meta_Get(m, vlc_meta_Genre));
562 ON_EMPTY(description, vlc_meta_Get(m, vlc_meta_Description));
563 }
564
565 if (NONEMPTY(title))
566 {
567 input_item_SetName(item, title);
568 input_item_SetTitle(item, title);
569 }
570
571 if (NONEMPTY(artist))
572 input_item_SetArtist(item, artist);
573
574 if (NONEMPTY(genre))
575 input_item_SetGenre(item, genre);
576
577 if (NONEMPTY(description))
578 input_item_SetDescription(item, description);
579
580 if (NONEMPTY(album))
581 input_item_SetAlbum(item, album);
582
583 if (year != 0)
584 {
585 char yearbuf[5];
586
587 snprintf(yearbuf, sizeof (yearbuf), "%u", year);
588 input_item_SetDate(item, yearbuf);
589 }
590
591 char num[4];
592 snprintf(num, sizeof (num), "%d", i + 1);
593 input_item_SetTrackNum(item, num);
594
595 input_item_node_AppendItem(node, item);
596 input_item_Release(item);
597 }
598 #undef ON_EMPTY
599 #undef NONEMPTY
600 return VLC_SUCCESS;
601 }
602
AccessControl(stream_t * access,int query,va_list args)603 static int AccessControl(stream_t *access, int query, va_list args)
604 {
605 if (query == STREAM_GET_META)
606 {
607 AccessGetMeta(access, va_arg(args, vlc_meta_t *));
608 return VLC_SUCCESS;
609 }
610 return access_vaDirectoryControlHelper(access, query, args);
611 }
612
AccessOpen(vlc_object_t * obj)613 static int AccessOpen(vlc_object_t *obj)
614 {
615 stream_t *access = (stream_t *)obj;
616 unsigned track;
617
618 vcddev_t *dev = DiscOpen(obj, access->psz_location, access->psz_filepath,
619 &track);
620 if (dev == NULL)
621 return VLC_EGENERIC;
622
623 if (track != 0 /* Only whole discs here */)
624 {
625 ioctl_Close(obj, dev);
626 return VLC_EGENERIC;
627 }
628
629 access_sys_t *sys = vlc_obj_malloc(obj, sizeof (*sys));
630 if (unlikely(sys == NULL))
631 {
632 ioctl_Close(obj, dev);
633 return VLC_ENOMEM;
634 }
635
636 sys->vcddev = dev;
637 sys->p_sectors = NULL;
638
639 sys->titles = ioctl_GetTracksMap(obj, dev, &sys->p_sectors);
640 if (sys->titles < 0)
641 {
642 msg_Err(obj, "cannot count tracks");
643 goto error;
644 }
645
646 if (sys->titles == 0)
647 {
648 msg_Err(obj, "no audio tracks found");
649 goto error;
650 }
651
652 #ifdef HAVE_LIBCDDB
653 msg_Dbg(obj, "retrieving metadata with CDDB");
654
655 sys->cddb = GetCDDBInfo(obj, sys->titles, sys->p_sectors);
656 if (sys->cddb != NULL)
657 msg_Dbg(obj, "disc ID: 0x%08x", cddb_disc_get_discid(sys->cddb));
658 else
659 msg_Dbg(obj, "CDDB failure");
660 #endif
661
662 if (ioctl_GetCdText(obj, dev, &sys->cdtextv, &sys->cdtextc))
663 {
664 msg_Dbg(obj, "CD-TEXT information missing");
665 sys->cdtextv = NULL;
666 sys->cdtextc = 0;
667 }
668
669 access->p_sys = sys;
670 access->pf_read = NULL;
671 access->pf_block = NULL;
672 access->pf_readdir = ReadDir;
673 access->pf_seek = NULL;
674 access->pf_control = AccessControl;
675 return VLC_SUCCESS;
676
677 error:
678 free(sys->p_sectors);
679 ioctl_Close(obj, dev);
680 return VLC_EGENERIC;
681 }
682
AccessClose(vlc_object_t * obj)683 static void AccessClose(vlc_object_t *obj)
684 {
685 stream_t *access = (stream_t *)obj;
686 access_sys_t *sys = access->p_sys;
687
688 for (int i = 0; i < sys->cdtextc; i++)
689 {
690 vlc_meta_t *meta = sys->cdtextv[i];
691 if (meta != NULL)
692 vlc_meta_Delete(meta);
693 }
694 free(sys->cdtextv);
695
696 #ifdef HAVE_LIBCDDB
697 if (sys->cddb != NULL)
698 cddb_disc_destroy(sys->cddb);
699 #endif
700
701 free(sys->p_sectors);
702 ioctl_Close(obj, sys->vcddev);
703 }
704
705 /*****************************************************************************
706 * Module descriptior
707 *****************************************************************************/
708 #define CDAUDIO_DEV_TEXT N_("Audio CD device")
709 #if defined( _WIN32 ) || defined( __OS2__ )
710 # define CDAUDIO_DEV_LONGTEXT N_( \
711 "This is the default Audio CD drive (or file) to use. Don't forget the " \
712 "colon after the drive letter (e.g. D:)")
713 # define CD_DEVICE "D:"
714 #else
715 # define CDAUDIO_DEV_LONGTEXT N_( \
716 "This is the default Audio CD device to use." )
717 # if defined(__OpenBSD__)
718 # define CD_DEVICE "/dev/cd0c"
719 # elif defined(__linux__)
720 # define CD_DEVICE "/dev/sr0"
721 # else
722 # define CD_DEVICE "/dev/cdrom"
723 # endif
724 #endif
725
726 vlc_module_begin ()
727 set_shortname( N_("Audio CD") )
728 set_description( N_("Audio CD input") )
729 set_capability( "access", 10 )
730 set_category( CAT_INPUT )
731 set_subcategory( SUBCAT_INPUT_ACCESS )
732 set_callbacks(AccessOpen, AccessClose)
733
734 add_loadfile( "cd-audio", CD_DEVICE, CDAUDIO_DEV_TEXT,
735 CDAUDIO_DEV_LONGTEXT, false )
736
737 add_usage_hint( N_("[cdda:][device][@[track]]") )
738 add_integer( "cdda-track", 0 , NULL, NULL, true )
739 change_volatile ()
740 add_integer( "cdda-first-sector", -1, NULL, NULL, true )
741 change_volatile ()
742 add_integer( "cdda-last-sector", -1, NULL, NULL, true )
743 change_volatile ()
744
745 #ifdef HAVE_LIBCDDB
746 add_string( "cddb-server", "freedb.videolan.org", N_( "CDDB Server" ),
747 N_( "Address of the CDDB server to use." ), true )
748 add_integer( "cddb-port", 80, N_( "CDDB port" ),
749 N_( "CDDB Server port to use." ), true )
750 change_integer_range( 1, 65535 )
751 #endif
752
753 add_shortcut( "cdda", "cddasimple" )
754
755 add_submodule()
756 set_capability( "access_demux", 10 )
757 set_callbacks(DemuxOpen, DemuxClose)
758 vlc_module_end ()
759