+ msg_Warn( p_access, "could not open %s", psz_source );
+ free( psz_source );
+ return VLC_EGENERIC;
+ }
+
+ p_cdda = calloc( 1, sizeof(cdda_data_t) );
+ if( p_cdda == NULL )
+ {
+ free( psz_source );
+ return VLC_ENOMEM;
+ }
+
+#ifdef HAVE_LIBCDDB
+ cddb_log_set_handler ( cddb_log_handler );
+ p_cdda->cddb.disc = NULL;
+ p_cdda->b_cddb_enabled =
+ config_GetInt( p_access, MODULE_STRING "-cddb-enabled" );
+#endif
+ p_cdda->b_cdtext =
+ config_GetInt( p_access, MODULE_STRING "-cdtext-enabled" );
+ p_cdda->b_cdtext_prefer =
+ config_GetInt( p_access, MODULE_STRING "-cdtext-prefer" );
+#if LIBCDIO_VERSION_NUM >= 73
+ p_cdda->b_audio_ctl =
+ config_GetInt( p_access, MODULE_STRING "-analog-output" );
+#endif
+
+ p_cdda->psz_source = strdup( psz_source );
+ p_cdda->b_header = false;
+ p_cdda->p_cdio = p_cdio;
+ p_cdda->i_tracks = 0;
+ p_cdda->i_titles = 0;
+ p_cdda->i_debug = config_GetInt( p_this, MODULE_STRING "-debug" );
+ p_cdda->b_nav_mode = config_GetInt(p_this, MODULE_STRING "-navigation-mode" );
+ p_cdda->i_blocks_per_read =
+ config_GetInt( p_this, MODULE_STRING "-blocks-per-read" );
+ p_cdda->last_disc_frame =
+ cdio_get_track_lsn( p_cdio, CDIO_CDROM_LEADOUT_TRACK );
+ p_cdda->p_input = vlc_object_find( p_access, VLC_OBJECT_INPUT,
+ FIND_PARENT );
+
+ if( 0 == p_cdda->i_blocks_per_read )
+ p_cdda->i_blocks_per_read = DEFAULT_BLOCKS_PER_READ;
+
+ if( (p_cdda->i_blocks_per_read < MIN_BLOCKS_PER_READ)
+ || (p_cdda->i_blocks_per_read > MAX_BLOCKS_PER_READ) )
+ {
+ msg_Warn( p_cdda_input,
+ "number of blocks (%d) has to be between %d and %d. "
+ "Using %d.",
+ p_cdda->i_blocks_per_read,
+ MIN_BLOCKS_PER_READ, MAX_BLOCKS_PER_READ,
+ DEFAULT_BLOCKS_PER_READ );
+ p_cdda->i_blocks_per_read = DEFAULT_BLOCKS_PER_READ;
+ }
+
+ dbg_print( (INPUT_DBG_CALL|INPUT_DBG_EXT), "%s", psz_source );
+
+ /* Set up p_access */
+ if( p_cdda->b_audio_ctl )
+ {
+ p_access->pf_read = CDDARead;
+ p_access->pf_block = NULL;
+ }
+ else
+ {
+ p_access->pf_read = NULL;
+ p_access->pf_block = CDDAReadBlocks;
+ }
+
+ p_access->pf_control = CDDAControl;
+ p_access->pf_seek = CDDASeek;
+
+ {
+ lsn_t i_last_lsn;
+
+ if( p_cdda->b_nav_mode )
+ i_last_lsn = p_cdda->last_disc_frame;
+ else
+ i_last_lsn = cdio_get_track_last_lsn( p_cdio, i_track );
+
+ if( CDIO_INVALID_LSN != i_last_lsn )
+ p_access->info.i_size = i_last_lsn * (uint64_t) CDIO_CD_FRAMESIZE_RAW;
+ else
+ p_access->info.i_size = 0;
+ }
+
+ p_access->info.i_update = 0;
+ p_access->info.b_eof = false;
+ p_access->info.i_title = 0;
+ p_access->info.i_seekpoint = 0;
+
+ p_access->p_sys = (access_sys_t *) p_cdda;
+
+ /* We read the Table Of Content information */
+ i_rc = CDDAInit( p_access, p_cdda );
+ if( VLC_SUCCESS != i_rc )
+ goto error;
+
+ cdda_play_track( p_access, i_track );
+ CDDAFixupPlaylist( p_access, p_cdda, b_single_track );
+
+#if LIBCDIO_VERSION_NUM >= 72
+ {
+ char *psz_paranoia = config_GetPsz( p_access,
+ MODULE_STRING "-paranoia" );
+
+ p_cdda->e_paranoia = PARANOIA_MODE_DISABLE;
+ if( psz_paranoia && *psz_paranoia )
+ {
+ if( !strncmp( psz_paranoia, "full", strlen("full") ) )
+ p_cdda->e_paranoia = PARANOIA_MODE_FULL;
+ else if( !strncmp(psz_paranoia, "overlap", strlen("overlap")) )
+ p_cdda->e_paranoia = PARANOIA_MODE_OVERLAP;
+
+ /* Use CD Paranoia? */
+ if( p_cdda->e_paranoia )
+ {
+ p_cdda->paranoia_cd =
+ cdio_cddap_identify_cdio( p_cdio, 1, NULL );
+ /* We'll set for verbose paranoia messages. */
+ cdio_cddap_verbose_set( p_cdda->paranoia_cd,
+ CDDA_MESSAGE_PRINTIT,
+ CDDA_MESSAGE_PRINTIT );
+ if ( 0 != cdio_cddap_open(p_cdda->paranoia_cd) )
+ {
+ msg_Warn( p_cdda_input, "unable to get paranoia support - "
+ "continuing without it." );
+ p_cdda->e_paranoia = PARANOIA_MODE_DISABLE;
+ }
+ else
+ {
+ p_cdda->paranoia = cdio_paranoia_init(p_cdda->paranoia_cd);
+ cdio_paranoia_seek( p_cdda->paranoia, p_cdda->i_lsn,
+ SEEK_SET);
+
+ /* Set reading mode for full or overlap paranoia,
+ * but allow skipping sectors. */
+ cdio_paranoia_modeset( p_cdda->paranoia,
+ PARANOIA_MODE_FULL == p_cdda->e_paranoia ?
+ PARANOIA_MODE_FULL^PARANOIA_MODE_NEVERSKIP :
+ PARANOIA_MODE_OVERLAP^PARANOIA_MODE_NEVERSKIP );
+ }
+ }
+ }
+ free( psz_paranoia );