Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

SoundPlayThread.h

Go to the documentation of this file.
00001 //-*-c++-*-
00002 #ifndef INCLUDED_SoundPlayThread_h_
00003 #define INCLUDED_SoundPlayThread_h_
00004 
00005 #include "IPC/CallbackThread.h"
00006 
00007 #ifdef __linux__
00008 #include <alsa/asoundlib.h>
00009 #endif
00010 
00011 class SoundPlayThread {
00012 public:
00013   SoundPlayThread() : initSuccess(false),
00014 #ifdef __APPLE__
00015     context(NULL)
00016 #else
00017     poller(&SoundPlayThread::poll,*this,TimeET(0L),TimeET(10L),true,CallbackPollThread::STOP_FALSE),
00018                       /*                      buf(NULL), bufsize(0), buffersInFlight(0),*/
00019                       lock(), pcm_handle(NULL), buffer_size(0), period_size(0), frame_size(0), buf(NULL)
00020 #endif
00021   {
00022     openSystem();
00023   }
00024   virtual ~SoundPlayThread() {
00025     if(initSuccess)
00026       closeSystem();
00027   }
00028   
00029   void reset();
00030   
00031 protected:
00032   void openSystem();
00033   void closeSystem();
00034   
00035   bool initSuccess;
00036   
00037 #ifdef __APPLE__
00038   struct SoundPlayContext * context;
00039 #else
00040   virtual bool poll();
00041   CallbackPollThread poller;
00042   /*
00043   static const long BUFFER_TIME=32;
00044   static const unsigned int NUM_BUFFERS=2;
00045   char * buf;
00046   size_t bufsize;
00047   unsigned int buffersInFlight;
00048   */
00049 
00050   Thread::Lock lock;
00051 
00052   snd_pcm_t * pcm_handle;
00053 
00054   snd_pcm_uframes_t buffer_size;
00055   snd_pcm_uframes_t period_size;
00056   unsigned int frame_size;
00057 
00058   char * buf;
00059 
00060 #endif
00061   
00062 private:
00063   SoundPlayThread(const SoundPlayThread& l); //!< don't call
00064   SoundPlayThread& operator=(const SoundPlayThread& l); //!< don't call
00065 };
00066 
00067 /*! @file
00068  * @brief 
00069  * @author Ethan Tira-Thompson (ejt) (Creator)
00070  */
00071 
00072 #endif

Tekkotsu Hardware Abstraction Layer 5.1CVS
Generated Mon May 9 05:01:39 2016 by Doxygen 1.6.3