summaryrefslogtreecommitdiff
path: root/libs/backends/wavesaudio/wavesapi/devicemanager/WCMRAudioDeviceManager.h
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2014-04-30 13:46:41 -0400
committerPaul Davis <paul@linuxaudiosystems.com>2014-04-30 13:46:41 -0400
commit19d21045af8492d0ffc9eda8a38632ee5fef04f5 (patch)
tree468131b69bcf6b5b967632337198a91c07113fe5 /libs/backends/wavesaudio/wavesapi/devicemanager/WCMRAudioDeviceManager.h
parent1ac88152967101c2fb1a264456e51211e14dcea6 (diff)
2nd attempt at updated Waves audio backend, with added -fms-extensions as previously applied (but not updated in Waves' repo) to allow anonymous unions, as used by PortMidi
Diffstat (limited to 'libs/backends/wavesaudio/wavesapi/devicemanager/WCMRAudioDeviceManager.h')
-rw-r--r--libs/backends/wavesaudio/wavesapi/devicemanager/WCMRAudioDeviceManager.h130
1 files changed, 56 insertions, 74 deletions
diff --git a/libs/backends/wavesaudio/wavesapi/devicemanager/WCMRAudioDeviceManager.h b/libs/backends/wavesaudio/wavesapi/devicemanager/WCMRAudioDeviceManager.h
index 0d6aa55dea..a3b1baa784 100644
--- a/libs/backends/wavesaudio/wavesapi/devicemanager/WCMRAudioDeviceManager.h
+++ b/libs/backends/wavesaudio/wavesapi/devicemanager/WCMRAudioDeviceManager.h
@@ -1,23 +1,6 @@
-/*
- Copyright (C) 2013 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
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
-*/
//----------------------------------------------------------------------------------
//
+// Copyright (c) 2008 Waves Audio Ltd. All rights reserved.
//
//! \file WCMRAudioDeviceManager.h
//!
@@ -42,19 +25,35 @@
#include "WCRefManager.h"
#include "BasicTypes/WUTypes.h"
#include "WUErrors.h"
+#include "WCThreadSafe.h"
#define WCUNUSEDPARAM(a)
-//forward decl.
-class WCMRAudioConnection;
class WCMRAudioDevice;
class WCMRAudioDeviceManager;
-typedef std::vector<WCMRAudioDevice *> WCMRAudioDeviceList; ///< Vector for audio devices
-typedef std::vector<WCMRAudioDevice *>::iterator WCMRAudioDeviceListIter; ///< Vector iterator for audio devices
-typedef std::vector<WCMRAudioDevice *>::const_iterator WCMRAudioDeviceListConstIter; ///< Vector iterator for audio devices
-typedef std::vector<WCMRAudioConnection *> WCMRAudioConnectionsList; ///< Vector for audio devices
+typedef unsigned int DeviceID;
+
+struct DeviceInfo
+{
+ DeviceID m_DeviceId;
+ std::string m_DeviceName;
+ std::vector<int> m_AvailableSampleRates;
+ unsigned int m_MaxInputChannels;
+ unsigned int m_MaxOutputChannels;
+
+ DeviceInfo():
+ m_DeviceId(-1), m_DeviceName("Unknown"), m_MaxInputChannels(0), m_MaxOutputChannels(0)
+ {};
+
+ DeviceInfo(unsigned int deviceID, const std::string & deviceName):
+ m_DeviceId(deviceID), m_DeviceName(deviceName), m_MaxInputChannels(0), m_MaxOutputChannels(0)
+ {};
+};
+typedef std::vector<DeviceInfo*> DeviceInfoVec;
+typedef DeviceInfoVec::iterator DeviceInfoVecIter;
+typedef DeviceInfoVec::const_iterator DeviceInfoVecConstIter;
/// for notification... A client must derive it's class from us.
class WCMRAudioDeviceManagerClient
@@ -71,6 +70,7 @@ class WCMRAudioDeviceManagerClient
BufferSizeChanged,
ClockSourceChanged,
DeviceStoppedStreaming,
+ DeviceStartsStreaming,
DeviceDroppedSamples,
DeviceConnectionLost,
DeviceGenericError,
@@ -123,7 +123,7 @@ public:
{
DeviceAvailable,
DeviceDisconnected,
- DeviceError
+ DeviceErrors
};
WCMRAudioDevice (WCMRAudioDeviceManager *pManager);///<Constructor
@@ -167,6 +167,8 @@ public:
virtual WTErr SendCustomCommand (int customCommand, void *pCommandParam); ///< Send a custom command to the audiodevice...
virtual uint32_t GetLatency (bool isInput); ///Get latency.
+
+ virtual WTErr UpdateDeviceInfo () = 0;
protected:
WCMRAudioDeviceManager *m_pMyManager; ///< The manager who's managing this device, can be used for sending notifications!
@@ -191,6 +193,7 @@ protected:
float m_MonitorGain; ///< Amount of gain to apply for monitoring signal.
};
+
// This enum is for choosing filter for audio devices scan
typedef enum eAudioDeviceFilter
{
@@ -202,65 +205,44 @@ typedef enum eAudioDeviceFilter
eAudioDeviceFilterNum // Number of enums
} eAudioDeviceFilter;
-//! WCMRAudioDeviceManager
-/*! The Audio Device Manager class */
+
class WCMRAudioDeviceManager : public WCRefManager
{
-private://< Private version of class functions which will be called by class's public function after mutex lock acquistion.
- WCMRAudioDevice* GetDefaultDevice_Private();
- WTErr DoIdle_Private();
- const WCMRAudioDeviceList& Devices_Private() const;
- WCMRAudioDevice* GetDeviceByName_Private(const std::string & nameToMatch) const;
-
public://< Public functions for the class.
- WCMRAudioDevice* GetDefaultDevice()
- {
- //wvNS::wvThread::ThreadMutex::lock theLock(m_AudioDeviceManagerMutex);
- return GetDefaultDevice_Private();
- }
-
- virtual WTErr DoIdle()
- {
- //wvNS::wvThread::ThreadMutex::lock theLock(m_AudioDeviceManagerMutex);
- return DoIdle_Private();
- }
+
+ WCMRAudioDeviceManager(WCMRAudioDeviceManagerClient *pTheClient, eAudioDeviceFilter eCurAudioDeviceFilter); ///< constructor
+ virtual ~WCMRAudioDeviceManager(void); ///< Destructor
- const WCMRAudioDeviceList& Devices() const
- {
- //wvNS::wvThread::ThreadMutex::lock theLock(m_AudioDeviceManagerMutex);
- return Devices_Private();
- }
+ //interfaces
+ WCMRAudioDevice* InitNewCurrentDevice(const std::string & deviceName);
+ void DestroyCurrentDevice();
+ const DeviceInfoVec DeviceInfoList () const;
+ WTErr GetDeviceInfoByName(const std::string & nameToMatch, DeviceInfo & devInfo) const;
+ WTErr GetDeviceBufferSizes(const std::string & nameToMatch, std::vector<int>& bufferSizes) const;
- WCMRAudioDevice* GetDeviceByName(const std::string & nameToMatch) const
- {
- //wvNS::wvThread::ThreadMutex::lock theLock(m_AudioDeviceManagerMutex);
- return GetDeviceByName_Private(nameToMatch);
- }
+ //virtual void EnableVerboseLogging(bool /*bEnable*/, const std::string& /*logFilePath*/) { };
-public:
-
- WCMRAudioDeviceManager(WCMRAudioDeviceManagerClient *pTheClient, eAudioDeviceFilter eCurAudioDeviceFilter
- ); ///< constructor
- virtual ~WCMRAudioDeviceManager(void); ///< Destructor
-
- virtual WTErr UpdateDeviceList () = 0; //has to be overridden!
-
-
- //This is primarily for use by WCMRAudioDevice and it's descendants... We could have made it
- //protected and made WCMRAudioDevice a friend, and then in some way found a way to extend
- //the friendship to WCMRAudioDevice's descendants, but that would require a lot of extra
- //effort!
- void NotifyClient (WCMRAudioDeviceManagerClient::NotificationReason forReason, void *pParam = NULL);
- virtual void EnableVerboseLogging(bool /*bEnable*/, const std::string& /*logFilePath*/) { };
+ //notify backend
+ void NotifyClient (WCMRAudioDeviceManagerClient::NotificationReason forReason, void *pParam = NULL);
protected:
- //< NOTE : Mutex protection is commented, but wrapper classes are still there, in case they are required in future.
- //wvNS::wvThread::ThreadMutex m_AudioDeviceManagerMutex; ///< Mutex for Audio device manager class function access.
- WCMRAudioDeviceManagerClient *m_pTheClient; ///< The device manager's client, used to send notifications.
+ mutable wvNS::wvThread::ThreadMutex m_AudioDeviceInfoVecMutex; // mutex to lock device info list
+ DeviceInfoVec m_DeviceInfoVec;
- WCMRAudioDeviceList m_Devices; ///< List of all relevant devices devices
- eAudioDeviceFilter m_eAudioDeviceFilter; // filter of 'm_Devices'
+ eAudioDeviceFilter m_eAudioDeviceFilter;
+ WCMRAudioDevice* m_CurrentDevice;
+
+private:
+ // override in derived classes
+ // made private to avoid pure virtual function call
+ virtual WCMRAudioDevice* initNewCurrentDeviceImpl(const std::string & deviceName) = 0;
+ virtual void destroyCurrentDeviceImpl() = 0;
+ virtual WTErr getDeviceBufferSizesImpl(const std::string & deviceName, std::vector<int>& bufferSizes) const = 0;
+ virtual WTErr generateDeviceListImpl() = 0;
+ virtual WTErr updateDeviceListImpl() = 0;
+
+ WCMRAudioDeviceManagerClient *m_pTheClient; ///< The device manager's client, used to send notifications.
};
#endif //#ifndef __WCMRAudioDeviceManager_h_