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>
41 /* #ifdef variables below are defined via config.h via #include vlc above. */
46 #ifdef HAVE_SYS_TYPES_H
47 #include <sys/types.h>
58 /* FIXME: This variable is a hack. Would be nice to eliminate. */
59 access_t *p_cdda_input = NULL;
61 /*****************************************************************************
63 *****************************************************************************/
64 static block_t *CDDAReadBlocks( access_t * p_access );
65 static int CDDASeek( access_t * p_access, int64_t i_pos );
66 static int CDDAControl( access_t *p_access, int i_query,
69 static int CDDAInit( access_t *p_access, cdda_data_t *p_cdda ) ;
72 /****************************************************************************
74 ****************************************************************************/
76 /* process messages that originate from libcdio. */
78 cdio_log_handler (cdio_log_level_t level, const char message[])
80 cdda_data_t *p_cdda = (cdda_data_t *)p_cdda_input->p_sys;
88 if (p_cdda->i_debug & INPUT_DBG_CDIO)
89 msg_Dbg( p_cdda_input, message);
92 msg_Warn( p_cdda_input, message);
96 msg_Err( p_cdda_input, message);
99 msg_Warn( p_cdda_input, message,
100 "The above message had unknown cdio log level",
108 /*! This routine is called by libcddb routines on error.
109 Setup is done by init_input_plugin.
112 cddb_log_handler (cddb_log_level_t level, const char message[])
114 cdda_data_t *p_cdda = (cdda_data_t *)p_cdda_input->p_sys;
119 if (!(p_cdda->i_debug & INPUT_DBG_CDDB)) return;
121 /* Fall through if to warn case */
123 cdio_log_handler (level, message);
126 #endif /*HAVE_LIBCDDB*/
129 /*! This routine is when xine is not fully set up (before full initialization)
130 or is not around (before finalization).
133 uninit_log_handler (cdio_log_level_t level, const char message[])
135 cdda_data_t *p_cdda = NULL;
138 p_cdda = (cdda_data_t *)p_cdda_input->p_sys;
144 if (!p_cdda || !(p_cdda->i_debug & (INPUT_DBG_CDIO|INPUT_DBG_CDDB)))
147 /* Fall through if to warn case */
149 fprintf(stderr, "WARN: %s\n", message);
152 fprintf(stderr, "ERROR: %s\n", message);
154 case CDIO_LOG_ASSERT:
155 fprintf(stderr, "ASSERT ERROR: %s\n", message);
158 fprintf(stderr, "UNKNOWN ERROR: %s\n%s %d\n", message,
159 "The above message had unknown cdio log level",
163 /* gl_default_cdio_log_handler (level, message); */
166 /*****************************************************************************
167 * CDDAReadBlocks: reads a group of blocks from the CD-DA and returns
168 * an allocated pointer to the data. NULL is returned if no data
169 * read. It is also possible if we haven't read a RIFF header in which
170 * case one that we creaded during Open/Initialization is returned.
171 *****************************************************************************/
172 static block_t * CDDAReadBlocks( access_t * p_access )
175 cdda_data_t *p_cdda = (cdda_data_t *) p_access->p_sys;
176 int i_blocks = p_cdda->i_blocks_per_read;
178 dbg_print((INPUT_DBG_CALL|INPUT_DBG_EXT|INPUT_DBG_LSN),
179 "called %d pos: %lld, size: %lld",
180 p_cdda->i_lsn, p_access->info.i_pos, p_access->info.i_size);
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_last_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->e_paranoia && p_cdda->paranoia )
244 for( i = 0; i < i_blocks; i++ )
246 int16_t *p_readbuf = cdio_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->p_buffer + i * CDIO_CD_FRAMESIZE_RAW,
261 p_readbuf, 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 += i_blocks * CDIO_CD_FRAMESIZE_RAW;
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->e_paranoia && p_cdda->paranoia )
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" );
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;
490 if (p_cdda->b_nav_mode)
491 i_last_lsn = cdio_get_track_lsn(p_cdio, CDIO_CDROM_LEADOUT_TRACK);
493 i_last_lsn = cdio_get_track_last_lsn(p_cdio, i_track);
495 if (CDIO_INVALID_LSN != i_last_lsn)
496 p_access->info.i_size = i_last_lsn * (uint64_t) CDIO_CD_FRAMESIZE_RAW;
498 p_access->info.i_size = 0;
501 p_access->info.i_update = 0;
502 p_access->info.b_eof = VLC_FALSE;
503 p_access->info.i_title = 0;
504 p_access->info.i_seekpoint = 0;
506 p_access->p_sys = (access_sys_t *) p_cdda;
508 /* We read the Table Of Content information */
509 i_rc = CDDAInit( p_access, p_cdda );
510 if ( VLC_SUCCESS != i_rc ) goto error;
512 CDDAFixupPlaylist( p_access, p_cdda, b_single_track );
514 #if LIBCDIO_VERSION_NUM >= 72
517 char *psz_paranoia = config_GetPsz( p_access,
518 MODULE_STRING "-paranoia" );
519 p_cdda->e_paranoia = paranoia_none;
520 if( psz_paranoia && *psz_paranoia )
523 if( !strncmp( psz_paranoia, "full", strlen("full") ) )
524 p_cdda->e_paranoia = paranoia_full;
525 else if( !strncmp( psz_paranoia, "overlap", strlen("overlap") ) )
526 p_cdda->e_paranoia = paranoia_overlap;
528 /* Use CD Paranoia? */
529 if ( p_cdda->e_paranoia ) {
530 p_cdda->paranoia_cd = cdio_cddap_identify_cdio(p_cdio, 1, NULL);
531 /* We'll set for verbose paranoia messages. */
532 cdio_cddap_verbose_set(p_cdda->paranoia_cd, CDDA_MESSAGE_PRINTIT,
533 CDDA_MESSAGE_PRINTIT);
534 if ( 0 != cdio_cddap_open(p_cdda->paranoia_cd) ) {
535 msg_Warn( p_cdda_input, "Unable to get paranoia support - "
536 "continuing without it." );
537 p_cdda->e_paranoia = paranoia_none;
539 p_cdda->paranoia = cdio_paranoia_init(p_cdda->paranoia_cd);
540 cdio_paranoia_seek(p_cdda->paranoia, p_cdda->i_lsn, SEEK_SET);
542 /* Set reading mode for full or overlap paranoia,
543 but allow skipping sectors. */
544 cdio_paranoia_modeset(p_cdda->paranoia,
545 paranoia_full == p_cdda->e_paranoia ?
546 PARANOIA_MODE_FULL^PARANOIA_MODE_NEVERSKIP :
547 PARANOIA_MODE_OVERLAP^PARANOIA_MODE_NEVERSKIP
555 /* Build a WAV header to put in front of the output data.
556 This gets sent back in the Block (read) routine.
558 memset( &p_cdda->waveheader, 0, sizeof(WAVEHEADER) );
559 SetWLE( &p_cdda->waveheader.Format, 1 ); /*WAVE_FORMAT_PCM*/
560 SetWLE( &p_cdda->waveheader.BitsPerSample, 16);
561 p_cdda->waveheader.MainChunkID = VLC_FOURCC('R', 'I', 'F', 'F');
562 p_cdda->waveheader.Length = 0; /* we just don't know */
563 p_cdda->waveheader.ChunkTypeID = VLC_FOURCC('W', 'A', 'V', 'E');
564 p_cdda->waveheader.SubChunkID = VLC_FOURCC('f', 'm', 't', ' ');
565 SetDWLE( &p_cdda->waveheader.SubChunkLength, 16);
566 SetWLE( &p_cdda->waveheader.Modus, 2);
567 SetDWLE( &p_cdda->waveheader.SampleFreq, CDDA_FREQUENCY_SAMPLE);
568 SetWLE( &p_cdda->waveheader.BytesPerSample,
569 2 /*Modus*/ * 16 /*BitsPerSample*/ / 8 );
570 SetDWLE( &p_cdda->waveheader.BytesPerSec,
571 2*16/8 /*BytesPerSample*/ * CDDA_FREQUENCY_SAMPLE );
572 p_cdda->waveheader.DataChunkID = VLC_FOURCC('d', 'a', 't', 'a');
573 p_cdda->waveheader.DataLength = 0; /* we just don't know */
576 var_Create( p_access, MODULE_STRING "-caching",
577 VLC_VAR_INTEGER|VLC_VAR_DOINHERIT );
578 vlc_object_release( p_cdda->p_input );
582 cdio_destroy( p_cdda->p_cdio );
583 if( psz_source) free( psz_source );
585 if ( p_cdda->p_input )
586 vlc_object_release( p_cdda->p_input );
594 /*****************************************************************************
595 * CDDAClose: closes cdda and frees any resources associded with it.
596 *****************************************************************************/
598 CDDAClose (vlc_object_t *p_this )
600 access_t *p_access = (access_t *) p_this;
601 cdda_data_t *p_cdda = (cdda_data_t *) p_access->p_sys;
604 dbg_print( (INPUT_DBG_CALL|INPUT_DBG_EXT), "" );
606 /* Remove playlist titles */
607 for( i = 0; i < p_cdda->i_titles; i++ )
609 vlc_input_title_Delete( p_cdda->p_title[i] );
613 cddb_log_set_handler ((cddb_log_handler_t) uninit_log_handler);
614 if (p_cdda->b_cddb_enabled)
615 cddb_disc_destroy(p_cdda->cddb.disc);
618 cdio_destroy( p_cdda->p_cdio );
619 cdio_log_set_handler (uninit_log_handler);
621 #if LIBCDIO_VERSION_NUM >= 72
622 if (p_cdda->paranoia)
623 cdio_paranoia_free(p_cdda->paranoia);
624 if (p_cdda->paranoia_cd)
625 cdio_cddap_close_no_free_cdio(p_cdda->paranoia_cd);
628 if (p_cdda->psz_mcn) free( p_cdda->psz_mcn );
629 if (p_cdda->psz_source) free( p_cdda->psz_source );
631 #if LIBCDDB_VERSION_NUM >= 1
639 /*****************************************************************************
640 * Control: The front-end or vlc engine calls here to ether get
641 * information such as meta information or plugin capabilities or to
642 * issue miscellaneous "set" requests.
643 *****************************************************************************/
644 static int CDDAControl( access_t *p_access, int i_query, va_list args )
646 cdda_data_t *p_cdda = (cdda_data_t *) p_access->p_sys;
650 dbg_print( (INPUT_DBG_CALL|INPUT_DBG_EXT|INPUT_DBG_EVENT),
651 "query %d", i_query );
655 /* Pass back a copy of meta information that was gathered when we
656 during the Open/Initialize call.
658 case ACCESS_GET_META:
660 vlc_meta_t **pp_meta = (vlc_meta_t**)va_arg( args, vlc_meta_t** );
661 if ( p_cdda->p_meta )
663 *pp_meta = vlc_meta_Duplicate( p_cdda->p_meta );
664 dbg_print( INPUT_DBG_META, "%s", "Meta copied" );
668 msg_Warn( p_access, "tried to copy NULL meta info" );
673 case ACCESS_CAN_CONTROL_PACE:
674 case ACCESS_CAN_FASTSEEK:
675 case ACCESS_CAN_SEEK:
676 case ACCESS_CAN_PAUSE:
678 vlc_bool_t *pb_bool = (vlc_bool_t*)va_arg( args, vlc_bool_t* );
679 dbg_print( INPUT_DBG_META,
680 "can seek/fastseek/pause/control pace");
688 pi_int = (int*)va_arg( args, int * );
689 *pi_int = p_cdda-> i_blocks_per_read * CDIO_CD_FRAMESIZE_RAW;
690 dbg_print( INPUT_DBG_META, "Get MTU %d", *pi_int);
694 case ACCESS_GET_PTS_DELAY:
696 int64_t *pi_64 = (int64_t*)va_arg( args, int64_t * );
697 *pi_64 = var_GetInteger( p_access, MODULE_STRING "-caching" )
698 * MILLISECONDS_PER_SEC;
703 case ACCESS_SET_PAUSE_STATE:
704 dbg_print( INPUT_DBG_META, "Set pause state");
707 case ACCESS_GET_TITLE_INFO:
709 input_title_t ***ppp_title =
710 (input_title_t***)va_arg( args, input_title_t*** );
712 pi_int = (int*)va_arg( args, int* );
713 *((int*)va_arg( args, int* )) = 1; /* Title offset */
715 dbg_print ( INPUT_DBG_EVENT,
716 "GET TITLE: i_tracks %d, i_tracks %d",
717 p_cdda->i_tracks, p_cdda->i_tracks );
719 CDDAMetaInfo( p_access, CDIO_INVALID_TRACK );
721 if ( p_cdda->b_nav_mode) {
723 CDDAFormatTitle( p_access, p_cdda->i_track );
724 input_Control( p_cdda->p_input, INPUT_SET_NAME,
729 /* Duplicate title info */
730 if( p_cdda->i_titles == 0 )
732 *pi_int = 0; ppp_title = NULL;
735 *pi_int = p_cdda->i_titles;
736 *ppp_title = calloc(1,
737 sizeof( input_title_t **) * p_cdda->i_titles );
739 if (!*ppp_title) return VLC_ENOMEM;
741 for( i = 0; i < p_cdda->i_titles; i++ )
743 if ( p_cdda->p_title[i] ) {
745 vlc_input_title_Duplicate( p_cdda->p_title[i] );
751 case ACCESS_SET_TITLE:
753 i = (int)va_arg( args, int );
755 dbg_print( INPUT_DBG_EVENT, "set title %d", i );
756 if( i != p_access->info.i_title )
759 p_access->info.i_title = i;
760 if ( p_cdda->b_nav_mode)
764 CDDAFormatTitle( p_access, i+1 );
765 input_Control( p_cdda->p_input, INPUT_SET_NAME,
768 p_cdda->i_track = p_cdda->i_first_track+i;
769 i_last_lsn = cdio_get_track_lsn(p_cdda->p_cdio,
770 CDIO_CDROM_LEADOUT_TRACK);
771 if (CDIO_INVALID_LSN != i_last_lsn)
772 p_access->info.i_size = (int64_t) CDIO_CD_FRAMESIZE_RAW
774 p_access->info.i_pos = (int64_t)
775 cdio_get_track_lsn( p_cdda->p_cdio, p_cdda->i_track )
776 * CDIO_CD_FRAMESIZE_RAW;
778 p_access->info.i_size = p_cdda->p_title[i]->i_size;
779 p_access->info.i_pos = 0;
781 p_access->info.i_update =
782 INPUT_UPDATE_TITLE | INPUT_UPDATE_SIZE;
784 /* Next sector to read */
786 cdio_get_track_lsn(p_cdda->p_cdio, p_cdda->i_first_track+i);
791 case ACCESS_SET_SEEKPOINT:
792 case ACCESS_SET_PRIVATE_ID_STATE:
793 dbg_print( INPUT_DBG_META, "set seekpoint/set private id state");
797 msg_Warn( p_access, "unimplemented query in control" );
804 /*****************************************************************************
807 Initialize information pertaining to the CD: the number of tracks,
808 first track number, LSNs for each track and the leadout. The leadout
809 information is stored after the last track. The LSN array is
810 0-origin, same as p_access->info. Add first_track to get what track
811 number this is on the CD. Note: libcdio uses the real track number.
813 On input we assume p_cdda->p_cdio and p_cdda->i_track have been set.
815 We return the VLC-type status, e.g. VLC_SUCCESS, VLC_ENOMEM, etc.
816 *****************************************************************************/
817 static int CDDAInit( access_t *p_access, cdda_data_t *p_cdda )
819 discmode_t discmode = CDIO_DISC_MODE_NO_INFO;
821 p_cdda->i_tracks = cdio_get_num_tracks(p_cdda->p_cdio);
822 p_cdda->i_first_track = cdio_get_first_track_num(p_cdda->p_cdio);
824 discmode = cdio_get_discmode(p_cdda->p_cdio);
826 case CDIO_DISC_MODE_CD_DA:
827 case CDIO_DISC_MODE_CD_MIXED:
828 /* These are possible for CD-DA */
831 /* These are not possible for CD-DA */
833 "Disc seems not to be CD-DA. libcdio reports it is %s",
834 discmode2str[discmode]
839 /* Set reading start LSN. */
840 p_cdda->i_lsn = cdio_get_track_lsn(p_cdda->p_cdio, p_cdda->i_track);