vlcproc.cpp 19.7 KB
Newer Older
1 2 3
/*****************************************************************************
 * vlcproc.cpp
 *****************************************************************************
4
 * Copyright (C) 2003 the VideoLAN team
5
 * $Id$
6 7
 *
 * Authors: Cyril Deguet     <asmax@via.ecp.fr>
8
 *          Olivier Teuli�e <ipkiss@via.ecp.fr>
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
 *****************************************************************************/

#include <vlc/aout.h>
26
#include <vlc/vout.h>
27
#include <aout_internal.h>
28 29 30 31

#include "vlcproc.hpp"
#include "os_factory.hpp"
#include "os_timer.hpp"
Cyril Deguet's avatar
Cyril Deguet committed
32
#include "var_manager.hpp"
33 34
#include "theme.hpp"
#include "window_manager.hpp"
35
#include "../commands/async_queue.hpp"
36
#include "../commands/cmd_change_skin.hpp"
37
#include "../commands/cmd_show_window.hpp"
38
#include "../commands/cmd_quit.hpp"
39
#include "../commands/cmd_resize.hpp"
40
#include "../commands/cmd_vars.hpp"
41
#include "../utils/var_bool.hpp"
42
#include <sstream>
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65


VlcProc *VlcProc::instance( intf_thread_t *pIntf )
{
    if( pIntf->p_sys->p_vlcProc == NULL )
    {
        pIntf->p_sys->p_vlcProc = new VlcProc( pIntf );
    }

    return pIntf->p_sys->p_vlcProc;
}


void VlcProc::destroy( intf_thread_t *pIntf )
{
    if( pIntf->p_sys->p_vlcProc )
    {
        delete pIntf->p_sys->p_vlcProc;
        pIntf->p_sys->p_vlcProc = NULL;
    }
}


66
VlcProc::VlcProc( intf_thread_t *pIntf ): SkinObject( pIntf ),
67 68
    m_varVoutSize( pIntf ), m_varEqBands( pIntf ),
    m_pVout( NULL ), m_pAout( NULL ), m_cmdManage( this )
