1 /*****************************************************************************
2 * access.c : CD digital audio input module for vlc using libcdio
3 *****************************************************************************
4 * Copyright (C) 2000, 2003, 2004, 2005 VideoLAN
7 * Authors: Rocky Bernstein <rocky@panix.com>
8 * Laurent Aimar <fenrir@via.ecp.fr>
9 * Gildas Bazin <gbazin@netcourrier.com>
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
24 *****************************************************************************/
26 /*****************************************************************************
28 *****************************************************************************/
29 #include "callback.h" /* FIXME - reorganize callback.h, cdda.h better */
30 #include "cdda.h" /* private structures. Also #includes vlc things */
31 #include "info.h" /* headers for meta info retrieval */
32 #include <vlc_playlist.h> /* Has to come *after* cdda.h */
35 #include <cdio/cdio.h>
36 #include <cdio/logging.h>
37 #include <cdio/cd_types.h>
38 #include <cdio/cdda.h>
42 /* #ifdef variables below are defined via config.h via #include vlc above. */
47 #ifdef HAVE_SYS_TYPES_H
48 #include <sys/types.h>
59 /* FIXME: This variable is a hack. Would be nice to eliminate. */
60 access_t *p_cdda_input = NULL;
62 /*****************************************************************************
64 *****************************************************************************/
65 static block_t *CDDAReadBlocks( access_t * p_access );
66 static int CDDASeek( access_t * p_access, int64_t i_pos );
67 static int CDDAControl( access_t *p_access, int i_query,
70 static int CDDAInit( access_t *p_access, cdda_data_t *p_cdda ) ;
73 /****************************************************************************
75 ****************************************************************************/
77 /* process messages that originate from libcdio. */
79 cdio_log_handler (cdio_log_level_t level, const char message[])
81 cdda_data_t *p_cdda = (cdda_data_t *)p_cdda_input->p_sys;
89 if (p_cdda->i_debug & INPUT_DBG_CDIO)
90 msg_Dbg( p_cdda_input, message);
93 msg_Warn( p_cdda_input, message);
97 msg_Err( p_cdda_input, message);
100 msg_Warn( p_cdda_input, message,
101 "The above message had unknown cdio log level",
109 /*! This routine is called by libcddb routines on error.
110 Setup is done by init_input_plugin.
113 cddb_log_handler (cddb_log_level_t level, const char message[])
115 cdda_data_t *p_cdda = (cdda_data_t *)p_cdda_input->p_sys;
120 if (!(p_cdda->i_debug & INPUT_DBG_CDDB)) return;
122 /* Fall through if to warn case */
124 cdio_log_handler (level, message);
127 #endif /*HAVE_LIBCDDB*/
130 /*! This routine is when xine is not fully set up (before full initialization)
131 or is not around (before finalization).
134 uninit_log_handler (cdio_log_level_t level, const char message[])
136 cdda_data_t *p_cdda = NULL;
139 p_cdda = (cdda_data_t *)p_cdda_input->p_sys;
145 if (!p_cdda || !(p_cdda->i_debug & (INPUT_DBG_CDIO|INPUT_DBG_CDDB)))
148 /* Fall through if to warn case */
150 fprintf(stderr, "WARN: %s\n", message);
153 fprintf(stderr, "ERROR: %s\n", message);
155 case CDIO_LOG_ASSERT:
156 fprintf(stderr, "ASSERT ERROR: %s\n", message);
159 fprintf(stderr, "UNKNOWN ERROR: %s\n%s %d\n", message,
160 "The above message had unknown cdio log level",
164 /* gl_default_cdio_log_handler (level, message); */
167 /*****************************************************************************
168 * CDDAReadBlocks: reads a group of blocks from the CD-DA and returns
169 * an allocated pointer to the data. NULL is returned if no data
170 * read. It is also possible if we haven't read a RIFF header in which
171 * case one that we creaded during Open/Initialization is returned.
172 *****************************************************************************/
173 static block_t * CDDAReadBlocks( access_t * p_access )
176 cdda_data_t *p_cdda = (cdda_data_t *) p_access->p_sys;
177 int i_blocks = p_cdda->i_blocks_per_read;
179 dbg_print((INPUT_DBG_CALL|INPUT_DBG_EXT|INPUT_DBG_LSN), "called %d",
182 /* Check end of file */
183 if( p_access->info.b_eof ) return NULL;
185 if( !p_cdda->b_header )
187 /* Return only the dummy RIFF header we created in Open/Init */
188 p_block = block_New( p_access, sizeof( WAVEHEADER ) );
189 memcpy( p_block->p_buffer, &p_cdda->waveheader, sizeof(WAVEHEADER) );
190 p_cdda->b_header = VLC_TRUE;
194 /* Check end of track */
195 while( p_cdda->i_lsn >= cdio_get_track_lsn(p_cdda->p_cdio,
198 if( p_cdda->i_track >= p_cdda->i_first_track + p_cdda->i_titles - 1 )
200 p_access->info.b_eof = VLC_TRUE;
204 p_access->info.i_update |= INPUT_UPDATE_TITLE;
205 p_access->info.i_title++;
208 if ( p_cdda-> b_nav_mode ) {
209 char *psz_title = CDDAFormatTitle( p_access, p_cdda->i_track );
210 input_Control( p_cdda->p_input, INPUT_SET_NAME, psz_title );
213 p_access->info.i_size =
214 p_cdda->p_title[p_access->info.i_title]->i_size;
215 p_access->info.i_pos = 0;
216 p_access->info.i_update |= INPUT_UPDATE_SIZE;
220 /* Possibly adjust i_blocks so we don't read past the end of a track. */
221 if( p_cdda->i_lsn + i_blocks >=
222 cdio_get_track_lsn(p_cdda->p_cdio, p_cdda->i_track+1) )
224 i_blocks = cdio_get_track_lsn( p_cdda->p_cdio, p_cdda->i_track+1 )
228 /* Do the actual reading */
229 p_block = block_New( p_access, i_blocks * CDIO_CD_FRAMESIZE_RAW );
232 msg_Err( p_access, "Cannot get a new block of size: %i",
233 i_blocks * CDIO_CD_FRAMESIZE_RAW );
238 #if LIBCDIO_VERSION_NUM >= 72
239 driver_return_code_t rc = DRIVER_OP_SUCCESS;
241 if ( p_cdda->b_paranoia_enabled )
244 for( i = 0; i < i_blocks; i++ )
246 int16_t *p_readbuf=paranoia_read(p_cdda->paranoia, NULL);
247 char *psz_err=cdio_cddap_errors(p_cdda->paranoia_cd);
248 char *psz_mes=cdio_cddap_messages(p_cdda->paranoia_cd);
250 if (psz_mes || psz_err)
251 msg_Err( p_access, "%s%s\n", psz_mes ? psz_mes: "",
252 psz_err ? psz_err: "" );
254 if (psz_err) free(psz_err);
255 if (psz_mes) free(psz_mes);
257 msg_Err( p_access, "paranoia read error on frame %i\n",
260 memcpy(p_block + i * CDIO_CD_FRAMESIZE_RAW, p_readbuf,
261 CDIO_CD_FRAMESIZE_RAW);
265 rc = cdio_read_audio_sectors( p_cdda->p_cdio, p_block->p_buffer,
266 p_cdda->i_lsn, i_blocks);
268 #define DRIVER_OP_SUCCESS 0
270 rc = cdio_read_audio_sectors( p_cdda->p_cdio, p_block->p_buffer,
271 p_cdda->i_lsn, i_blocks);
273 if( rc != DRIVER_OP_SUCCESS )
275 msg_Err( p_access, "could not read %d sectors starting from %lu",
276 i_blocks, (long unsigned int) p_cdda->i_lsn );
277 block_Release( p_block );
279 /* If we had problems above, assume the problem is with
280 the first sector of the read and set to skip it. In
281 the future libcdio may have cdparanoia support.
284 p_access->info.i_pos += CDIO_CD_FRAMESIZE_RAW;
289 p_cdda->i_lsn += i_blocks;
290 p_access->info.i_pos += p_block->i_buffer;
295 /****************************************************************************
296 * CDDASeek - change position for subsequent reads. For example, this
297 * can happen if the user moves a position slider bar in a GUI.
298 ****************************************************************************/
299 static int CDDASeek( access_t * p_access, int64_t i_pos )
301 cdda_data_t *p_cdda = (cdda_data_t *) p_access->p_sys;
303 p_cdda->i_lsn = (i_pos / CDIO_CD_FRAMESIZE_RAW);
305 #if LIBCDIO_VERSION_NUM >= 72
306 if ( p_cdda->b_paranoia_enabled )
307 cdio_paranoia_seek(p_cdda->paranoia, p_cdda->i_lsn, SEEK_SET);
310 if ( ! p_cdda->b_nav_mode )
311 p_cdda->i_lsn += cdio_get_track_lsn(p_cdda->p_cdio, p_cdda->i_track);
313 /* Seeked backwards and we are doing disc mode. */
314 if ( p_cdda->b_nav_mode && p_access->info.i_pos > i_pos ) {
318 for( i_track = p_cdda->i_track;
320 p_cdda->i_lsn < cdio_get_track_lsn(p_cdda->p_cdio, i_track);
321 i_track--, p_access->info.i_title-- ) ;
323 p_cdda->i_track = i_track;
324 p_access->info.i_update |= INPUT_UPDATE_TITLE;
325 psz_title = CDDAFormatTitle( p_access, p_cdda->i_track );
326 input_Control( p_cdda->p_input, INPUT_SET_NAME,
332 p_access->info.i_pos = i_pos;
334 dbg_print( (INPUT_DBG_CALL|INPUT_DBG_EXT|INPUT_DBG_SEEK),
335 "lsn %lu, offset: %lld",
336 (long unsigned int) p_cdda->i_lsn, i_pos );
340 /****************************************************************************
342 ****************************************************************************/
344 /*****************************************************************************
345 * Open: open cdda device or image file and initialize structures
346 * for subsequent operations.
347 *****************************************************************************/
349 CDDAOpen( vlc_object_t *p_this )
351 access_t *p_access = (access_t*)p_this;
352 char * psz_source = NULL;
353 cdda_data_t *p_cdda = NULL;
356 vlc_bool_t b_single_track = false;
357 int i_rc = VLC_EGENERIC;
359 p_access->p_sys = NULL;
361 /* Set where to log errors messages from libcdio. */
362 p_cdda_input = p_access;
364 /* parse the options passed in command line : */
366 if( p_access->psz_path && *p_access->psz_path )
368 char *psz_parser = psz_source = strdup( p_access->psz_path );
370 while( *psz_parser && *psz_parser != '@' )
375 if( *psz_parser == '@' )
381 if ('T' == *psz_parser || 't' == *psz_parser )
384 i_track = (int)strtol( psz_parser, NULL, 10 );
385 i_track = i_track ? i_track : 1;
386 b_single_track = true;
390 if (!psz_source || !*psz_source)
392 /* No device/track given. Continue only when this plugin was
394 if( !p_this->b_force ) return VLC_EGENERIC;
396 psz_source = var_CreateGetString( p_this, "cd-audio" );
398 if( !psz_source || !*psz_source )
400 /* Scan for a CD-ROM drive with a CD-DA in it. */
402 cdio_get_devices_with_cap(NULL, CDIO_FS_AUDIO, false);
404 if (NULL == cd_drives || NULL == cd_drives[0] )
407 "libcdio couldn't find something with a CD-DA in it" );
408 if (cd_drives) cdio_free_device_list(cd_drives);
412 psz_source = strdup(cd_drives[0]);
413 cdio_free_device_list(cd_drives);
417 cdio_log_set_handler ( cdio_log_handler );
420 if( !(p_cdio = cdio_open( psz_source, DRIVER_UNKNOWN )) )
422 msg_Warn( p_access, "could not open %s", psz_source );
423 if (psz_source) free( psz_source );
427 p_cdda = calloc( 1, sizeof(cdda_data_t) );
430 msg_Err( p_access, "out of memory" );
436 cddb_log_set_handler ( cddb_log_handler );
437 p_cdda->cddb.disc = NULL;
438 p_cdda->b_cddb_enabled =
439 config_GetInt( p_access, MODULE_STRING "-cddb-enabled" );
442 p_cdda->b_cdtext_enabled =
443 config_GetInt( p_access, MODULE_STRING "-cdtext-enabled" );
445 p_cdda->b_cdtext_prefer =
446 config_GetInt( p_access, MODULE_STRING "-cdtext-prefer" );
448 p_cdda->psz_source = strdup(psz_source);
449 p_cdda->b_header = VLC_FALSE;
450 p_cdda->p_cdio = p_cdio;
451 p_cdda->i_tracks = 0;
452 p_cdda->i_titles = 0;
453 p_cdda->i_track = i_track;
454 p_cdda->i_debug = config_GetInt(p_this, MODULE_STRING
456 p_cdda->b_nav_mode = config_GetInt(p_this, MODULE_STRING
457 "-navigation-mode" );
458 p_cdda->i_blocks_per_read
459 = config_GetInt(p_this, MODULE_STRING "-blocks-per-read");
461 p_cdda->p_input = vlc_object_find( p_access, VLC_OBJECT_INPUT,
464 if (0 == p_cdda->i_blocks_per_read)
465 p_cdda->i_blocks_per_read = DEFAULT_BLOCKS_PER_READ;
467 if ( p_cdda->i_blocks_per_read < MIN_BLOCKS_PER_READ
468 || p_cdda->i_blocks_per_read > MAX_BLOCKS_PER_READ )
470 msg_Warn( p_cdda_input,
471 "Number of blocks (%d) has to be between %d and %d. "
473 p_cdda->i_blocks_per_read,
474 MIN_BLOCKS_PER_READ, MAX_BLOCKS_PER_READ,
475 DEFAULT_BLOCKS_PER_READ );
476 p_cdda->i_blocks_per_read = DEFAULT_BLOCKS_PER_READ;
479 dbg_print( (INPUT_DBG_CALL|INPUT_DBG_EXT), "%s", psz_source );
481 /* Set up p_access */
482 p_access->pf_read = NULL;
483 p_access->pf_block = CDDAReadBlocks;
484 p_access->pf_control = CDDAControl;
485 p_access->pf_seek = CDDASeek;
487 p_access->info.i_size = 0;
489 p_access->info.i_update = 0;
490 p_access->info.b_eof = VLC_FALSE;
491 p_access->info.i_title = 0;
492 p_access->info.i_seekpoint = 0;
494 p_access->p_sys = (access_sys_t *) p_cdda;
496 /* We read the Table Of Content information */
497 i_rc = CDDAInit( p_access, p_cdda );
498 if ( VLC_SUCCESS != i_rc ) goto error;
500 CDDAFixupPlaylist( p_access, p_cdda, b_single_track );
502 #if LIBCDIO_VERSION_NUM >= 72
503 p_cdda->b_paranoia_enabled =
504 config_GetInt( p_access, MODULE_STRING "-paranoia-enabled" );
506 /* Use CD Paranoia? */
507 if ( p_cdda->b_paranoia_enabled ) {
508 p_cdda->paranoia_cd = cdio_cddap_identify_cdio(p_cdio, 1, NULL);
509 /* We'll set for verbose paranoia messages. */
510 cdio_cddap_verbose_set(p_cdda->paranoia_cd, CDDA_MESSAGE_PRINTIT,
511 CDDA_MESSAGE_PRINTIT);
512 if ( 0 != cdio_cddap_open(p_cdda->paranoia_cd) ) {
513 msg_Warn( p_cdda_input, "Unable to get paranoia support - "
514 "continuing without it." );
515 p_cdda->b_paranoia_enabled = VLC_FALSE;
517 p_cdda->paranoia = cdio_paranoia_init(p_cdda->paranoia_cd);
518 cdio_paranoia_seek(p_cdda->paranoia, p_cdda->i_lsn, SEEK_SET);
520 /* Set reading mode for full paranoia, but allow skipping sectors. */
521 cdio_paranoia_modeset(p_cdda->paranoia,
522 PARANOIA_MODE_FULL^PARANOIA_MODE_NEVERSKIP);
528 /* Build a WAV header to put in front of the output data.
529 This gets sent back in the Block (read) routine.
531 memset( &p_cdda->waveheader, 0, sizeof(WAVEHEADER) );
532 SetWLE( &p_cdda->waveheader.Format, 1 ); /*WAVE_FORMAT_PCM*/
533 SetWLE( &p_cdda->waveheader.BitsPerSample, 16);
534 p_cdda->waveheader.MainChunkID = VLC_FOURCC('R', 'I', 'F', 'F');
535 p_cdda->waveheader.Length = 0; /* we just don't know */
536 p_cdda->waveheader.ChunkTypeID = VLC_FOURCC('W', 'A', 'V', 'E');
537 p_cdda->waveheader.SubChunkID = VLC_FOURCC('f', 'm', 't', ' ');
538 SetDWLE( &p_cdda->waveheader.SubChunkLength, 16);
539 SetWLE( &p_cdda->waveheader.Modus, 2);
540 SetDWLE( &p_cdda->waveheader.SampleFreq, CDDA_FREQUENCY_SAMPLE);
541 SetWLE( &p_cdda->waveheader.BytesPerSample,
542 2 /*Modus*/ * 16 /*BitsPerSample*/ / 8 );
543 SetDWLE( &p_cdda->waveheader.BytesPerSec,
544 2*16/8 /*BytesPerSample*/ * CDDA_FREQUENCY_SAMPLE );
545 p_cdda->waveheader.DataChunkID = VLC_FOURCC('d', 'a', 't', 'a');
546 p_cdda->waveheader.DataLength = 0; /* we just don't know */
549 var_Create( p_access, MODULE_STRING "-caching",
550 VLC_VAR_INTEGER|VLC_VAR_DOINHERIT );
551 vlc_object_release( p_cdda->p_input );
555 cdio_destroy( p_cdda->p_cdio );
556 if( psz_source) free( psz_source );
558 if ( p_cdda->p_input )
559 vlc_object_release( p_cdda->p_input );
567 /*****************************************************************************
568 * CDDAClose: closes cdda and frees any resources associded with it.
569 *****************************************************************************/
571 CDDAClose (vlc_object_t *p_this )
573 access_t *p_access = (access_t *) p_this;
574 cdda_data_t *p_cdda = (cdda_data_t *) p_access->p_sys;
577 dbg_print( (INPUT_DBG_CALL|INPUT_DBG_EXT), "" );
579 /* Remove playlist titles */
580 for( i = 0; i < p_cdda->i_titles; i++ )
582 vlc_input_title_Delete( p_cdda->p_title[i] );
586 cddb_log_set_handler ((cddb_log_handler_t) uninit_log_handler);
587 if (p_cdda->b_cddb_enabled)
588 cddb_disc_destroy(p_cdda->cddb.disc);
591 cdio_destroy( p_cdda->p_cdio );
592 cdio_log_set_handler (uninit_log_handler);
594 #if LIBCDIO_VERSION_NUM >= 72
595 if (p_cdda->paranoia)
596 cdio_paranoia_free(p_cdda->paranoia);
597 if (p_cdda->paranoia_cd)
598 cdio_cddap_close_no_free_cdio(p_cdda->paranoia_cd);
601 if (p_cdda->psz_mcn) free( p_cdda->psz_mcn );
602 if (p_cdda->psz_source) free( p_cdda->psz_source );
608 /*****************************************************************************
609 * Control: The front-end or vlc engine calls here to ether get
610 * information such as meta information or plugin capabilities or to
611 * issue miscellaneous "set" requests.
612 *****************************************************************************/
613 static int CDDAControl( access_t *p_access, int i_query, va_list args )
615 cdda_data_t *p_cdda = (cdda_data_t *) p_access->p_sys;
619 dbg_print( (INPUT_DBG_CALL|INPUT_DBG_EXT|INPUT_DBG_EVENT),
620 "query %d", i_query );
624 /* Pass back a copy of meta information that was gathered when we
625 during the Open/Initialize call.
627 case ACCESS_GET_META:
629 vlc_meta_t **pp_meta = (vlc_meta_t**)va_arg( args, vlc_meta_t** );
630 if ( p_cdda->p_meta )
632 *pp_meta = vlc_meta_Duplicate( p_cdda->p_meta );
633 dbg_print( INPUT_DBG_META, "%s", "Meta copied" );
637 msg_Warn( p_access, "tried to copy NULL meta info" );
642 case ACCESS_CAN_SEEK:
643 case ACCESS_CAN_FASTSEEK:
644 case ACCESS_CAN_PAUSE:
645 case ACCESS_CAN_CONTROL_PACE:
647 vlc_bool_t *pb_bool = (vlc_bool_t*)va_arg( args, vlc_bool_t* );
655 pi_int = (int*)va_arg( args, int * );
656 *pi_int = p_cdda-> i_blocks_per_read * CDIO_CD_FRAMESIZE_RAW;
660 case ACCESS_GET_PTS_DELAY:
662 int64_t *pi_64 = (int64_t*)va_arg( args, int64_t * );
663 *pi_64 = var_GetInteger( p_access, MODULE_STRING "-caching" )
664 * MILLISECONDS_PER_SEC;
669 case ACCESS_SET_PAUSE_STATE:
672 case ACCESS_GET_TITLE_INFO:
674 input_title_t ***ppp_title =
675 (input_title_t***)va_arg( args, input_title_t*** );
677 pi_int = (int*)va_arg( args, int* );
678 *((int*)va_arg( args, int* )) = 1; /* Title offset */
680 dbg_print ( INPUT_DBG_EVENT,
681 "GET TITLE: i_tracks %d, i_tracks %d",
682 p_cdda->i_tracks, p_cdda->i_tracks );
684 CDDAMetaInfo( p_access, CDIO_INVALID_TRACK );
686 if ( p_cdda->b_nav_mode) {
688 CDDAFormatTitle( p_access, p_cdda->i_track );
689 input_Control( p_cdda->p_input, INPUT_SET_NAME,
694 /* Duplicate title info */
695 if( p_cdda->i_titles == 0 )
697 *pi_int = 0; ppp_title = NULL;
700 *pi_int = p_cdda->i_titles;
701 *ppp_title = calloc(1,
702 sizeof( input_title_t **) * p_cdda->i_titles );
704 if (!*ppp_title) return VLC_ENOMEM;
706 for( i = 0; i < p_cdda->i_titles; i++ )
708 if ( p_cdda->p_title[i] ) {
710 vlc_input_title_Duplicate( p_cdda->p_title[i] );
716 case ACCESS_SET_TITLE:
718 i = (int)va_arg( args, int );
720 dbg_print( INPUT_DBG_EVENT, "set title %d", i );
721 if( i != p_access->info.i_title )
724 p_access->info.i_update |= INPUT_UPDATE_TITLE;
725 p_access->info.i_title = i;
726 if ( p_cdda->b_nav_mode) {
728 CDDAFormatTitle( p_access, i+1 );
729 input_Control( p_cdda->p_input, INPUT_SET_NAME,
732 p_cdda->i_track = i+1;
733 p_access->info.i_pos =
734 cdio_get_track_lsn( p_cdda->p_cdio, p_cdda->i_track )
735 * CDIO_CD_FRAMESIZE_RAW;
737 p_access->info.i_update |= INPUT_UPDATE_SIZE;
738 p_access->info.i_size = p_cdda->p_title[i]->i_size;
739 p_access->info.i_pos = 0;
742 /* Next sector to read */
744 cdio_get_track_lsn(p_cdda->p_cdio, p_cdda->i_first_track+i);
749 case ACCESS_SET_SEEKPOINT:
750 case ACCESS_SET_PRIVATE_ID_STATE:
754 msg_Warn( p_access, "unimplemented query in control" );
761 /*****************************************************************************
764 Initialize information pertaining to the CD: the number of tracks,
765 first track number, LSNs for each track and the leadout. The leadout
766 information is stored after the last track. The LSN array is
767 0-origin, same as p_access->info. Add first_track to get what track
768 number this is on the CD. Note: libcdio uses the real track number.
770 On input we assume p_cdda->p_cdio and p_cdda->i_track have been set.
772 We return the VLC-type status, e.g. VLC_SUCCESS, VLC_ENOMEM, etc.
773 *****************************************************************************/
774 static int CDDAInit( access_t *p_access, cdda_data_t *p_cdda )
776 discmode_t discmode = CDIO_DISC_MODE_NO_INFO;
778 p_cdda->i_tracks = cdio_get_num_tracks(p_cdda->p_cdio);
779 p_cdda->i_first_track = cdio_get_first_track_num(p_cdda->p_cdio);
781 discmode = cdio_get_discmode(p_cdda->p_cdio);
783 case CDIO_DISC_MODE_CD_DA:
784 case CDIO_DISC_MODE_CD_MIXED:
785 /* These are possible for CD-DA */
788 /* These are not possible for CD-DA */
790 "Disc seems not to be CD-DA. libcdio reports it is %s",
791 discmode2str[discmode]
796 /* Set reading start LSN. */
797 p_cdda->i_lsn = cdio_get_track_lsn(p_cdda->p_cdio, p_cdda->i_track);