00001 /*********************************************************************** 00002 00003 FinalMix: DeviceOSS.h 00004 by Martin Decky 00005 00006 Redistribution of this file is permitted under the GNU Public License. 00007 00008 0.9.2 Initial 00009 0.9.4 Complete rewrite, native pthreads instead of wxThread 00010 0.9.5 Documentation 00011 00012 **********************************************************************/ 00013 00014 00015 #include "Devices.h" 00016 #include <wx/wx.h> 00017 #include <wx/string.h> 00018 00019 00020 #if defined(__WXGTK__) || defined(__WXMOTIF__) 00021 00022 00023 #ifndef _FM_DEVICEOSS_H_ 00024 #define _FM_DEVICEOSS_H_ 00025 00026 00027 #include <pthread.h> 00028 #include <semaphore.h> 00029 00030 00040 class OSSDevice : public Device { 00041 public: 00042 OSSDevice(); 00043 virtual ~OSSDevice(); 00045 virtual const wxString & Name() const; 00047 static Device * RegisterDevice(); 00049 virtual bool Init(const format_ex_t & fmt, DeviceCallback & callback); 00050 virtual void Play(); 00051 virtual void Pause(); 00052 virtual void Done(); 00054 virtual samples_t GetPosition(); 00056 virtual void Configure(wxWindow * parent); 00058 friend void * play_thread(void * data); 00059 friend void * push_thread(void * data); 00060 private: 00061 void done(); 00063 DeviceCallback * cb; 00064 format_ex_t pfmt; 00066 pthread_t play; 00067 pthread_t push; 00069 wxString pdev_name; 00070 int pdev; 00071 bool opened; 00072 bool playing; 00073 int initstate; 00074 00075 sem_t play_sem; 00076 sem_t push_sem; 00078 pthread_mutex_t buf_mutex; 00079 size_t buf_count; 00080 size_t buf_len; 00081 size_t buf_start; 00082 size_t buf_size; 00083 size_t latency; 00084 void * buf; 00085 samples_t position; 00086 samples_t rpos; 00087 int oldpos; 00088 }; 00089 00090 #endif 00091 00092 #endif