Commit 5fd6cb5a authored by Erwan Tulou's avatar Erwan Tulou

skins2: replace all remaining FIND_ANYWHERE with more appropriate functions

parent 25c59e90
......@@ -23,14 +23,19 @@
#include "cmd_audio.hpp"
#include "../src/vlcproc.hpp"
#include <vlc_playlist.h>
#include <vlc_input.h>
#include <vlc_aout.h>
#include <string>
void CmdSetEqualizer::execute()
{
// Get the audio output
aout_instance_t *pAout = (aout_instance_t *)vlc_object_find( getIntf(),
VLC_OBJECT_AOUT, FIND_ANYWHERE );
aout_instance_t *pAout = NULL;
playlist_t *pPlaylist = getIntf()->p_sys->p_playlist;
input_thread_t *pInput = playlist_CurrentInput( pPlaylist );
if( pInput )
pAout = input_GetAout( pInput );
// XXX
string filters;
......@@ -46,12 +51,16 @@ void CmdSetEqualizer::execute()
{
pAout->pp_inputs[i]->b_restart = true;
}
vlc_object_release( pAout );
}
else
{
config_PutPsz( getIntf(), "audio-filter", filters.c_str() );
}
if( pAout )
vlc_object_release( pAout );
if( pInput )
vlc_object_release( pInput );
}
void CmdVolumeChanged::execute()
......
......@@ -23,12 +23,13 @@
#include "cmd_dvd.hpp"
#include <vlc_input.h>
#include <vlc_playlist.h>
void CmdDvdNextTitle::execute()
{
input_thread_t *p_input =
(input_thread_t *)vlc_object_find( getIntf(), VLC_OBJECT_INPUT,
FIND_ANYWHERE );
playlist_t *pPlaylist = getIntf()->p_sys->p_playlist;
input_thread_t *p_input = playlist_CurrentInput( pPlaylist );
if( p_input )
{
var_TriggerCallback( p_input, "next-title" );
......@@ -39,9 +40,9 @@ void CmdDvdNextTitle::execute()
void CmdDvdPreviousTitle::execute()
{
input_thread_t *p_input =
(input_thread_t *)vlc_object_find( getIntf(), VLC_OBJECT_INPUT,
FIND_ANYWHERE );
playlist_t *pPlaylist = getIntf()->p_sys->p_playlist;
input_thread_t *p_input = playlist_CurrentInput( pPlaylist );
if( p_input )
{
var_TriggerCallback( p_input, "prev-title" );
......@@ -52,9 +53,9 @@ void CmdDvdPreviousTitle::execute()
void CmdDvdNextChapter::execute()
{
input_thread_t *p_input =
(input_thread_t *)vlc_object_find( getIntf(), VLC_OBJECT_INPUT,
FIND_ANYWHERE );
playlist_t *pPlaylist = getIntf()->p_sys->p_playlist;
input_thread_t *p_input = playlist_CurrentInput( pPlaylist );
if( p_input )
{
var_TriggerCallback( p_input, "next-chapter" );
......@@ -65,9 +66,9 @@ void CmdDvdNextChapter::execute()
void CmdDvdPreviousChapter::execute()
{
input_thread_t *p_input =
(input_thread_t *)vlc_object_find( getIntf(), VLC_OBJECT_INPUT,
FIND_ANYWHERE );
playlist_t *pPlaylist = getIntf()->p_sys->p_playlist;
input_thread_t *p_input = playlist_CurrentInput( pPlaylist );
if( p_input )
{
var_TriggerCallback( p_input, "prev-chapter" );
......@@ -78,9 +79,9 @@ void CmdDvdPreviousChapter::execute()
void CmdDvdRootMenu::execute()
{
input_thread_t *p_input =
(input_thread_t *)vlc_object_find( getIntf(), VLC_OBJECT_INPUT,
FIND_ANYWHERE );
playlist_t *pPlaylist = getIntf()->p_sys->p_playlist;
input_thread_t *p_input = playlist_CurrentInput( pPlaylist );
if( p_input )
{
vlc_value_t val;
......
......@@ -79,9 +79,9 @@ void CmdStop::execute()
void CmdSlower::execute()
{
input_thread_t *pInput =
(input_thread_t *)vlc_object_find( getIntf(), VLC_OBJECT_INPUT,
FIND_ANYWHERE );
playlist_t *pPlaylist = getIntf()->p_sys->p_playlist;
input_thread_t *pInput = playlist_CurrentInput( pPlaylist );
if( pInput )
{
vlc_value_t val;
......@@ -95,9 +95,9 @@ void CmdSlower::execute()
void CmdFaster::execute()
{
input_thread_t *pInput =
(input_thread_t *)vlc_object_find( getIntf(), VLC_OBJECT_INPUT,
FIND_ANYWHERE );
playlist_t *pPlaylist = getIntf()->p_sys->p_playlist;
input_thread_t *pInput = playlist_CurrentInput( pPlaylist );
if( pInput )
{
vlc_value_t val;
......
......@@ -230,12 +230,16 @@ void VlcProc::CmdManage::execute()
void VlcProc::refreshAudio()
{
char *pFilters;
aout_instance_t *pAout = NULL;
playlist_t *pPlaylist = getIntf()->p_sys->p_playlist;
input_thread_t *pInput = playlist_CurrentInput( pPlaylist );
if( pInput )
pAout = input_GetAout( pInput );
// Check if the audio output has changed
aout_instance_t *pAout = (aout_instance_t *)vlc_object_find( getIntf(),
VLC_OBJECT_AOUT, FIND_ANYWHERE );
if( pAout )
{
// Check if the audio output has changed
if( pAout != m_pAout )
{
// Register the equalizer callbacks
......@@ -250,7 +254,6 @@ void VlcProc::refreshAudio()
}
// Get the audio filters
pFilters = var_GetNonEmptyString( pAout, "audio-filter" );
vlc_object_release( pAout );
}
else
{
......@@ -262,6 +265,11 @@ void VlcProc::refreshAudio()
VarBoolImpl *pVarEqualizer = (VarBoolImpl*)m_cVarEqualizer.get();
pVarEqualizer->set( pFilters && strstr( pFilters, "equalizer" ) );
free( pFilters );
if( pAout )
vlc_object_release( pAout );
if( pInput )
vlc_object_release( pInput );
}
void VlcProc::refreshVolume()
......
......@@ -26,6 +26,8 @@
#endif
#include <vlc_common.h>
#include <vlc_playlist.h>
#include <vlc_input.h>
#include <vlc_aout.h>
#include "equalizer.hpp"
#include "../utils/var_percent.hpp"
......@@ -81,6 +83,13 @@ VariablePtr EqualizerBands::getBand( int band )
void EqualizerBands::onUpdate( Subject<VarPercent> &rBand, void *arg )
{
aout_instance_t *pAout = NULL;
playlist_t *pPlaylist = getIntf()->p_sys->p_playlist;
input_thread_t *pInput = playlist_CurrentInput( pPlaylist );
if( pInput )
pAout = input_GetAout( pInput );
// Make sure we are not called from set()
if (!m_isUpdating)
{
......@@ -98,18 +107,20 @@ void EqualizerBands::onUpdate( Subject<VarPercent> &rBand, void *arg )
ss << " " << val;
}
string bands = ss.str();
aout_instance_t *pAout = (aout_instance_t *)vlc_object_find( getIntf(),
VLC_OBJECT_AOUT, FIND_ANYWHERE );
config_PutPsz( getIntf(), "equalizer-bands", bands.c_str() );
if( pAout )
{
// Update the audio output
var_SetString( pAout, "equalizer-bands", (char*)bands.c_str() );
vlc_object_release( pAout );
}
}
if( pAout )
vlc_object_release( pAout );
if( pInput )
vlc_object_release( pInput );
}
......@@ -122,6 +133,13 @@ EqualizerPreamp::EqualizerPreamp( intf_thread_t *pIntf ): VarPercent( pIntf )
void EqualizerPreamp::set( float percentage, bool updateVLC )
{
aout_instance_t *pAout = NULL;
playlist_t *pPlaylist = getIntf()->p_sys->p_playlist;
input_thread_t *pInput = playlist_CurrentInput( pPlaylist );
if( pInput )
pAout = input_GetAout( pInput );
VarPercent::set( percentage );
// Avoid infinite loop
......@@ -129,14 +147,16 @@ void EqualizerPreamp::set( float percentage, bool updateVLC )
{
float val = 40 * percentage - 20;
aout_instance_t *pAout = (aout_instance_t *)vlc_object_find( getIntf(),
VLC_OBJECT_AOUT, FIND_ANYWHERE );
config_PutFloat( getIntf(), "equalizer-preamp", val );
if( pAout )
{
// Update the audio output
var_SetFloat( pAout, "equalizer-preamp", val );
vlc_object_release( pAout );
}
}
if( pAout )
vlc_object_release( pAout );
if( pInput )
vlc_object_release( pInput );
}
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