2 Copyright (C) 2014 Waves Audio Ltd.
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 //----------------------------------------------------------------------------------
23 //! \file WCMRNativeAudio.h
25 //! WCMRNativeAudio and related class declarations
27 //---------------------------------------------------------------------------------*/
28 #ifndef __WCMRNativeAudio_h_
29 #define __WCMRNativeAudio_h_
31 #if defined(PLATFORM_WINDOWS)
35 #include "WCRefManager.h"
36 #include "WCMRAudioDeviceManager.h"
38 #if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_9
42 class WCMRNativeAudioDevice; //forward
46 class WCMRNativeAudioDevice : public WCMRAudioDevice
50 WCMRNativeAudioDevice (WCMRAudioDeviceManager *pManager, bool useMultithreading = true, bool bNoCopy = false) :
51 WCMRAudioDevice (pManager)
52 , m_UseMultithreading (useMultithreading)
53 , m_bNoCopyAudioBuffer(bNoCopy)
55 virtual ~WCMRNativeAudioDevice () {}
58 bool m_UseMultithreading;
59 bool m_bNoCopyAudioBuffer; ///< This flag determines whether the audio callback performs a copy of audio, or the source/sink perform the copy. It should be true to let source/sink do the copies.
64 //! A dummy device to allow apps to choose "None" in case no real device connection is required.
65 class WCMRNativeAudioNoneDevice : public WCMRNativeAudioDevice
68 WCMRNativeAudioNoneDevice (WCMRAudioDeviceManager *pManager);
69 virtual ~WCMRNativeAudioNoneDevice ();
70 virtual WTErr SetActive (bool newState);///<Prepare/Activate device.
71 virtual WTErr SetStreaming (bool newState);///<Start/Stop Streaming - should reconnect connections when streaming starts!
72 virtual WTErr SetCurrentBufferSize (int newSize);///<Change Current Buffer Size : This is a requset, might not be successful at run time!
73 virtual WTErr UpdateDeviceInfo ();
77 static void* __SilenceThread(void *This);
78 void _SilenceThread();
79 #if defined(PLATFORM_WINDOWS)
80 void _usleep(uint64_t usec);
82 inline void _usleep(uint64_t usec) { ::usleep(usec); }
84 static const size_t __m_NumInputChannels = 0;
85 static const size_t __m_NumOutputChannels = 0;
86 pthread_t m_SilenceThread;
87 float *_m_inputBuffer;
88 float *_m_outputBuffer;
89 static uint64_t __get_time_nanos ();
90 #if defined (PLATFORM_WINDOWS)
91 HANDLE _waitableTimerForUsleep;
96 #endif //#ifndef __WCMRNativeAudio_h_