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

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