Commit 2ecaf892 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

fingerprinter: remove cancellation cleanup, simplify

Cancellation cannot occur here.
parent f5ae6480
...@@ -55,11 +55,6 @@ struct fingerprinter_sys_t ...@@ -55,11 +55,6 @@ struct fingerprinter_sys_t
vlc_array_t *queue; vlc_array_t *queue;
} processing; } processing;
/* tracked in sys for cancelability */
input_item_t *p_item;
input_thread_t *p_input;
chromaprint_fingerprint_t chroma_fingerprint;
/* clobberable by cleanups */ /* clobberable by cleanups */
int i_cancel_state; int i_cancel_state;
int i; int i;
...@@ -132,30 +127,12 @@ static void ApplyResult( fingerprint_request_t *p_r, int i_resultid ) ...@@ -132,30 +127,12 @@ static void ApplyResult( fingerprint_request_t *p_r, int i_resultid )
vlc_mutex_unlock( &p_item->lock ); vlc_mutex_unlock( &p_item->lock );
} }
static void cancelDoFingerprint( void *p_arg ) static void DoFingerprint( vlc_object_t *p_this, acoustid_fingerprint_t *fp,
{ const char *psz_uri )
fingerprinter_sys_t *p_sys = ( fingerprinter_sys_t * ) p_arg;
if ( p_sys->p_input )
{
input_Close( p_sys->p_input );
}
/* cleanup temporary result */
if ( p_sys->chroma_fingerprint.psz_fingerprint )
FREENULL( p_sys->chroma_fingerprint.psz_fingerprint );
if ( p_sys->p_item )
input_item_Release( p_sys->p_item );
}
static void DoFingerprint( vlc_object_t *p_this, fingerprinter_sys_t *p_sys,
acoustid_fingerprint_t *fp, const char *psz_uri )
{ {
p_sys->p_input = NULL; input_item_t *p_item = input_item_New( NULL, NULL );
p_sys->p_item = NULL; if ( unlikely(p_item == NULL) )
p_sys->chroma_fingerprint.psz_fingerprint = NULL; return;
vlc_cleanup_push( cancelDoFingerprint, p_sys );
p_sys->p_item = input_item_New( NULL, NULL );
if ( ! p_sys->p_item ) goto end;
char *psz_sout_option; char *psz_sout_option;
/* Note: need at -max- 2 channels, but we can't guess it before playing */ /* Note: need at -max- 2 channels, but we can't guess it before playing */
...@@ -163,40 +140,49 @@ static void DoFingerprint( vlc_object_t *p_this, fingerprinter_sys_t *p_sys, ...@@ -163,40 +140,49 @@ static void DoFingerprint( vlc_object_t *p_this, fingerprinter_sys_t *p_sys,
if ( asprintf( &psz_sout_option, if ( asprintf( &psz_sout_option,
"sout=#transcode{acodec=%s,channels=2}:chromaprint", "sout=#transcode{acodec=%s,channels=2}:chromaprint",
( VLC_CODEC_S16L == VLC_CODEC_S16N ) ? "s16l" : "s16b" ) ( VLC_CODEC_S16L == VLC_CODEC_S16N ) ? "s16l" : "s16b" )
== -1 ) goto end; == -1 )
input_item_AddOption( p_sys->p_item, psz_sout_option, VLC_INPUT_OPTION_TRUSTED ); {
input_item_Release( p_item );
return;
}
input_item_AddOption( p_item, psz_sout_option, VLC_INPUT_OPTION_TRUSTED );
free( psz_sout_option ); free( psz_sout_option );
input_item_AddOption( p_sys->p_item, "vout=dummy", VLC_INPUT_OPTION_TRUSTED ); input_item_AddOption( p_item, "vout=dummy", VLC_INPUT_OPTION_TRUSTED );
input_item_AddOption( p_sys->p_item, "aout=dummy", VLC_INPUT_OPTION_TRUSTED ); input_item_AddOption( p_item, "aout=dummy", VLC_INPUT_OPTION_TRUSTED );
if ( fp->i_duration ) if ( fp->i_duration )
{ {
if ( asprintf( &psz_sout_option, "stop-time=%u", fp->i_duration ) == -1 ) goto end; if ( asprintf( &psz_sout_option, "stop-time=%u", fp->i_duration ) == -1 )
input_item_AddOption( p_sys->p_item, psz_sout_option, VLC_INPUT_OPTION_TRUSTED ); {
input_item_Release( p_item );
return;
}
input_item_AddOption( p_item, psz_sout_option, VLC_INPUT_OPTION_TRUSTED );
free( psz_sout_option ); free( psz_sout_option );
} }
input_item_SetURI( p_sys->p_item, psz_uri ) ; input_item_SetURI( p_item, psz_uri ) ;
p_sys->p_input = input_Create( p_this, p_sys->p_item, "fingerprinter", NULL ); input_thread_t *p_input = input_Create( p_this, p_item, "fingerprinter", NULL );
if ( p_sys->p_input ) input_item_Release( p_item );
{
p_sys->chroma_fingerprint.i_duration = fp->i_duration;
var_Create( p_sys->p_input, "fingerprint-data", VLC_VAR_ADDRESS );
var_SetAddress( p_sys->p_input, "fingerprint-data", & p_sys->chroma_fingerprint );
input_Start( p_sys->p_input ); if( p_input == NULL )
input_Stop( p_sys->p_input ); return;
input_Close( p_sys->p_input );
p_sys->p_input = NULL;
if ( p_sys->chroma_fingerprint.psz_fingerprint ) chromaprint_fingerprint_t chroma_fingerprint;
{
fp->psz_fingerprint = strdup( p_sys->chroma_fingerprint.psz_fingerprint ); chroma_fingerprint.psz_fingerprint = NULL;
if ( ! fp->i_duration ) /* had not given hint */ chroma_fingerprint.i_duration = fp->i_duration;
fp->i_duration = p_sys->chroma_fingerprint.i_duration;
} var_Create( p_input, "fingerprint-data", VLC_VAR_ADDRESS );
} var_SetAddress( p_input, "fingerprint-data", &chroma_fingerprint );
end:
vlc_cleanup_run( ); input_Start( p_input );
input_Stop( p_input );
input_Close( p_input );
fp->psz_fingerprint = chroma_fingerprint.psz_fingerprint;
if( !fp->i_duration ) /* had not given hint */
fp->i_duration = chroma_fingerprint.i_duration;
} }
/***************************************************************************** /*****************************************************************************
...@@ -318,7 +304,7 @@ static void *Run( void *opaque ) ...@@ -318,7 +304,7 @@ static void *Run( void *opaque )
if ( p_data->i_duration ) if ( p_data->i_duration )
acoustid_print.i_duration = p_data->i_duration; acoustid_print.i_duration = p_data->i_duration;
DoFingerprint( VLC_OBJECT(p_fingerprinter), p_sys, DoFingerprint( VLC_OBJECT(p_fingerprinter),
&acoustid_print, psz_uri ); &acoustid_print, psz_uri );
free( psz_uri ); free( psz_uri );
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment