~ubuntu-branches/ubuntu/natty/vlc/natty

« back to all changes in this revision

Viewing changes to modules/gui/skins2/commands/async_queue.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Benjamin Drung
  • Date: 2010-06-25 01:09:16 UTC
  • mfrom: (1.1.30 upstream)
  • Revision ID: james.westby@ubuntu.com-20100625010916-asxhep2mutg6g6pd
Tags: 1.1.0-1ubuntu1
* Merge from Debian unstable, remaining changes:
  - build and install the libx264 plugin
  - add Xb-Npp header to vlc package
  - Add apport hook to include more vlc dependencies in bug reports
* Drop xulrunner patches.
* Drop 502_xulrunner_191.diff.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 * async_queue.cpp
3
3
 *****************************************************************************
4
4
 * Copyright (C) 2003 the VideoLAN team
5
 
 * $Id: de19dc7b3710fbb4921a1a8bd0cefac36021e98b $
 
5
 * $Id: 759ff6a6e5d37fa65d3ee7b67145aa3b6eb8f616 $
6
6
 *
7
7
 * Authors: Cyril Deguet     <asmax@via.ecp.fr>
8
8
 *          Olivier Teulière <ipkiss@via.ecp.fr>
67
67
 
68
68
void AsyncQueue::destroy( intf_thread_t *pIntf )
69
69
{
70
 
    if( pIntf->p_sys->p_queue )
71
 
    {
72
 
        delete pIntf->p_sys->p_queue;
73
 
        pIntf->p_sys->p_queue = NULL;
74
 
    }
 
70
    delete pIntf->p_sys->p_queue;
 
71
    pIntf->p_sys->p_queue = NULL;
75
72
}
76
73
 
77
74
 
78
75
void AsyncQueue::push( const CmdGenericPtr &rcCommand, bool removePrev )
79
76
{
 
77
    vlc_mutex_lock( &m_lock );
 
78
 
80
79
    if( removePrev )
81
80
    {
82
81
        // Remove the commands of the same type
83
82
        remove( rcCommand.get()->getType(), rcCommand );
84
83
    }
85
84
    m_cmdList.push_back( rcCommand );
 
85
 
 
86
    vlc_mutex_unlock( &m_lock );
86
87
}
87
88
 
88
89
 
89
90
void AsyncQueue::remove( const string &rType, const CmdGenericPtr &rcCommand )
90
91
{
91
 
    vlc_mutex_lock( &m_lock );
92
 
 
93
 
    list<CmdGenericPtr>::iterator it;
94
 
    for( it = m_cmdList.begin(); it != m_cmdList.end(); it++ )
 
92
    cmdList_t::iterator it;
 
93
    for( it = m_cmdList.begin(); it != m_cmdList.end(); /* nothing */ )
95
94
    {
96
 
        // Remove the command if it is of the given type
97
 
        if( (*it).get()->getType() == rType )
 
95
        // Remove the command if it is of the given type and the command
 
96
        // doesn't disagree. Note trickery to avoid skipping entries
 
97
        // while maintaining iterator validity.
 
98
 
 
99
        if( (*it).get()->getType() == rType &&
 
100
            rcCommand.get()->checkRemove( (*it).get() ) )
98
101
        {
99
 
            // Maybe the command wants to check if it must really be
100
 
            // removed
101
 
            if( rcCommand.get()->checkRemove( (*it).get() ) == true )
102
 
            {
103
 
                list<CmdGenericPtr>::iterator itNew = it;
104
 
                itNew++;
105
 
                m_cmdList.erase( it );
106
 
                it = itNew;
107
 
            }
 
102
            cmdList_t::iterator itNew = it;
 
103
            ++itNew;
 
104
            m_cmdList.erase( it );
 
105
            it = itNew;
108
106
        }
 
107
        else ++it;
109
108
    }
110
 
 
111
 
    vlc_mutex_unlock( &m_lock );
112
109
}
113
110
 
114
111