Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

IEEE1394Writer Class Reference

#include <ieee1394io.h>

List of all members.

Public Member Functions

 IEEE1394Writer ()
virtual ~IEEE1394Writer ()
void StartThread ()
void StopThread ()
int WaitForAction (bool isBlocking, int seconds=1)
void TriggerAction ()
virtual bool SendFrame (Frame &frame, bool isBlocking=true)=0
virtual bool isValid ()=0
virtual void * Thread ()=0

Protected Attributes

bool m_isInitialised
unsigned int m_channel
unsigned int m_nBuffers
deque< Frame * > m_deque
pthread_t m_thread
pthread_mutex_t m_dequeMutex
 this mutex protects capture related variables that could possibly accessed from two threads at the same time
pthread_mutex_t m_conditionMutex
 This condition and mutex are used to indicate when new frames are received.
pthread_cond_t m_condition
bool m_isRunning
 A state variable for starting and stopping thread.

Static Private Member Functions

static void * ThreadProxy (void *arg)


Constructor & Destructor Documentation

IEEE1394Writer::IEEE1394Writer  ) 
 

Definition at line 1210 of file ieee1394io.cc.

References m_condition, m_conditionMutex, and m_dequeMutex.

01210                                :
01211         m_isInitialised( false ), m_isRunning( false )
01212 {
01213     pthread_mutex_init( &m_dequeMutex, NULL );
01214     pthread_mutex_init( &m_conditionMutex, NULL );
01215     pthread_cond_init( &m_condition, NULL );
01216 }

IEEE1394Writer::~IEEE1394Writer  )  [virtual]
 

Definition at line 1218 of file ieee1394io.cc.

References GetFramePool(), m_condition, m_conditionMutex, m_deque, and m_dequeMutex.

01219 {
01220     for ( int i = m_deque.size(); i > 0; --i )
01221     {
01222         Frame* frame = m_deque[ 0 ];
01223         m_deque.pop_front();
01224         GetFramePool()->DoneWithFrame( frame );
01225     }
01226     pthread_mutex_destroy( &m_conditionMutex );
01227     pthread_cond_destroy( &m_condition );
01228     pthread_mutex_destroy( &m_dequeMutex );
01229 }


Member Function Documentation

virtual bool IEEE1394Writer::isValid  )  [pure virtual]
 

Referenced by Export1394::start().

virtual bool IEEE1394Writer::SendFrame Frame frame,
bool  isBlocking = true
[pure virtual]
 

Referenced by readThread(), PageTrim::showFrame(), and PageEditor::showFrame().

void IEEE1394Writer::StartThread  ) 
 

Definition at line 1231 of file ieee1394io.cc.

References m_isRunning, m_thread, and ThreadProxy().

01232 {
01233     if ( m_isRunning )
01234         return;
01235     pthread_create( &m_thread, NULL, ThreadProxy, this );
01236 }

void IEEE1394Writer::StopThread  ) 
 

Definition at line 1238 of file ieee1394io.cc.

References m_isRunning, and m_thread.

01239 {
01240     if ( m_isRunning )
01241     {
01242         m_isRunning = false;
01243         pthread_join( m_thread, NULL );
01244     }
01245 }

virtual void* IEEE1394Writer::Thread  )  [pure virtual]
 

void * IEEE1394Writer::ThreadProxy void *  arg  )  [static, private]
 

Definition at line 1301 of file ieee1394io.cc.

Referenced by StartThread().

01302 {
01303     IEEE1394Writer* self = static_cast< IEEE1394Writer* >( arg );
01304     return self->Thread();
01305 }

void IEEE1394Writer::TriggerAction  ) 
 

Definition at line 1294 of file ieee1394io.cc.

References m_condition, and m_conditionMutex.

01295 {
01296     pthread_mutex_lock( &m_conditionMutex );
01297     pthread_cond_signal( &m_condition );
01298     pthread_mutex_unlock( &m_conditionMutex );
01299 }

int IEEE1394Writer::WaitForAction bool  isBlocking,
int  seconds = 1
 

Definition at line 1247 of file ieee1394io.cc.

References m_condition, m_conditionMutex, m_deque, m_dequeMutex, and m_nBuffers.

01248 {
01249     pthread_mutex_lock( &m_dequeMutex );
01250     int size = m_deque.size( );
01251     pthread_mutex_unlock( &m_dequeMutex );
01252 
01253     if ( ( unsigned int )size >= m_nBuffers )
01254     {
01255         if ( isBlocking )
01256         {
01257             pthread_mutex_lock( &m_conditionMutex );
01258             if ( seconds == 0 )
01259             {
01260                 pthread_cond_wait( &m_condition, &m_conditionMutex );
01261                 pthread_mutex_unlock( &m_conditionMutex );
01262                 pthread_mutex_lock( &m_dequeMutex );
01263                 size = m_deque.size( );
01264             }
01265             else
01266             {
01267                 struct timeval tp;
01268                 struct timespec ts;
01269                 int result;
01270     
01271                 gettimeofday( &tp, NULL );
01272                 ts.tv_sec = tp.tv_sec + seconds;
01273                 ts.tv_nsec = tp.tv_usec * 1000;
01274     
01275                 result = pthread_cond_timedwait( &m_condition, &m_conditionMutex, &ts );
01276                 pthread_mutex_unlock( &m_conditionMutex );
01277                 pthread_mutex_lock( &m_dequeMutex );
01278     
01279                 size = m_deque.size();
01280                 if ( ( unsigned int )size >= m_nBuffers )
01281                     size = -size;
01282             }
01283             pthread_mutex_unlock( &m_dequeMutex );
01284         }
01285         else
01286         {
01287             size = -size;
01288         }
01289     }
01290 
01291     return size;
01292 }


Member Data Documentation

unsigned int IEEE1394Writer::m_channel [protected]
 

Definition at line 223 of file ieee1394io.h.

pthread_cond_t IEEE1394Writer::m_condition [protected]
 

Definition at line 235 of file ieee1394io.h.

Referenced by IEEE1394Writer(), TriggerAction(), WaitForAction(), and ~IEEE1394Writer().

pthread_mutex_t IEEE1394Writer::m_conditionMutex [protected]
 

This condition and mutex are used to indicate when new frames are received.

Definition at line 234 of file ieee1394io.h.

Referenced by IEEE1394Writer(), TriggerAction(), WaitForAction(), and ~IEEE1394Writer().

deque< Frame* > IEEE1394Writer::m_deque [protected]
 

Definition at line 225 of file ieee1394io.h.

Referenced by WaitForAction(), and ~IEEE1394Writer().

pthread_mutex_t IEEE1394Writer::m_dequeMutex [protected]
 

this mutex protects capture related variables that could possibly accessed from two threads at the same time

Definition at line 230 of file ieee1394io.h.

Referenced by IEEE1394Writer(), WaitForAction(), and ~IEEE1394Writer().

bool IEEE1394Writer::m_isInitialised [protected]
 

Definition at line 222 of file ieee1394io.h.

bool IEEE1394Writer::m_isRunning [protected]
 

A state variable for starting and stopping thread.

Definition at line 238 of file ieee1394io.h.

Referenced by StartThread(), and StopThread().

unsigned int IEEE1394Writer::m_nBuffers [protected]
 

Definition at line 224 of file ieee1394io.h.

Referenced by WaitForAction().

pthread_t IEEE1394Writer::m_thread [protected]
 

Definition at line 226 of file ieee1394io.h.

Referenced by StartThread(), and StopThread().


The documentation for this class was generated from the following files:
Generated on Sun Mar 11 22:13:00 2007 for Kino by  doxygen 1.4.2