69 70 71
{
    // Create a timer to poll the status of the vlc
    OSFactory *pOsFactory = OSFactory::instance( pIntf );
72
    m_pTimer = pOsFactory->createOSTimer( m_cmdManage );
73 74
    m_pTimer->start( 100, false );

Cyril Deguet's avatar
Cyril Deguet committed
75 76
    // Create and register VLC variables
    VarManager *pVarManager = VarManager::instance( getIntf() );
77

78 79 80
#define REGISTER_VAR( var, type, name ) \
    var = VariablePtr( new type( getIntf() ) ); \
    pVarManager->registerVar( var, name );
Cyril Deguet's avatar
Cyril Deguet committed
81 82 83
    REGISTER_VAR( m_cPlaylist, Playlist, "playlist" )
    pVarManager->registerVar( getPlaylistVar().getPositionVarPtr(),
                              "playlist.slider" );
84
    REGISTER_VAR( m_cVarRandom, VarBoolImpl, "playlist.isRandom" )
85
    REGISTER_VAR( m_cVarLoop, VarBoolImpl, "playlist.isLoop" )
86
    REGISTER_VAR( m_cVarRepeat, VarBoolImpl, "playlist.isRepeat" )
87 88 89
    REGISTER_VAR( m_cPlaytree, Playtree, "playtree" )
    pVarManager->registerVar( getPlaytreeVar().getPositionVarPtr(),
                              "playtree.slider" );
90 91 92
    pVarManager->registerVar( m_cVarRandom, "playtree.isRandom" );
    pVarManager->registerVar( m_cVarLoop, "playtree.isLoop" );
    pVarManager->registerVar( m_cVarRepeat, "playtree.isRepeat" );
93
    REGISTER_VAR( m_cVarTime, StreamTime, "time" )
Cyril Deguet's avatar
Cyril Deguet committed
94
    REGISTER_VAR( m_cVarVolume, Volume, "volume" )
95
    REGISTER_VAR( m_cVarMute, VarBoolImpl, "vlc.isMute" )
96 97 98 99
    REGISTER_VAR( m_cVarPlaying, VarBoolImpl, "vlc.isPlaying" )
    REGISTER_VAR( m_cVarStopped, VarBoolImpl, "vlc.isStopped" )
    REGISTER_VAR( m_cVarPaused, VarBoolImpl, "vlc.isPaused" )
    REGISTER_VAR( m_cVarSeekable, VarBoolImpl, "vlc.isSeekable" )
100
    REGISTER_VAR( m_cVarEqualizer, VarBoolImpl, "equalizer.isEnabled" )
101
    REGISTER_VAR( m_cVarEqPreamp, EqualizerPreamp, "equalizer.preamp" )
102
#undef REGISTER_VAR
103 104 105 106
    m_cVarStreamName = VariablePtr( new VarText( getIntf(), false ) );
    pVarManager->registerVar( m_cVarStreamName, "streamName" );
    m_cVarStreamURI = VariablePtr( new VarText( getIntf(), false ) );
    pVarManager->registerVar( m_cVarStreamURI, "streamURI" );
Cyril Deguet's avatar
Cyril Deguet committed
107

108 109 110 111 112 113 114 115
    // Register the equalizer bands
    for( int i = 0; i < EqualizerBands::kNbBands; i++)
    {
        stringstream ss;
        ss << "equalizer.band(" << i << ")";
        pVarManager->registerVar( m_varEqBands.getBand( i ), ss.str() );
    }

116 117 118 119 120
    // XXX WARNING XXX
    // The object variable callbacks are called from other VLC threads,
    // so they must put commands in the queue and NOT do anything else
    // (X11 calls are not reentrant)

121
    // Called when the playlist changes
122
    var_AddCallback( pIntf->p_sys->p_playlist, "intf-change",
123
                     onIntfChange, this );
124 125
    // Called when a playlist item is added
    // TODO: properly handle item-append
Clément Stenac's avatar
Clément Stenac committed
126 127
    var_AddCallback( pIntf->p_sys->p_playlist, "item-append",
                     onIntfChange, this );
128 129 130 131
    // Called when a playlist item is deleted
    // TODO: properly handle item-deleted
    var_AddCallback( pIntf->p_sys->p_playlist, "item-deleted",
                     onIntfChange, this );
132 133 134
    // Called when the "interface shower" wants us to show the skin
    var_AddCallback( pIntf->p_sys->p_playlist, "intf-show",
                     onIntfShow, this );
135
    // Called when the current played item changes
136
    var_AddCallback( pIntf->p_sys->p_playlist, "playlist-current",
137
                     onPlaylistChange, this );
138 139
    // Called when a playlist item changed
    var_AddCallback( pIntf->p_sys->p_playlist, "item-change",
140
                     onItemChange, this );
141 142
    // Called when our skins2 demux wants us to load a new skin
    var_AddCallback( pIntf, "skin-to-load", onSkinToLoad, this );
143

144 145 146 147 148
    // Callbacks for vout requests
    getIntf()->pf_request_window = &getWindow;
    getIntf()->pf_release_window = &releaseWindow;
    getIntf()->pf_control_window = &controlWindow;

149 150 151 152 153 154 155 156 157 158 159 160
    getIntf()->p_sys->p_input = NULL;
}


VlcProc::~VlcProc()
{
    m_pTimer->stop();
    delete( m_pTimer );
    if( getIntf()->p_sys->p_input )
    {
        vlc_object_release( getIntf()->p_sys->p_input );
    }
161 162 163 164 165 166 167 168

    // Callbacks for vout requests
    getIntf()->pf_request_window = NULL;
    getIntf()->pf_release_window = NULL;
    getIntf()->pf_control_window = NULL;

    var_DelCallback( getIntf()->p_sys->p_playlist, "intf-change",
                     onIntfChange, this );
169
    var_DelCallback( getIntf()->p_sys->p_playlist, "item-append",
170
                     onIntfChange, this );
171
    var_DelCallback( getIntf()->p_sys->p_playlist, "item-deleted",
172
                     onIntfChange, this );
173 174
    var_DelCallback( getIntf()->p_sys->p_playlist, "intf-show",
                     onIntfShow, this );
175 176 177 178
    var_DelCallback( getIntf()->p_sys->p_playlist, "playlist-current",
                     onPlaylistChange, this );
    var_DelCallback( getIntf()->p_sys->p_playlist, "item-change",
                     onItemChange, this );
179
    var_DelCallback( getIntf(), "skin-to-load", onSkinToLoad, this );
180 181 182
}


