1 //----------------------------------------------------------------------------------
3 // Copyright (c) 2008 Waves Audio Ltd. All rights reserved.
5 //! \file WCMRNativeAudio.h
7 //! WCMRNativeAudio and related class declarations
9 //---------------------------------------------------------------------------------*/
10 #ifndef __WCMRNativeAudio_h_
11 #define __WCMRNativeAudio_h_
13 #if defined(PLATFORM_WINDOWS)
17 #include "WCRefManager.h"
18 #include "WCMRAudioDeviceManager.h"
20 class WCMRNativeAudioDevice; //forward
24 class WCMRNativeAudioDevice : public WCMRAudioDevice
28 WCMRNativeAudioDevice (WCMRAudioDeviceManager *pManager, bool useMultithreading = true, bool bNoCopy = false) :
29 WCMRAudioDevice (pManager)
30 , m_UseMultithreading (useMultithreading)
31 , m_bNoCopyAudioBuffer(bNoCopy)
33 virtual ~WCMRNativeAudioDevice () {}
36 bool m_UseMultithreading;
37 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.
42 //! A dummy device to allow apps to choose "None" in case no real device connection is required.
43 class WCMRNativeAudioNoneDevice : public WCMRNativeAudioDevice
46 WCMRNativeAudioNoneDevice (WCMRAudioDeviceManager *pManager);
47 virtual ~WCMRNativeAudioNoneDevice ();
48 virtual WTErr SetActive (bool newState);///<Prepare/Activate device.
49 virtual WTErr SetStreaming (bool newState);///<Start/Stop Streaming - should reconnect connections when streaming starts!
50 virtual WTErr SetCurrentBufferSize (int newSize);///<Change Current Buffer Size : This is a requset, might not be successful at run time!
51 virtual WTErr UpdateDeviceInfo ();
55 static void* __SilenceThread(void *This);
56 void _SilenceThread();
57 #if defined(PLATFORM_WINDOWS)
58 void _usleep(uint64_t usec);
60 inline void _usleep(uint64_t usec) { ::usleep(usec); }
62 static const size_t __m_NumInputChannels = 0;
63 static const size_t __m_NumOutputChannels = 0;
64 pthread_t m_SilenceThread;
65 float *_m_inputBuffer;
66 float *_m_outputBuffer;
67 static uint64_t __get_time_nanos ();
68 #if defined (PLATFORM_WINDOWS)
69 HANDLE _waitableTimerForUsleep;
74 #endif //#ifndef __WCMRNativeAudio_h_