Commit 56d4e908 authored by Erwan Tulou's avatar Erwan Tulou

skins2: simplify equalizer initialization

parent 6d2b8a0a
...@@ -32,7 +32,6 @@ void CmdSetEqualizer::execute() ...@@ -32,7 +32,6 @@ void CmdSetEqualizer::execute()
playlist_t* pPlaylist = getIntf()->p_sys->p_playlist; playlist_t* pPlaylist = getIntf()->p_sys->p_playlist;
playlist_EnableAudioFilter( pPlaylist, "equalizer", m_enable ); playlist_EnableAudioFilter( pPlaylist, "equalizer", m_enable );
VlcProc::instance( getIntf() )->update_equalizer();
} }
...@@ -82,7 +82,7 @@ void VlcProc::destroy( intf_thread_t *pIntf ) ...@@ -82,7 +82,7 @@ void VlcProc::destroy( intf_thread_t *pIntf )
#define SET_VOLUME(m,v,b) ((Volume*)(m).get())->setVolume(v,b) #define SET_VOLUME(m,v,b) ((Volume*)(m).get())->setVolume(v,b)
VlcProc::VlcProc( intf_thread_t *pIntf ): SkinObject( pIntf ), VlcProc::VlcProc( intf_thread_t *pIntf ): SkinObject( pIntf ),
m_varEqBands( pIntf ), m_pVout( NULL ), m_pAout( NULL ) m_varEqBands( pIntf ), m_pVout( NULL )
{ {
// Create and register VLC variables // Create and register VLC variables
VarManager *pVarManager = VarManager::instance( getIntf() ); VarManager *pVarManager = VarManager::instance( getIntf() );
...@@ -189,11 +189,6 @@ VlcProc::VlcProc( intf_thread_t *pIntf ): SkinObject( pIntf ), ...@@ -189,11 +189,6 @@ VlcProc::VlcProc( intf_thread_t *pIntf ): SkinObject( pIntf ),
VlcProc::~VlcProc() VlcProc::~VlcProc()
{ {
if( m_pAout )
{
vlc_object_release( m_pAout );
m_pAout = NULL;
}
if( m_pVout ) if( m_pVout )
{ {
vlc_object_release( m_pVout ); vlc_object_release( m_pVout );
...@@ -533,57 +528,6 @@ void VlcProc::on_intf_event_changed( vlc_object_t* p_obj, vlc_value_t newVal ) ...@@ -533,57 +528,6 @@ void VlcProc::on_intf_event_changed( vlc_object_t* p_obj, vlc_value_t newVal )
break; break;
} }
case INPUT_EVENT_AOUT:
{
audio_output_t* pAout = input_GetAout( pInput );
// end of input or aout reuse (nothing to do)
if( !pAout || pAout == m_pAout )
{
if( pAout )
vlc_object_release( pAout );
break;
}
// remove previous Aout if any
if( m_pAout )
{
var_DelCallback( m_pAout, "audio-filter",
onGenericCallback, this );
var_DelCallback( m_pAout, "equalizer-bands",
onEqBandsChange, this );
var_DelCallback( m_pAout, "equalizer-preamp",
onEqPreampChange, this );
vlc_object_release( m_pAout );
m_pAout = NULL;
}
m_pAout = pAout;
// make sure some key variables exist !
// yes, this is a ugly but needed hack
if( !var_Type( pAout, "equalizer-bands" ) )
var_Create( pAout, "equalizer-bands",
VLC_VAR_STRING | VLC_VAR_DOINHERIT);
if( !var_Type( pAout, "equalizer-preamp" ) )
var_Create( pAout, "equalizer-preamp",
VLC_VAR_FLOAT | VLC_VAR_DOINHERIT);
// New Aout (addCallbacks)
var_AddCallback( pAout, "audio-filter",
onGenericCallback, this );
var_AddCallback( pAout, "equalizer-bands",
onEqBandsChange, this );
var_AddCallback( pAout, "equalizer-preamp",
onEqPreampChange, this );
char *pFilters = var_GetNonEmptyString( pAout, "audio-filter" );
bool b_equalizer = pFilters && strstr( pFilters, "equalizer" );
free( pFilters );
SET_BOOL( m_cVarEqualizer, b_equalizer );
break;
}
case INPUT_EVENT_CHAPTER: case INPUT_EVENT_CHAPTER:
{ {
vlc_value_t chapters_count; vlc_value_t chapters_count;
...@@ -779,7 +723,7 @@ void VlcProc::init_variables() ...@@ -779,7 +723,7 @@ void VlcProc::init_variables()
SET_BOOL( m_cVarStopped, true ); SET_BOOL( m_cVarStopped, true );
update_equalizer(); init_equalizer();
} }
...@@ -815,19 +759,55 @@ void VlcProc::update_current_input() ...@@ -815,19 +759,55 @@ void VlcProc::update_current_input()
} }
} }
void VlcProc::update_equalizer() void VlcProc::init_equalizer()
{ {
playlist_t* pPlaylist = getIntf()->p_sys->p_playlist;
audio_output_t* pAout = playlist_GetAout( pPlaylist );
if( pAout )
{
if( !var_Type( pAout, "equalizer-bands" ) )
var_Create( pAout, "equalizer-bands",
VLC_VAR_STRING | VLC_VAR_DOINHERIT);
if( !var_Type( pAout, "equalizer-preamp" ) )
var_Create( pAout, "equalizer-preamp",
VLC_VAR_FLOAT | VLC_VAR_DOINHERIT);
char *pFilters; // New Aout (addCallbacks)
if( m_pAout ) var_AddCallback( pAout, "audio-filter",
pFilters = var_GetNonEmptyString( m_pAout, "audio-filter" ); onGenericCallback, this );
else var_AddCallback( pAout, "equalizer-bands",
pFilters = var_InheritString( getIntf(), "audio-filter" ); onEqBandsChange, this );
var_AddCallback( pAout, "equalizer-preamp",
onEqPreampChange, this );
}
// is equalizer enabled ?
char *pFilters = pAout ?
var_GetNonEmptyString( pAout, "audio-filter" ) :
var_InheritString( getIntf(), "audio-filter" );
bool b_equalizer = pFilters && strstr( pFilters, "equalizer" ); bool b_equalizer = pFilters && strstr( pFilters, "equalizer" );
free( pFilters ); free( pFilters );
SET_BOOL( m_cVarEqualizer, b_equalizer ); SET_BOOL( m_cVarEqualizer, b_equalizer );
// retrieve initial bands
char* bands = pAout ?
var_GetString( pAout, "equalizer-bands" ) :
var_InheritString( getIntf(), "equalizer-bands" );
if( bands )
{
m_varEqBands.set( bands );
free( bands );
}
// retrieve initial preamp
float preamp = pAout ?
var_GetFloat( pAout, "equalizer-preamp" ) :
var_InheritFloat( getIntf(), "equalizer-preamp" );
EqualizerPreamp *pVarPreamp = (EqualizerPreamp*)m_cVarEqPreamp.get();
pVarPreamp->set( (preamp + 20.0) / 40.0 );
if( pAout )
vlc_object_release( pAout);
} }
void VlcProc::setFullscreenVar( bool b_fullscreen ) void VlcProc::setFullscreenVar( bool b_fullscreen )
......
...@@ -95,8 +95,8 @@ public: ...@@ -95,8 +95,8 @@ public:
/// Indicate whether the embedded video output is currently used /// Indicate whether the embedded video output is currently used
bool isVoutUsed() const { return m_pVout != NULL; } bool isVoutUsed() const { return m_pVout != NULL; }
/// update equalizer /// initialize equalizer
void update_equalizer( ); void init_equalizer( );
/// update global variables for the current input /// update global variables for the current input
void update_current_input( ); void update_current_input( );
...@@ -164,8 +164,6 @@ private: ...@@ -164,8 +164,6 @@ private:
/// Vout thread /// Vout thread
vout_thread_t *m_pVout; vout_thread_t *m_pVout;
/// Audio output
audio_output_t *m_pAout;
// reset variables when input is over // reset variables when input is over
void reset_input(); void reset_input();
......
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