183
void VlcProc::registerVoutWindow( void *pVoutWindow )
184
{
185
    m_handleSet.insert( pVoutWindow );
186 187 188 189 190 191 192 193 194
    // Reparent the vout window
    if( m_pVout )
    {
        if( vout_Control( m_pVout, VOUT_REPARENT ) != VLC_SUCCESS )
            vout_Control( m_pVout, VOUT_CLOSE );
    }
}


195 196 197 198 199 200
void VlcProc::unregisterVoutWindow( void *pVoutWindow )
{
    m_handleSet.erase( pVoutWindow );
}


201 202 203 204 205 206 207 208 209 210 211
void VlcProc::dropVout()
{
    if( m_pVout )
    {
        if( vout_Control( m_pVout, VOUT_REPARENT ) != VLC_SUCCESS )
            vout_Control( m_pVout, VOUT_CLOSE );
        m_pVout = NULL;
    }
}


212 213 214
void VlcProc::manage()
{
    // Did the user requested to quit vlc ?
215
    if( getIntf()->b_die || getIntf()->p_vlc->b_die )
216 217 218 219 220 221
    {
        CmdQuit *pCmd = new CmdQuit( getIntf() );
        AsyncQueue *pQueue = AsyncQueue::instance( getIntf() );
        pQueue->push( CmdGenericPtr( pCmd ) );
    }

Cyril Deguet's avatar
Cyril Deguet committed
222
    // Get the VLC variables
223
    StreamTime *pTime = (StreamTime*)m_cVarTime.get();
224 225 226 227
    VarBoolImpl *pVarPlaying = (VarBoolImpl*)m_cVarPlaying.get();
    VarBoolImpl *pVarStopped = (VarBoolImpl*)m_cVarStopped.get();
    VarBoolImpl *pVarPaused = (VarBoolImpl*)m_cVarPaused.get();
    VarBoolImpl *pVarSeekable = (VarBoolImpl*)m_cVarSeekable.get();
228
    VarBoolImpl *pVarRandom = (VarBoolImpl*)m_cVarRandom.get();
229
    VarBoolImpl *pVarLoop = (VarBoolImpl*)m_cVarLoop.get();
230
    VarBoolImpl *pVarRepeat = (VarBoolImpl*)m_cVarRepeat.get();
Cyril Deguet's avatar
Cyril Deguet committed
231

232 233
    // Refresh audio variables
    refreshAudio();
234

235
   // Update the input
236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251
    if( getIntf()->p_sys->p_input == NULL )
    {
        getIntf()->p_sys->p_input = (input_thread_t *)vlc_object_find(
            getIntf(), VLC_OBJECT_INPUT, FIND_ANYWHERE );
    }
    else if( getIntf()->p_sys->p_input->b_dead )
    {
        vlc_object_release( getIntf()->p_sys->p_input );
        getIntf()->p_sys->p_input = NULL;
    }

    input_thread_t *pInput = getIntf()->p_sys->p_input;

    if( pInput && !pInput->b_die )
    {
        // Refresh time variables
252 253 254
        vlc_value_t pos;
        var_Get( pInput, "position", &pos );
        pTime->set( pos.f_float, false );
255 256

        // Get the status of the playlist
257 258
        playlist_status_t status =
            getIntf()->p_sys->p_playlist->status.i_status;
259

260 261 262
        pVarPlaying->set( status == PLAYLIST_RUNNING );
        pVarStopped->set( status == PLAYLIST_STOPPED );
        pVarPaused->set( status == PLAYLIST_PAUSED );
263

264
        pVarSeekable->set( pos.f_float != 0.0 );
265 266 267
    }
    else
    {
268 269 270 271
        pVarPlaying->set( false );
        pVarPaused->set( false );
        pVarStopped->set( true );
        pVarSeekable->set( false );
Cyril Deguet's avatar
Cyril Deguet committed
272
        pTime->set( 0, false );
273
    }
274 275 276 277

    // Refresh the random variable
    vlc_value_t val;
    var_Get( getIntf()->p_sys->p_playlist, "random", &val );
278
    pVarRandom->set( val.b_bool != 0 );
279 280 281

    // Refresh the loop variable
    var_Get( getIntf()->p_sys->p_playlist, "loop", &val );
282
    pVarLoop->set( val.b_bool != 0 );
283 284 285

    // Refresh the repeat variable
    var_Get( getIntf()->p_sys->p_playlist, "repeat", &val );
286
    pVarRepeat->set( val.b_bool != 0 );
287 288 289
}


