Commit 3a9b48da authored by Clément Stenac's avatar Clément Stenac

CDDAX:

    - coding style fixes
    - adapted to new playlist API
    - only put generic things in Meta-information

wxWidgets:
    - Fixed playlist updating

core:
    - added playlist_ItemGetByInput
    - implemented input_item_t.b_fixed name : if this is set, the interface should not try to "improve" the display string.
parent 180ca722
...@@ -62,6 +62,8 @@ struct input_item_t ...@@ -62,6 +62,8 @@ struct input_item_t
int i_es; /**< Number of es format descriptions */ int i_es; /**< Number of es format descriptions */
es_format_t **es; /**< Pointer to an array of es formats */ es_format_t **es; /**< Pointer to an array of es formats */
vlc_bool_t b_fixed_name; /**< Can the interface change the name ?*/
vlc_mutex_t lock; /**< Item cannot be changed without this lock */ vlc_mutex_t lock; /**< Item cannot be changed without this lock */
}; };
...@@ -85,6 +87,7 @@ static inline void vlc_input_item_Init( vlc_object_t *p_o, input_item_t *p_i ) ...@@ -85,6 +87,7 @@ static inline void vlc_input_item_Init( vlc_object_t *p_o, input_item_t *p_i )
p_i->pp_categories = 0; p_i->pp_categories = 0;
p_i->es = 0; p_i->es = 0;
p_i->i_type = ITEM_TYPE_UNKNOWN; p_i->i_type = ITEM_TYPE_UNKNOWN;
p_i->b_fixed_name = VLC_TRUE;
vlc_mutex_init( p_o, &p_i->lock ); vlc_mutex_init( p_o, &p_i->lock );
} }
......
...@@ -112,10 +112,12 @@ static void ...@@ -112,10 +112,12 @@ static void
cddb_log_handler (cddb_log_level_t level, const char message[]) cddb_log_handler (cddb_log_level_t level, const char message[])
{ {
cdda_data_t *p_cdda = (cdda_data_t *)p_cdda_input->p_sys; cdda_data_t *p_cdda = (cdda_data_t *)p_cdda_input->p_sys;
switch (level) { switch (level)
{
case CDDB_LOG_DEBUG: case CDDB_LOG_DEBUG:
case CDDB_LOG_INFO: case CDDB_LOG_INFO:
if (!(p_cdda->i_debug & INPUT_DBG_CDDB)) return; if (!(p_cdda->i_debug & INPUT_DBG_CDDB)) return;
/* Fall through if to warn case */ /* Fall through if to warn case */
default: default:
cdio_log_handler (level, message); cdio_log_handler (level, message);
...@@ -135,11 +137,13 @@ uninit_log_handler (cdio_log_level_t level, const char message[]) ...@@ -135,11 +137,13 @@ uninit_log_handler (cdio_log_level_t level, const char message[])
if (p_cdda_input) if (p_cdda_input)
p_cdda = (cdda_data_t *)p_cdda_input->p_sys; p_cdda = (cdda_data_t *)p_cdda_input->p_sys;
switch (level) { switch (level)
{
case CDIO_LOG_DEBUG: case CDIO_LOG_DEBUG:
case CDIO_LOG_INFO: case CDIO_LOG_INFO:
if (!p_cdda || !(p_cdda->i_debug & (INPUT_DBG_CDIO|INPUT_DBG_CDDB))) if (!p_cdda || !(p_cdda->i_debug & (INPUT_DBG_CDIO|INPUT_DBG_CDDB)))
return; return;
/* Fall through if to warn case */ /* Fall through if to warn case */
case CDIO_LOG_WARN: case CDIO_LOG_WARN:
fprintf(stderr, "WARN: %s\n", message); fprintf(stderr, "WARN: %s\n", message);
...@@ -151,8 +155,7 @@ uninit_log_handler (cdio_log_level_t level, const char message[]) ...@@ -151,8 +155,7 @@ uninit_log_handler (cdio_log_level_t level, const char message[])
fprintf(stderr, "ASSERT ERROR: %s\n", message); fprintf(stderr, "ASSERT ERROR: %s\n", message);
break; break;
default: default:
fprintf(stderr, "UNKNOWN ERROR: %s\n%s %d\n", fprintf(stderr, "UNKNOWN ERROR: %s\n%s %d\n", message,
message,
"The above message had unknown cdio log level", "The above message had unknown cdio log level",
level); level);
} }
...@@ -166,8 +169,7 @@ uninit_log_handler (cdio_log_level_t level, const char message[]) ...@@ -166,8 +169,7 @@ uninit_log_handler (cdio_log_level_t level, const char message[])
* read. It is also possible if we haven't read a RIFF header in which * read. It is also possible if we haven't read a RIFF header in which
* case one that we creaded during Open/Initialization is returned. * case one that we creaded during Open/Initialization is returned.
*****************************************************************************/ *****************************************************************************/
static block_t * static block_t * CDDAReadBlocks( access_t * p_access )
CDDAReadBlocks( access_t * p_access )
{ {
block_t *p_block; block_t *p_block;
cdda_data_t *p_cdda = (cdda_data_t *) p_access->p_sys; cdda_data_t *p_cdda = (cdda_data_t *) p_access->p_sys;
...@@ -246,8 +248,7 @@ CDDAReadBlocks( access_t * p_access ) ...@@ -246,8 +248,7 @@ CDDAReadBlocks( access_t * p_access )
* CDDASeek - change position for subsequent reads. For example, this * CDDASeek - change position for subsequent reads. For example, this
* can happen if the user moves a position slider bar in a GUI. * can happen if the user moves a position slider bar in a GUI.
****************************************************************************/ ****************************************************************************/
static int static int CDDASeek( access_t * p_access, int64_t i_pos )
CDDASeek( access_t * p_access, int64_t i_pos )
{ {
cdda_data_t *p_cdda = (cdda_data_t *) p_access->p_sys; cdda_data_t *p_cdda = (cdda_data_t *) p_access->p_sys;
...@@ -269,8 +270,7 @@ CDDASeek( access_t * p_access, int64_t i_pos ) ...@@ -269,8 +270,7 @@ CDDASeek( access_t * p_access, int64_t i_pos )
* Open: open cdda device or image file and initialize structures * Open: open cdda device or image file and initialize structures
* for subsequent operations. * for subsequent operations.
*****************************************************************************/ *****************************************************************************/
int int E_(CDDAOpen)( vlc_object_t *p_this )
E_(CDDAOpen)( vlc_object_t *p_this )
{ {
access_t *p_access = (access_t*)p_this; access_t *p_access = (access_t*)p_this;
char * psz_source = NULL; char * psz_source = NULL;
...@@ -319,12 +319,14 @@ E_(CDDAOpen)( vlc_object_t *p_this ) ...@@ -319,12 +319,14 @@ E_(CDDAOpen)( vlc_object_t *p_this )
psz_source = var_CreateGetString( p_this, "cd-audio" ); psz_source = var_CreateGetString( p_this, "cd-audio" );
if( !psz_source || !*psz_source ) { if( !psz_source || !*psz_source )
{
/* Scan for a CD-ROM drive with a CD-DA in it. */ /* Scan for a CD-ROM drive with a CD-DA in it. */
char **cd_drives = char **cd_drives =
cdio_get_devices_with_cap(NULL, CDIO_FS_AUDIO, false); cdio_get_devices_with_cap(NULL, CDIO_FS_AUDIO, false);
if (NULL == cd_drives || NULL == cd_drives[0] ) { if (NULL == cd_drives || NULL == cd_drives[0] )
{
msg_Err( p_access, msg_Err( p_access,
"libcdio couldn't find something with a CD-DA in it" ); "libcdio couldn't find something with a CD-DA in it" );
if (cd_drives) cdio_free_device_list(cd_drives); if (cd_drives) cdio_free_device_list(cd_drives);
...@@ -382,7 +384,8 @@ E_(CDDAOpen)( vlc_object_t *p_this ) ...@@ -382,7 +384,8 @@ E_(CDDAOpen)( vlc_object_t *p_this )
p_cdda->i_blocks_per_read = DEFAULT_BLOCKS_PER_READ; p_cdda->i_blocks_per_read = DEFAULT_BLOCKS_PER_READ;
if ( p_cdda->i_blocks_per_read < MIN_BLOCKS_PER_READ if ( p_cdda->i_blocks_per_read < MIN_BLOCKS_PER_READ
|| p_cdda->i_blocks_per_read > MAX_BLOCKS_PER_READ ) { || p_cdda->i_blocks_per_read > MAX_BLOCKS_PER_READ )
{
msg_Warn( p_cdda_input, msg_Warn( p_cdda_input,
"Number of blocks (%d) has to be between %d and %d. " "Number of blocks (%d) has to be between %d and %d. "
"Using %d.", "Using %d.",
...@@ -392,7 +395,6 @@ E_(CDDAOpen)( vlc_object_t *p_this ) ...@@ -392,7 +395,6 @@ E_(CDDAOpen)( vlc_object_t *p_this )
p_cdda->i_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 ); dbg_print( (INPUT_DBG_CALL|INPUT_DBG_EXT), "%s", psz_source );
/* Set up p_access */ /* Set up p_access */
...@@ -439,6 +441,7 @@ E_(CDDAOpen)( vlc_object_t *p_this ) ...@@ -439,6 +441,7 @@ E_(CDDAOpen)( vlc_object_t *p_this )
/* PTS delay */ /* PTS delay */
var_Create( p_access, MODULE_STRING "-caching", var_Create( p_access, MODULE_STRING "-caching",
VLC_VAR_INTEGER|VLC_VAR_DOINHERIT ); VLC_VAR_INTEGER|VLC_VAR_DOINHERIT );
vlc_object_release( p_cdda->p_input );
return VLC_SUCCESS; return VLC_SUCCESS;
error: error:
...@@ -446,6 +449,7 @@ E_(CDDAOpen)( vlc_object_t *p_this ) ...@@ -446,6 +449,7 @@ E_(CDDAOpen)( vlc_object_t *p_this )
free( p_cdda ); free( p_cdda );
error2: error2:
free( psz_source ); free( psz_source );
vlc_object_release( p_cdda->p_input );
return i_rc; return i_rc;
} }
...@@ -453,8 +457,7 @@ E_(CDDAOpen)( vlc_object_t *p_this ) ...@@ -453,8 +457,7 @@ E_(CDDAOpen)( vlc_object_t *p_this )
/***************************************************************************** /*****************************************************************************
* CDDAClose: closes cdda and frees any resources associded with it. * CDDAClose: closes cdda and frees any resources associded with it.
*****************************************************************************/ *****************************************************************************/
void void E_(CDDAClose)( vlc_object_t *p_this )
E_(CDDAClose)( vlc_object_t *p_this )
{ {
access_t *p_access = (access_t *) p_this; access_t *p_access = (access_t *) p_this;
cdda_data_t *p_cdda = (cdda_data_t *) p_access->p_sys; cdda_data_t *p_cdda = (cdda_data_t *) p_access->p_sys;
...@@ -505,15 +508,16 @@ static int CDDAControl( access_t *p_access, int i_query, va_list args ) ...@@ -505,15 +508,16 @@ static int CDDAControl( access_t *p_access, int i_query, va_list args )
case ACCESS_GET_META: case ACCESS_GET_META:
{ {
vlc_meta_t **pp_meta = (vlc_meta_t**)va_arg( args, vlc_meta_t** ); vlc_meta_t **pp_meta = (vlc_meta_t**)va_arg( args, vlc_meta_t** );
if ( p_cdda->p_meta ) { if ( p_cdda->p_meta )
{
*pp_meta = vlc_meta_Duplicate( p_cdda->p_meta ); *pp_meta = vlc_meta_Duplicate( p_cdda->p_meta );
dbg_print( INPUT_DBG_META, "%s", "Meta copied" ); dbg_print( INPUT_DBG_META, "%s", "Meta copied" );
} else }
else
msg_Warn( p_access, "tried to copy NULL meta info" ); msg_Warn( p_access, "tried to copy NULL meta info" );
return VLC_SUCCESS; return VLC_SUCCESS;
} }
return VLC_EGENERIC;
case ACCESS_CAN_SEEK: case ACCESS_CAN_SEEK:
case ACCESS_CAN_FASTSEEK: case ACCESS_CAN_FASTSEEK:
...@@ -522,14 +526,16 @@ static int CDDAControl( access_t *p_access, int i_query, va_list args ) ...@@ -522,14 +526,16 @@ static int CDDAControl( access_t *p_access, int i_query, va_list args )
{ {
vlc_bool_t *pb_bool = (vlc_bool_t*)va_arg( args, vlc_bool_t* ); vlc_bool_t *pb_bool = (vlc_bool_t*)va_arg( args, vlc_bool_t* );
*pb_bool = VLC_TRUE; *pb_bool = VLC_TRUE;
break; return VLC_SUCCESS;;
} }
/* */ /* */
case ACCESS_GET_MTU: case ACCESS_GET_MTU:
{
pi_int = (int*)va_arg( args, int * ); pi_int = (int*)va_arg( args, int * );
*pi_int = p_cdda-> i_blocks_per_read * CDIO_CD_FRAMESIZE_RAW; *pi_int = p_cdda-> i_blocks_per_read * CDIO_CD_FRAMESIZE_RAW;
break; break;
}
case ACCESS_GET_PTS_DELAY: case ACCESS_GET_PTS_DELAY:
{ {
...@@ -544,14 +550,20 @@ static int CDDAControl( access_t *p_access, int i_query, va_list args ) ...@@ -544,14 +550,20 @@ static int CDDAControl( access_t *p_access, int i_query, va_list args )
break; break;
case ACCESS_GET_TITLE_INFO: case ACCESS_GET_TITLE_INFO:
{ input_title_t ***ppp_title; {
input_title_t ***ppp_title;
ppp_title = (input_title_t***)va_arg( args, input_title_t*** ); ppp_title = (input_title_t***)va_arg( args, input_title_t*** );
pi_int = (int*)va_arg( args, int* ); pi_int = (int*)va_arg( args, int* );
*((int*)va_arg( args, int* )) = 1; /* Title offset */ *((int*)va_arg( args, int* )) = 1; /* Title offset */
/* Duplicate title info */ /* Duplicate title info */
/*** printf("+++ i_tracks %d, i_titles %d\n", printf("+++ i_tracks %d, i_titles %d\n",
p_cdda->i_tracks, p_cdda->i_titles); ***/ p_cdda->i_tracks, p_cdda->i_titles);
if( p_cdda->i_titles == 0 )
{
*pi_int = 0; ppp_title = NULL;
return VLC_SUCCESS;
}
*pi_int = p_cdda->i_titles; *pi_int = p_cdda->i_titles;
*ppp_title = malloc(sizeof( input_title_t **) * p_cdda->i_titles ); *ppp_title = malloc(sizeof( input_title_t **) * p_cdda->i_titles );
...@@ -563,10 +575,11 @@ static int CDDAControl( access_t *p_access, int i_query, va_list args ) ...@@ -563,10 +575,11 @@ static int CDDAControl( access_t *p_access, int i_query, va_list args )
(*ppp_title)[i] = (*ppp_title)[i] =
vlc_input_title_Duplicate( p_cdda->p_title[i] ); vlc_input_title_Duplicate( p_cdda->p_title[i] );
} }
}
break; break;
}
case ACCESS_SET_TITLE: case ACCESS_SET_TITLE:
{
i = (int)va_arg( args, int ); i = (int)va_arg( args, int );
if( i != p_access->info.i_title ) if( i != p_access->info.i_title )
{ {
...@@ -581,6 +594,7 @@ static int CDDAControl( access_t *p_access, int i_query, va_list args ) ...@@ -581,6 +594,7 @@ static int CDDAControl( access_t *p_access, int i_query, va_list args )
p_cdda->i_lsn = p_cdda->lsn[p_cdda->i_first_track+i]; p_cdda->i_lsn = p_cdda->lsn[p_cdda->i_first_track+i];
} }
break; break;
}
case ACCESS_SET_SEEKPOINT: case ACCESS_SET_SEEKPOINT:
case ACCESS_SET_PRIVATE_ID_STATE: case ACCESS_SET_PRIVATE_ID_STATE:
...@@ -607,8 +621,7 @@ static int CDDAControl( access_t *p_access, int i_query, va_list args ) ...@@ -607,8 +621,7 @@ static int CDDAControl( access_t *p_access, int i_query, va_list args )
We return the VLC-type status, e.g. VLC_SUCCESS, VLC_ENOMEM, etc. We return the VLC-type status, e.g. VLC_SUCCESS, VLC_ENOMEM, etc.
*****************************************************************************/ *****************************************************************************/
static int static int CDDAInit( access_t *p_access, cdda_data_t *p_cdda )
CDDAInit( access_t *p_access, cdda_data_t *p_cdda )
{ {
track_t i; track_t i;
discmode_t discmode = CDIO_DISC_MODE_NO_INFO; discmode_t discmode = CDIO_DISC_MODE_NO_INFO;
......
...@@ -34,7 +34,8 @@ E_(CDDADebugCB) ( vlc_object_t *p_this, const char *psz_name, ...@@ -34,7 +34,8 @@ E_(CDDADebugCB) ( vlc_object_t *p_this, const char *psz_name,
p_cdda = (cdda_data_t *)p_cdda_input->p_sys; p_cdda = (cdda_data_t *)p_cdda_input->p_sys;
if (p_cdda->i_debug & (INPUT_DBG_CALL|INPUT_DBG_EXT)) { if (p_cdda->i_debug & (INPUT_DBG_CALL|INPUT_DBG_EXT))
{
msg_Dbg( p_cdda_input, "Old debug (x%0x) %d, new debug (x%0x) %d", msg_Dbg( p_cdda_input, "Old debug (x%0x) %d, new debug (x%0x) %d",
p_cdda->i_debug, p_cdda->i_debug, val.i_int, val.i_int); p_cdda->i_debug, p_cdda->i_debug, val.i_int, val.i_int);
} }
...@@ -55,7 +56,8 @@ E_(CDDBEnabledCB) ( vlc_object_t *p_this, const char *psz_name, ...@@ -55,7 +56,8 @@ E_(CDDBEnabledCB) ( vlc_object_t *p_this, const char *psz_name,
p_cdda = (cdda_data_t *)p_cdda_input->p_sys; p_cdda = (cdda_data_t *)p_cdda_input->p_sys;
#ifdef HAVE_LIBCDDB #ifdef HAVE_LIBCDDB
if (p_cdda->i_debug & (INPUT_DBG_CALL|INPUT_DBG_EXT)) { if (p_cdda->i_debug & (INPUT_DBG_CALL|INPUT_DBG_EXT))
{
msg_Dbg( p_cdda_input, "Old CDDB Enabled (x%0x) %d, new (x%0x) %d", msg_Dbg( p_cdda_input, "Old CDDB Enabled (x%0x) %d, new (x%0x) %d",
p_cdda->b_cddb_enabled, p_cdda->b_cddb_enabled, p_cdda->b_cddb_enabled, p_cdda->b_cddb_enabled,
val.b_bool, val.b_bool); val.b_bool, val.b_bool);
...@@ -75,7 +77,8 @@ E_(CDTextEnabledCB) ( vlc_object_t *p_this, const char *psz_name, ...@@ -75,7 +77,8 @@ E_(CDTextEnabledCB) ( vlc_object_t *p_this, const char *psz_name,
p_cdda = (cdda_data_t *)p_cdda_input->p_sys; p_cdda = (cdda_data_t *)p_cdda_input->p_sys;
if (p_cdda->i_debug & (INPUT_DBG_CALL|INPUT_DBG_EXT)) { if (p_cdda->i_debug & (INPUT_DBG_CALL|INPUT_DBG_EXT))
{
msg_Dbg( p_cdda_input, "Old CDText Enabled (x%0x) %d, new (x%0x) %d", msg_Dbg( p_cdda_input, "Old CDText Enabled (x%0x) %d, new (x%0x) %d",
p_cdda->b_cdtext_enabled, p_cdda->b_cdtext_enabled, p_cdda->b_cdtext_enabled, p_cdda->b_cdtext_enabled,
val.b_bool, val.b_bool); val.b_bool, val.b_bool);
...@@ -95,7 +98,8 @@ E_(CDTextPreferCB) ( vlc_object_t *p_this, const char *psz_name, ...@@ -95,7 +98,8 @@ E_(CDTextPreferCB) ( vlc_object_t *p_this, const char *psz_name,
p_cdda = (cdda_data_t *)p_cdda_input->p_sys; p_cdda = (cdda_data_t *)p_cdda_input->p_sys;
#ifdef HAVE_LIBCDDB #ifdef HAVE_LIBCDDB
if (p_cdda->i_debug & (INPUT_DBG_CALL|INPUT_DBG_EXT)) { if ( p_cdda->i_debug & (INPUT_DBG_CALL|INPUT_DBG_EXT))
{
msg_Dbg( p_cdda_input, "Old CDText Prefer (x%0x) %d, new (x%0x) %d", msg_Dbg( p_cdda_input, "Old CDText Prefer (x%0x) %d, new (x%0x) %d",
p_cdda->b_cdtext_prefer, p_cdda->b_cdtext_prefer, p_cdda->b_cdtext_prefer, p_cdda->b_cdtext_prefer,
val.b_bool, val.b_bool); val.b_bool, val.b_bool);
...@@ -115,7 +119,8 @@ E_(CDDABlocksPerReadCB) ( vlc_object_t *p_this, const char *psz_name, ...@@ -115,7 +119,8 @@ E_(CDDABlocksPerReadCB) ( vlc_object_t *p_this, const char *psz_name,
p_cdda = (cdda_data_t *)p_cdda_input->p_sys; p_cdda = (cdda_data_t *)p_cdda_input->p_sys;
if (p_cdda->i_debug & (INPUT_DBG_CALL|INPUT_DBG_EXT)) { if (p_cdda->i_debug & (INPUT_DBG_CALL|INPUT_DBG_EXT))
{
msg_Dbg( p_cdda_input, "Old blocks per read: %d, new %d", msg_Dbg( p_cdda_input, "Old blocks per read: %d, new %d",
p_cdda->i_blocks_per_read, val.i_int); p_cdda->i_blocks_per_read, val.i_int);
} }
...@@ -123,11 +128,11 @@ E_(CDDABlocksPerReadCB) ( vlc_object_t *p_this, const char *psz_name, ...@@ -123,11 +128,11 @@ E_(CDDABlocksPerReadCB) ( vlc_object_t *p_this, const char *psz_name,
if (0 == val.i_int) val.i_int = DEFAULT_BLOCKS_PER_READ; if (0 == val.i_int) val.i_int = DEFAULT_BLOCKS_PER_READ;
if ( val.i_int >= MIN_BLOCKS_PER_READ && val.i_int <= MAX_BLOCKS_PER_READ ) if ( val.i_int >= MIN_BLOCKS_PER_READ && val.i_int <= MAX_BLOCKS_PER_READ )
p_cdda->i_blocks_per_read = val.i_int; p_cdda->i_blocks_per_read = val.i_int;
else { else
{
msg_Warn( p_cdda_input, msg_Warn( p_cdda_input,
"Number of blocks (%d) has to be between %d and %d. No change.", "Number of blocks (%d) has to be between %d and %d. No change.",
val.i_int, MIN_BLOCKS_PER_READ, MAX_BLOCKS_PER_READ ); val.i_int, MIN_BLOCKS_PER_READ, MAX_BLOCKS_PER_READ );
} }
return VLC_SUCCESS; return VLC_SUCCESS;
} }
...@@ -47,10 +47,8 @@ ...@@ -47,10 +47,8 @@
if (val) var=strdup(val); if (val) var=strdup(val);
static void static void GetCDDBInfo( access_t *p_access, cdda_data_t *p_cdda )
GetCDDBInfo( access_t *p_access, cdda_data_t *p_cdda )
{ {
int i, i_matches; int i, i_matches;
cddb_conn_t *conn = cddb_new(); cddb_conn_t *conn = cddb_new();
const CdIo *p_cdio = p_cdda->p_cdio; const CdIo *p_cdio = p_cdda->p_cdio;
...@@ -61,7 +59,8 @@ GetCDDBInfo( access_t *p_access, cdda_data_t *p_cdda ) ...@@ -61,7 +59,8 @@ GetCDDBInfo( access_t *p_access, cdda_data_t *p_cdda )
cddb_log_set_handler (uninit_log_handler); cddb_log_set_handler (uninit_log_handler);
#endif #endif
if (!conn) { if (!conn)
{
msg_Warn( p_access, "Unable to initialize libcddb" ); msg_Warn( p_access, "Unable to initialize libcddb" );
goto cddb_destroy; goto cddb_destroy;
} }
...@@ -69,11 +68,9 @@ GetCDDBInfo( access_t *p_access, cdda_data_t *p_cdda ) ...@@ -69,11 +68,9 @@ GetCDDBInfo( access_t *p_access, cdda_data_t *p_cdda )
cddb_set_email_address( conn, cddb_set_email_address( conn,
config_GetPsz( p_access, config_GetPsz( p_access,
MODULE_STRING "-cddb-email") ); MODULE_STRING "-cddb-email") );
cddb_set_server_name( conn, cddb_set_server_name( conn,
config_GetPsz( p_access, config_GetPsz( p_access,
MODULE_STRING "-cddb-server") ); MODULE_STRING "-cddb-server") );
cddb_set_server_port(conn, cddb_set_server_port(conn,
config_GetInt( p_access, config_GetInt( p_access,
MODULE_STRING "-cddb-port") ); MODULE_STRING "-cddb-port") );
...@@ -92,18 +89,25 @@ GetCDDBInfo( access_t *p_access, cdda_data_t *p_cdda ) ...@@ -92,18 +89,25 @@ GetCDDBInfo( access_t *p_access, cdda_data_t *p_cdda )
config_GetInt( p_access, MODULE_STRING "-cddb-timeout") ); config_GetInt( p_access, MODULE_STRING "-cddb-timeout") );
if (config_GetInt( p_access, MODULE_STRING "-cddb-httpd" )) { if (config_GetInt( p_access, MODULE_STRING "-cddb-httpd" ) )
{
cddb_http_enable(conn); cddb_http_enable(conn);
} else }
else
{
cddb_http_disable(conn); cddb_http_disable(conn);
}
p_cdda->cddb.disc = cddb_disc_new(); p_cdda->cddb.disc = cddb_disc_new();
if (!p_cdda->cddb.disc) {
if (!p_cdda->cddb.disc)
{
msg_Err( p_access, "Unable to create CDDB disc structure." ); msg_Err( p_access, "Unable to create CDDB disc structure." );
goto cddb_end; goto cddb_end;
} }
for(i = 0; i < p_cdda->i_tracks; i++) { for(i = 0; i < p_cdda->i_tracks; i++)
{
track_t i_track = p_cdda->i_first_track + i; track_t i_track = p_cdda->i_first_track + i;
cddb_track_t *t = cddb_track_new(); cddb_track_t *t = cddb_track_new();
t->frame_offset = cdio_get_track_lba(p_cdio, i_track); t->frame_offset = cdio_get_track_lba(p_cdio, i_track);
...@@ -114,13 +118,16 @@ GetCDDBInfo( access_t *p_access, cdda_data_t *p_cdda ) ...@@ -114,13 +118,16 @@ GetCDDBInfo( access_t *p_access, cdda_data_t *p_cdda )
cdio_get_track_lba(p_cdio, CDIO_CDROM_LEADOUT_TRACK) cdio_get_track_lba(p_cdio, CDIO_CDROM_LEADOUT_TRACK)
/ CDIO_CD_FRAMES_PER_SEC; / CDIO_CD_FRAMES_PER_SEC;
if (!cddb_disc_calc_discid(p_cdda->cddb.disc)) { if (!cddb_disc_calc_discid(p_cdda->cddb.disc))
{
msg_Err( p_access, "CDDB disc ID calculation failed" ); msg_Err( p_access, "CDDB disc ID calculation failed" );
goto cddb_destroy; goto cddb_destroy;
} }
i_matches = cddb_query(conn, p_cdda->cddb.disc); i_matches = cddb_query(conn, p_cdda->cddb.disc);
if (i_matches > 0) {
if (i_matches > 0)
{
if (i_matches > 1) if (i_matches > 1)
msg_Warn( p_access, "Found %d matches in CDDB. Using first one.", msg_Warn( p_access, "Found %d matches in CDDB. Using first one.",
i_matches); i_matches);
...@@ -129,14 +136,16 @@ GetCDDBInfo( access_t *p_access, cdda_data_t *p_cdda ) ...@@ -129,14 +136,16 @@ GetCDDBInfo( access_t *p_access, cdda_data_t *p_cdda )
if (p_cdda->i_debug & INPUT_DBG_CDDB) if (p_cdda->i_debug & INPUT_DBG_CDDB)
cddb_disc_print(p_cdda->cddb.disc); cddb_disc_print(p_cdda->cddb.disc);
} else { }
else
{
msg_Warn( p_access, "CDDB error: %s", cddb_error_str(errno)); msg_Warn( p_access, "CDDB error: %s", cddb_error_str(errno));
} }
cddb_destroy: cddb_destroy:
cddb_destroy(conn); cddb_destroy(conn);
cddb_end: ; cddb_end: ;
} }
#endif /*HAVE_LIBCDDB*/ #endif /*HAVE_LIBCDDB*/
...@@ -210,8 +219,7 @@ GetCDDBInfo( access_t *p_access, cdda_data_t *p_cdda ) ...@@ -210,8 +219,7 @@ GetCDDBInfo( access_t *p_access, cdda_data_t *p_cdda )
media info" or in playlist info. The intialization of CD-Text or CDDB media info" or in playlist info. The intialization of CD-Text or CDDB
is done here though. is done here though.
*/ */
void void CDDAMetaInfo( access_t *p_access, int i_track )
CDDAMetaInfo( access_t *p_access )
{ {
cdda_data_t *p_cdda = (cdda_data_t *) p_access->p_sys; cdda_data_t *p_cdda = (cdda_data_t *) p_access->p_sys;
...@@ -220,27 +228,42 @@ CDDAMetaInfo( access_t *p_access ) ...@@ -220,27 +228,42 @@ CDDAMetaInfo( access_t *p_access )
p_cdda->psz_mcn = cdio_get_mcn(p_cdda->p_cdio); p_cdda->psz_mcn = cdio_get_mcn(p_cdda->p_cdio);
#ifdef HAVE_LIBCDDB #ifdef HAVE_LIBCDDB
if ( p_cdda->b_cddb_enabled ) { if ( p_cdda->b_cddb_enabled )
{
GetCDDBInfo(p_access, p_cdda); GetCDDBInfo(p_access, p_cdda);
if ( p_cdda->cddb.disc )
if ( p_cdda->cddb.disc ) { {
p_cdda->p_meta = vlc_meta_New();