[vlc-devel] [PATCH 1/2] lib/audio: Disable audio track if requested
M. GOUJON Évan
goujon.evan at gmail.com
Wed Mar 30 21:46:48 CEST 2016
Sorry for my late reply, I've done additional tests to exacly understand
what's going on.
On 03/29/2016 03:05 PM, Rémi Denis-Courmont wrote:
> Le 2016-03-28 13:13, GOUJON Évan a écrit :
>> ---
>> lib/audio.c | 10 ++++++++++
>> 1 file changed, 10 insertions(+)
>>
>> diff --git a/lib/audio.c b/lib/audio.c
>> index 7901c64..03a5df4 100644
>> --- a/lib/audio.c
>> +++ b/lib/audio.c
>> @@ -419,6 +419,16 @@ int libvlc_audio_set_track(
>> libvlc_media_player_t *p_mi, int i_track )
>> if( !p_input_thread )
>> return -1;
>>
>> + if( i_track == -1 )
>> + {
>> + if( var_SetInteger( p_input_thread, "audio-es", i_track ) < 0 )
>> + libvlc_printerr( "Unable to disable sound track" );
>> + else
>> + i_ret = 0;
>> + vlc_object_release( p_input_thread );
>> + return i_ret;
>> + }
>> +
>
> Did you actually test the error case? Seems bizarre.
I must admit it's a bit strange at a first look but that's the logic
used in the for loop below that part (not shown) : i_ret is initialized
to -1 and in case of error, print the error, free and exit, otherwise,
set i_ret to 0, free and exit.
Since libvlc_get_input_thread returned a valid pointer, we should free
it, everytime.
I'm developping a media player with different "backends" (= decoding
library).
I choose a file, try each backend to see if it can play the file and
then do some "adjustments" and start playing.
By "adjustments", I mean choosing output (pixel) format, setting up
callbacks, enabling/disabling streams, inserting custom filters...
The issue here is that I was trying to enable/disable a track just after
parsing the media and before playing it.
Now I understand vlc cannot do that until it actually start playing.
If I delay the libvlc_{audio,video}_set_track call, it works.
Sorry for the noise, you can drop my patches.
More information about the vlc-devel
mailing list