Commit 0433b507 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Require an aout instance to create an aout input

The input resource creates the aout instance with the input manager as
its parent object.

If this fail, the aout input should not be created at all. This removes
the fallback to an aout instance with the decoder object as parent.
This would potentially crash as the decoder is shorter-lived than the
aout instance.
parent ed94986f
......@@ -150,10 +150,8 @@ int aout_VolumeNoneSet( aout_instance_t *, audio_volume_t );
int aout_VolumeNoneInfos( aout_instance_t *, audio_volume_t * );
/* From dec.c */
#define aout_DecNew(a, b, c, d, e) __aout_DecNew(VLC_OBJECT(a), b, c, d, e)
aout_input_t * __aout_DecNew( vlc_object_t *, aout_instance_t **,
audio_sample_format_t *, const audio_replay_gain_t *,
const aout_request_vout_t * );
aout_input_t *aout_DecNew( aout_instance_t *, audio_sample_format_t *,
const audio_replay_gain_t *, const aout_request_vout_t * );
int aout_DecDelete ( aout_instance_t *, aout_input_t * );
aout_buffer_t * aout_DecNewBuffer( aout_input_t *, size_t );
void aout_DecDeleteBuffer( aout_instance_t *, aout_input_t *, aout_buffer_t * );
......
......@@ -37,10 +37,11 @@
#include "aout_internal.h"
/*****************************************************************************
* aout_DecNew : create a decoder
*****************************************************************************/
static aout_input_t * DecNew( aout_instance_t * p_aout,
#undef aout_DecNew
/**
* Creates an audio output
*/
aout_input_t *aout_DecNew( aout_instance_t *p_aout,
audio_sample_format_t *p_format,
const audio_replay_gain_t *p_replay_gain,
const aout_request_vout_t *p_request_vout )
......@@ -166,29 +167,6 @@ error:
return NULL;
}
aout_input_t * __aout_DecNew( vlc_object_t * p_this,
aout_instance_t ** pp_aout,
audio_sample_format_t * p_format,
const audio_replay_gain_t *p_replay_gain,
const aout_request_vout_t *p_request_video )
{
aout_instance_t *p_aout = *pp_aout;
if ( p_aout == NULL )
{
msg_Dbg( p_this, "no aout present, spawning one" );
p_aout = aout_New( p_this );
/* Everything failed, I'm a loser, I just wanna die */
if( p_aout == NULL )
return NULL;
vlc_object_attach( p_aout, p_this );
*pp_aout = p_aout;
}
return DecNew( p_aout, p_format, p_replay_gain, p_request_video );
}
/*****************************************************************************
* aout_DecDelete : delete a decoder
*****************************************************************************/
......
......@@ -2275,8 +2275,12 @@ static aout_buffer_t *aout_new_buffer( decoder_t *p_dec, int i_samples )
p_aout = p_owner->p_aout;
if( !p_aout )
p_aout = input_resource_RequestAout( p_owner->p_resource, NULL );
p_aout_input = aout_DecNew( p_dec, &p_aout,
&format, &p_dec->fmt_out.audio_replay_gain, &request_vout );
if( p_aout )
p_aout_input = aout_DecNew( p_aout, &format,
&p_dec->fmt_out.audio_replay_gain,
&request_vout );
else
p_aout_input = NULL;
vlc_mutex_lock( &p_owner->lock );
......
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