290
void VlcProc::CmdManage::execute()
291
{
292 293
    // Just forward to VlcProc
    m_pParent->manage();
294 295 296
}


297 298
void VlcProc::refreshAudio()
{
299 300
    char *pFilters = NULL;

301 302 303
    // Check if the audio output has changed
    aout_instance_t *pAout = (aout_instance_t *)vlc_object_find( getIntf(),
            VLC_OBJECT_AOUT, FIND_ANYWHERE );
304
    if( pAout )
305 306 307
    {
        if( pAout != m_pAout )
        {
308
            // Register the equalizer callbacks
309
            if( !var_AddCallback( pAout, "equalizer-bands",
310 311 312
                                  onEqBandsChange, this ) &&
                !var_AddCallback( pAout, "equalizer-preamp",
                                  onEqPreampChange, this ) )
313 314 315 316 317
            {
                m_pAout = pAout;
                //char * psz_bands = var_GetString( p_aout, "equalizer-bands" );
            }
        }
318 319
        // Get the audio filters
        pFilters = var_GetString( pAout, "audio-filter" );
320 321
        vlc_object_release( pAout );
    }
322 323 324 325 326
    else
    {
        // Get the audio filters
        pFilters = config_GetPsz( getIntf(), "audio-filter" );
    }
327 328 329 330 331 332 333 334 335 336

    // Refresh sound volume
    audio_volume_t volume;
    aout_VolumeGet( getIntf(), &volume );
    Volume *pVolume = (Volume*)m_cVarVolume.get();
    pVolume->set( (double)volume * 2.0 / AOUT_VOLUME_MAX );

    // Set the mute variable
    VarBoolImpl *pVarMute = (VarBoolImpl*)m_cVarMute.get();
    pVarMute->set( volume == 0 );
337 338 339 340

    // Refresh the equalizer variable
    VarBoolImpl *pVarEqualizer = (VarBoolImpl*)m_cVarEqualizer.get();
    pVarEqualizer->set( pFilters && strstr( pFilters, "equalizer" ) );
341 342 343
}


344 345 346 347
int VlcProc::onIntfChange( vlc_object_t *pObj, const char *pVariable,
                           vlc_value_t oldVal, vlc_value_t newVal,
                           void *pParam )
{
348
    VlcProc *pThis = (VlcProc*)pParam;
349

350 351 352 353
    // Update the stream variable
    playlist_t *p_playlist = (playlist_t*)pObj;
    pThis->updateStreamName(p_playlist);

354 355
    // Create a playlist notify command
    CmdNotifyPlaylist *pCmd = new CmdNotifyPlaylist( pThis->getIntf() );
356
    // Create a playtree notify command
357
    CmdPlaytreeChanged *pCmdTree = new CmdPlaytreeChanged( pThis->getIntf() );
358 359 360 361

    // Push the command in the asynchronous command queue
    AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
    pQueue->push( CmdGenericPtr( pCmd ) );
362
    pQueue->push( CmdGenericPtr( pCmdTree ) );
363 364 365 366 367

    return VLC_SUCCESS;
}


