alter platform-dependent preprocessor macros to use the same names as the rest of...
[ardour.git] / libs / backends / wavesaudio / wavesapi / devicemanager / WCMRNativeAudio.h
1 //----------------------------------------------------------------------------------
2 //
3 // Copyright (c) 2008 Waves Audio Ltd. All rights reserved.
4 //
5 //! \file       WCMRNativeAudio.h
6 //!
7 //! WCMRNativeAudio and related class declarations
8 //!
9 //---------------------------------------------------------------------------------*/
10 #ifndef __WCMRNativeAudio_h_
11         #define __WCMRNativeAudio_h_
12
13 #if defined(PLATFORM_WINDOWS)
14 #include "windows.h"
15 #endif
16 #include "pthread.h"
17 #include "WCRefManager.h"
18 #include "WCMRAudioDeviceManager.h"
19
20 class WCMRNativeAudioDevice; //forward
21
22
23
24 class WCMRNativeAudioDevice : public WCMRAudioDevice
25 {
26 public:
27
28         WCMRNativeAudioDevice (WCMRAudioDeviceManager *pManager, bool useMultithreading = true, bool bNoCopy = false) :
29                 WCMRAudioDevice (pManager)
30                 , m_UseMultithreading (useMultithreading)
31         , m_bNoCopyAudioBuffer(bNoCopy)
32                 {}
33         virtual ~WCMRNativeAudioDevice () {}
34
35 protected:
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.
38
39 };
40
41
42 //! A dummy device to allow apps to choose "None" in case no real device connection is required.
43 class WCMRNativeAudioNoneDevice : public WCMRNativeAudioDevice
44 {
45 public:
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 ();
52
53 private:
54
55         static void* __SilenceThread(void *This);
56         void _SilenceThread();
57 #if defined(PLATFORM_WINDOWS)
58         void _usleep(uint64_t usec);
59 #else
60         inline void _usleep(uint64_t usec) { ::usleep(usec); }
61 #endif
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;
70 #endif
71 };
72
73
74 #endif //#ifndef __WCMRNativeAudio_h_