]> git.sesse.net Git - vlc/commitdiff
skins2: replace all remaining FIND_ANYWHERE with more appropriate functions
authorErwan Tulou <erwan10@videolan.org>
Tue, 25 Aug 2009 08:02:15 +0000 (10:02 +0200)
committerErwan Tulou <erwan10@videolan.org>
Tue, 25 Aug 2009 08:12:23 +0000 (10:12 +0200)
modules/gui/skins2/commands/cmd_audio.cpp
modules/gui/skins2/commands/cmd_dvd.cpp
modules/gui/skins2/commands/cmd_input.cpp
modules/gui/skins2/src/vlcproc.cpp
modules/gui/skins2/vars/equalizer.cpp

index ec7878cc01a59c2c3c3f27810fb2a935b9585649..ea5658582d4b8646b365aa5ad979dd7feac16474 100644 (file)
 
 #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()
index b96f4b7cbe03ae3e640afdc57a41e6a6ebacb144..9c47276816542b53201b85cbf9ca71d2acf756a6 100644 (file)
 
 #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;
index 761bd7c636b4e2a3e70ce8c7796eb7fd2bdafdd2..ea71409e2426d576b8d93238e60c1b5508a60e04 100644 (file)
@@ -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;
index af4654a4f09c98bc4e774eb3d684fe3e1683e080..f5c8cd1fed6c4b970428e84c237e4745d3632b98 100644 (file)
@@ -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()
index 3600017df9090704b545c7e78788937098a1e531..38649d101c7e03db1b18aa7dc38a4688de0c38b9 100644 (file)
@@ -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 );
 }