368 369 370 371 372 373 374 375 376
int VlcProc::onIntfShow( vlc_object_t *pObj, const char *pVariable,
                         vlc_value_t oldVal, vlc_value_t newVal,
                         void *pParam )
{
    if (newVal.i_int)
    {
        VlcProc *pThis = (VlcProc*)pParam;

        // Create a raise all command
377 378
        CmdRaiseAll *pCmd = new CmdRaiseAll( pThis->getIntf(),
            pThis->getIntf()->p_sys->p_theme->getWindowManager() );
379 380 381 382 383 384 385 386 387 388

        // Push the command in the asynchronous command queue
        AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
        pQueue->push( CmdGenericPtr( pCmd ) );
    }

    return VLC_SUCCESS;
}


389 390 391 392
int VlcProc::onItemChange( vlc_object_t *pObj, const char *pVariable,
                           vlc_value_t oldVal, vlc_value_t newVal,
                           void *pParam )
{
393
    VlcProc *pThis = (VlcProc*)pParam;
394

395 396 397 398
    // Update the stream variable
    playlist_t *p_playlist = (playlist_t*)pObj;
    pThis->updateStreamName(p_playlist);

399 400 401
    // Create a playlist notify command
    // TODO: selective update
    CmdNotifyPlaylist *pCmd = new CmdNotifyPlaylist( pThis->getIntf() );
402
    // Create a playtree notify command
403 404
    CmdPlaytreeUpdate *pCmdTree = new CmdPlaytreeUpdate( pThis->getIntf(),
                                                         newVal.i_int );
405 406 407 408

    // Push the command in the asynchronous command queue
    AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
    pQueue->push( CmdGenericPtr( pCmd ) );
409
    pQueue->push( CmdGenericPtr( pCmdTree ), false );
410

411 412 413 414
    return VLC_SUCCESS;
}


415 416 417 418
int VlcProc::onPlaylistChange( vlc_object_t *pObj, const char *pVariable,
                               vlc_value_t oldVal, vlc_value_t newVal,
                               void *pParam )
{
419
    VlcProc *pThis = (VlcProc*)pParam;
420

421 422
    AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );

423
    // Update the stream variable
424
    playlist_t *p_playlist = (playlist_t*)pObj;
425
    pThis->updateStreamName(p_playlist);
426

427
    // Create a playlist notify command
428
    // TODO: selective update
429
    CmdNotifyPlaylist *pCmd = new CmdNotifyPlaylist( pThis->getIntf() );
430
    // Create a playtree notify command
431
    CmdPlaytreeChanged *pCmdTree = new CmdPlaytreeChanged( pThis->getIntf() );
432 433 434

    // Push the command in the asynchronous command queue
    pQueue->push( CmdGenericPtr( pCmd ) );
435
    pQueue->push( CmdGenericPtr( pCmdTree ) );
436

437 438 439
    return VLC_SUCCESS;
}

440

441 442 443 444
int VlcProc::onSkinToLoad( vlc_object_t *pObj, const char *pVariable,
                           vlc_value_t oldVal, vlc_value_t newVal,
                           void *pParam )
{
445
    VlcProc *pThis = (VlcProc*)pParam;
446 447 448 449 450 451 452 453 454 455 456 457 458

    // Create a playlist notify command
    CmdChangeSkin *pCmd =
        new CmdChangeSkin( pThis->getIntf(), newVal.psz_string );

    // Push the command in the asynchronous command queue
    AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
    pQueue->push( CmdGenericPtr( pCmd ) );

    return VLC_SUCCESS;
}


459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484
void VlcProc::updateStreamName( playlist_t *p_playlist )
{
    if( p_playlist->p_input )
    {
        VarText &rStreamName = getStreamNameVar();
        VarText &rStreamURI = getStreamURIVar();
        // XXX: we should not need to access p_input->psz_source directly, a
        // getter should be provided by VLC core
        string name = p_playlist->p_input->input.p_item->psz_name;
        // XXX: This should be done in VLC core, not here...
        // Remove path information if any
        OSFactory *pFactory = OSFactory::instance( getIntf() );
        string::size_type pos = name.rfind( pFactory->getDirSeparator() );
        if( pos != string::npos )
        {
            name = name.substr( pos + 1, name.size() - pos + 1 );
        }
        UString srcName( getIntf(), name.c_str() );
        UString srcURI( getIntf(),
                         p_playlist->p_input->input.p_item->psz_uri );

        // Create commands to update the stream variables
        CmdSetText *pCmd1 = new CmdSetText( getIntf(), rStreamName, srcName );
        CmdSetText *pCmd2 = new CmdSetText( getIntf(), rStreamURI, srcURI );
        // Push the commands in the asynchronous command queue
        AsyncQueue *pQueue = AsyncQueue::instance( getIntf() );
485 486
        pQueue->push( CmdGenericPtr( pCmd1 ), false );
        pQueue->push( CmdGenericPtr( pCmd2 ), false );
487 488 489 490
    }
}


