Commit 360a96dd authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont
Browse files

interfaces: use playlist_GetAout() where applicable (fixes #7601)

parent 0716a916
......@@ -160,9 +160,6 @@ static int PutAction( intf_thread_t *p_intf, int i_action )
/* Update the vout */
vout_thread_t *p_vout = p_input ? input_GetVout( p_input ) : NULL;
/* Update the aout */
vlc_object_t *p_aout = p_input ? (vlc_object_t *)input_GetAout( p_input ) : NULL;
/* Register OSD channels */
/* FIXME: this check can fail if the new vout is reallocated at the same
* address as the old one... We should rather listen to vout events.
......@@ -318,7 +315,9 @@ static int PutAction( intf_thread_t *p_intf, int i_action )
case ACTIONID_AUDIODEVICE_CYCLE:
{
if( !p_aout )
vlc_object_t *p_aout =
(vlc_object_t *)playlist_GetAout( p_playlist );
if( p_aout == NULL )
break;
vlc_value_t val, list, list2;
......@@ -363,6 +362,7 @@ static int PutAction( intf_thread_t *p_intf, int i_action )
list2.p_list->p_values[i].psz_string);
}
var_FreeList( &list, &list2 );
vlc_object_release( p_aout );
break;
}
......@@ -923,8 +923,6 @@ static int PutAction( intf_thread_t *p_intf, int i_action )
}
}
cleanup_and_continue:
if( p_aout )
vlc_object_release( p_aout );
if( p_vout )
vlc_object_release( p_vout );
if( p_input )
......
......@@ -1687,17 +1687,11 @@ static int AudioConfig( vlc_object_t *p_this, char const *psz_cmd,
{
VLC_UNUSED(oldval); VLC_UNUSED(p_data);
intf_thread_t *p_intf = (intf_thread_t*)p_this;
input_thread_t *p_input =
playlist_CurrentInput( p_intf->p_sys->p_playlist );
const char * psz_variable;
vlc_value_t val_name;
int i_error;
if( !p_input )
return VLC_ENOOBJ;
vlc_object_t * p_aout = (vlc_object_t *)input_GetAout( p_input );
vlc_object_release( p_input );
vlc_object_t *p_aout = (vlc_object_t *)playlist_GetAout( pl_Get(p_this) );
if ( p_aout == NULL )
return VLC_ENOOBJ;
......
......@@ -495,7 +495,7 @@ static VLCMainMenu *_o_sharedInstance = nil;
if ([o_mi_videotrack isEnabled] == YES)
[o_mi_subtitle setEnabled: YES];
audio_output_t * p_aout = input_GetAout(p_input);
audio_output_t * p_aout = playlist_GetAout(p_playlist);
if (p_aout != NULL) {
[self setupVarMenuItem: o_mi_channels target: (vlc_object_t *)p_aout
var: "stereo-mode" selector: @selector(toggleVar:)];
......
......@@ -530,12 +530,10 @@ vout_thread_t *getVoutForActiveWindow(void)
audio_output_t *getAout(void)
{
input_thread_t *p_input = getInput();
if (!p_input)
intf_thread_t *p_intf = VLCIntf;
if (!p_intf)
return NULL;
audio_output_t *p_aout = input_GetAout(p_input);
vlc_object_release(p_input);
return p_aout;
return playlist_GetAout(pl_Get(p_intf));
}
#pragma mark -
......
......@@ -1028,7 +1028,7 @@ vout_thread_t* MainInputManager::getVout()
audio_output_t * MainInputManager::getAout()
{
return p_input ? input_GetAout( p_input ) : NULL;
return playlist_GetAout( THEPL );
}
void MainInputManager::customEvent( QEvent *event )
......
......@@ -84,12 +84,8 @@ VariablePtr EqualizerBands::getBand( int band )
void EqualizerBands::onUpdate( Subject<VarPercent> &rBand, void *arg )
{
(void)rBand; (void)arg;
audio_output_t *pAout = NULL;
playlist_t *pPlaylist = getIntf()->p_sys->p_playlist;
input_thread_t *pInput = playlist_CurrentInput( pPlaylist );
if( pInput )
pAout = input_GetAout( pInput );
audio_output_t *pAout = playlist_GetAout( pPlaylist );
// Make sure we are not called from set()
if (!m_isUpdating)
......@@ -120,8 +116,6 @@ void EqualizerBands::onUpdate( Subject<VarPercent> &rBand, void *arg )
if( pAout )
vlc_object_release( pAout );
if( pInput )
vlc_object_release( pInput );
}
......@@ -134,12 +128,8 @@ EqualizerPreamp::EqualizerPreamp( intf_thread_t *pIntf ): VarPercent( pIntf )
void EqualizerPreamp::set( float percentage, bool updateVLC )
{
audio_output_t *pAout = NULL;
playlist_t *pPlaylist = getIntf()->p_sys->p_playlist;
input_thread_t *pInput = playlist_CurrentInput( pPlaylist );
if( pInput )
pAout = input_GetAout( pInput );
audio_output_t *pAout = playlist_GetAout( pPlaylist );
VarPercent::set( percentage );
......@@ -158,6 +148,4 @@ void EqualizerPreamp::set( float percentage, bool updateVLC )
if( pAout )
vlc_object_release( pAout );
if( pInput )
vlc_object_release( pInput );
}
......@@ -60,14 +60,9 @@
*****************************************************************************/
static int vlclua_preamp_get( lua_State *L )
{
input_thread_t *p_input = vlclua_get_input_internal( L );
if( !p_input )
return 0;
audio_output_t *p_aout = input_GetAout( p_input );
vlc_object_release( p_input );
if( !p_aout)
playlist_t *p_playlist = vlclua_get_playlist_internal( L );
audio_output_t *p_aout = playlist_GetAout( p_playlist );
if( p_aout == NULL )
return 0;
char *psz_af = var_GetNonEmptyString( p_aout, "audio-filter" );
......@@ -90,13 +85,9 @@ static int vlclua_preamp_get( lua_State *L )
*****************************************************************************/
static int vlclua_preamp_set( lua_State *L )
{
input_thread_t *p_input = vlclua_get_input_internal( L );
if( !p_input )
return 0;
audio_output_t *p_aout = input_GetAout( p_input );
vlc_object_release( p_input );
if( !p_aout )
playlist_t *p_playlist = vlclua_get_playlist_internal( L );
audio_output_t *p_aout = playlist_GetAout( p_playlist );
if( p_aout == NULL )
return 0;
char *psz_af = var_GetNonEmptyString( p_aout, "audio-filter" );
......@@ -133,12 +124,10 @@ Band 9: 16 kHz
static int vlclua_equalizer_get( lua_State *L )
{
const unsigned bands = 10;
input_thread_t *p_input = vlclua_get_input_internal( L );
if( !p_input )
return 0;
audio_output_t *p_aout = input_GetAout( p_input );
vlc_object_release( p_input );
if( !p_aout )
playlist_t *p_playlist = vlclua_get_playlist_internal( L );
audio_output_t *p_aout = playlist_GetAout( p_playlist );
if( p_aout == NULL )
return 0;
char *psz_af = var_GetNonEmptyString( p_aout, "audio-filter" );
......@@ -201,13 +190,10 @@ static int vlclua_equalizer_set( lua_State *L )
int bandid = luaL_checknumber( L, 1 );
if( bandid < 0 || bandid > 9)
return 0;
input_thread_t *p_input = vlclua_get_input_internal( L );
if( !p_input )
return 0;
audio_output_t *p_aout = input_GetAout( p_input );
vlc_object_release( p_input );
if( !p_aout )
playlist_t *p_playlist = vlclua_get_playlist_internal( L );
audio_output_t *p_aout = playlist_GetAout( p_playlist );
if( p_aout == NULL )
return 0;
char *psz_af = var_GetNonEmptyString( p_aout, "audio-filter" );
......@@ -261,28 +247,22 @@ static int vlclua_equalizer_setpreset( lua_State *L )
int presetid = luaL_checknumber( L, 1 );
if( presetid >= NB_PRESETS || presetid < 0 )
return 0;
input_thread_t *p_input = vlclua_get_input_internal( L );
if( p_input )
playlist_t *p_playlist = vlclua_get_playlist_internal( L );
audio_output_t *p_aout = playlist_GetAout( p_playlist );
if( p_aout == NULL )
return 0;
int ret = 0;
char *psz_af = var_InheritString( p_aout, "audio-filter" );
if( psz_af != NULL && strstr ( psz_af, "equalizer" ) != NULL )
{
audio_output_t *p_aout = input_GetAout( p_input );
vlc_object_release( p_input );
if( !p_aout )
{
return 0;
}
char *psz_af = var_GetNonEmptyString( p_aout, "audio-filter" );
if( !psz_af || strstr ( psz_af, "equalizer" ) == NULL )
{
free( psz_af );
vlc_object_release( p_aout );
return 0;
}
free( psz_af );
var_SetString( p_aout , "equalizer-preset" , preset_list[presetid] );
vlc_object_release( p_aout );
return 1;
ret = 1;
}
return 0;
free( psz_af );
vlc_object_release( p_aout );
return ret;
}
/****************************************************************************
......
......@@ -127,18 +127,12 @@ static int vlclua_get_vout( lua_State *L )
}
static int vlclua_get_aout( lua_State *L )
{
input_thread_t *p_input= vlclua_get_input_internal( L );
if( p_input )
{
audio_output_t *p_aout = input_GetAout( p_input );
vlc_object_release(p_input);
if(p_aout)
{
vlclua_push_vlc_object( L, (vlc_object_t *)p_aout );
return 1;
}
}
lua_pushnil( L );
playlist_t *p_playlist = vlclua_get_playlist_internal( L );
audio_output_t *p_aout = playlist_GetAout( p_playlist );
if( p_aout != NULL )
vlclua_push_vlc_object( L, (vlc_object_t *)p_aout );
else
lua_pushnil( L );
return 1;
}
/*****************************************************************************
......
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