add correct copyright statements to all files in Waves backend except those derived...
[ardour.git] / libs / backends / wavesaudio / wavesapi / devicemanager / WCMRCoreAudioDeviceManager.h
index 96d2a9d70ec13941a4c947259aa650a8978674c2..74d1d18dfd6afbc9eecc5dd10292f535b335f806 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2013 Waves Audio Ltd.
+    Copyright (C) 2014 Waves Audio Ltd.
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
@@ -16,6 +16,7 @@
     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
 */
+
 //----------------------------------------------------------------------------------
 //
 //
@@ -98,7 +99,7 @@ protected:
 
        AudioDeviceID m_DeviceID; ///< The CoreAudio device id
        bool m_StopRequested; ///< should be set to true when want to stop, set to false otherwise.
-       float *m_pInputData; ///< This is what came in with the most recent callback.
+    float *m_pInputData; ///< This is what came in with the most recent callback.
        int m_SampleCounter; ///< The current running sample counter, updated by the audio callback.
        int m_SampleCountAtLastIdle; ///< What was the sample count last time we checked...
        int m_StalledSampleCounter; ///< The number of idle calls with same sample count detected
@@ -110,9 +111,7 @@ protected:
 //     int m_CyclesToAccumulate; ///< The number of cycles to accumulate the values for - maximum for last one second.
 //     unsigned int m_CyclePeriod; ///< The number of host time units for a cycle period - determined by buffer size and sampling rate
        
-       
-       
-       AudioBufferList m_InputAudioBufferList; ///< The buffer list used to get AHHAL to render input to.
+
        AudioUnit m_AUHALAudioUnit;///< The AUHAL AudioUnit
 
        int m_BufferSizeChangeRequested;
@@ -138,7 +137,7 @@ protected:
        uint32_t m_NextSampleToUse;
 #endif //WV_USE_TONE_GEN
        
-       WTErr UpdateDeviceInfo (bool updateSRSupported, bool updateBufferSizes);
+       WTErr UpdateDeviceInfo ();
        WTErr UpdateDeviceName();
        WTErr UpdateDeviceInputs();
        WTErr UpdateDeviceOutputs();
@@ -169,6 +168,7 @@ protected:
        AudioDevicePropertyID inPropertyID, void *inClientData);
        void PropertyChangeProc (AudioDevicePropertyID inPropertyID);
     
+    void resetAudioDevice();
 private:
 
 };
@@ -181,40 +181,29 @@ class WCMRCoreAudioDeviceManager : public WCMRAudioDeviceManager
 public:
 
        WCMRCoreAudioDeviceManager(WCMRAudioDeviceManagerClient *pTheClient, eAudioDeviceFilter eCurAudioDeviceFilter,
-               bool useMultithreading = true, eCABS_Method eCABS_method = eCABS_Simple, bool bNocopy = false); ///< constructor
+               bool useMultithreading = true, bool bNocopy = false); ///< constructor
        virtual ~WCMRCoreAudioDeviceManager(void); ///< Destructor
-       
-
-       virtual WTErr UpdateDeviceList() //has to be overridden!
-    {
-                       //wvNS::wvThread::ThreadMutex::lock theLock(m_AudioDeviceManagerMutex);
-        return UpdateDeviceList_Private();
-    }
-
-       virtual eCABS_Method GetBufferSizeMethod()
-    { 
-                       //wvNS::wvThread::ThreadMutex::lock theLock(m_AudioDeviceManagerMutex);
-        return GetBufferSizeMethod_Private();
-    }
-       
-       virtual WTErr DoIdle();
-       
-private:
-    WTErr UpdateDeviceList_Private();
-    eCABS_Method GetBufferSizeMethod_Private() { return m_eCABS_Method; }
 
 protected:
-
-       int m_UpdateDeviceListRequested; ///< Number of times device list change has been detected.
-       int m_UpdateDeviceListProcessed; ///< Number of times device list change has been processed.
+    static OSStatus HardwarePropertyChangeCallback (AudioHardwarePropertyID inPropertyID, void* inClientData);
+    
+    virtual WCMRAudioDevice*   initNewCurrentDeviceImpl(const std::string & deviceName);
+       virtual void                            destroyCurrentDeviceImpl();
+       virtual WTErr                           generateDeviceListImpl();
+    virtual WTErr                              updateDeviceListImpl();
+    virtual WTErr               getDeviceSampleRatesImpl(const std::string & deviceName, std::vector<int>& sampleRates) const;
+       virtual WTErr                           getDeviceBufferSizesImpl(const std::string & deviceName, std::vector<int>& bufferSizes) const;
+    
        bool m_UseMultithreading; ///< Flag indicates whether to use multi-threading for audio processing.
     bool m_bNoCopyAudioBuffer;
-       eCABS_Method m_eCABS_Method; // Type of core audio buffer size list method
-
-       static OSStatus StaticPropertyChangeProc (AudioHardwarePropertyID inPropertyID, void* inClientData);
-       OSStatus PropertyChangeProc (AudioHardwarePropertyID inPropertyID);
-
-       void remove_pattern(const std::string& original_str, const std::string& pattern_str, std::string& return_str);
+           
+private:
+    // helper functions for this class only
+    WTErr getDeviceAvailableSampleRates(DeviceID deviceId, std::vector<int>& sampleRates);
+    WTErr getDeviceMaxInputChannels(DeviceID deviceId, unsigned int& inputChannels);
+    WTErr getDeviceMaxOutputChannels(DeviceID deviceId, unsigned int& outputChannels);
+    
+    WCMRAudioDevice*                   m_NoneDevice;
 };
 
 #endif //#ifndef __WCMRCoreAudioDeviceManager_h_