3
3
*****************************************************************************
4
4
* Copyright (C) 2003 the VideoLAN team
5
* $Id: de19dc7b3710fbb4921a1a8bd0cefac36021e98b $
5
* $Id: 759ff6a6e5d37fa65d3ee7b67145aa3b6eb8f616 $
7
7
* Authors: Cyril Deguet <asmax@via.ecp.fr>
8
8
* Olivier Teulière <ipkiss@via.ecp.fr>
68
68
void AsyncQueue::destroy( intf_thread_t *pIntf )
70
if( pIntf->p_sys->p_queue )
72
delete pIntf->p_sys->p_queue;
73
pIntf->p_sys->p_queue = NULL;
70
delete pIntf->p_sys->p_queue;
71
pIntf->p_sys->p_queue = NULL;
78
75
void AsyncQueue::push( const CmdGenericPtr &rcCommand, bool removePrev )
77
vlc_mutex_lock( &m_lock );
82
81
// Remove the commands of the same type
83
82
remove( rcCommand.get()->getType(), rcCommand );
85
84
m_cmdList.push_back( rcCommand );
86
vlc_mutex_unlock( &m_lock );
89
90
void AsyncQueue::remove( const string &rType, const CmdGenericPtr &rcCommand )
91
vlc_mutex_lock( &m_lock );
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 */ )
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.
99
if( (*it).get()->getType() == rType &&
100
rcCommand.get()->checkRemove( (*it).get() ) )
99
// Maybe the command wants to check if it must really be
101
if( rcCommand.get()->checkRemove( (*it).get() ) == true )
103
list<CmdGenericPtr>::iterator itNew = it;
105
m_cmdList.erase( it );
102
cmdList_t::iterator itNew = it;
104
m_cmdList.erase( it );
111
vlc_mutex_unlock( &m_lock );