vlcproc.cpp
上传用户:kjfoods
上传日期:2020-07-06
资源大小:29949k
文件大小:21k
源码类别:

midi

开发平台:

Unix_Linux

  1. /*****************************************************************************
  2.  * vlcproc.cpp
  3.  *****************************************************************************
  4.  * Copyright (C) 2003-2009 the VideoLAN team
  5.  * $Id: 3b985cf970a1af9cbd96659c175b9c3bda62d59e $
  6.  *
  7.  * Authors: Cyril Deguet     <asmax@via.ecp.fr>
  8.  *          Olivier Teulière <ipkiss@via.ecp.fr>
  9.  *
  10.  * This program is free software; you can redistribute it and/or modify
  11.  * it under the terms of the GNU General Public License as published by
  12.  * the Free Software Foundation; either version 2 of the License, or
  13.  * (at your option) any later version.
  14.  *
  15.  * This program is distributed in the hope that it will be useful,
  16.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  18.  * GNU General Public License for more details.
  19.  *
  20.  * You should have received a copy of the GNU General Public License
  21.  * along with this program; if not, write to the Free Software
  22.  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  23.  *****************************************************************************/
  24. #ifdef HAVE_CONFIG_H
  25. # include "config.h"
  26. #endif
  27. #include <vlc_common.h>
  28. #include <vlc_aout.h>
  29. #include <vlc_vout.h>
  30. #include <vlc_playlist.h>
  31. #include <vlc_window.h>
  32. #include "vlcproc.hpp"
  33. #include "os_factory.hpp"
  34. #include "os_loop.hpp"
  35. #include "os_timer.hpp"
  36. #include "var_manager.hpp"
  37. #include "vout_manager.hpp"
  38. #include "theme.hpp"
  39. #include "window_manager.hpp"
  40. #include "../commands/async_queue.hpp"
  41. #include "../commands/cmd_change_skin.hpp"
  42. #include "../commands/cmd_show_window.hpp"
  43. #include "../commands/cmd_quit.hpp"
  44. #include "../commands/cmd_resize.hpp"
  45. #include "../commands/cmd_vars.hpp"
  46. #include "../commands/cmd_dialogs.hpp"
  47. #include "../commands/cmd_update_item.hpp"
  48. #include "../utils/var_bool.hpp"
  49. #include <sstream>
  50. VlcProc *VlcProc::instance( intf_thread_t *pIntf )
  51. {
  52.     if( pIntf->p_sys->p_vlcProc == NULL )
  53.     {
  54.         pIntf->p_sys->p_vlcProc = new VlcProc( pIntf );
  55.     }
  56.     return pIntf->p_sys->p_vlcProc;
  57. }
  58. void VlcProc::destroy( intf_thread_t *pIntf )
  59. {
  60.     if( pIntf->p_sys->p_vlcProc )
  61.     {
  62.         delete pIntf->p_sys->p_vlcProc;
  63.         pIntf->p_sys->p_vlcProc = NULL;
  64.     }
  65. }
  66. VlcProc::VlcProc( intf_thread_t *pIntf ): SkinObject( pIntf ),
  67.     m_varVoutSize( pIntf ), m_varEqBands( pIntf ),
  68.     m_pVout( NULL ), m_pAout( NULL ), m_cmdManage( this )
  69. {
  70.     // Create a timer to poll the status of the vlc
  71.     OSFactory *pOsFactory = OSFactory::instance( pIntf );
  72.     m_pTimer = pOsFactory->createOSTimer( m_cmdManage );
  73.     m_pTimer->start( 100, false );
  74.     // Create and register VLC variables
  75.     VarManager *pVarManager = VarManager::instance( getIntf() );
  76. #define REGISTER_VAR( var, type, name ) 
  77.     var = VariablePtr( new type( getIntf() ) ); 
  78.     pVarManager->registerVar( var, name );
  79.     REGISTER_VAR( m_cVarRandom, VarBoolImpl, "playlist.isRandom" )
  80.     REGISTER_VAR( m_cVarLoop, VarBoolImpl, "playlist.isLoop" )
  81.     REGISTER_VAR( m_cVarRepeat, VarBoolImpl, "playlist.isRepeat" )
  82.     REGISTER_VAR( m_cPlaytree, Playtree, "playtree" )
  83.     pVarManager->registerVar( getPlaytreeVar().getPositionVarPtr(),
  84.                               "playtree.slider" );
  85.     pVarManager->registerVar( m_cVarRandom, "playtree.isRandom" );
  86.     pVarManager->registerVar( m_cVarLoop, "playtree.isLoop" );
  87.     REGISTER_VAR( m_cVarPlaying, VarBoolImpl, "vlc.isPlaying" )
  88.     REGISTER_VAR( m_cVarStopped, VarBoolImpl, "vlc.isStopped" )
  89.     REGISTER_VAR( m_cVarPaused, VarBoolImpl, "vlc.isPaused" )
  90.     /* Input variables */
  91.     pVarManager->registerVar( m_cVarRepeat, "playtree.isRepeat" );
  92.     REGISTER_VAR( m_cVarTime, StreamTime, "time" )
  93.     REGISTER_VAR( m_cVarSeekable, VarBoolImpl, "vlc.isSeekable" )
  94.     REGISTER_VAR( m_cVarDvdActive, VarBoolImpl, "dvd.isActive" )
  95.     /* Vout variables */
  96.     REGISTER_VAR( m_cVarFullscreen, VarBoolImpl, "vlc.isFullscreen" )
  97.     REGISTER_VAR( m_cVarHasVout, VarBoolImpl, "vlc.hasVout" )
  98.     /* Aout variables */
  99.     REGISTER_VAR( m_cVarHasAudio, VarBoolImpl, "vlc.hasAudio" )
  100.     REGISTER_VAR( m_cVarVolume, Volume, "volume" )
  101.     REGISTER_VAR( m_cVarMute, VarBoolImpl, "vlc.isMute" )
  102.     REGISTER_VAR( m_cVarEqualizer, VarBoolImpl, "equalizer.isEnabled" )
  103.     REGISTER_VAR( m_cVarEqPreamp, EqualizerPreamp, "equalizer.preamp" )
  104. #undef REGISTER_VAR
  105.     m_cVarStreamName = VariablePtr( new VarText( getIntf(), false ) );
  106.     pVarManager->registerVar( m_cVarStreamName, "streamName" );
  107.     m_cVarStreamURI = VariablePtr( new VarText( getIntf(), false ) );
  108.     pVarManager->registerVar( m_cVarStreamURI, "streamURI" );
  109.     m_cVarStreamBitRate = VariablePtr( new VarText( getIntf(), false ) );
  110.     pVarManager->registerVar( m_cVarStreamBitRate, "bitrate" );
  111.     m_cVarStreamSampleRate = VariablePtr( new VarText( getIntf(), false ) );
  112.     pVarManager->registerVar( m_cVarStreamSampleRate, "samplerate" );
  113.     // Register the equalizer bands
  114.     for( int i = 0; i < EqualizerBands::kNbBands; i++)
  115.     {
  116.         stringstream ss;
  117.         ss << "equalizer.band(" << i << ")";
  118.         pVarManager->registerVar( m_varEqBands.getBand( i ), ss.str() );
  119.     }
  120.     // XXX WARNING XXX
  121.     // The object variable callbacks are called from other VLC threads,
  122.     // so they must put commands in the queue and NOT do anything else
  123.     // (X11 calls are not reentrant)
  124.     // Called when the playlist changes
  125.     var_AddCallback( pIntf->p_sys->p_playlist, "intf-change",
  126.                      onIntfChange, this );
  127.     // Called when a playlist item is added
  128.     var_AddCallback( pIntf->p_sys->p_playlist, "playlist-item-append",
  129.                      onItemAppend, this );
  130.     // Called when a playlist item is deleted
  131.     // TODO: properly handle item-deleted
  132.     var_AddCallback( pIntf->p_sys->p_playlist, "playlist-item-deleted",
  133.                      onItemDelete, this );
  134.     // Called when the "interface shower" wants us to show the skin
  135.     var_AddCallback( pIntf->p_libvlc, "intf-show",
  136.                      onIntfShow, this );
  137.     // Called when the current played item changes
  138.     var_AddCallback( pIntf->p_sys->p_playlist, "item-current",
  139.                      onPlaylistChange, this );
  140.     // Called when a playlist item changed
  141.     var_AddCallback( pIntf->p_sys->p_playlist, "item-change",
  142.                      onItemChange, this );
  143.     // Called when our skins2 demux wants us to load a new skin
  144.     var_AddCallback( pIntf, "skin-to-load", onSkinToLoad, this );
  145.     // Called when we have an interaction dialog to display
  146.     var_Create( pIntf, "interaction", VLC_VAR_ADDRESS );
  147.     var_AddCallback( pIntf, "interaction", onInteraction, this );
  148.     interaction_Register( pIntf );
  149.     getIntf()->p_sys->p_input = NULL;
  150. }
  151. VlcProc::~VlcProc()
  152. {
  153.     m_pTimer->stop();
  154.     delete( m_pTimer );
  155.     if( getIntf()->p_sys->p_input )
  156.     {
  157.         vlc_object_release( getIntf()->p_sys->p_input );
  158.         getIntf()->p_sys->p_input = NULL;
  159.     }
  160.     interaction_Unregister( getIntf() );
  161.     var_DelCallback( getIntf()->p_sys->p_playlist, "intf-change",
  162.                      onIntfChange, this );
  163.     var_DelCallback( getIntf()->p_sys->p_playlist, "playlist-item-append",
  164.                      onItemAppend, this );
  165.     var_DelCallback( getIntf()->p_sys->p_playlist, "playlist-item-deleted",
  166.                      onItemDelete, this );
  167.     var_DelCallback( getIntf()->p_libvlc, "intf-show",
  168.                      onIntfShow, this );
  169.     var_DelCallback( getIntf()->p_sys->p_playlist, "item-current",
  170.                      onPlaylistChange, this );
  171.     var_DelCallback( getIntf()->p_sys->p_playlist, "item-change",
  172.                      onItemChange, this );
  173.     var_DelCallback( getIntf(), "skin-to-load", onSkinToLoad, this );
  174.     var_DelCallback( getIntf(), "interaction", onInteraction, this );
  175. }
  176. void VlcProc::manage()
  177. {
  178. #ifdef WIN32
  179.     if( !vlc_object_alive( getIntf() ) &&
  180.         !getIntf()->p_sys->b_exitRequested )
  181.     {
  182.         getIntf()->p_sys->b_exitRequested = true;
  183.         // explicitly stop the playlist
  184.         playlist_Stop( getIntf()->p_sys->p_playlist );
  185.         if( !VoutManager::instance( getIntf() )->hasVout() )
  186.             getIntf()->p_sys->b_exitOK = true;
  187.     }
  188.     if( getIntf()->p_sys->b_exitOK )
  189.     {
  190.         // Get the instance of OSFactory
  191.         OSFactory *pOsFactory = OSFactory::instance( getIntf() );
  192.         // Exit the main OS loop
  193.         pOsFactory->getOSLoop()->exit();
  194.         return;
  195.     }
  196. #else
  197.     // Did the user request to quit vlc ?
  198.     if( !vlc_object_alive( getIntf() ) )
  199.     {
  200.         // Get the instance of OSFactory
  201.         OSFactory *pOsFactory = OSFactory::instance( getIntf() );
  202.         // Exit the main OS loop
  203.         pOsFactory->getOSLoop()->exit();
  204.         return;
  205.     }
  206. #endif
  207.     refreshPlaylist();
  208.     refreshAudio();
  209.     refreshInput();
  210. }
  211. void VlcProc::CmdManage::execute()
  212. {
  213.     // Just forward to VlcProc
  214.     m_pParent->manage();
  215. }
  216. void VlcProc::refreshAudio()
  217. {
  218.     char *pFilters;
  219.     // Check if the audio output has changed
  220.     aout_instance_t *pAout = (aout_instance_t *)vlc_object_find( getIntf(),
  221.             VLC_OBJECT_AOUT, FIND_ANYWHERE );
  222.     if( pAout )
  223.     {
  224.         if( pAout != m_pAout )
  225.         {
  226.             // Register the equalizer callbacks
  227.             if( !var_AddCallback( pAout, "equalizer-bands",
  228.                                   onEqBandsChange, this ) &&
  229.                 !var_AddCallback( pAout, "equalizer-preamp",
  230.                                   onEqPreampChange, this ) )
  231.             {
  232.                 m_pAout = pAout;
  233.                 //char * psz_bands = var_GetString( p_aout, "equalizer-bands" );
  234.             }
  235.         }
  236.         // Get the audio filters
  237.         pFilters = var_GetNonEmptyString( pAout, "audio-filter" );
  238.         vlc_object_release( pAout );
  239.     }
  240.     else
  241.     {
  242.         // Get the audio filters
  243.         pFilters = config_GetPsz( getIntf(), "audio-filter" );
  244.     }
  245.     // Refresh sound volume
  246.     audio_volume_t volume;
  247.     aout_VolumeGet( getIntf(), &volume );
  248.     Volume *pVolume = (Volume*)m_cVarVolume.get();
  249.     pVolume->set( (double)volume * 2.0 / AOUT_VOLUME_MAX );
  250.     // Set the mute variable
  251.     VarBoolImpl *pVarMute = (VarBoolImpl*)m_cVarMute.get();
  252.     pVarMute->set( volume == 0 );
  253.     // Refresh the equalizer variable
  254.     VarBoolImpl *pVarEqualizer = (VarBoolImpl*)m_cVarEqualizer.get();
  255.     pVarEqualizer->set( pFilters && strstr( pFilters, "equalizer" ) );
  256.     free( pFilters );
  257. }
  258. void VlcProc::refreshPlaylist()
  259. {
  260.     // Refresh the random variable
  261.     VarBoolImpl *pVarRandom = (VarBoolImpl*)m_cVarRandom.get();
  262.     vlc_value_t val;
  263.     var_Get( getIntf()->p_sys->p_playlist, "random", &val );
  264.     pVarRandom->set( val.b_bool != 0 );
  265.     // Refresh the loop variable
  266.     VarBoolImpl *pVarLoop = (VarBoolImpl*)m_cVarLoop.get();
  267.     var_Get( getIntf()->p_sys->p_playlist, "loop", &val );
  268.     pVarLoop->set( val.b_bool != 0 );
  269.     // Refresh the repeat variable
  270.     VarBoolImpl *pVarRepeat = (VarBoolImpl*)m_cVarRepeat.get();
  271.     var_Get( getIntf()->p_sys->p_playlist, "repeat", &val );
  272.     pVarRepeat->set( val.b_bool != 0 );
  273. }
  274. void VlcProc::refreshInput()
  275. {
  276.     StreamTime *pTime = (StreamTime*)m_cVarTime.get();
  277.     VarBoolImpl *pVarSeekable = (VarBoolImpl*)m_cVarSeekable.get();
  278.     VarBoolImpl *pVarDvdActive = (VarBoolImpl*)m_cVarDvdActive.get();
  279.     VarBoolImpl *pVarHasVout = (VarBoolImpl*)m_cVarHasVout.get();
  280.     VarBoolImpl *pVarHasAudio = (VarBoolImpl*)m_cVarHasAudio.get();
  281.     VarText *pBitrate = (VarText*)m_cVarStreamBitRate.get();
  282.     VarText *pSampleRate = (VarText*)m_cVarStreamSampleRate.get();
  283.     VarBoolImpl *pVarFullscreen = (VarBoolImpl*)m_cVarFullscreen.get();
  284.     VarBoolImpl *pVarPlaying = (VarBoolImpl*)m_cVarPlaying.get();
  285.     VarBoolImpl *pVarStopped = (VarBoolImpl*)m_cVarStopped.get();
  286.     VarBoolImpl *pVarPaused = (VarBoolImpl*)m_cVarPaused.get();
  287.     // Update the input
  288.     if( getIntf()->p_sys->p_input == NULL )
  289.     {
  290.         getIntf()->p_sys->p_input =
  291.             playlist_CurrentInput( getIntf()->p_sys->p_playlist );
  292.     }
  293.     else if( getIntf()->p_sys->p_input->b_dead )
  294.     {
  295.         vlc_object_release( getIntf()->p_sys->p_input );
  296.         getIntf()->p_sys->p_input = NULL;
  297.     }
  298.     input_thread_t *pInput = getIntf()->p_sys->p_input;
  299.     if( pInput && vlc_object_alive (pInput) )
  300.     {
  301.         // Refresh time variables
  302.         vlc_value_t pos;
  303.         var_Get( pInput, "position", &pos );
  304.         pTime->set( pos.f_float, false );
  305.         pVarSeekable->set( pos.f_float != 0.0 );
  306.         // Refresh DVD detection
  307.         vlc_value_t chapters_count;
  308.         var_Change( pInput, "chapter", VLC_VAR_CHOICESCOUNT,
  309.                         &chapters_count, NULL );
  310.         pVarDvdActive->set( chapters_count.i_int > 0 );
  311.         // Get the input bitrate
  312.         int bitrate = var_GetInteger( pInput, "bit-rate" ) / 1000;
  313.         pBitrate->set( UString::fromInt( getIntf(), bitrate ) );
  314.         // Get the audio sample rate
  315.         int sampleRate = var_GetInteger( pInput, "sample-rate" ) / 1000;
  316.         pSampleRate->set( UString::fromInt( getIntf(), sampleRate ) );
  317.         // Do we have audio
  318.         vlc_value_t audio_es;
  319.         var_Change( pInput, "audio-es", VLC_VAR_CHOICESCOUNT,
  320.                         &audio_es, NULL );
  321.         pVarHasAudio->set( audio_es.i_int > 0 );
  322.         // Refresh fullscreen status
  323.         vout_thread_t *pVout = input_GetVout( pInput );
  324.         pVarHasVout->set( pVout != NULL );
  325.         if( pVout )
  326.         {
  327.             pVarFullscreen->set( var_GetBool( pVout, "fullscreen" ) );
  328.             vlc_object_release( pVout );
  329.         }
  330.         // Refresh play/pause status
  331.         int state = var_GetInteger( pInput, "state" );
  332.         pVarStopped->set( false );
  333.         pVarPlaying->set( state != PAUSE_S );
  334.         pVarPaused->set( state == PAUSE_S );
  335.     }
  336.     else
  337.     {
  338.         pVarSeekable->set( false );
  339.         pVarDvdActive->set( false );
  340.         pTime->set( 0, false );
  341.         pVarFullscreen->set( false );
  342.         pVarHasAudio->set( false );
  343.         pVarHasVout->set( false );
  344.         pVarStopped->set( true );
  345.         pVarPlaying->set( false );
  346.         pVarPaused->set( false );
  347.     }
  348. }
  349. int VlcProc::onIntfChange( vlc_object_t *pObj, const char *pVariable,
  350.                            vlc_value_t oldVal, vlc_value_t newVal,
  351.                            void *pParam )
  352. {
  353.     VlcProc *pThis = (VlcProc*)pParam;
  354.     // Update the stream variable
  355.     pThis->updateStreamName();
  356.     // Create a playtree notify command (for new style playtree)
  357.     CmdPlaytreeChanged *pCmdTree = new CmdPlaytreeChanged( pThis->getIntf() );
  358.     // Push the command in the asynchronous command queue
  359.     AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
  360.     pQueue->push( CmdGenericPtr( pCmdTree ) );
  361.     return VLC_SUCCESS;
  362. }
  363. int VlcProc::onIntfShow( vlc_object_t *pObj, const char *pVariable,
  364.                          vlc_value_t oldVal, vlc_value_t newVal,
  365.                          void *pParam )
  366. {
  367.     if (newVal.b_bool)
  368.     {
  369.         VlcProc *pThis = (VlcProc*)pParam;
  370.         // Create a raise all command
  371.         CmdRaiseAll *pCmd = new CmdRaiseAll( pThis->getIntf(),
  372.             pThis->getIntf()->p_sys->p_theme->getWindowManager() );
  373.         // Push the command in the asynchronous command queue
  374.         AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
  375.         pQueue->push( CmdGenericPtr( pCmd ) );
  376.     }
  377.     return VLC_SUCCESS;
  378. }
  379. int VlcProc::onItemChange( vlc_object_t *pObj, const char *pVariable,
  380.                            vlc_value_t oldVal, vlc_value_t newVal,
  381.                            void *pParam )
  382. {
  383.     VlcProc *pThis = (VlcProc*)pParam;
  384.     // Update the stream variable
  385.     pThis->updateStreamName();
  386.     // Create a playtree notify command
  387.     CmdPlaytreeUpdate *pCmdTree = new CmdPlaytreeUpdate( pThis->getIntf(),
  388.                                                          newVal.i_int );
  389.     // Push the command in the asynchronous command queue
  390.     AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
  391.     pQueue->push( CmdGenericPtr( pCmdTree ), true );
  392.     return VLC_SUCCESS;
  393. }
  394. int VlcProc::onItemAppend( vlc_object_t *pObj, const char *pVariable,
  395.                            vlc_value_t oldVal, vlc_value_t newVal,
  396.                            void *pParam )
  397. {
  398.     VlcProc *pThis = (VlcProc*)pParam;
  399.     playlist_add_t *p_add = (playlist_add_t*)malloc( sizeof(
  400.                                                 playlist_add_t ) ) ;
  401.     memcpy( p_add, newVal.p_address, sizeof( playlist_add_t ) ) ;
  402.     CmdGenericPtr ptrTree;
  403.     CmdPlaytreeAppend *pCmdTree = new CmdPlaytreeAppend( pThis->getIntf(),
  404.                                                              p_add );
  405.     ptrTree = CmdGenericPtr( pCmdTree );
  406.     // Push the command in the asynchronous command queue
  407.     AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
  408.     pQueue->push( ptrTree , false );
  409.     return VLC_SUCCESS;
  410. }
  411. int VlcProc::onItemDelete( vlc_object_t *pObj, const char *pVariable,
  412.                            vlc_value_t oldVal, vlc_value_t newVal,
  413.                            void *pParam )
  414. {
  415.     VlcProc *pThis = (VlcProc*)pParam;
  416.     int i_id = newVal.i_int;
  417.     CmdGenericPtr ptrTree;
  418.     CmdPlaytreeDelete *pCmdTree = new CmdPlaytreeDelete( pThis->getIntf(),
  419.                                                          i_id);
  420.     ptrTree = CmdGenericPtr( pCmdTree );
  421.     // Push the command in the asynchronous command queue
  422.     AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
  423.     pQueue->push( ptrTree , false );
  424.     return VLC_SUCCESS;
  425. }
  426. int VlcProc::onPlaylistChange( vlc_object_t *pObj, const char *pVariable,
  427.                                vlc_value_t oldVal, vlc_value_t newVal,
  428.                                void *pParam )
  429. {
  430.     VlcProc *pThis = (VlcProc*)pParam;
  431.     AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
  432.     // Update the stream variable
  433.     pThis->updateStreamName();
  434.     // Create two playtree notify commands: one for old item, one for new
  435.     CmdPlaytreeUpdate *pCmdTree = new CmdPlaytreeUpdate( pThis->getIntf(),
  436.                                                          oldVal.i_int );
  437.     pQueue->push( CmdGenericPtr( pCmdTree ) , true );
  438.     pCmdTree = new CmdPlaytreeUpdate( pThis->getIntf(), newVal.i_int );
  439.     pQueue->push( CmdGenericPtr( pCmdTree ) , true );
  440.     return VLC_SUCCESS;
  441. }
  442. int VlcProc::onSkinToLoad( vlc_object_t *pObj, const char *pVariable,
  443.                            vlc_value_t oldVal, vlc_value_t newVal,
  444.                            void *pParam )
  445. {
  446.     VlcProc *pThis = (VlcProc*)pParam;
  447.     // Create a playlist notify command
  448.     CmdChangeSkin *pCmd =
  449.         new CmdChangeSkin( pThis->getIntf(), newVal.psz_string );
  450.     // Push the command in the asynchronous command queue
  451.     AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
  452.     pQueue->push( CmdGenericPtr( pCmd ) );
  453.     return VLC_SUCCESS;
  454. }
  455. int VlcProc::onInteraction( vlc_object_t *pObj, const char *pVariable,
  456.                             vlc_value_t oldVal, vlc_value_t newVal,
  457.                             void *pParam )
  458. {
  459.     VlcProc *pThis = (VlcProc*)pParam;
  460.     interaction_dialog_t *p_dialog = (interaction_dialog_t *)(newVal.p_address);
  461.     CmdInteraction *pCmd = new CmdInteraction( pThis->getIntf(), p_dialog );
  462.     AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
  463.     pQueue->push( CmdGenericPtr( pCmd ) );
  464.     return VLC_SUCCESS;
  465. }
  466. void VlcProc::updateStreamName()
  467. {
  468.     // Create a update item command
  469.     CmdUpdateItem *pCmdItem = new CmdUpdateItem( getIntf(), getStreamNameVar(), getStreamURIVar() );
  470.     // Push the command in the asynchronous command queue
  471.     AsyncQueue *pQueue = AsyncQueue::instance( getIntf() );
  472.     pQueue->push( CmdGenericPtr( pCmdItem ) );
  473. }
  474. int VlcProc::onEqBandsChange( vlc_object_t *pObj, const char *pVariable,
  475.                               vlc_value_t oldVal, vlc_value_t newVal,
  476.                               void *pParam )
  477. {
  478.     VlcProc *pThis = (VlcProc*)pParam;
  479.     // Post a set equalizer bands command
  480.     CmdSetEqBands *pCmd = new CmdSetEqBands( pThis->getIntf(),
  481.                                              pThis->m_varEqBands,
  482.                                              newVal.psz_string );
  483.     AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
  484.     pQueue->push( CmdGenericPtr( pCmd ) );
  485.     return VLC_SUCCESS;
  486. }
  487. int VlcProc::onEqPreampChange( vlc_object_t *pObj, const char *pVariable,
  488.                                vlc_value_t oldVal, vlc_value_t newVal,
  489.                                void *pParam )
  490. {
  491.     VlcProc *pThis = (VlcProc*)pParam;
  492.     EqualizerPreamp *pVarPreamp = (EqualizerPreamp*)(pThis->m_cVarEqPreamp.get());
  493.     // Post a set preamp command
  494.     CmdSetEqPreamp *pCmd = new CmdSetEqPreamp( pThis->getIntf(), *pVarPreamp,
  495.                                               (newVal.f_float + 20.0) / 40.0 );
  496.     AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
  497.     pQueue->push( CmdGenericPtr( pCmd ) );
  498.     return VLC_SUCCESS;
  499. }