[vlc-devel] commit: skins2: replace all remaining FIND_ANYWHERE with more appropriate functions ( Erwan Tulou )

git version control git at videolan.org
Tue Aug 25 10:16:10 CEST 2009


vlc | branch: master | Erwan Tulou <erwan10 at videolan.org> | Tue Aug 25 10:02:15 2009 +0200| [5fd6cb5a65ce56c85a0a737574463b94c74f7e41] | committer: Erwan Tulou 

skins2: replace all remaining FIND_ANYWHERE with more appropriate functions

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=5fd6cb5a65ce56c85a0a737574463b94c74f7e41
---

 modules/gui/skins2/commands/cmd_audio.cpp |   17 +++++++++++---
 modules/gui/skins2/commands/cmd_dvd.cpp   |   31 +++++++++++++------------
 modules/gui/skins2/commands/cmd_input.cpp |   12 +++++-----
 modules/gui/skins2/src/vlcproc.cpp        |   16 ++++++++++---
 modules/gui/skins2/vars/equalizer.cpp     |   34 +++++++++++++++++++++++------
 5 files changed, 74 insertions(+), 36 deletions(-)

diff --git a/modules/gui/skins2/commands/cmd_audio.cpp b/modules/gui/skins2/commands/cmd_audio.cpp
index ec7878c..ea56585 100644
--- a/modules/gui/skins2/commands/cmd_audio.cpp
+++ b/modules/gui/skins2/commands/cmd_audio.cpp
@@ -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()
diff --git a/modules/gui/skins2/commands/cmd_dvd.cpp b/modules/gui/skins2/commands/cmd_dvd.cpp
index b96f4b7..9c47276 100644
--- a/modules/gui/skins2/commands/cmd_dvd.cpp
+++ b/modules/gui/skins2/commands/cmd_dvd.cpp
@@ -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;
diff --git a/modules/gui/skins2/commands/cmd_input.cpp b/modules/gui/skins2/commands/cmd_input.cpp
index 761bd7c..ea71409 100644
--- a/modules/gui/skins2/commands/cmd_input.cpp
+++ b/modules/gui/skins2/commands/cmd_input.cpp
@@ -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;
diff --git a/modules/gui/skins2/src/vlcproc.cpp b/modules/gui/skins2/src/vlcproc.cpp
index af4654a..f5c8cd1 100644
--- a/modules/gui/skins2/src/vlcproc.cpp
+++ b/modules/gui/skins2/src/vlcproc.cpp
@@ -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()
diff --git a/modules/gui/skins2/vars/equalizer.cpp b/modules/gui/skins2/vars/equalizer.cpp
index 3600017..38649d1 100644
--- a/modules/gui/skins2/vars/equalizer.cpp
+++ b/modules/gui/skins2/vars/equalizer.cpp
@@ -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 );
 }




More information about the vlc-devel mailing list