491 492 493 494 495 496 497
void *VlcProc::getWindow( intf_thread_t *pIntf, vout_thread_t *pVout,
                          int *pXHint, int *pYHint,
                          unsigned int *pWidthHint,
                          unsigned int *pHeightHint )
{
    VlcProc *pThis = pIntf->p_sys->p_vlcProc;
    pThis->m_pVout = pVout;
498 499 500 501 502 503
    if( pThis->m_handleSet.empty() )
    {
        return NULL;
    }
    else
    {
504 505 506 507 508 509 510 511
        // Get the window handle
        void *pWindow = *pThis->m_handleSet.begin();
        // Post a resize vout command
        CmdResizeVout *pCmd = new CmdResizeVout( pThis->getIntf(), pWindow,
                                                 *pWidthHint, *pHeightHint );
        AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
        pQueue->push( CmdGenericPtr( pCmd ) );
        return pWindow;
512
    }
513 514 515 516 517 518 519 520 521 522 523 524 525
}


void VlcProc::releaseWindow( intf_thread_t *pIntf, void *pWindow )
{
    VlcProc *pThis = pIntf->p_sys->p_vlcProc;
    pThis->m_pVout = NULL;
}


int VlcProc::controlWindow( intf_thread_t *pIntf, void *pWindow,
                            int query, va_list args )
{
526 527 528 529
    VlcProc *pThis = pIntf->p_sys->p_vlcProc;

    switch( query )
    {
530
        case VOUT_SET_SIZE:
531 532 533
        {
            if( pThis->m_pVout )
            {
534 535 536 537 538
                unsigned int i_width  = va_arg( args, unsigned int );
                unsigned int i_height = va_arg( args, unsigned int );
                if( !i_width ) i_width = pThis->m_pVout->i_window_width;
                if( !i_height ) i_height = pThis->m_pVout->i_window_height;

539 540 541
                // Post a resize vout command
                CmdResizeVout *pCmd =
                    new CmdResizeVout( pThis->getIntf(), pWindow,
542
                                       i_width, i_height );
543 544 545 546 547 548 549 550 551 552
                AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
                pQueue->push( CmdGenericPtr( pCmd ) );
            }
        }

        default:
            msg_Dbg( pIntf, "control query not supported" );
            break;
    }

553 554 555
    return VLC_SUCCESS;
}

556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572

int VlcProc::onEqBandsChange( vlc_object_t *pObj, const char *pVariable,
                              vlc_value_t oldVal, vlc_value_t newVal,
                              void *pParam )
{
    VlcProc *pThis = (VlcProc*)pParam;

    // Post a set equalizer bands command
    CmdSetEqBands *pCmd = new CmdSetEqBands( pThis->getIntf(),
                                             pThis->m_varEqBands,
                                             newVal.psz_string );
    AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
    pQueue->push( CmdGenericPtr( pCmd ) );

    return VLC_SUCCESS;
}

573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589

int VlcProc::onEqPreampChange( vlc_object_t *pObj, const char *pVariable,
                               vlc_value_t oldVal, vlc_value_t newVal,
                               void *pParam )
{
    VlcProc *pThis = (VlcProc*)pParam;
    EqualizerPreamp *pVarPreamp = (EqualizerPreamp*)(pThis->m_cVarEqPreamp.get());

    // Post a set preamp command
    CmdSetEqPreamp *pCmd = new CmdSetEqPreamp( pThis->getIntf(), *pVarPreamp,
                                              (newVal.f_float + 20.0) / 40.0 );
    AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
    pQueue->push( CmdGenericPtr( pCmd ) );

    return VLC_SUCCESS;
}