Comment remaining unsolved bug.
[ardour.git] / libs / backends / wavesaudio / wavesapi / devicemanager / WCMRNativeAudio.h
1 /*
2     Copyright (C) 2014 Waves Audio Ltd.
3
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.
8
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.
13
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.
17
18 */
19
20 //----------------------------------------------------------------------------------
21 //
22 //
23 //! \file       WCMRNativeAudio.h
24 //!
25 //! WCMRNativeAudio and related class declarations
26 //!
27 //---------------------------------------------------------------------------------*/
28 #ifndef __WCMRNativeAudio_h_
29         #define __WCMRNativeAudio_h_
30
31 #if defined(PLATFORM_WINDOWS)
32 #include "windows.h"
33 #endif
34 #include "pthread.h"
35 #include "WCRefManager.h"
36 #include "WCMRAudioDeviceManager.h"
37
38 #if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_9
39 #include <unistd.h>
40 #endif
41
42 class WCMRNativeAudioDevice; //forward
43
44
45
46 class WCMRNativeAudioDevice : public WCMRAudioDevice
47 {
48 public:
49
50         WCMRNativeAudioDevice (WCMRAudioDeviceManager *pManager, bool useMultithreading = true, bool bNoCopy = false) :
51                 WCMRAudioDevice (pManager)
52                 , m_UseMultithreading (useMultithreading)
53         , m_bNoCopyAudioBuffer(bNoCopy)
54                 {}
55         virtual ~WCMRNativeAudioDevice () {}
56
57 protected:
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.
60
61 };
62
63
64 //! A dummy device to allow apps to choose "None" in case no real device connection is required.
65 class WCMRNativeAudioNoneDevice : public WCMRNativeAudioDevice
66 {
67 public:
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 ();
74
75 private:
76
77         static void* __SilenceThread(void *This);
78         void _SilenceThread();
79 #if defined(PLATFORM_WINDOWS)
80         void _usleep(uint64_t usec);
81 #else
82         inline void _usleep(uint64_t usec) { ::usleep(usec); }
83 #endif
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;
92 #endif
93 };
94
95
96 #endif //#ifndef __WCMRNativeAudio_h_