device.h

Go to the documentation of this file.
00001 #ifndef DEVICE_H
00002 #define DEVICE_H
00003 
00004 
00005 #include <queue>
00006 #include "audiere.h"
00007 #include "threads.h"
00008 
00009 
00010 namespace audiere {
00011   
00013   class StopEventImpl : public RefImplementation<StopEvent> {
00014   public:
00015     StopEventImpl(OutputStream* os, Reason reason) {
00016       m_stream = os;
00017       m_reason = reason;
00018     }
00019 
00020     OutputStream* ADR_CALL getOutputStream() {
00021       return m_stream.get();
00022     }
00023 
00024     Reason ADR_CALL getReason() {
00025       return m_reason;
00026     }
00027 
00028   private:
00029     OutputStreamPtr m_stream;
00030     Reason m_reason;
00031   };
00032 
00033 
00035   class AbstractDevice : public RefImplementation<AudioDevice> {
00036   protected:
00037     AbstractDevice();
00038     ~AbstractDevice();
00039 
00040   public:
00041     void ADR_CALL registerCallback(Callback* callback);
00042     void ADR_CALL unregisterCallback(Callback* callback);
00043     void ADR_CALL clearCallbacks();
00044 
00045   protected:
00046     void fireStopEvent(OutputStream* stream, StopEvent::Reason reason);
00047     void fireStopEvent(const StopEventPtr& event);
00048 
00049   private:
00050     static void eventThread(void* arg);
00051     void eventThread();
00052     void processEvent(Event* event);
00053 
00054     volatile bool m_thread_exists;
00055     volatile bool m_thread_should_die;
00056 
00057     Mutex m_event_mutex;
00058     CondVar m_events_available;
00059     typedef std::queue<EventPtr> EventQueue;
00060     EventQueue m_events;
00061 
00062     std::vector<CallbackPtr> m_callbacks;
00063   };
00064 
00065 }
00066 
00067 
00068 #endif

Generated on Mon Feb 13 23:07:46 2006 for audiere by  doxygen 1.4.6