|
Blender
V2.59
|
00001 /* 00002 * $Id: AUD_JackDevice.h 35141 2011-02-25 10:21:56Z jesterking $ 00003 * 00004 * ***** BEGIN GPL LICENSE BLOCK ***** 00005 * 00006 * Copyright 2009-2011 Jörg Hermann Müller 00007 * 00008 * This file is part of AudaSpace. 00009 * 00010 * Audaspace is free software; you can redistribute it and/or modify 00011 * it under the terms of the GNU General Public License as published by 00012 * the Free Software Foundation; either version 2 of the License, or 00013 * (at your option) any later version. 00014 * 00015 * AudaSpace is distributed in the hope that it will be useful, 00016 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00018 * GNU General Public License for more details. 00019 * 00020 * You should have received a copy of the GNU General Public License 00021 * along with Audaspace; if not, write to the Free Software Foundation, 00022 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00023 * 00024 * ***** END GPL LICENSE BLOCK ***** 00025 */ 00026 00032 #ifndef AUD_JACKDEVICE 00033 #define AUD_JACKDEVICE 00034 00035 00036 #include "AUD_SoftwareDevice.h" 00037 #include "AUD_Buffer.h" 00038 00039 #include <string> 00040 00041 #include <jack.h> 00042 #include <ringbuffer.h> 00043 00044 typedef void (*AUD_syncFunction)(void*, int, float); 00045 00049 class AUD_JackDevice : public AUD_SoftwareDevice 00050 { 00051 private: 00055 jack_port_t** m_ports; 00056 00060 jack_client_t* m_client; 00061 00065 AUD_Buffer m_buffer; 00066 00070 AUD_Buffer m_deinterleavebuf; 00071 00072 jack_ringbuffer_t** m_ringbuffers; 00073 00077 bool m_valid; 00078 00083 static void jack_shutdown(void *data); 00084 00091 static int jack_mix(jack_nframes_t length, void *data); 00092 00093 static int jack_sync(jack_transport_state_t state, jack_position_t* pos, void* data); 00094 00098 jack_transport_state_t m_nextState; 00099 00103 jack_transport_state_t m_state; 00104 00108 int m_sync; 00109 00113 AUD_syncFunction m_syncFunc; 00114 00118 void* m_syncFuncData; 00119 00123 pthread_t m_mixingThread; 00124 00125 pthread_mutex_t m_mixingLock; 00126 00127 pthread_cond_t m_mixingCondition; 00128 00129 static void* runMixingThread(void* device); 00130 00131 void updateRingBuffers(); 00132 00133 // hide copy constructor and operator= 00134 AUD_JackDevice(const AUD_JackDevice&); 00135 AUD_JackDevice& operator=(const AUD_JackDevice&); 00136 00137 protected: 00138 virtual void playing(bool playing); 00139 00140 public: 00149 AUD_JackDevice(std::string name, AUD_DeviceSpecs specs, int buffersize = AUD_DEFAULT_BUFFER_SIZE); 00150 00154 virtual ~AUD_JackDevice(); 00155 00156 void startPlayback(); 00157 void stopPlayback(); 00158 void seekPlayback(float time); 00159 void setSyncCallback(AUD_syncFunction sync, void* data); 00160 float getPlaybackPosition(); 00161 bool doesPlayback(); 00162 }; 00163 00164 #endif //AUD_JACKDEVICE