diff options
Diffstat (limited to 'libs/backends/wavesaudio')
10 files changed, 664 insertions, 664 deletions
diff --git a/libs/backends/wavesaudio/wavesapi/MiscUtils/UMicroseconds.cpp b/libs/backends/wavesaudio/wavesapi/MiscUtils/UMicroseconds.cpp index 5e3d2b4da8..fb31d24a78 100644 --- a/libs/backends/wavesaudio/wavesapi/MiscUtils/UMicroseconds.cpp +++ b/libs/backends/wavesaudio/wavesapi/MiscUtils/UMicroseconds.cpp @@ -7,7 +7,7 @@ #include "UMicroseconds.h" -namespace wvNS { +namespace wvNS { UMicroseconds& UMicroseconds::ReadTime() { // Note: g_get_monotonic_time() may be a viable alternative @@ -39,7 +39,7 @@ UMicroseconds& UMicroseconds::ReadTime() return *this; } /* - Removed in favor of the posix implementation. + Removed in favor of the posix implementation. #ifdef __APPLE__ uint32_t UMicroseconds::hi() {return reinterpret_cast<UnsignedWide*>(&theTime)->hi;} uint32_t UMicroseconds::lo() {return reinterpret_cast<UnsignedWide*>(&theTime)->lo;} @@ -74,4 +74,4 @@ UMicrosecondsAccumulator& UMicrosecondsAccumulator::operator+=(const UMicrosecon return *this; } -} // namespace wvNS { +} // namespace wvNS { diff --git a/libs/backends/wavesaudio/wavesapi/Threads/WCThreadSafe.cpp b/libs/backends/wavesaudio/wavesapi/Threads/WCThreadSafe.cpp index 32e099b518..1ee568af1e 100644 --- a/libs/backends/wavesaudio/wavesapi/Threads/WCThreadSafe.cpp +++ b/libs/backends/wavesaudio/wavesapi/Threads/WCThreadSafe.cpp @@ -66,7 +66,7 @@ namespace wvThread //--------------------- begin measurement code // poll to align to a tick of gettimeofday ::gettimeofday(&tvtmp,0); - do { + do { ::gettimeofday(&tvstart,0); __asm__ __volatile__ (".byte 0x0f, 0x31" : "=A" (Tstart)); // RDTSC } while (tvtmp.tv_usec!=tvstart.tv_usec); @@ -74,7 +74,7 @@ namespace wvThread ::usleep(sktd_TSC_MeasurementPeriod); // ::gettimeofday(&tvtmp,0); - do { + do { ::gettimeofday(&tvend,0); __asm__ __volatile__ (".byte 0x0f, 0x31" : "=A" (Tend)); // RDTSC } while (tvtmp.tv_usec!=tvend.tv_usec); @@ -86,10 +86,10 @@ namespace wvThread #endif return nTicksPerMicrosecond; } - + #if defined(__APPLE__) //&& !defined(__MACH__) - + bool FindNetInterfaceByIPAddress(const char *sIP, char *sInterface) // sIP and sInterface are both char[16] { FILE *fProcess , *pSubcall; @@ -106,7 +106,7 @@ namespace wvThread while (pToken) { sprintf(sCommand, "ifconfig %s | grep \"inet %s \"", pToken, sIP); - + pSubcall = popen(sCommand, "r"); if (pSubcall) { @@ -121,12 +121,12 @@ namespace wvThread } } pclose(pSubcall); - pToken = strtok(NULL, " "); + pToken = strtok(NULL, " "); } - + } pclose(fProcess); - + return res; } #endif // MACOS @@ -198,7 +198,7 @@ namespace wvThread #elif XPLATFORMTHREADS_POSIX void yield() { ::sched_yield(); } #endif - + @@ -214,14 +214,14 @@ namespace wvThread inline void obtain() { EnsureThreadingInitialized(); ::EnterCriticalSection (&m_critsec); } inline void release() { EnsureThreadingInitialized(); ::LeaveCriticalSection (&m_critsec); } inline bool tryobtain() { EnsureThreadingInitialized(); return TryEnterCriticalSection(&m_critsec)!=FALSE; } - + #elif defined (XPLATFORMTHREADS_POSIX) protected: pthread_mutex_t m_ptmutex; public: - inline OSDependentMutex() - { - EnsureThreadingInitialized(); + inline OSDependentMutex() + { + EnsureThreadingInitialized(); pthread_mutexattr_t attr; pthread_mutexattr_init(&attr); pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE); @@ -237,7 +237,7 @@ namespace wvThread ThreadMutexInited::ThreadMutexInited() : m_osdmutex(0) {} - + void ThreadMutexInited::init() { if (! is_init()) @@ -245,7 +245,7 @@ namespace wvThread m_osdmutex = new OSDependentMutex; } } - + void ThreadMutexInited::uninit() { if (is_init()) @@ -254,38 +254,38 @@ namespace wvThread m_osdmutex = 0; } } - + ThreadMutexInited::~ThreadMutexInited() { uninit(); - } - + } + void ThreadMutexInited::obtain() { if (is_init()) { - m_osdmutex->obtain(); + m_osdmutex->obtain(); } - } + } void ThreadMutexInited::release() { if (is_init()) { - m_osdmutex->release(); + m_osdmutex->release(); } - } - + } + bool ThreadMutexInited::tryobtain() { bool retVal = true; if (is_init()) { - retVal = m_osdmutex->tryobtain(); + retVal = m_osdmutex->tryobtain(); } return retVal; - } - + } + class ThreadConditionSignal::OSDependentObject : public noncopyableobject { #if defined (XPLATFORMTHREADS_POSIX) @@ -294,17 +294,17 @@ namespace wvThread pthread_cond_t m_ptcond; pthread_mutex_t m_ptmutex; public: - inline OSDependentObject() + inline OSDependentObject() { - EnsureThreadingInitialized(); + EnsureThreadingInitialized(); ::pthread_mutex_init(&m_ptmutex,0); - ::pthread_cond_init(&m_ptcond, 0); + ::pthread_cond_init(&m_ptcond, 0); } inline ~OSDependentObject() { ::pthread_cond_destroy(&m_ptcond), ::pthread_mutex_destroy(&m_ptmutex); } inline void signal_unicast() { ::pthread_cond_signal(&m_ptcond); } inline void signal_broadcast() { ::pthread_cond_broadcast(&m_ptcond); } inline void await_signal() { ::pthread_cond_wait(&m_ptcond, &m_ptmutex); } - inline bool await_signal(timediff td) + inline bool await_signal(timediff td) { timespec tspecDeadline; timeval tvNow; @@ -423,14 +423,14 @@ namespace wvThread #endif // OS switch }; - void ThreadConditionSignal::obtain_mutex() - { - m_osdepobj.obtain_mutex(); + void ThreadConditionSignal::obtain_mutex() + { + m_osdepobj.obtain_mutex(); } bool ThreadConditionSignal::tryobtain_mutex() { return m_osdepobj.tryobtain_mutex(); } - void ThreadConditionSignal::release_mutex() - { - m_osdepobj.release_mutex(); + void ThreadConditionSignal::release_mutex() + { + m_osdepobj.release_mutex(); } void ThreadConditionSignal::await_condition() { m_osdepobj.await_signal(); } @@ -587,7 +587,7 @@ namespace wvThread 0 // where to store thread ID ); - if (h) + if (h) { th.m_oshandle = h; if (pri!=ThreadPriority::Normal) @@ -620,8 +620,8 @@ namespace wvThread ThunkedThreadWrapper, ptwdata ); - - if (anyerr) + + if (anyerr) th=Invalid; else th.m_oshandle = OSDependent::from_oshandle(pt); @@ -676,7 +676,7 @@ namespace wvThread class WCThreadRef::OSDependent { public: - static void GetCurrentThreadRef(WCThreadRef& tid); + static void GetCurrentThreadRef(WCThreadRef& tid); #if XPLATFORMTHREADS_WINDOWS static inline uintptr_t from_os(DWORD thread_id) { return (uintptr_t)(thread_id); } static inline DWORD to_os(uintptr_t thread_id) { return (DWORD)(thread_id); } @@ -735,7 +735,7 @@ namespace wvThread WCThreadRef GetCurrentThreadRef() { - EnsureThreadingInitialized(); // Is it necessary? + EnsureThreadingInitialized(); // Is it necessary? WCThreadRef tRefToReturn; WCThreadRef::OSDependent::GetCurrentThreadRef(tRefToReturn); return tRefToReturn; @@ -794,7 +794,7 @@ namespace wvThread bool WCAtomicLock::obtain(const uint32_t in_num_trys) { bool retVal = false; - + uint32_t timeOut = in_num_trys; while (true) { @@ -812,7 +812,7 @@ namespace wvThread sleep_milliseconds(1000); } } - + return retVal; } diff --git a/libs/backends/wavesaudio/wavesapi/akupara/basics.hpp b/libs/backends/wavesaudio/wavesapi/akupara/basics.hpp index a25e0dd89d..45d29955c7 100644 --- a/libs/backends/wavesaudio/wavesapi/akupara/basics.hpp +++ b/libs/backends/wavesaudio/wavesapi/akupara/basics.hpp @@ -15,7 +15,7 @@ namespace Akupara { // The ultimate nothingness // This is useful for writing constructors that nullify their object, and for testing nullness - struct null_type + struct null_type { null_type() {} null_type(const null_type *) {} // this allows 0 to be implicitly converted to null_type diff --git a/libs/backends/wavesaudio/wavesapi/akupara/compiletime_functions.hpp b/libs/backends/wavesaudio/wavesapi/akupara/compiletime_functions.hpp index 85eee8fcee..9c146dcebf 100644 --- a/libs/backends/wavesaudio/wavesapi/akupara/compiletime_functions.hpp +++ b/libs/backends/wavesaudio/wavesapi/akupara/compiletime_functions.hpp @@ -18,22 +18,22 @@ namespace Akupara // Integer log2 functions //------------------------------------------------------------------------ - template<unsigned int n> + template<unsigned int n> struct compiletime_bit_count_to_represent { static const unsigned int value = 1+compiletime_bit_count_to_represent<(n>>1)>::value; }; - template<> + template<> struct compiletime_bit_count_to_represent<0> { static const unsigned int value = 0; }; //------------------------------------------------------------------------ - template<unsigned int n> + template<unsigned int n> struct compiletime_log2_ceiling { static const unsigned int value=compiletime_bit_count_to_represent<n-1>::value; }; - template<> + template<> struct compiletime_log2_ceiling<0> {}; // no value for 0 argument //------------------------------------------------------------------------ - template<unsigned int n> + template<unsigned int n> struct compiletime_log2_floor { static const unsigned int value=compiletime_bit_count_to_represent<n>::value-1; }; - template<> + template<> struct compiletime_log2_floor<0> {}; // no value for 0 argument //------------------------------------------------------------------------ @@ -41,13 +41,13 @@ namespace Akupara // Assertion - accessing 'value' will generate a compile-time error if the argument evaluates to false //------------------------------------------------------------------------ - template<bool> + template<bool> struct compiletime_assert; template<> struct compiletime_assert<true> { static const bool value=true; }; - template<> + template<> struct compiletime_assert<false> {}; // no value member for false assertion -> compile time error //------------------------------------------------------------------------ @@ -60,7 +60,7 @@ namespace Akupara template<typename _true_type, typename _false_type> struct compiletime_select_type<true, _true_type, _false_type> { typedef _true_type type; }; - template<typename _true_type, typename _false_type> + template<typename _true_type, typename _false_type> struct compiletime_select_type<false, _true_type, _false_type> { typedef _false_type type; }; //------------------------------------------------------------------------ @@ -72,7 +72,7 @@ namespace Akupara //------------------------------------------------------------------------ namespace detail { - template<unsigned int _size, bool _signed> + template<unsigned int _size, bool _signed> struct integer_with_byte_count_base; template<> @@ -149,15 +149,15 @@ namespace Akupara AKUPARA_SIGNED_UNSIGNED_INTEGER_PAIR(3, int ) //AKUPARA_SIGNED_UNSIGNED_INTEGER_PAIR(4, int32_t )// 64BitConversion - template<> - struct - signed_unsigned_pair<4> - { - typedef int32_t signed_type; - typedef uint32_t unsigned_type; + template<> + struct + signed_unsigned_pair<4> + { + typedef int32_t signed_type; + typedef uint32_t unsigned_type; }; - - + + AKUPARA_SIGNED_UNSIGNED_INTEGER_PAIR(5, long long) AKUPARA_SIGNED_UNSIGNED_FLOAT_PAIR (6, float ) AKUPARA_SIGNED_UNSIGNED_FLOAT_PAIR (7, double ) diff --git a/libs/backends/wavesaudio/wavesapi/akupara/threading/atomic_ops.hpp b/libs/backends/wavesaudio/wavesapi/akupara/threading/atomic_ops.hpp index e87f548a2b..b5010eaff9 100644 --- a/libs/backends/wavesaudio/wavesapi/akupara/threading/atomic_ops.hpp +++ b/libs/backends/wavesaudio/wavesapi/akupara/threading/atomic_ops.hpp @@ -1,6 +1,6 @@ /* * Akupara/threading/atomic_ops.hpp -* +* * * Created by Udi Barzilai on 06/06. * Copyright 2006 __MyCompanyName__. All rights reserved. @@ -91,16 +91,16 @@ namespace Akupara //---------------------------------------------------------------------------------------- namespace detail { - template<unsigned int _byte_count> - struct largest_atomic_byte_count_upto - { - static const unsigned int value = - machine::implements_load<_byte_count>::value && machine::implements_store<_byte_count>::value ? -_byte_count : - largest_atomic_byte_count_upto<_byte_count/2>::value; + template<unsigned int _byte_count> + struct largest_atomic_byte_count_upto + { + static const unsigned int value = + machine::implements_load<_byte_count>::value && machine::implements_store<_byte_count>::value ? +_byte_count : + largest_atomic_byte_count_upto<_byte_count/2>::value; }; - template<> + template<> struct largest_atomic_byte_count_upto<0> { static const unsigned int value = 0; }; const unsigned int k_byte_count_best_atomic = largest_atomic_byte_count_upto<sizeof(int)>::value; @@ -129,7 +129,7 @@ _byte_count : namespace detail { template< - typename _integer_type, + typename _integer_type, bool _implements_CAS = machine::implements_CAS <sizeof(_integer_type)>::value, bool _implements_LL_SC = machine::implements_LL_SC<sizeof(_integer_type)>::value> struct implementation_CAS @@ -138,7 +138,7 @@ _byte_count : }; // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // specialization for native CAS support - template<typename _integer_type, bool _implements_LL_SC> + template<typename _integer_type, bool _implements_LL_SC> struct implementation_CAS<_integer_type, true, _implements_LL_SC> { static const bool s_exists = true; @@ -164,7 +164,7 @@ _byte_count : // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - } // namespace detail // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - template<typename _integer_type> + template<typename _integer_type> inline bool compare_and_store(volatile _integer_type * operand_address, const _integer_type & expected_value, const _integer_type & value_to_store) { // if your compiler can't find the function to call here then there is no implementation available for your machine @@ -181,7 +181,7 @@ _byte_count : namespace detail { template< - typename _integer_type, + typename _integer_type, bool _0 = machine::implements_fetch_and_add<sizeof(_integer_type)>::value, bool _1 = machine::implements_add_and_fetch<sizeof(_integer_type)>::value, bool _2 = machine::implements_LL_SC <sizeof(_integer_type)>::value, @@ -244,7 +244,7 @@ _byte_count : }; // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - } // namespace detail - template<typename _integer_type> + template<typename _integer_type> inline _integer_type fetch_and_add(volatile _integer_type * operand_address, const _integer_type & addend) { // if your compiler can't find the function to call here then there is no implementation available for your machine @@ -260,7 +260,7 @@ _byte_count : namespace detail { template< - typename _integer_type, + typename _integer_type, bool _0 = machine::implements_add_and_fetch<sizeof(_integer_type)>::value, bool _1 = machine::implements_fetch_and_add<sizeof(_integer_type)>::value, bool _2 = machine::implements_LL_SC <sizeof(_integer_type)>::value, @@ -323,7 +323,7 @@ _byte_count : }; // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - } // namespace detail - template<typename _integer_type> + template<typename _integer_type> inline _integer_type add_and_fetch(volatile _integer_type * operand_address, const _integer_type & addend) { // if your compiler can't find the function to call here then there is no implementation available for your machine @@ -335,7 +335,7 @@ _byte_count : //---------------------------------------------------------------------------------------- // add - template<typename _integer_type> + template<typename _integer_type> inline void add(volatile _integer_type * operand_address, const _integer_type & addend) { if (machine::implements_add<sizeof(_integer_type)>::value) diff --git a/libs/backends/wavesaudio/wavesapi/akupara/threading/atomic_ops_gcc_x86.hpp b/libs/backends/wavesaudio/wavesapi/akupara/threading/atomic_ops_gcc_x86.hpp index 3039433bcf..148c297552 100644 --- a/libs/backends/wavesaudio/wavesapi/akupara/threading/atomic_ops_gcc_x86.hpp +++ b/libs/backends/wavesaudio/wavesapi/akupara/threading/atomic_ops_gcc_x86.hpp @@ -1,6 +1,6 @@ /* * Akupara/threading/atomic_ops_gcc_x86.hpp - * + * * * Created by Udi Barzilai on 06/06. * Copyright 2006 __MyCompanyName__. All rights reserved. diff --git a/libs/backends/wavesaudio/wavesapi/devicemanager/WCMRAudioDeviceManager.cpp b/libs/backends/wavesaudio/wavesapi/devicemanager/WCMRAudioDeviceManager.cpp index ecd1b05698..481aa2d860 100644 --- a/libs/backends/wavesaudio/wavesapi/devicemanager/WCMRAudioDeviceManager.cpp +++ b/libs/backends/wavesaudio/wavesapi/devicemanager/WCMRAudioDeviceManager.cpp @@ -12,7 +12,7 @@ //********************************************************************************************** -// WCMRAudioDevice::WCMRAudioDevice +// WCMRAudioDevice::WCMRAudioDevice // //! Constructor for the audio device. The derived classes will need to do more actual work, such //! as determining supported sampling rates, buffer sizes, and channel counts. Connection @@ -20,7 +20,7 @@ //! //! \param *pManager : The audio device manager that's managing this device. //! \return Nothing. -//! +//! //********************************************************************************************** WCMRAudioDevice::WCMRAudioDevice (WCMRAudioDeviceManager *pManager) : m_pMyManager (pManager) @@ -39,19 +39,19 @@ WCMRAudioDevice::WCMRAudioDevice (WCMRAudioDeviceManager *pManager) : //********************************************************************************************** -// WCMRAudioDevice::~WCMRAudioDevice +// WCMRAudioDevice::~WCMRAudioDevice // //! Destructor for the audio device. It release all the connections that were created. //! //! \param none -//! +//! //! \return Nothing. -//! +//! //********************************************************************************************** WCMRAudioDevice::~WCMRAudioDevice () { AUTO_FUNC_DEBUG; - try + try { } catch (...) @@ -65,14 +65,14 @@ WCMRAudioDevice::~WCMRAudioDevice () //********************************************************************************************** -// WCMRAudioDevice::DeviceName +// WCMRAudioDevice::DeviceName // //! Retrieves Device's name. //! //! \param none -//! +//! //! \return The device name. -//! +//! //********************************************************************************************** const std::string& WCMRAudioDevice::DeviceName () const { @@ -83,14 +83,14 @@ const std::string& WCMRAudioDevice::DeviceName () const //********************************************************************************************** -// WCMRAudioDevice::InputChannels +// WCMRAudioDevice::InputChannels // //! Retrieves Input Channel information. Note that the list may be changed at run-time. //! //! \param none -//! +//! //! \return A vector with Input Channel Names. -//! +//! //********************************************************************************************** const std::vector<std::string>& WCMRAudioDevice::InputChannels () { @@ -101,14 +101,14 @@ const std::vector<std::string>& WCMRAudioDevice::InputChannels () //********************************************************************************************** -// WCMRAudioDevice::OutputChannels +// WCMRAudioDevice::OutputChannels // //! Retrieves Output Channel Information. Note that the list may be changed at run-time. //! //! \param none -//! +//! //! \return A vector with Output Channel Names. -//! +//! //********************************************************************************************** const std::vector<std::string>& WCMRAudioDevice::OutputChannels () { @@ -119,14 +119,14 @@ const std::vector<std::string>& WCMRAudioDevice::OutputChannels () //********************************************************************************************** -// WCMRAudioDevice::SamplingRates +// WCMRAudioDevice::SamplingRates // //! Retrieves supported sampling rate information. //! //! \param none -//! +//! //! \return A vector with supported sampling rates. -//! +//! //********************************************************************************************** const std::vector<int>& WCMRAudioDevice::SamplingRates () { @@ -136,15 +136,15 @@ const std::vector<int>& WCMRAudioDevice::SamplingRates () //********************************************************************************************** -// WCMRAudioDevice::CurrentSamplingRate +// WCMRAudioDevice::CurrentSamplingRate // -//! The device's current sampling rate. This may be overridden, if the device needs to +//! The device's current sampling rate. This may be overridden, if the device needs to //! query the driver for the current rate. //! //! \param none -//! +//! //! \return The device's current sampling rate. -1 on error. -//! +//! //********************************************************************************************** int WCMRAudioDevice::CurrentSamplingRate () { @@ -155,15 +155,15 @@ int WCMRAudioDevice::CurrentSamplingRate () //********************************************************************************************** -// WCMRAudioDevice::SetCurrentSamplingRate +// WCMRAudioDevice::SetCurrentSamplingRate // -//! Change the sampling rate to be used by the device. This will most likely be overridden, +//! Change the sampling rate to be used by the device. This will most likely be overridden, //! the base class simply updates the member variable. //! //! \param newRate : The rate to use (samples per sec). -//! +//! //! \return eNoErr always. The derived classes may return error codes. -//! +//! //********************************************************************************************** WTErr WCMRAudioDevice::SetCurrentSamplingRate (int newRate) { @@ -176,14 +176,14 @@ WTErr WCMRAudioDevice::SetCurrentSamplingRate (int newRate) //********************************************************************************************** -// WCMRAudioDevice::BufferSizes +// WCMRAudioDevice::BufferSizes // //! Retrieves supported buffer size information. //! //! \param none -//! +//! //! \return A vector with supported buffer sizes. -//! +//! //********************************************************************************************** const std::vector<int>& WCMRAudioDevice::BufferSizes () { @@ -195,13 +195,13 @@ const std::vector<int>& WCMRAudioDevice::BufferSizes () //********************************************************************************************** // WCMRAudioDevice::CurrentBufferSize // -//! The device's current buffer size in use. This may be overridden, if the device needs to +//! The device's current buffer size in use. This may be overridden, if the device needs to //! query the driver for the current size. //! //! \param none -//! +//! //! \return The device's current buffer size. 0 on error. -//! +//! //********************************************************************************************** int WCMRAudioDevice::CurrentBufferSize () { @@ -216,9 +216,9 @@ int WCMRAudioDevice::CurrentBufferSize () //! data other then the audio buffers, like frames info in SG, so it can be overridden //! //! \param none -//! +//! //! \return The device's current block size. 0 on error. -//! +//! //********************************************************************************************** int WCMRAudioDevice::CurrentBlockSize() { @@ -230,13 +230,13 @@ int WCMRAudioDevice::CurrentBlockSize() //********************************************************************************************** // WCMRAudioDevice::SetCurrentBufferSize // -//! Change the buffer size to be used by the device. This will most likely be overridden, +//! Change the buffer size to be used by the device. This will most likely be overridden, //! the base class simply updates the member variable. //! //! \param newSize : The buffer size to use (in sample-frames) -//! +//! //! \return eNoErr always. The derived classes may return error codes. -//! +//! //********************************************************************************************** WTErr WCMRAudioDevice::SetCurrentBufferSize (int newSize) { @@ -250,15 +250,15 @@ WTErr WCMRAudioDevice::SetCurrentBufferSize (int newSize) //********************************************************************************************** -// WCMRAudioDevice::ConnectionStatus +// WCMRAudioDevice::ConnectionStatus // //! Retrieves the device's current connection status. This will most likely be overridden, //! in case some driver communication is required to query the status. //! //! \param none -//! +//! //! \return A ConnectionStates value. -//! +//! //********************************************************************************************** WCMRAudioDevice::ConnectionStates WCMRAudioDevice::ConnectionStatus () { @@ -270,14 +270,14 @@ WCMRAudioDevice::ConnectionStates WCMRAudioDevice::ConnectionStatus () //********************************************************************************************** -// WCMRAudioDevice::Active +// WCMRAudioDevice::Active // //! Retrieves Device activation status. //! //! \param none -//! +//! //! \return true if device is active, false otherwise. -//! +//! //********************************************************************************************** bool WCMRAudioDevice::Active () { @@ -288,15 +288,15 @@ bool WCMRAudioDevice::Active () //********************************************************************************************** -// WCMRAudioDevice::SetActive +// WCMRAudioDevice::SetActive // //! Sets the device's activation status. //! //! \param newState : Should be true to activate, false to deactivate. This roughly corresponds //! to opening and closing the device handle/stream/audio unit. -//! +//! //! \return eNoErr always, the derived classes may return appropriate error code. -//! +//! //********************************************************************************************** WTErr WCMRAudioDevice::SetActive (bool newState) { @@ -310,14 +310,14 @@ WTErr WCMRAudioDevice::SetActive (bool newState) //********************************************************************************************** -// WCMRAudioDevice::Streaming +// WCMRAudioDevice::Streaming // //! Retrieves Device streaming status. //! //! \param none -//! +//! //! \return true if device is streaming, false otherwise. -//! +//! //********************************************************************************************** bool WCMRAudioDevice::Streaming () { @@ -333,9 +333,9 @@ bool WCMRAudioDevice::Streaming () //! //! \param newState : Should be true to start streaming, false to stop streaming. This roughly //! corresponds to calling Start/Stop on the lower level interface. -//! +//! //! \return eNoErr always, the derived classes may return appropriate error code. -//! +//! //********************************************************************************************** WTErr WCMRAudioDevice::SetStreaming (bool newState) { @@ -387,15 +387,15 @@ bool WCMRAudioDevice::IsProcessActive() //********************************************************************************************** -// WCMRAudioDevice::DoIdle +// WCMRAudioDevice::DoIdle // //! A place for doing idle time processing. The derived classes will probably do something //! meaningful. //! //! \param none -//! +//! //! \return eNoErr always. -//! +//! //********************************************************************************************** WTErr WCMRAudioDevice::DoIdle () { @@ -408,14 +408,14 @@ WTErr WCMRAudioDevice::DoIdle () //********************************************************************************************** -// WCMRAudioDevice::InputLevels +// WCMRAudioDevice::InputLevels // //! Retrieve current input levels. //! //! \param none -//! +//! //! \return A vector (the same size as input channels list) that contains current input levels. -//! +//! //********************************************************************************************** const std::vector<float>& WCMRAudioDevice::InputLevels () { @@ -427,14 +427,14 @@ const std::vector<float>& WCMRAudioDevice::InputLevels () //********************************************************************************************** -// WCMRAudioDevice::OutputLevels +// WCMRAudioDevice::OutputLevels // //! Retrieve current output levels. //! //! \param none -//! +//! //! \return A vector (the same size as output channels list) that contains current output levels. -//! +//! //********************************************************************************************** const std::vector<float>& WCMRAudioDevice::OutputLevels () { @@ -446,16 +446,16 @@ const std::vector<float>& WCMRAudioDevice::OutputLevels () //********************************************************************************************** -// WCMRAudioDevice::GetMonitorInfo +// WCMRAudioDevice::GetMonitorInfo // //! Retrieves current monitoring information. //! //! \param *pLeftChannel : Pointer to receive left monitor channel index. //! \param *pRightChannel : Pointer to receive right monitor channel index. //! \param *pGain : Pointer to receive the gain (linear) to be applied. -//! +//! //! \return Nothing. -//! +//! //********************************************************************************************** void WCMRAudioDevice::GetMonitorInfo (int *pLeftChannel, int *pRightChannel, float *pGain) { @@ -471,15 +471,15 @@ void WCMRAudioDevice::GetMonitorInfo (int *pLeftChannel, int *pRightChannel, flo //********************************************************************************************** -// WCMRAudioDevice::SetMonitorChannels +// WCMRAudioDevice::SetMonitorChannels // //! Used to set the channels to be used for monitoring. //! //! \param leftChannel : Left monitor channel index. //! \param rightChannel : Right monitor channel index. -//! +//! //! \return eNoErr always, the derived classes may return appropriate errors. -//! +//! //********************************************************************************************** WTErr WCMRAudioDevice::SetMonitorChannels (int leftChannel, int rightChannel) { @@ -493,14 +493,14 @@ WTErr WCMRAudioDevice::SetMonitorChannels (int leftChannel, int rightChannel) //********************************************************************************************** -// WCMRAudioDevice::SetMonitorGain +// WCMRAudioDevice::SetMonitorGain // //! Used to set monitor gain (or atten). //! -//! \param newGain : The new gain or atten. value to use. Specified as a linear multiplier (not dB) -//! +//! \param newGain : The new gain or atten. value to use. Specified as a linear multiplier (not dB) +//! //! \return eNoErr always, the derived classes may return appropriate errors. -//! +//! //********************************************************************************************** WTErr WCMRAudioDevice::SetMonitorGain (float newGain) { @@ -514,15 +514,15 @@ WTErr WCMRAudioDevice::SetMonitorGain (float newGain) //********************************************************************************************** -// WCMRAudioDevice::ShowConfigPanel +// WCMRAudioDevice::ShowConfigPanel // //! Used to show device specific config/control panel. Some interfaces may not support it. //! Some interfaces may require the device to be active before it can display a panel. //! //! \param pParam : A device/interface specific parameter - optional. -//! +//! //! \return eNoErr always, the derived classes may return errors. -//! +//! //********************************************************************************************** WTErr WCMRAudioDevice::ShowConfigPanel (void *WCUNUSEDPARAM(pParam)) { @@ -532,16 +532,16 @@ WTErr WCMRAudioDevice::ShowConfigPanel (void *WCUNUSEDPARAM(pParam)) //********************************************************************************************** -// WCMRAudioDevice::SendCustomCommand +// WCMRAudioDevice::SendCustomCommand // -//! Used to Send a custom command to the audiodevice. Some interfaces may require the device +//! Used to Send a custom command to the audiodevice. Some interfaces may require the device //! to be active before it can do anything in this. //! //! \param customCommand : A device/interface specific command. //! \param pCommandParam : A device/interface/command specific parameter - optional. -//! +//! //! \return eNoErr always, the derived classes may return errors. -//! +//! //********************************************************************************************** WTErr WCMRAudioDevice::SendCustomCommand (int WCUNUSEDPARAM(customCommand), void *WCUNUSEDPARAM(pCommandParam)) { @@ -573,10 +573,10 @@ uint32_t WCMRAudioDevice::GetLatency (bool isInput) // //! The constructuor, most of the work will be done in the derived class' constructor. //! -//! \param *pTheClient : -//! +//! \param *pTheClient : +//! //! \return Nothing. -//! +//! //********************************************************************************************** WCMRAudioDeviceManager::WCMRAudioDeviceManager(WCMRAudioDeviceManagerClient *pTheClient, eAudioDeviceFilter eCurAudioDeviceFilter) : m_eAudioDeviceFilter(eCurAudioDeviceFilter) @@ -592,9 +592,9 @@ WCMRAudioDeviceManager::WCMRAudioDeviceManager(WCMRAudioDeviceManagerClient *pTh //! It clears the device list, releasing each of the device. //! //! \param none -//! +//! //! \return Nothing. -//! +//! //********************************************************************************************** WCMRAudioDeviceManager::~WCMRAudioDeviceManager() { @@ -674,15 +674,15 @@ WTErr WCMRAudioDeviceManager::GetDeviceBufferSizes(const std::string & nameToMat //********************************************************************************************** -// WCMRAudioDeviceManager::NotifyClient +// WCMRAudioDeviceManager::NotifyClient // //! A helper routine used to call the client for notification. //! //! \param forReason : The reason for notification. //! \param *pParam : A parameter (if required) for notification. -//! +//! //! \return Nothing. -//! +//! //********************************************************************************************** void WCMRAudioDeviceManager::NotifyClient (WCMRAudioDeviceManagerClient::NotificationReason forReason, void *pParam) { diff --git a/libs/backends/wavesaudio/wavesapi/devicemanager/WCMRCoreAudioDeviceManager.cpp b/libs/backends/wavesaudio/wavesapi/devicemanager/WCMRCoreAudioDeviceManager.cpp index f7f05d7f45..2a9a9ba19f 100644 --- a/libs/backends/wavesaudio/wavesapi/devicemanager/WCMRCoreAudioDeviceManager.cpp +++ b/libs/backends/wavesaudio/wavesapi/devicemanager/WCMRCoreAudioDeviceManager.cpp @@ -18,7 +18,7 @@ #define ENABLE_DEVICE_CHANGE_LISTNER 1 #define PROPERTY_CHANGE_SLEEP_TIME_MILLISECONDS 10 -#define PROPERTY_CHANGE_TIMEOUT_SECONDS 5 +#define PROPERTY_CHANGE_TIMEOUT_SECONDS 5 #define USE_IOCYCLE_TIMES 1 ///< Set this to 0 to use individual thread cpu measurement using namespace wvNS; @@ -34,7 +34,7 @@ static const int gAllBufferSizes[] = { 32, 64, 96, 128, 192, 256, 512, 1024, 2048, -1 /* negative terminated list */ }; - + ///< The default SR. static const int DEFAULT_SR = 44100; @@ -47,29 +47,29 @@ static const int NONE_DEVICE_ID = -1; static const int NUM_STALLS_FOR_NOTIFICATION = 2 * 50; // 2*50 corresponds to 2 * 50 x 42 ms idle timer - about 4 seconds. static const int CHANGE_CHECK_COUNTER_PERIOD = 100; // 120 corresponds to 120 x 42 ms idle timer - about 4 seconds. -#define AUHAL_OUTPUT_ELEMENT 0 +#define AUHAL_OUTPUT_ELEMENT 0 #define AUHAL_INPUT_ELEMENT 1 #include <sys/sysctl.h> -static int getProcessorCount() +static int getProcessorCount() { int count = 1; size_t size = sizeof(count); - if (sysctlbyname("hw.ncpu", &count, &size, NULL, 0)) + if (sysctlbyname("hw.ncpu", &count, &size, NULL, 0)) return 1; //if something did not work, let's revert to a safe value... if (count == 0) count = 1; - - return count; + + return count; } //********************************************************************************************** -// WCMRCoreAudioDevice::WCMRCoreAudioDevice +// WCMRCoreAudioDevice::WCMRCoreAudioDevice // //! Constructor for the audio device. Opens the PA device and gets information about the device. //! such as determining supported sampling rates, buffer sizes, and channel counts. @@ -77,11 +77,11 @@ static int getProcessorCount() //! \param *pManager : The audio device manager that's managing this device. //! \param deviceID : The port audio device ID. //! \param useMultithreading : Whether to use multi-threading for audio processing. Default is true. -//! +//! //! \return Nothing. -//! +//! //********************************************************************************************** -WCMRCoreAudioDevice::WCMRCoreAudioDevice (WCMRCoreAudioDeviceManager *pManager, AudioDeviceID deviceID, bool useMultithreading, bool bNocopy) +WCMRCoreAudioDevice::WCMRCoreAudioDevice (WCMRCoreAudioDeviceManager *pManager, AudioDeviceID deviceID, bool useMultithreading, bool bNocopy) : WCMRNativeAudioDevice (pManager, useMultithreading, bNocopy) , m_SampleCountAtLastIdle (0) , m_StalledSampleCounter(0) @@ -112,16 +112,16 @@ WCMRCoreAudioDevice::WCMRCoreAudioDevice (WCMRCoreAudioDeviceManager *pManager, //Update device info... m_DeviceID = deviceID; - + m_CurrentSamplingRate = DEFAULT_SR; m_CurrentBufferSize = DEFAULT_BUFFERSIZE; m_StopRequested = true; m_pInputData = NULL; - + m_CPUCount = getProcessorCount(); m_LastCPULog = wvThread::now() - 10 * wvThread::ktdOneSecond; - - + + /* @constant kAudioDevicePropertyNominalSampleRate @@ -132,10 +132,10 @@ WCMRCoreAudioDevice::WCMRCoreAudioDevice (WCMRCoreAudioDeviceManager *pManager, err = kAudioHardwareNoError; if (AudioDeviceGetProperty(m_DeviceID, 0, 0, kAudioDevicePropertyNominalSampleRate, &propSize, ¤tNominalRate) != kAudioHardwareNoError) err = AudioDeviceGetProperty(m_DeviceID, 0, 1, kAudioDevicePropertyNominalSampleRate, &propSize, ¤tNominalRate); - + if (err == kAudioHardwareNoError) m_CurrentSamplingRate = (int)currentNominalRate; - + /* @constant kAudioDevicePropertyBufferFrameSize A UInt32 whose value indicates the number of frames in the IO buffers. @@ -146,11 +146,11 @@ WCMRCoreAudioDevice::WCMRCoreAudioDevice (WCMRCoreAudioDeviceManager *pManager, err = kAudioHardwareNoError; if (AudioDeviceGetProperty(m_DeviceID, 0, 0, kAudioDevicePropertyBufferFrameSize, &propSize, &bufferSize) != kAudioHardwareNoError) err = AudioDeviceGetProperty(m_DeviceID, 0, 1, kAudioDevicePropertyBufferFrameSize, &propSize, &bufferSize); - + if (err == kAudioHardwareNoError) m_CurrentBufferSize = (int)bufferSize; - - + + UpdateDeviceInfo(); //should use a valid current SR... @@ -164,7 +164,7 @@ WCMRCoreAudioDevice::WCMRCoreAudioDevice (WCMRCoreAudioDeviceManager *pManager, m_CurrentSamplingRate = m_SamplingRates[0]; } } - + //should use a valid current buffer size if (m_BufferSizes.size()) { @@ -176,7 +176,7 @@ WCMRCoreAudioDevice::WCMRCoreAudioDevice (WCMRCoreAudioDeviceManager *pManager, m_CurrentBufferSize = m_BufferSizes[0]; } } - + //build our input/output level lists for (unsigned int currentChannel = 0; currentChannel < m_InputChannels.size(); currentChannel++) { @@ -188,22 +188,22 @@ WCMRCoreAudioDevice::WCMRCoreAudioDevice (WCMRCoreAudioDeviceManager *pManager, { m_OutputLevels.push_back (0.0); } - + } //********************************************************************************************** -// WCMRCoreAudioDevice::~WCMRCoreAudioDevice +// WCMRCoreAudioDevice::~WCMRCoreAudioDevice // //! Destructor for the audio device. The base release all the connections that were created, if //! they have not been already destroyed! Here we simply stop streaming, and close device //! handles if necessary. //! //! \param none -//! +//! //! \return Nothing. -//! +//! //********************************************************************************************** WCMRCoreAudioDevice::~WCMRCoreAudioDevice () { @@ -216,13 +216,13 @@ WCMRCoreAudioDevice::~WCMRCoreAudioDevice () { SetStreaming (false); } - + //If device is active (meaning stream is open) we need to close it. if (Active()) { SetActive (false); } - + } catch (...) { @@ -234,29 +234,29 @@ WCMRCoreAudioDevice::~WCMRCoreAudioDevice () //********************************************************************************************** -// WCMRCoreAudioDevice::UpdateDeviceInfo +// WCMRCoreAudioDevice::UpdateDeviceInfo // //! Updates Device Information about channels, sampling rates, buffer sizes. -//! +//! //! \return WTErr. -//! +//! //********************************************************************************************** WTErr WCMRCoreAudioDevice::UpdateDeviceInfo () { AUTO_FUNC_DEBUG; - - WTErr retVal = eNoErr; - + + WTErr retVal = eNoErr; + // Some devices change the ID during restart WTErr errId = UpdateDeviceId(); - + // Update all devices parts regardless of errors WTErr errName = UpdateDeviceName(); WTErr errIn = UpdateDeviceInputs(); WTErr errOut = UpdateDeviceOutputs(); - WTErr errSR = eNoErr; - WTErr errBS = eNoErr; - + WTErr errSR = eNoErr; + WTErr errBS = eNoErr; + errSR = UpdateDeviceSampleRates(); errBS = UpdateDeviceBufferSizes(); @@ -264,8 +264,8 @@ WTErr WCMRCoreAudioDevice::UpdateDeviceInfo () { retVal = eCoreAudioFailed; } - - return retVal; + + return retVal; } @@ -278,22 +278,22 @@ WTErr WCMRCoreAudioDevice::UpdateDeviceId() ASSERT_ERROR(osErr, "AudioHardwareGetProperty 1"); if (WUIsError(osErr)) throw osErr; - + size_t numDevices = propSize / sizeof (AudioDeviceID); AudioDeviceID* deviceIDs = new AudioDeviceID[numDevices]; - + //retrieve the device IDs propSize = numDevices * sizeof (AudioDeviceID); osErr = AudioHardwareGetProperty (kAudioHardwarePropertyDevices, &propSize, deviceIDs); ASSERT_ERROR(osErr, "Error while getting audio devices: AudioHardwareGetProperty 2"); if (WUIsError(osErr)) throw osErr; - + //now add the ones that are not there... for (size_t deviceIndex = 0; deviceIndex < numDevices; deviceIndex++) { DeviceInfo* pDevInfo = 0; - + //Get device name and create new DeviceInfo entry //Get property name size. osErr = AudioDeviceGetPropertyInfo(deviceIDs[deviceIndex], 0, 0, kAudioDevicePropertyDeviceName, &propSize, NULL); @@ -306,9 +306,9 @@ WTErr WCMRCoreAudioDevice::UpdateDeviceId() { if ( (m_DeviceName == deviceName) && (m_DeviceID != deviceIDs[deviceIndex]) ) { - + m_DeviceID = deviceIDs[deviceIndex]; - + m_pMyManager->NotifyClient (WCMRAudioDeviceManagerClient::DeviceDebugInfo, (void *)"Current device has changed it's id."); } } @@ -317,7 +317,7 @@ WTErr WCMRCoreAudioDevice::UpdateDeviceId() retVal = eCoreAudioFailed; DEBUG_MSG("Failed to get device name. Device ID: " << m_DeviceID); } - + delete [] deviceName; } else @@ -326,14 +326,14 @@ WTErr WCMRCoreAudioDevice::UpdateDeviceId() DEBUG_MSG("Failed to get device name prop Info. Device ID: " << m_DeviceID); } } - + delete [] deviceIDs; return retVal; } //********************************************************************************************** -// WCMRCoreAudioDevice::UpdateDeviceName +// WCMRCoreAudioDevice::UpdateDeviceName // //! Updates Device name. //! @@ -341,20 +341,20 @@ WTErr WCMRCoreAudioDevice::UpdateDeviceId() //! //! 1. Get property name size. //! 2. Get property: name. -//! +//! //! \return WTErr. -//! +//! //********************************************************************************************** WTErr WCMRCoreAudioDevice::UpdateDeviceName() { AUTO_FUNC_DEBUG; - WTErr retVal = eNoErr; + WTErr retVal = eNoErr; OSStatus err = kAudioHardwareNoError; UInt32 propSize = 0; - + // Initiate name to unknown. m_DeviceName = "Unknown"; - + //! 1. Get property name size. err = AudioDeviceGetPropertyInfo(m_DeviceID, 0, 0, kAudioDevicePropertyDeviceName, &propSize, NULL); if (err == kAudioHardwareNoError) @@ -371,7 +371,7 @@ WTErr WCMRCoreAudioDevice::UpdateDeviceName() retVal = eCoreAudioFailed; DEBUG_MSG("Failed to get device name. Device ID: " << m_DeviceID); } - + delete [] deviceName; } else @@ -379,12 +379,12 @@ WTErr WCMRCoreAudioDevice::UpdateDeviceName() retVal = eCoreAudioFailed; DEBUG_MSG("Failed to get device name property size. Device ID: " << m_DeviceID); } - + return retVal; } //********************************************************************************************** -// WCMRCoreAudioDevice::UpdateDeviceInputs +// WCMRCoreAudioDevice::UpdateDeviceInputs // //! Updates Device Inputs. //! @@ -397,18 +397,18 @@ WTErr WCMRCoreAudioDevice::UpdateDeviceName() //! 1. Get property cannels input size. //! 2. Get property: cannels input. //! 3. Update input channels -//! +//! //! \return WTErr. -//! +//! //********************************************************************************************** WTErr WCMRCoreAudioDevice::UpdateDeviceInputs() { AUTO_FUNC_DEBUG; - WTErr retVal = eNoErr; + WTErr retVal = eNoErr; OSStatus err = kAudioHardwareNoError; UInt32 propSize = 0; int maxInputChannels = 0; - + // 1. Get property cannels input size. err = AudioDeviceGetPropertyInfo (m_DeviceID, 0, 1/* Input */, kAudioDevicePropertyStreamConfiguration, &propSize, NULL); if (err == kAudioHardwareNoError) @@ -417,11 +417,11 @@ WTErr WCMRCoreAudioDevice::UpdateDeviceInputs() // Allocate size according to the property size. Note that this is a variable sized struct... AudioBufferList *pStreamBuffers = (AudioBufferList *)malloc(propSize); - + if (pStreamBuffers) { memset (pStreamBuffers, 0, propSize); - + // Get the Input channels err = AudioDeviceGetProperty (m_DeviceID, 0, true/* Input */, kAudioDevicePropertyStreamConfiguration, &propSize, pStreamBuffers); if (err == kAudioHardwareNoError) @@ -437,7 +437,7 @@ WTErr WCMRCoreAudioDevice::UpdateDeviceInputs() retVal = eCoreAudioFailed; DEBUG_MSG("Failed to get device Input channels. Device Name: " << m_DeviceName.c_str()); } - + free (pStreamBuffers); } else @@ -451,24 +451,24 @@ WTErr WCMRCoreAudioDevice::UpdateDeviceInputs() retVal = eCoreAudioFailed; DEBUG_MSG("Failed to get device Input channels property size. Device Name: " << m_DeviceName.c_str()); } - + // Update input channels m_InputChannels.clear(); - + for (int channel = 0; channel < maxInputChannels; channel++) { CFStringRef cfName; std::stringstream chNameStream; UInt32 nameSize = 0; OSStatus error = kAudioHardwareNoError; - + error = AudioDeviceGetPropertyInfo (m_DeviceID, channel + 1, true /* Input */, kAudioDevicePropertyChannelNameCFString, &nameSize, NULL); - + if (error == kAudioHardwareNoError) { error = AudioDeviceGetProperty (m_DeviceID, @@ -478,7 +478,7 @@ WTErr WCMRCoreAudioDevice::UpdateDeviceInputs() &nameSize, &cfName); } - + bool decoded = false; char* cstr_name = 0; if (error == kAudioHardwareNoError) @@ -488,9 +488,9 @@ WTErr WCMRCoreAudioDevice::UpdateDeviceInputs() cstr_name = new char[maxSize]; decoded = CFStringGetCString(cfName, cstr_name, maxSize, kCFStringEncodingUTF8); } - + chNameStream << (channel+1) << " - "; - + if (cstr_name && decoded && (0 != std::strlen(cstr_name) ) ) { chNameStream << cstr_name; } @@ -500,15 +500,15 @@ WTErr WCMRCoreAudioDevice::UpdateDeviceInputs() } m_InputChannels.push_back (chNameStream.str()); - + delete [] cstr_name; } - + return retVal; } //********************************************************************************************** -// WCMRCoreAudioDevice::UpdateDeviceOutputs +// WCMRCoreAudioDevice::UpdateDeviceOutputs // //! Updates Device Outputs. //! @@ -521,31 +521,31 @@ WTErr WCMRCoreAudioDevice::UpdateDeviceInputs() //! 1. Get property cannels output size. //! 2. Get property: cannels output. //! 3. Update output channels -//! +//! //! \return Nothing. -//! +//! //********************************************************************************************** WTErr WCMRCoreAudioDevice::UpdateDeviceOutputs() { AUTO_FUNC_DEBUG; - - WTErr retVal = eNoErr; + + WTErr retVal = eNoErr; OSStatus err = kAudioHardwareNoError; UInt32 propSize = 0; int maxOutputChannels = 0; - + //! 1. Get property cannels output size. err = AudioDeviceGetPropertyInfo (m_DeviceID, 0, 0/* Output */, kAudioDevicePropertyStreamConfiguration, &propSize, NULL); if (err == kAudioHardwareNoError) { //! 2. Get property: cannels output. - + // Allocate size according to the property size. Note that this is a variable sized struct... AudioBufferList *pStreamBuffers = (AudioBufferList *)malloc(propSize); if (pStreamBuffers) { memset (pStreamBuffers, 0, propSize); - + // Get the Output channels err = AudioDeviceGetProperty (m_DeviceID, 0, 0/* Output */, kAudioDevicePropertyStreamConfiguration, &propSize, pStreamBuffers); if (err == kAudioHardwareNoError) @@ -574,7 +574,7 @@ WTErr WCMRCoreAudioDevice::UpdateDeviceOutputs() retVal = eCoreAudioFailed; DEBUG_MSG("Failed to get device Output channels property size. Device Name: " << m_DeviceName.c_str()); } - + // Update output channels m_OutputChannels.clear(); for (int channel = 0; channel < maxOutputChannels; channel++) @@ -583,14 +583,14 @@ WTErr WCMRCoreAudioDevice::UpdateDeviceOutputs() std::stringstream chNameStream; UInt32 nameSize = 0; OSStatus error = kAudioHardwareNoError; - + error = AudioDeviceGetPropertyInfo (m_DeviceID, channel + 1, false /* Output */, kAudioDevicePropertyChannelNameCFString, &nameSize, NULL); - + if (error == kAudioHardwareNoError) { error = AudioDeviceGetProperty (m_DeviceID, @@ -600,7 +600,7 @@ WTErr WCMRCoreAudioDevice::UpdateDeviceOutputs() &nameSize, &cfName); } - + bool decoded = false; char* cstr_name = 0; if (error == kAudioHardwareNoError ) @@ -610,9 +610,9 @@ WTErr WCMRCoreAudioDevice::UpdateDeviceOutputs() cstr_name = new char[maxSize]; decoded = CFStringGetCString(cfName, cstr_name, maxSize, kCFStringEncodingUTF8); } - + chNameStream << (channel+1) << " - "; - + if (cstr_name && decoded && (0 != std::strlen(cstr_name) ) ) { chNameStream << cstr_name; } @@ -620,17 +620,17 @@ WTErr WCMRCoreAudioDevice::UpdateDeviceOutputs() { chNameStream << "Output " << (channel+1); } - + m_OutputChannels.push_back (chNameStream.str()); - + delete [] cstr_name; } - + return retVal; } //********************************************************************************************** -// WCMRCoreAudioDevice::UpdateDeviceSampleRates +// WCMRCoreAudioDevice::UpdateDeviceSampleRates // //! Updates Device Sample rates. //! @@ -639,43 +639,43 @@ WTErr WCMRCoreAudioDevice::UpdateDeviceOutputs() //! 1. Get sample rate property size. //! 2. Get property: sample rates. //! 3. Update sample rates -//! +//! //! \return Nothing. -//! +//! //********************************************************************************************** WTErr WCMRCoreAudioDevice::UpdateDeviceSampleRates() { AUTO_FUNC_DEBUG; - - WTErr retVal = eNoErr; + + WTErr retVal = eNoErr; OSStatus err = kAudioHardwareNoError; UInt32 propSize = 0; - + m_SamplingRates.clear(); - + //! 1. Get sample rate property size. err = AudioDeviceGetPropertyInfo(m_DeviceID, 0, 0, kAudioDevicePropertyAvailableNominalSampleRates, &propSize, NULL); if (err == kAudioHardwareNoError) { //! 2. Get property: cannels output. - + // Allocate size accrding to the number of audio values int numRates = propSize / sizeof(AudioValueRange); AudioValueRange* supportedRates = new AudioValueRange[numRates]; - + // Get sampling rates from Audio device err = AudioDeviceGetProperty(m_DeviceID, 0, 0, kAudioDevicePropertyAvailableNominalSampleRates, &propSize, supportedRates); if (err == kAudioHardwareNoError) { //! 3. Update sample rates - + // now iterate through our standard SRs for(int ourSR=0; gAllSampleRates[ourSR] > 0; ourSR++) { //check to see if our SR is in the supported rates... for (int deviceSR = 0; deviceSR < numRates; deviceSR++) { - if ((supportedRates[deviceSR].mMinimum <= gAllSampleRates[ourSR]) && + if ((supportedRates[deviceSR].mMinimum <= gAllSampleRates[ourSR]) && (supportedRates[deviceSR].mMaximum >= gAllSampleRates[ourSR])) { m_SamplingRates.push_back ((int)gAllSampleRates[ourSR]); @@ -689,7 +689,7 @@ WTErr WCMRCoreAudioDevice::UpdateDeviceSampleRates() retVal = eCoreAudioFailed; DEBUG_MSG("Failed to get device Sample rates. Device Name: " << m_DeviceName.c_str()); } - + delete [] supportedRates; } else @@ -697,13 +697,13 @@ WTErr WCMRCoreAudioDevice::UpdateDeviceSampleRates() retVal = eCoreAudioFailed; DEBUG_MSG("Failed to get device Sample rates property size. Device Name: " << m_DeviceName.c_str()); } - + return retVal; } //********************************************************************************************** -// WCMRCoreAudioDevice::UpdateDeviceBufferSizes_Simple +// WCMRCoreAudioDevice::UpdateDeviceBufferSizes_Simple // // Use kAudioDevicePropertyBufferFrameSizeRange // @@ -712,21 +712,21 @@ WTErr WCMRCoreAudioDevice::UpdateDeviceSampleRates() // // 1. Get buffer size range // 2. Run on all ranges and add them to the list -// +// // \return error code -// +// //********************************************************************************************** WTErr WCMRCoreAudioDevice::UpdateDeviceBufferSizes () { AUTO_FUNC_DEBUG; - + WTErr retVal = eNoErr; OSStatus err = kAudioHardwareNoError; UInt32 propSize = 0; - + // Clear buffer sizes m_BufferSizes.clear(); - + // 1. Get buffer size range AudioValueRange bufferSizesRange; propSize = sizeof (AudioValueRange); @@ -741,7 +741,7 @@ WTErr WCMRCoreAudioDevice::UpdateDeviceBufferSizes () m_BufferSizes.push_back (gAllBufferSizes[bsize]); } } - + //if we didn't get a single hit, let's simply add the min. and the max... if (m_BufferSizes.empty()) { @@ -754,21 +754,21 @@ WTErr WCMRCoreAudioDevice::UpdateDeviceBufferSizes () retVal = eCoreAudioFailed; DEBUG_MSG("Failed to get device buffer sizes range. Device Name: " << m_DeviceName.c_str()); } - + return retVal; } //********************************************************************************************** -// WCMRCoreAudioDevice::DeviceName +// WCMRCoreAudioDevice::DeviceName // //! in case of 'eMatchedDuplexDevices' and a matching device exists return common device name //! in all other cases retur base class function implementation //! //! \param none -//! +//! //! \return current device name -//! +//! //********************************************************************************************** const std::string& WCMRCoreAudioDevice::DeviceName() const { @@ -776,14 +776,14 @@ const std::string& WCMRCoreAudioDevice::DeviceName() const } //********************************************************************************************** -// WCMRCoreAudioDevice::InputChannels +// WCMRCoreAudioDevice::InputChannels // //! return base class function implementation //! //! \param none -//! +//! //! \return base class function implementation -//! +//! //********************************************************************************************** const std::vector<std::string>& WCMRCoreAudioDevice::InputChannels() { @@ -791,15 +791,15 @@ const std::vector<std::string>& WCMRCoreAudioDevice::InputChannels() } //********************************************************************************************** -// WCMRCoreAudioDevice::OutputChannels +// WCMRCoreAudioDevice::OutputChannels // //! in case of 'eMatchedDuplexDevices' return matching device output channel if there is one //! in all other cases retur base class function implementation //! //! \param none -//! +//! //! \return list of output channels of current device -//! +//! //********************************************************************************************** const std::vector<std::string>& WCMRCoreAudioDevice::OutputChannels() { @@ -808,15 +808,15 @@ const std::vector<std::string>& WCMRCoreAudioDevice::OutputChannels() //********************************************************************************************** -// WCMRCoreAudioDevice::SamplingRates +// WCMRCoreAudioDevice::SamplingRates // //! in case of 'eMatchedDuplexDevices' and a matching device exists return common sample rate //! in all other cases retur base class function implementation //! //! \param none -//! +//! //! \return current sample rate -//! +//! //********************************************************************************************** const std::vector<int>& WCMRCoreAudioDevice::SamplingRates() { @@ -824,15 +824,15 @@ const std::vector<int>& WCMRCoreAudioDevice::SamplingRates() } //********************************************************************************************** -// WCMRCoreAudioDevice::CurrentSamplingRate +// WCMRCoreAudioDevice::CurrentSamplingRate // -//! The device's current sampling rate. This may be overridden, if the device needs to +//! The device's current sampling rate. This may be overridden, if the device needs to //! query the driver for the current rate. //! //! \param none -//! +//! //! \return The device's current sampling rate. -1 on error. -//! +//! //********************************************************************************************** int WCMRCoreAudioDevice::CurrentSamplingRate () { @@ -846,7 +846,7 @@ int WCMRCoreAudioDevice::CurrentSamplingRate () err = kAudioHardwareNoError; if (AudioDeviceGetProperty(m_DeviceID, 0, 0, kAudioDevicePropertyNominalSampleRate, &propSize, ¤tNominalRate) != kAudioHardwareNoError) err = AudioDeviceGetProperty(m_DeviceID, 0, 1, kAudioDevicePropertyNominalSampleRate, &propSize, ¤tNominalRate); - + if (err == kAudioHardwareNoError) m_CurrentSamplingRate = (int)currentNominalRate; else @@ -861,14 +861,14 @@ int WCMRCoreAudioDevice::CurrentSamplingRate () //********************************************************************************************** -// WCMRCoreAudioDevice::SetCurrentSamplingRate +// WCMRCoreAudioDevice::SetCurrentSamplingRate // -//! Change the sampling rate to be used by the device. +//! Change the sampling rate to be used by the device. //! //! \param newRate : The rate to use (samples per sec). -//! +//! //! \return eNoErr always. The derived classes may return error codes. -//! +//! //********************************************************************************************** WTErr WCMRCoreAudioDevice::SetCurrentSamplingRate (int newRate) { @@ -879,7 +879,7 @@ WTErr WCMRCoreAudioDevice::SetCurrentSamplingRate (int newRate) //changes the status. int oldRate = CurrentSamplingRate(); bool oldActive = Active(); - + //no change, nothing to do if (oldRate == newRate) goto Exit; @@ -892,7 +892,7 @@ WTErr WCMRCoreAudioDevice::SetCurrentSamplingRate (int newRate) retVal = eCommandLineParameter; goto Exit; } - + if (Streaming()) { //Can't change, perhaps use an "in use" type of error @@ -905,34 +905,34 @@ WTErr WCMRCoreAudioDevice::SetCurrentSamplingRate (int newRate) //Deactivate it for the change... SetActive (false); } - + retVal = SetAndCheckCurrentSamplingRate (newRate); if(retVal == eNoErr) { retVal = UpdateDeviceInfo (); } - //reactivate it. + //reactivate it. if (oldActive) { retVal = SetActive (true); } - + Exit: return (retVal); - + } //********************************************************************************************** -// WCMRCoreAudioDevice::SetAndCheckCurrentSamplingRate +// WCMRCoreAudioDevice::SetAndCheckCurrentSamplingRate // -//! Change the sampling rate to be used by the device. +//! Change the sampling rate to be used by the device. //! //! \param newRate : The rate to use (samples per sec). -//! +//! //! \return eNoErr always. The derived classes may return error codes. -//! +//! //********************************************************************************************** WTErr WCMRCoreAudioDevice::SetAndCheckCurrentSamplingRate (int newRate) { @@ -941,12 +941,12 @@ WTErr WCMRCoreAudioDevice::SetAndCheckCurrentSamplingRate (int newRate) WTErr retVal = eNoErr; OSStatus err = kAudioHardwareNoError; UInt32 propSize = 0; - + // 1. Set new sampling rate Float64 newNominalRate = newRate; propSize = sizeof (Float64); err = AudioDeviceSetProperty(m_DeviceID, NULL, 0, 0, kAudioDevicePropertyNominalSampleRate, propSize, &newNominalRate); - + if (err != kAudioHardwareNoError) { retVal = eCoreAudioFailed; @@ -955,12 +955,12 @@ WTErr WCMRCoreAudioDevice::SetAndCheckCurrentSamplingRate (int newRate) else { // 2. wait for the SR to actually change... - + // Set total time out time int tryAgain = ((PROPERTY_CHANGE_TIMEOUT_SECONDS * 1000) / PROPERTY_CHANGE_SLEEP_TIME_MILLISECONDS) ; int actualWait = 0; Float64 actualSamplingRate = 0.0; - + // Run as ling as time out is not finished while (tryAgain) { @@ -980,21 +980,21 @@ WTErr WCMRCoreAudioDevice::SetAndCheckCurrentSamplingRate (int newRate) m_pMyManager->NotifyClient (WCMRAudioDeviceManagerClient::DeviceDebugInfo, (void *)"Could not read Sampling Rate for verification."); DEBUG_MSG ("Unable to get SR. Device name: " << m_DeviceName.c_str()); } - + // oh well...there's always another millisecond... wvThread::sleep_milliseconds (PROPERTY_CHANGE_SLEEP_TIME_MILLISECONDS); tryAgain--; actualWait++; } - + // If sample rate actually changed if (tryAgain != 0) { m_pMyManager->NotifyClient (WCMRAudioDeviceManagerClient::DeviceDebugInfo, (void *)"Changed the Sampling Rate."); - + // Update member with new rate m_CurrentSamplingRate = newRate; - + char debugMsg[128]; snprintf (debugMsg, sizeof(debugMsg), "Actual Wait for SR Change was %d milliseconds", actualWait * PROPERTY_CHANGE_SLEEP_TIME_MILLISECONDS); m_pMyManager->NotifyClient (WCMRAudioDeviceManagerClient::DeviceDebugInfo, (void *)debugMsg); @@ -1010,15 +1010,15 @@ WTErr WCMRCoreAudioDevice::SetAndCheckCurrentSamplingRate (int newRate) found = true; } } - + if (found) { // Update member with last read value m_CurrentSamplingRate = static_cast<int>(actualSamplingRate); - + char debugMsg[128]; snprintf (debugMsg, sizeof(debugMsg), "Unable to change SR, even after waiting for %d milliseconds", actualWait * PROPERTY_CHANGE_SLEEP_TIME_MILLISECONDS); m_pMyManager->NotifyClient (WCMRAudioDeviceManagerClient::DeviceDebugInfo, (void *)debugMsg); - + float sample_rate_update = actualSamplingRate; m_pMyManager->NotifyClient (WCMRAudioDeviceManagerClient::SamplingRateChanged, (void *)&sample_rate_update); } else { @@ -1026,21 +1026,21 @@ WTErr WCMRCoreAudioDevice::SetAndCheckCurrentSamplingRate (int newRate) } } } - + return (retVal); } //********************************************************************************************** -// WCMRCoreAudioDevice::BufferSizes +// WCMRCoreAudioDevice::BufferSizes // //! in case of 'eMatchedDuplexDevices' and a matching device exists return common buffer sizes //! in all other cases retur base class function implementation //! //! \param none -//! +//! //! \return current sample rate -//! +//! //********************************************************************************************** const std::vector<int>& WCMRCoreAudioDevice::BufferSizes() { @@ -1051,13 +1051,13 @@ const std::vector<int>& WCMRCoreAudioDevice::BufferSizes() //********************************************************************************************** // WCMRCoreAudioDevice::CurrentBufferSize // -//! The device's current buffer size in use. This may be overridden, if the device needs to +//! The device's current buffer size in use. This may be overridden, if the device needs to //! query the driver for the current size. //! //! \param none -//! +//! //! \return The device's current buffer size. 0 on error. -//! +//! //********************************************************************************************** int WCMRCoreAudioDevice::CurrentBufferSize () { @@ -1071,13 +1071,13 @@ int WCMRCoreAudioDevice::CurrentBufferSize () //********************************************************************************************** // WCMRCoreAudioDevice::SetCurrentBufferSize // -//! Change the buffer size to be used by the device. This will most likely be overridden, +//! Change the buffer size to be used by the device. This will most likely be overridden, //! the base class simply updates the member variable. //! //! \param newSize : The buffer size to use (in sample-frames) -//! +//! //! \return eNoErr always. The derived classes may return error codes. -//! +//! //********************************************************************************************** WTErr WCMRCoreAudioDevice::SetCurrentBufferSize (int newSize) { @@ -1092,20 +1092,20 @@ WTErr WCMRCoreAudioDevice::SetCurrentBufferSize (int newSize) //same size, nothing to do. if (oldSize == newSize) goto Exit; - + if (Streaming()) { //Can't change, perhaps use an "in use" type of error retVal = eGenericErr; goto Exit; } - + if (oldActive) { //Deactivate it for the change... SetActive (false); } - + // when audio device is inactive it is safe to set a working buffer size according to new buffer size // if 'newSize' is not a valid buffer size, another valid buffer size will be set retVal = SetWorkingBufferSize(newSize); @@ -1115,7 +1115,7 @@ WTErr WCMRCoreAudioDevice::SetCurrentBufferSize (int newSize) goto Exit; } - //reactivate it. + //reactivate it. if (oldActive) { retVal = SetActive (true); @@ -1125,9 +1125,9 @@ WTErr WCMRCoreAudioDevice::SetCurrentBufferSize (int newSize) goto Exit; } } - + Exit: - + return (retVal); } @@ -1136,10 +1136,10 @@ WTErr WCMRCoreAudioDevice::SetWorkingBufferSize(int newSize) AUTO_FUNC_DEBUG; WTErr retVal = eNoErr; OSStatus err = kAudioHardwareNoError; - + // 1. Set new buffer size err = SetBufferSizesByIO(newSize); - + // If there's no error it means this buffer size is supported if(err == kAudioHardwareNoError) { @@ -1151,18 +1151,18 @@ WTErr WCMRCoreAudioDevice::SetWorkingBufferSize(int newSize) // In case the new buffer size could not be set, set another working buffer size // Run on all buffer sizes: - + // Try setting buffer sizes that are bigger then selected buffer size first, - // Since bigger buffer sizes usually work safer + // Since bigger buffer sizes usually work safer for(std::vector<int>::const_iterator iter = m_BufferSizes.begin();iter != m_BufferSizes.end();++iter) { int nCurBS = *iter; - + if(nCurBS > newSize) { // Try setting current buffer size err = SetBufferSizesByIO(nCurBS); - + // in case buffer size is valid if(err == kAudioHardwareNoError) { @@ -1172,19 +1172,19 @@ WTErr WCMRCoreAudioDevice::SetWorkingBufferSize(int newSize) } } } - + // If bigger buffer sizes failed, go to smaller buffer sizes if(err != kAudioHardwareNoError) { for(std::vector<int>::const_iterator iter = m_BufferSizes.begin();iter != m_BufferSizes.end();++iter) { int nCurBS = *iter; - + if(nCurBS < newSize) { // Try setting current buffer size err = SetBufferSizesByIO(*iter); - + // in case buffer size is valid if(err == kAudioHardwareNoError) { @@ -1195,7 +1195,7 @@ WTErr WCMRCoreAudioDevice::SetWorkingBufferSize(int newSize) } } } - + // Check if a valid buffer size was found if(err == kAudioHardwareNoError) { @@ -1212,18 +1212,18 @@ WTErr WCMRCoreAudioDevice::SetWorkingBufferSize(int newSize) DEBUG_MSG("Unable to set any buffer size. Device Name: " << m_DeviceName.c_str()); } } - + return retVal; } OSStatus WCMRCoreAudioDevice::SetBufferSizesByIO(int newSize) { OSStatus err = kAudioHardwareNoError; - + // 1. Set new buffer size UInt32 bufferSize = (UInt32)newSize; UInt32 propSize = sizeof (UInt32); - + // Set new buffer size to input if (!m_InputChannels.empty()) { @@ -1233,27 +1233,27 @@ OSStatus WCMRCoreAudioDevice::SetBufferSizesByIO(int newSize) { err = AudioDeviceSetProperty(m_DeviceID, NULL, 0, 0, kAudioDevicePropertyBufferFrameSize, propSize, &bufferSize); } - + return err; } //********************************************************************************************** -// WCMRCoreAudioDevice::ConnectionStatus +// WCMRCoreAudioDevice::ConnectionStatus // //! Retrieves the device's current connection status. This will most likely be overridden, //! in case some driver communication is required to query the status. //! //! \param none -//! +//! //! \return A ConnectionStates value. -//! +//! //********************************************************************************************** WCMRCoreAudioDevice::ConnectionStates WCMRCoreAudioDevice::ConnectionStatus () { AUTO_FUNC_DEBUG; //ToDo: May want to do something more to extract the actual status! return (m_ConnectionStatus); - + } @@ -1263,25 +1263,25 @@ WCMRCoreAudioDevice::ConnectionStates WCMRCoreAudioDevice::ConnectionStatus () //! Sets up the AUHAL for IO, allowing changes to the devices to be used by the AudioUnit. //! //! \param none -//! +//! //! \return eNoErr on success, an error code on failure. -//! +//! //********************************************************************************************** WTErr WCMRCoreAudioDevice::EnableAudioUnitIO() { AUTO_FUNC_DEBUG; WTErr retVal = eNoErr; OSStatus err = kAudioHardwareNoError; - + UInt32 enableIO = 1; if (!m_InputChannels.empty()) { /////////////// //ENABLE IO (INPUT) - //You must enable the Audio Unit (AUHAL) for input - + //You must enable the Audio Unit (AUHAL) for input + //Enable input on the AUHAL - err = AudioUnitSetProperty(m_AUHALAudioUnit, + err = AudioUnitSetProperty(m_AUHALAudioUnit, kAudioOutputUnitProperty_EnableIO, kAudioUnitScope_Input, AUHAL_INPUT_ELEMENT, &enableIO, sizeof(enableIO)); @@ -1293,18 +1293,18 @@ WTErr WCMRCoreAudioDevice::EnableAudioUnitIO() goto Exit; } } - + //disable Output on the AUHAL if there's no output if (m_OutputChannels.empty()) enableIO = 0; else enableIO = 1; - + err = AudioUnitSetProperty(m_AUHALAudioUnit, kAudioOutputUnitProperty_EnableIO, kAudioUnitScope_Output, AUHAL_OUTPUT_ELEMENT, &enableIO, sizeof(enableIO)); - + if (err) { DEBUG_MSG("Couldn't Enable/Disable IO on output scope of output element, error = " << err); @@ -1323,9 +1323,9 @@ Exit: //! Sets up listeners to listen for Audio Device property changes, so that app can be notified. //! //! \param none -//! +//! //! \return eNoErr on success, an error code on failure. -//! +//! //********************************************************************************************** WTErr WCMRCoreAudioDevice::EnableListeners() { @@ -1336,7 +1336,7 @@ WTErr WCMRCoreAudioDevice::EnableListeners() //listner for SR change... err = AudioDeviceAddPropertyListener(m_DeviceID, 0, 0, kAudioDevicePropertyNominalSampleRate, StaticPropertyChangeProc, this); - + if (err) { DEBUG_MSG("Couldn't Setup SR Property Listner, error = " << err); @@ -1347,14 +1347,14 @@ WTErr WCMRCoreAudioDevice::EnableListeners() #if ENABLE_DEVICE_CHANGE_LISTNER { //listner for device change... - + err = AudioDeviceAddPropertyListener (m_DeviceID, kAudioPropertyWildcardChannel, true, kAudioDevicePropertyDeviceHasChanged, StaticPropertyChangeProc, this); - + if (err) { DEBUG_MSG("Couldn't Setup device change Property Listner, error = " << err); @@ -1362,21 +1362,21 @@ WTErr WCMRCoreAudioDevice::EnableListeners() goto Exit; } } -#endif //ENABLE_DEVICE_CHANGE_LISTNER - +#endif //ENABLE_DEVICE_CHANGE_LISTNER + //listner for dropouts... err = AudioDeviceAddPropertyListener(m_DeviceID, 0, 0, kAudioDeviceProcessorOverload, StaticPropertyChangeProc, this); - + if (err) { DEBUG_MSG("Couldn't Setup Processor Overload Property Listner, error = " << err); retVal = eGenericErr; goto Exit; } - -Exit: + +Exit: return retVal; } @@ -1388,9 +1388,9 @@ Exit: //! Undoes the work done by EnableListeners //! //! \param none -//! +//! //! \return eNoErr on success, an error code on failure. -//! +//! //********************************************************************************************** WTErr WCMRCoreAudioDevice::DisableListeners() { @@ -1401,39 +1401,39 @@ WTErr WCMRCoreAudioDevice::DisableListeners() //listner for SR change... err = AudioDeviceRemovePropertyListener(m_DeviceID, 0, 0, kAudioDevicePropertyNominalSampleRate, StaticPropertyChangeProc); - + if (err) { DEBUG_MSG("Couldn't Cleanup SR Property Listner, error = " << err); //not sure if we need to report this... } -#if ENABLE_DEVICE_CHANGE_LISTNER +#if ENABLE_DEVICE_CHANGE_LISTNER { err = AudioDeviceRemovePropertyListener (m_DeviceID, kAudioPropertyWildcardChannel, true/* Input */, kAudioDevicePropertyDeviceHasChanged, StaticPropertyChangeProc); - + if (err) { DEBUG_MSG("Couldn't Cleanup device input stream change Property Listner, error = " << err); //not sure if we need to report this... } - + } -#endif //ENABLE_DEVICE_CHANGE_LISTNER +#endif //ENABLE_DEVICE_CHANGE_LISTNER err = AudioDeviceRemovePropertyListener(m_DeviceID, 0, 0, kAudioDeviceProcessorOverload, StaticPropertyChangeProc); - + if (err) { DEBUG_MSG("Couldn't Cleanup device change Property Listner, error = " << err); //not sure if we need to report this... } - + return retVal; } @@ -1450,9 +1450,9 @@ WTErr WCMRCoreAudioDevice::DisableListeners() //! \param isInput : If the change is for Input. //! \param inPropertyID : The property that has changed. //! \param inClientData: What was passed when listener was enabled, in our case teh WCMRCoreAudioDevice object. -//! +//! //! \return 0 always. -//! +//! //********************************************************************************************** OSStatus WCMRCoreAudioDevice::StaticPropertyChangeProc (AudioDeviceID /*inDevice*/, UInt32 /*inChannel*/, Boolean /*isInput*/, AudioDevicePropertyID inPropertyID, void *inClientData) @@ -1462,7 +1462,7 @@ OSStatus WCMRCoreAudioDevice::StaticPropertyChangeProc (AudioDeviceID /*inDevice WCMRCoreAudioDevice* pCoreDevice = (WCMRCoreAudioDevice *)inClientData; pCoreDevice->PropertyChangeProc (inPropertyID); } - + return 0; } @@ -1475,9 +1475,9 @@ OSStatus WCMRCoreAudioDevice::StaticPropertyChangeProc (AudioDeviceID /*inDevice //! on an arbitrary thread, we simply update the request counters and return. //! //! \param none -//! +//! //! \return nothing. -//! +//! //********************************************************************************************** void WCMRCoreAudioDevice::PropertyChangeProc (AudioDevicePropertyID inPropertyID) { @@ -1486,14 +1486,14 @@ void WCMRCoreAudioDevice::PropertyChangeProc (AudioDevicePropertyID inPropertyID case kAudioDevicePropertyNominalSampleRate: m_SRChangeRequested++; break; -#if ENABLE_DEVICE_CHANGE_LISTNER +#if ENABLE_DEVICE_CHANGE_LISTNER case kAudioDevicePropertyDeviceHasChanged: { m_ResetRequested++; m_pMyManager->NotifyClient (WCMRAudioDeviceManagerClient::RequestReset); } break; -#endif //ENABLE_DEVICE_CHANGE_LISTNER +#endif //ENABLE_DEVICE_CHANGE_LISTNER case kAudioDeviceProcessorOverload: { if (m_IgnoreThisDrop) @@ -1515,9 +1515,9 @@ void WCMRCoreAudioDevice::PropertyChangeProc (AudioDevicePropertyID inPropertyID //! Sets up the AUHAL AudioUnit for device IO. //! //! \param none -//! +//! //! \return eNoErr on success, an error code on failure. -//! +//! //********************************************************************************************** WTErr WCMRCoreAudioDevice::SetupAUHAL() { @@ -1533,17 +1533,17 @@ WTErr WCMRCoreAudioDevice::SetupAUHAL() //Some audio units serve as Outputs, Mixers, or DSP //units. See AUComponent.h for listing desc.componentType = kAudioUnitType_Output; - + //Every Component has a subType, which will give a clearer picture //of what this components function will be. desc.componentSubType = kAudioUnitSubType_HALOutput; - - //all Audio Units in AUComponent.h must use + + //all Audio Units in AUComponent.h must use //"kAudioUnitManufacturer_Apple" as the Manufacturer desc.componentManufacturer = kAudioUnitManufacturer_Apple; desc.componentFlags = 0; desc.componentFlagsMask = 0; - + //Finds a component that meets the desc spec's comp = FindNextComponent(NULL, &desc); if (comp == NULL) @@ -1552,17 +1552,17 @@ WTErr WCMRCoreAudioDevice::SetupAUHAL() retVal = eGenericErr; goto Exit; } - + //gains access to the services provided by the component - OpenAComponent(comp, &m_AUHALAudioUnit); + OpenAComponent(comp, &m_AUHALAudioUnit); + - retVal = EnableAudioUnitIO(); if (retVal != eNoErr) goto Exit; //Now setup the device to use by the audio unit... - + //input if (!m_InputChannels.empty()) { @@ -1592,7 +1592,7 @@ WTErr WCMRCoreAudioDevice::SetupAUHAL() goto Exit; } } - + //also set Sample Rate... { retVal = SetAndCheckCurrentSamplingRate(m_CurrentSamplingRate); @@ -1612,10 +1612,10 @@ WTErr WCMRCoreAudioDevice::SetupAUHAL() //we don't really quit here..., just keep going even if this does not work, //the AUHAL is supposed to take care of this by way of slicing... m_pMyManager->NotifyClient (WCMRAudioDeviceManagerClient::DeviceDebugInfo, (void *)"Could not set buffer size."); - + } } - + //convertor quality { UInt32 quality = kAudioConverterQuality_Max; @@ -1624,7 +1624,7 @@ WTErr WCMRCoreAudioDevice::SetupAUHAL() kAudioUnitProperty_RenderQuality, kAudioUnitScope_Global, AUHAL_OUTPUT_ELEMENT, &quality, sizeof (quality)); - + if (err != kAudioHardwareNoError) { DEBUG_MSG ("Unable to set Convertor Quality, error = " << err); @@ -1632,7 +1632,7 @@ WTErr WCMRCoreAudioDevice::SetupAUHAL() goto Exit; } } - + memset (&auhalStreamFormat, 0, sizeof (auhalStreamFormat)); propSize = sizeof (auhalStreamFormat); err = AudioUnitGetProperty(m_AUHALAudioUnit, @@ -1645,12 +1645,12 @@ WTErr WCMRCoreAudioDevice::SetupAUHAL() retVal = eGenericErr; goto Exit; } - + if (auhalStreamFormat.mSampleRate != (Float64)m_CurrentSamplingRate) { TRACE_MSG ("AUHAL's Input SR differs from expected SR, expected = " << m_CurrentSamplingRate << ", AUHAL's = " << (UInt32)auhalStreamFormat.mSampleRate); } - + //format, and slice size... memset (&streamFormatToUse, 0, sizeof (streamFormatToUse)); streamFormatToUse.mFormatID = kAudioFormatLinearPCM; @@ -1676,7 +1676,7 @@ WTErr WCMRCoreAudioDevice::SetupAUHAL() retVal = eGenericErr; goto Exit; } - + UInt32 bufferSize = m_CurrentBufferSize; err = AudioUnitSetProperty(m_AUHALAudioUnit, kAudioUnitProperty_MaximumFramesPerSlice, kAudioUnitScope_Output, @@ -1689,7 +1689,7 @@ WTErr WCMRCoreAudioDevice::SetupAUHAL() retVal = eGenericErr; goto Exit; } - + } if (!m_OutputChannels.empty()) @@ -1704,13 +1704,13 @@ WTErr WCMRCoreAudioDevice::SetupAUHAL() retVal = eGenericErr; goto Exit; } - + if (auhalStreamFormat.mSampleRate != (Float64)m_CurrentSamplingRate) { TRACE_MSG ("AUHAL's Output SR differs from expected SR, expected = " << m_CurrentSamplingRate << ", AUHAL's = " << (UInt32)auhalStreamFormat.mSampleRate); } - - + + streamFormatToUse.mChannelsPerFrame = m_OutputChannels.size(); streamFormatToUse.mBytesPerFrame = sizeof (float)*streamFormatToUse.mChannelsPerFrame; streamFormatToUse.mBytesPerPacket = streamFormatToUse.mBytesPerFrame; @@ -1742,7 +1742,7 @@ WTErr WCMRCoreAudioDevice::SetupAUHAL() } } - + //setup callback (IOProc) { AURenderCallbackStruct renderCallback; @@ -1750,13 +1750,13 @@ WTErr WCMRCoreAudioDevice::SetupAUHAL() propSize = sizeof (renderCallback); renderCallback.inputProc = StaticAudioIOProc; renderCallback.inputProcRefCon = this; - + err = AudioUnitSetProperty(m_AUHALAudioUnit, (m_OutputChannels.empty() ? (AudioUnitPropertyID)kAudioOutputUnitProperty_SetInputCallback : (AudioUnitPropertyID)kAudioUnitProperty_SetRenderCallback), kAudioUnitScope_Output, m_OutputChannels.empty() ? AUHAL_INPUT_ELEMENT : AUHAL_OUTPUT_ELEMENT, &renderCallback, sizeof (renderCallback)); - + if (err != kAudioHardwareNoError) { DEBUG_MSG ("Unable to set callback, error = " << err); @@ -1768,7 +1768,7 @@ WTErr WCMRCoreAudioDevice::SetupAUHAL() retVal = EnableListeners(); if (retVal != eNoErr) goto Exit; - + //initialize the audio-unit now! err = AudioUnitInitialize(m_AUHALAudioUnit); if (err != kAudioHardwareNoError) @@ -1777,11 +1777,11 @@ WTErr WCMRCoreAudioDevice::SetupAUHAL() retVal = eGenericErr; goto Exit; } - + Exit: if (retVal != eNoErr) TearDownAUHAL(); - + return retVal; } @@ -1793,9 +1793,9 @@ Exit: //! Undoes the work done by SetupAUHAL //! //! \param none -//! +//! //! \return eNoErr on success, an error code on failure. -//! +//! //********************************************************************************************** WTErr WCMRCoreAudioDevice::TearDownAUHAL() { @@ -1814,23 +1814,23 @@ WTErr WCMRCoreAudioDevice::TearDownAUHAL() //********************************************************************************************** -// WCMRCoreAudioDevice::SetActive +// WCMRCoreAudioDevice::SetActive // -//! Sets the device's activation status. Essentially, opens or closes the PA device. +//! Sets the device's activation status. Essentially, opens or closes the PA device. //! If it's an ASIO device it may result in buffer size change in some cases. //! //! \param newState : Should be true to activate, false to deactivate. This roughly corresponds //! to opening and closing the device handle/stream/audio unit. -//! +//! //! \return eNoErr on success, an error code otherwise. -//! +//! //********************************************************************************************** WTErr WCMRCoreAudioDevice::SetActive (bool newState) { AUTO_FUNC_DEBUG; WTErr retVal = eNoErr; - + if (Active() == newState) goto Exit; @@ -1881,10 +1881,10 @@ WTErr WCMRCoreAudioDevice::SetActive (bool newState) UpdateDeviceInfo(); } - + m_IsActive = newState; - -Exit: + +Exit: return (retVal); } @@ -1919,10 +1919,10 @@ void WCMRCoreAudioDevice::SetupToneGenerator () fscanf(toneGenHandle, "%d", &toneFreq); if ((toneFreq <= 0) || (toneFreq > (m_CurrentSamplingRate/2))) { - toneFreq = 1000; + toneFreq = 1000; } - - + + m_ToneDataSamples = m_CurrentSamplingRate / toneFreq; int toneDataSamplesFrac = m_CurrentSamplingRate % m_ToneDataSamples; int powerOfTen = 1; @@ -1932,10 +1932,10 @@ void WCMRCoreAudioDevice::SetupToneGenerator () toneDataSamplesFrac = m_CurrentSamplingRate % m_ToneDataSamples; powerOfTen++; } - + //allocate m_pToneData = new float_t[m_ToneDataSamples]; - + //fill with a -6dB Sine Tone uint32_t numSamplesLeft = m_ToneDataSamples; float_t *pNextSample = m_pToneData; @@ -1948,9 +1948,9 @@ void WCMRCoreAudioDevice::SetupToneGenerator () pNextSample++; numSamplesLeft--; } - + m_NextSampleToUse = 0; - + fclose(toneGenHandle); } } @@ -1964,9 +1964,9 @@ void WCMRCoreAudioDevice::SetupToneGenerator () //! //! \param newState : Should be true to start streaming, false to stop streaming. This roughly //! corresponds to calling Start/Stop on the lower level interface. -//! +//! //! \return eNoErr always, the derived classes may return appropriate error code. -//! +//! //********************************************************************************************** WTErr WCMRCoreAudioDevice::SetStreaming (bool newState) { @@ -1988,7 +1988,7 @@ WTErr WCMRCoreAudioDevice::SetStreaming (bool newState) m_SampleCounter = 0; m_IOProcThreadPort = 0; m_pMyManager->NotifyClient (WCMRAudioDeviceManagerClient::DeviceDebugInfo, (void *)"Starting AUHAL."); - + // Prepare for streaming - tell Engine to do the initialization for process callback m_pMyManager->NotifyClient (WCMRAudioDeviceManagerClient::DeviceStartsStreaming); @@ -1999,11 +1999,11 @@ WTErr WCMRCoreAudioDevice::SetStreaming (bool newState) unsigned int computationUS = (unsigned int)(0.8 * periodAndConstraintUS); //assuming we may want to use up to 80% CPU //ErrandManager().SetRealTimeConstraintsForAllThreads (periodAndConstraintUS, computationUS, periodAndConstraintUS); } - + err = AudioOutputUnitStart (m_AUHALAudioUnit); - + m_StopRequested = false; - + if(err) { DEBUG_MSG( "Failed to start AudioUnit, err " << err ); @@ -2028,7 +2028,7 @@ WTErr WCMRCoreAudioDevice::SetStreaming (bool newState) err = AudioUnitReset (m_AUHALAudioUnit, kAudioUnitScope_Global, AUHAL_OUTPUT_ELEMENT); } } - + if(err) { DEBUG_MSG( "Failed to stop AudioUnit " << err ); @@ -2041,24 +2041,24 @@ WTErr WCMRCoreAudioDevice::SetStreaming (bool newState) // After units restart, reset request for reset and SR change m_SRChangeReported = m_SRChangeRequested; m_ResetReported = m_ResetRequested; - + m_IsStreaming = newState; -Exit: +Exit: return (retVal); } //********************************************************************************************** -// WCMRCoreAudioDevice::DoIdle +// WCMRCoreAudioDevice::DoIdle // //! A place for doing idle time processing. The other derived classes will probably do something //! meaningful. //! //! \param none -//! +//! //! \return eNoErr always. -//! +//! //********************************************************************************************** WTErr WCMRCoreAudioDevice::DoIdle () { @@ -2081,7 +2081,7 @@ WTErr WCMRCoreAudioDevice::DoIdle () m_pMyManager->NotifyClient (WCMRAudioDeviceManagerClient::RequestResync); m_ResyncReported = m_ResyncRequested; } - + if (m_SRChangeReported != m_SRChangeRequested) { m_SRChangeReported = m_SRChangeRequested; @@ -2095,7 +2095,7 @@ WTErr WCMRCoreAudioDevice::DoIdle () m_DropsReported = m_DropsDetected; } - + //Perhaps add checks to make sure a stream counter is incrementing if //stream is supposed to be streaming! if (Streaming()) @@ -2117,7 +2117,7 @@ WTErr WCMRCoreAudioDevice::DoIdle () } }*/ - + return (eNoErr); } @@ -2126,15 +2126,15 @@ WTErr WCMRCoreAudioDevice::DoIdle () //********************************************************************************************** -// WCMRCoreAudioDevice::SetMonitorChannels +// WCMRCoreAudioDevice::SetMonitorChannels // //! Used to set the channels to be used for monitoring. //! //! \param leftChannel : Left monitor channel index. //! \param rightChannel : Right monitor channel index. -//! +//! //! \return eNoErr always, the derived classes may return appropriate errors. -//! +//! //********************************************************************************************** WTErr WCMRCoreAudioDevice::SetMonitorChannels (int leftChannel, int rightChannel) { @@ -2149,22 +2149,22 @@ WTErr WCMRCoreAudioDevice::SetMonitorChannels (int leftChannel, int rightChannel //********************************************************************************************** -// WCMRCoreAudioDevice::SetMonitorGain +// WCMRCoreAudioDevice::SetMonitorGain // //! Used to set monitor gain (or atten). //! -//! \param newGain : The new gain or atten. value to use. Specified as a linear multiplier (not dB) -//! +//! \param newGain : The new gain or atten. value to use. Specified as a linear multiplier (not dB) +//! //! \return eNoErr always, the derived classes may return appropriate errors. -//! +//! //********************************************************************************************** WTErr WCMRCoreAudioDevice::SetMonitorGain (float newGain) { AUTO_FUNC_DEBUG; //This will most likely be overridden, the base class simply //changes the member. - - + + m_MonitorGain = newGain; return (eNoErr); } @@ -2173,21 +2173,21 @@ WTErr WCMRCoreAudioDevice::SetMonitorGain (float newGain) //********************************************************************************************** -// WCMRCoreAudioDevice::ShowConfigPanel +// WCMRCoreAudioDevice::ShowConfigPanel // //! Used to show device specific config/control panel. Some interfaces may not support it. //! Some interfaces may require the device to be active before it can display a panel. //! //! \param pParam : A device/interface specific parameter, should be the app window handle for ASIO. -//! +//! //! \return eNoErr always, the derived classes may return errors. -//! +//! //********************************************************************************************** WTErr WCMRCoreAudioDevice::ShowConfigPanel (void */*pParam*/) { AUTO_FUNC_DEBUG; WTErr retVal = eNoErr; - + CFStringRef configAP; UInt32 propSize = sizeof (configAP); /* @@ -2197,7 +2197,7 @@ WTErr WCMRCoreAudioDevice::ShowConfigPanel (void */*pParam*/) is the bundle ID for Audio MIDI Setup. The caller is responsible for releasing the returned CFObject. */ - + if (AudioDeviceGetProperty(m_DeviceID, 0, 0, kAudioDevicePropertyConfigurationApplication, &propSize, &configAP) == kAudioHardwareNoError) { // get the FSRef of the config app @@ -2212,16 +2212,16 @@ WTErr WCMRCoreAudioDevice::ShowConfigPanel (void */*pParam*/) // open default AudioMIDISetup if device app is not found CFStringRef audiMidiSetupApp = CFStringCreateWithCString(kCFAllocatorDefault, "com.apple.audio.AudioMIDISetup", kCFStringEncodingMacRoman); theError = LSFindApplicationForInfo(kLSUnknownCreator, audiMidiSetupApp, NULL, &theAppFSRef, NULL); - + if (!theError) { LSOpenFSRef(&theAppFSRef, NULL); } } - + CFRelease (configAP); } - + return (retVal); } @@ -2238,9 +2238,9 @@ WTErr WCMRCoreAudioDevice::ShowConfigPanel (void */*pParam*/) //! \param inBusNumber : The AU element. //! \param inNumberFrames: Number af Audio frames that are requested. //! \param ioData : Where the playback data is to be placed. -//! +//! //! \return 0 always -//! +//! //********************************************************************************************** OSStatus WCMRCoreAudioDevice::StaticAudioIOProc(void *inRefCon, AudioUnitRenderActionFlags * ioActionFlags, const AudioTimeStamp *inTimeStamp, UInt32 inBusNumber, UInt32 inNumberFrames, @@ -2267,9 +2267,9 @@ OSStatus WCMRCoreAudioDevice::StaticAudioIOProc(void *inRefCon, AudioUnitRenderA //! \param inBusNumber : The AU element. //! \param inNumberFrames: Number af Audio frames that are requested. //! \param ioData : Where the playback data is to be placed. -//! +//! //! \return 0 always -//! +//! //********************************************************************************************** OSStatus WCMRCoreAudioDevice::AudioIOProc(AudioUnitRenderActionFlags * ioActionFlags, const AudioTimeStamp *inTimeStamp, UInt32 /*inBusNumber*/, UInt32 inNumberFrames, @@ -2278,17 +2278,17 @@ OSStatus WCMRCoreAudioDevice::AudioIOProc(AudioUnitRenderActionFlags * ioAction UInt64 theStartTime = AudioGetCurrentHostTime(); OSStatus retVal = 0; - + if (m_StopRequested) return retVal; if (m_IOProcThreadPort == 0) m_IOProcThreadPort = mach_thread_self (); - + //cannot really deal with it unless the number of frames are the same as our buffer size! if (inNumberFrames != (UInt32)m_CurrentBufferSize) return retVal; - + //Retrieve the input data... if (!m_InputChannels.empty()) { @@ -2298,9 +2298,9 @@ OSStatus WCMRCoreAudioDevice::AudioIOProc(AudioUnitRenderActionFlags * ioAction inputAudioBufferList.mBuffers[0].mNumberChannels = m_InputChannels.size(); inputAudioBufferList.mBuffers[0].mDataByteSize = expectedDataSize; inputAudioBufferList.mBuffers[0].mData = NULL;//new float[expectedDataSize]; // we are going to get buffer from CoreAudio - + retVal = AudioUnitRender(m_AUHALAudioUnit, ioActionFlags, inTimeStamp, AUHAL_INPUT_ELEMENT, inNumberFrames, &inputAudioBufferList); - + if (retVal == kAudioHardwareNoError && inputAudioBufferList.mBuffers[0].mNumberChannels == m_InputChannels.size() && inputAudioBufferList.mBuffers[0].mDataByteSize == expectedDataSize ) @@ -2313,31 +2313,31 @@ OSStatus WCMRCoreAudioDevice::AudioIOProc(AudioUnitRenderActionFlags * ioAction return retVal; } } - + //is this an input only device? if (m_OutputChannels.empty()) AudioCallback (NULL, inNumberFrames, (int64_t)inTimeStamp->mSampleTime, theStartTime); else if ((!m_OutputChannels.empty()) && (ioData->mBuffers[0].mNumberChannels == m_OutputChannels.size())) AudioCallback ((float *)ioData->mBuffers[0].mData, inNumberFrames, (int64_t)inTimeStamp->mSampleTime, theStartTime); - + return retVal; } //********************************************************************************************** -// WCMRCoreAudioDevice::AudioCallback +// WCMRCoreAudioDevice::AudioCallback // -//! Here's where the actual audio processing happens. We call upon all the active connections' -//! sinks to provide data to us which can be put/mixed in the output buffer! Also, we make the +//! Here's where the actual audio processing happens. We call upon all the active connections' +//! sinks to provide data to us which can be put/mixed in the output buffer! Also, we make the //! input data available to any sources that may call upon us during this time! //! //! \param *pOutputBuffer : Points to a buffer to receive playback data. For Input only devices, this will be NULL //! \param framesPerBuffer : Number of sample frames in input and output buffers. Number of channels, //! which are interleaved, is fixed at Device Open (Active) time. In this implementation, //! the number of channels are fixed to use the maximum available. -//! +//! //! \return true -//! +//! //********************************************************************************************** int WCMRCoreAudioDevice::AudioCallback (float *pOutputBuffer, unsigned long framesPerBuffer, int64_t inSampleTime, uint64_t inCycleStartTime) { @@ -2349,9 +2349,9 @@ int WCMRCoreAudioDevice::AudioCallback (float *pOutputBuffer, unsigned long fram inSampleTime, AudioConvertHostTimeToNanos(inCycleStartTime) }; - + m_pMyManager->NotifyClient (WCMRAudioDeviceManagerClient::AudioCallback, (void *)&audioCallbackData); - + m_SampleCounter += framesPerBuffer; return m_StopRequested; } @@ -2377,11 +2377,11 @@ uint32_t WCMRCoreAudioDevice::GetLatency(bool isInput) UInt32 propSize = sizeof(UInt32); UInt32 value1 = 0; UInt32 value2 = 0; - + UInt32 latency = 0; std::vector<int> streamLatencies; - - + + err = AudioDeviceGetProperty(m_DeviceID, 0, isInput, kAudioDevicePropertyLatency, &propSize, &value1); if (err != kAudioHardwareNoError) { @@ -2403,7 +2403,7 @@ uint32_t WCMRCoreAudioDevice::GetLatency(bool isInput) latency += streamLatencies[i]; } } - + return latency; } @@ -2422,7 +2422,7 @@ OSStatus WCMRCoreAudioDevice::GetStreamLatency(AudioDeviceID device, bool isInpu OSStatus err = kAudioHardwareNoError; UInt32 outSize1, outSize2, outSize3; Boolean outWritable; - + err = AudioDeviceGetPropertyInfo(device, 0, isInput, kAudioDevicePropertyStreams, &outSize1, &outWritable); if (err == noErr) { int stream_count = outSize1 / sizeof(UInt32); @@ -2430,19 +2430,19 @@ OSStatus WCMRCoreAudioDevice::GetStreamLatency(AudioDeviceID device, bool isInpu AudioBufferList bufferList[stream_count]; UInt32 streamLatency; outSize2 = sizeof(UInt32); - + err = AudioDeviceGetProperty(device, 0, isInput, kAudioDevicePropertyStreams, &outSize1, streamIDs); if (err != noErr) { DEBUG_MSG("GetStreamLatencies kAudioDevicePropertyStreams err = " << err); return err; } - + err = AudioDeviceGetPropertyInfo(device, 0, isInput, kAudioDevicePropertyStreamConfiguration, &outSize3, &outWritable); if (err != noErr) { DEBUG_MSG("GetStreamLatencies kAudioDevicePropertyStreamConfiguration err = " << err); return err; } - + for (int i = 0; i < stream_count; i++) { err = AudioStreamGetProperty(streamIDs[i], 0, kAudioStreamPropertyLatency, &outSize2, &streamLatency); if (err != noErr) { @@ -2468,9 +2468,9 @@ OSStatus WCMRCoreAudioDevice::GetStreamLatency(AudioDeviceID device, bool isInpu //! //! \param *pTheClient : The manager's client object (which receives notifications). //! \param useMultithreading : Whether to use multi-threading for audio processing. Default is true. -//! +//! //! \return Nothing. -//! +//! //********************************************************************************************** WCMRCoreAudioDeviceManager::WCMRCoreAudioDeviceManager(WCMRAudioDeviceManagerClient *pTheClient, eAudioDeviceFilter eCurAudioDeviceFilter, bool useMultithreading, bool bNocopy) @@ -2488,7 +2488,7 @@ WCMRCoreAudioDeviceManager::WCMRCoreAudioDeviceManager(WCMRAudioDeviceManagerCli // http://lists.apple.com/archives/coreaudio-api/2009/Oct/msg00214.html // // As per Jeff's suggestion, opened an Apple Bug on this - ID# 7364011 - + CFRunLoopRef nullRunLoop = 0; OSStatus err = AudioHardwareSetProperty (kAudioHardwarePropertyRunLoop, sizeof(CFRunLoopRef), &nullRunLoop); @@ -2499,7 +2499,7 @@ WCMRCoreAudioDeviceManager::WCMRCoreAudioDeviceManager(WCMRAudioDeviceManagerCli //add a listener to find out when devices change... AudioHardwareAddPropertyListener (kAudioHardwarePropertyDevices, HardwarePropertyChangeCallback, this); - + //Always add the None device first... m_NoneDevice = new WCMRNativeAudioNoneDevice(this); @@ -2517,9 +2517,9 @@ WCMRCoreAudioDeviceManager::WCMRCoreAudioDeviceManager(WCMRAudioDeviceManagerCli //! It clears the device list, releasing each of the device. //! //! \param none -//! +//! //! \return Nothing. -//! +//! //********************************************************************************************** WCMRCoreAudioDeviceManager::~WCMRCoreAudioDeviceManager() { @@ -2541,24 +2541,24 @@ WCMRCoreAudioDeviceManager::~WCMRCoreAudioDeviceManager() WCMRAudioDevice* WCMRCoreAudioDeviceManager::initNewCurrentDeviceImpl(const std::string & deviceName) { destroyCurrentDeviceImpl(); - + std::cout << "API::PortAudioDeviceManager::initNewCurrentDevice " << deviceName << std::endl; if (deviceName == m_NoneDevice->DeviceName() ) { m_CurrentDevice = m_NoneDevice; return m_CurrentDevice; } - + DeviceInfo devInfo; WTErr err = GetDeviceInfoByName(deviceName, devInfo); - + if (eNoErr == err) { try { std::cout << "API::PortAudioDeviceManager::Creating PA device: " << devInfo.m_DeviceId << ", Device Name: " << devInfo.m_DeviceName << std::endl; TRACE_MSG ("API::PortAudioDeviceManager::Creating PA device: " << devInfo.m_DeviceId << ", Device Name: " << devInfo.m_DeviceName); - + m_CurrentDevice = new WCMRCoreAudioDevice (this, devInfo.m_DeviceId, m_UseMultithreading, m_bNoCopyAudioBuffer); } catch (...) @@ -2567,7 +2567,7 @@ WCMRAudioDevice* WCMRCoreAudioDeviceManager::initNewCurrentDeviceImpl(const std: DEBUG_MSG ("Unabled to create PA Device: " << devInfo.m_DeviceId); } } - + return m_CurrentDevice; } @@ -2576,37 +2576,37 @@ void WCMRCoreAudioDeviceManager::destroyCurrentDeviceImpl() { if (m_CurrentDevice != m_NoneDevice) delete m_CurrentDevice; - + m_CurrentDevice = 0; } - - + + WTErr WCMRCoreAudioDeviceManager::getDeviceAvailableSampleRates(DeviceID deviceId, std::vector<int>& sampleRates) { AUTO_FUNC_DEBUG; - + WTErr retVal = eNoErr; OSStatus err = kAudioHardwareNoError; UInt32 propSize = 0; - + sampleRates.clear(); - + //! 1. Get sample rate property size. err = AudioDeviceGetPropertyInfo(deviceId, 0, 0, kAudioDevicePropertyAvailableNominalSampleRates, &propSize, NULL); if (err == kAudioHardwareNoError) { //! 2. Get property: cannels output. - + // Allocate size according to the number of audio values int numRates = propSize / sizeof(AudioValueRange); AudioValueRange* supportedRates = new AudioValueRange[numRates]; - + // Get sampling rates from Audio device err = AudioDeviceGetProperty(deviceId, 0, 0, kAudioDevicePropertyAvailableNominalSampleRates, &propSize, supportedRates); if (err == kAudioHardwareNoError) { //! 3. Update sample rates - + // now iterate through our standard SRs for(int ourSR=0; gAllSampleRates[ourSR] > 0; ourSR++) { @@ -2627,7 +2627,7 @@ WTErr WCMRCoreAudioDeviceManager::getDeviceAvailableSampleRates(DeviceID deviceI retVal = eCoreAudioFailed; DEBUG_MSG("Failed to get device Sample rates. Device Name: " << m_DeviceName.c_str()); } - + delete [] supportedRates; } else @@ -2635,11 +2635,11 @@ WTErr WCMRCoreAudioDeviceManager::getDeviceAvailableSampleRates(DeviceID deviceI retVal = eCoreAudioFailed; DEBUG_MSG("Failed to get device Sample rates property size. Device Name: " << m_DeviceName.c_str()); } - + return retVal; } - + WTErr WCMRCoreAudioDeviceManager::getDeviceMaxInputChannels(DeviceID deviceId, unsigned int& inputChannels) { AUTO_FUNC_DEBUG; @@ -2653,14 +2653,14 @@ WTErr WCMRCoreAudioDeviceManager::getDeviceMaxInputChannels(DeviceID deviceId, u if (err == kAudioHardwareNoError) { //! 2. Get property: cannels input. - + // Allocate size according to the property size. Note that this is a variable sized struct... AudioBufferList *pStreamBuffers = (AudioBufferList *)malloc(propSize); - + if (pStreamBuffers) { memset (pStreamBuffers, 0, propSize); - + // Get the Input channels err = AudioDeviceGetProperty (deviceId, 0, 1/* Input */, kAudioDevicePropertyStreamConfiguration, &propSize, pStreamBuffers); if (err == kAudioHardwareNoError) @@ -2676,7 +2676,7 @@ WTErr WCMRCoreAudioDeviceManager::getDeviceMaxInputChannels(DeviceID deviceId, u retVal = eCoreAudioFailed; DEBUG_MSG("Failed to get device Input channels. Device Name: " << m_DeviceName.c_str()); } - + free (pStreamBuffers); } else @@ -2690,15 +2690,15 @@ WTErr WCMRCoreAudioDeviceManager::getDeviceMaxInputChannels(DeviceID deviceId, u retVal = eCoreAudioFailed; DEBUG_MSG("Failed to get device Input channels property size. Device Name: " << m_DeviceName.c_str()); } - + return retVal; } - + WTErr WCMRCoreAudioDeviceManager::getDeviceMaxOutputChannels(DeviceID deviceId, unsigned int& outputChannels) { AUTO_FUNC_DEBUG; - + WTErr retVal = eNoErr; OSStatus err = kAudioHardwareNoError; UInt32 propSize = 0; @@ -2709,13 +2709,13 @@ WTErr WCMRCoreAudioDeviceManager::getDeviceMaxOutputChannels(DeviceID deviceId, if (err == kAudioHardwareNoError) { //! 2. Get property: cannels output. - + // Allocate size according to the property size. Note that this is a variable sized struct... AudioBufferList *pStreamBuffers = (AudioBufferList *)malloc(propSize); if (pStreamBuffers) { memset (pStreamBuffers, 0, propSize); - + // Get the Output channels err = AudioDeviceGetProperty (deviceId, 0, 0/* Output */, kAudioDevicePropertyStreamConfiguration, &propSize, pStreamBuffers); if (err == kAudioHardwareNoError) @@ -2744,19 +2744,19 @@ WTErr WCMRCoreAudioDeviceManager::getDeviceMaxOutputChannels(DeviceID deviceId, retVal = eCoreAudioFailed; DEBUG_MSG("Failed to get device Output channels property size. Device Name: " << m_DeviceName.c_str()); } - + return retVal; } - - + + WTErr WCMRCoreAudioDeviceManager::generateDeviceListImpl() { AUTO_FUNC_DEBUG; - + // lock the list first wvNS::wvThread::ThreadMutex::lock theLock(m_AudioDeviceInfoVecMutex); m_DeviceInfoVec.clear(); - + //First, get info from None device which is always present if (m_NoneDevice) { @@ -2764,13 +2764,13 @@ WTErr WCMRCoreAudioDeviceManager::generateDeviceListImpl() pDevInfo->m_AvailableSampleRates = m_NoneDevice->SamplingRates(); m_DeviceInfoVec.push_back(pDevInfo); } - + WTErr retVal = eNoErr; OSStatus osErr = noErr; AudioDeviceID* deviceIDs = 0; - + openlog("WCMRCoreAudioDeviceManager", LOG_PID | LOG_CONS, LOG_USER); - + try { //Get device count... @@ -2779,22 +2779,22 @@ WTErr WCMRCoreAudioDeviceManager::generateDeviceListImpl() ASSERT_ERROR(osErr, "AudioHardwareGetProperty 1"); if (WUIsError(osErr)) throw osErr; - + size_t numDevices = propSize / sizeof (AudioDeviceID); deviceIDs = new AudioDeviceID[numDevices]; - + //retrieve the device IDs propSize = numDevices * sizeof (AudioDeviceID); osErr = AudioHardwareGetProperty (kAudioHardwarePropertyDevices, &propSize, deviceIDs); ASSERT_ERROR(osErr, "Error while getting audio devices: AudioHardwareGetProperty 2"); if (WUIsError(osErr)) throw osErr; - + //now add the ones that are not there... for (size_t deviceIndex = 0; deviceIndex < numDevices; deviceIndex++) { DeviceInfo* pDevInfo = 0; - + //Get device name and create new DeviceInfo entry //Get property name size. osErr = AudioDeviceGetPropertyInfo(deviceIDs[deviceIndex], 0, 0, kAudioDevicePropertyDeviceName, &propSize, NULL); @@ -2812,7 +2812,7 @@ WTErr WCMRCoreAudioDeviceManager::generateDeviceListImpl() retVal = eCoreAudioFailed; DEBUG_MSG("Failed to get device name. Device ID: " << m_DeviceID); } - + delete [] deviceName; } else @@ -2820,51 +2820,51 @@ WTErr WCMRCoreAudioDeviceManager::generateDeviceListImpl() retVal = eCoreAudioFailed; DEBUG_MSG("Failed to get device name property size. Device ID: " << m_DeviceID); } - + if (pDevInfo) { //Retrieve all the information we need for the device WTErr wErr = eNoErr; - + //Get available sample rates for the device std::vector<int> availableSampleRates; wErr = getDeviceAvailableSampleRates(pDevInfo->m_DeviceId, availableSampleRates); - + if (wErr != eNoErr) { DEBUG_MSG ("Failed to get device available sample rates. Device ID: " << m_DeviceID); delete pDevInfo; continue; //proceed to the next device } - + pDevInfo->m_AvailableSampleRates = availableSampleRates; - + //Get max input channels uint32_t maxInputChannels; wErr = getDeviceMaxInputChannels(pDevInfo->m_DeviceId, maxInputChannels); - + if (wErr != eNoErr) { DEBUG_MSG ("Failed to get device max input channels count. Device ID: " << m_DeviceID); delete pDevInfo; continue; //proceed to the next device } - + pDevInfo->m_MaxInputChannels = maxInputChannels; - + //Get max output channels uint32_t maxOutputChannels; wErr = getDeviceMaxOutputChannels(pDevInfo->m_DeviceId, maxOutputChannels); - + if (wErr != eNoErr) { DEBUG_MSG ("Failed to get device max output channels count. Device ID: " << m_DeviceID); delete pDevInfo; continue; //proceed to the next device } - + pDevInfo->m_MaxOutputChannels = maxOutputChannels; - + //Now check if this device is acceptable according to current input/output settings bool bRejectDevice = false; switch(m_eAudioDeviceFilter) @@ -2907,7 +2907,7 @@ WTErr WCMRCoreAudioDeviceManager::generateDeviceListImpl() m_DeviceInfoVec.push_back(pDevInfo); break; } - + if(bRejectDevice) { syslog (LOG_NOTICE, "%s rejected, In Channels = %d, Out Channels = %d\n", @@ -2917,23 +2917,23 @@ WTErr WCMRCoreAudioDeviceManager::generateDeviceListImpl() } } } - - + + //If no devices were found, that's not a good thing! if (m_DeviceInfoVec.empty()) { DEBUG_MSG ("No matching CoreAudio devices were found\n"); - } + } } catch (...) { if (WUNoError(retVal)) retVal = eCoreAudioFailed; } - + delete[] deviceIDs; closelog(); - + return retVal; } @@ -2942,26 +2942,26 @@ WTErr WCMRCoreAudioDeviceManager::updateDeviceListImpl() { wvNS::wvThread::ThreadMutex::lock theLock(m_AudioDeviceInfoVecMutex); WTErr err = generateDeviceListImpl(); - + if (eNoErr != err) { std::cout << "API::PortAudioDeviceManager::updateDeviceListImpl: Device list update error: "<< err << std::endl; } - + if (m_CurrentDevice) { // if we have device initialized we should find out if this device is still connected DeviceInfo devInfo; WTErr deviceLookUpErr = GetDeviceInfoByName(m_CurrentDevice->DeviceName(), devInfo ); - + if (eNoErr != deviceLookUpErr) { NotifyClient (WCMRAudioDeviceManagerClient::IODeviceDisconnected); return err; } - + WCMRCoreAudioDevice* current_device = dynamic_cast<WCMRCoreAudioDevice*>(m_CurrentDevice); - + if ( current_device && (current_device->DeviceID() != devInfo.m_DeviceId ) ) { @@ -2969,9 +2969,9 @@ WTErr WCMRCoreAudioDeviceManager::updateDeviceListImpl() return err; } } - + NotifyClient (WCMRAudioDeviceManagerClient::DeviceListChanged); - + return err; } @@ -2979,13 +2979,13 @@ WTErr WCMRCoreAudioDeviceManager::updateDeviceListImpl() WTErr WCMRCoreAudioDeviceManager::getDeviceSampleRatesImpl(const std::string & deviceName, std::vector<int>& sampleRates) const { AUTO_FUNC_DEBUG; - + WTErr retVal = eNoErr; OSStatus err = kAudioHardwareNoError; UInt32 propSize = 0; - + sampleRates.clear(); - + //first check if the request has been made for None device if (deviceName == m_NoneDevice->DeviceName() ) { @@ -2997,28 +2997,28 @@ WTErr WCMRCoreAudioDeviceManager::getDeviceSampleRatesImpl(const std::string & d sampleRates.assign(m_CurrentDevice->SamplingRates().begin(), m_CurrentDevice->SamplingRates().end() ); return retVal; } - + DeviceInfo devInfo; retVal = GetDeviceInfoByName(deviceName, devInfo); - + //! 1. Get sample rate property size. err = AudioDeviceGetPropertyInfo(devInfo.m_DeviceId, 0, 0, kAudioDevicePropertyAvailableNominalSampleRates, &propSize, NULL); - + if (err == kAudioHardwareNoError) { //! 2. Get property: cannels output. - + // Allocate size accrding to the number of audio values int numRates = propSize / sizeof(AudioValueRange); AudioValueRange* supportedRates = new AudioValueRange[numRates]; - + // Get sampling rates from Audio device err = AudioDeviceGetProperty(devInfo.m_DeviceId, 0, 0, kAudioDevicePropertyAvailableNominalSampleRates, &propSize, supportedRates); - + if (err == kAudioHardwareNoError) { //! 3. Update sample rates - + // now iterate through our standard SRs for(int ourSR=0; gAllSampleRates[ourSR] > 0; ourSR++) { @@ -3039,7 +3039,7 @@ WTErr WCMRCoreAudioDeviceManager::getDeviceSampleRatesImpl(const std::string & d retVal = eCoreAudioFailed; DEBUG_MSG("Failed to get device Sample rates. Device Name: " << m_DeviceName.c_str()); } - + delete [] supportedRates; } else @@ -3049,7 +3049,7 @@ WTErr WCMRCoreAudioDeviceManager::getDeviceSampleRatesImpl(const std::string & d } devInfo.m_AvailableSampleRates.assign(sampleRates.begin(), sampleRates.end() ); - + return retVal; } @@ -3057,28 +3057,28 @@ WTErr WCMRCoreAudioDeviceManager::getDeviceSampleRatesImpl(const std::string & d WTErr WCMRCoreAudioDeviceManager::getDeviceBufferSizesImpl(const std::string & deviceName, std::vector<int>& bufferSizes) const { AUTO_FUNC_DEBUG; - + WTErr retVal = eNoErr; OSStatus err = kAudioHardwareNoError; UInt32 propSize = 0; - + bufferSizes.clear(); - + //first check if the request has been made for None device if (deviceName == m_NoneDevice->DeviceName() ) { bufferSizes = m_NoneDevice->BufferSizes(); return retVal; } - + if (m_CurrentDevice && m_CurrentDevice->DeviceName () == deviceName) { bufferSizes.assign(m_CurrentDevice->BufferSizes().begin(), m_CurrentDevice->BufferSizes().end() ); return retVal; } - + DeviceInfo devInfo; retVal = GetDeviceInfoByName(deviceName, devInfo); - + if (eNoErr == retVal) { // 1. Get buffer size range @@ -3095,7 +3095,7 @@ WTErr WCMRCoreAudioDeviceManager::getDeviceBufferSizesImpl(const std::string & d bufferSizes.push_back (gAllBufferSizes[bsize]); } } - + //if we didn't get a single hit, let's simply add the min. and the max... if (bufferSizes.empty()) { @@ -3115,7 +3115,7 @@ WTErr WCMRCoreAudioDeviceManager::getDeviceBufferSizesImpl(const std::string & d std::cout << "API::PortAudioDeviceManager::GetBufferSizes: Device not found: "<< deviceName << std::endl; } - + return retVal; } @@ -3131,10 +3131,10 @@ OSStatus WCMRCoreAudioDeviceManager::HardwarePropertyChangeCallback (AudioHardwa pManager->updateDeviceListImpl(); } break; - + default: break; } - + return 0; } diff --git a/libs/backends/wavesaudio/wavesapi/devicemanager/WCMRNativeAudio.cpp b/libs/backends/wavesaudio/wavesapi/devicemanager/WCMRNativeAudio.cpp index 2e0490b02e..0bce97423c 100644 --- a/libs/backends/wavesaudio/wavesapi/devicemanager/WCMRNativeAudio.cpp +++ b/libs/backends/wavesaudio/wavesapi/devicemanager/WCMRNativeAudio.cpp @@ -30,8 +30,8 @@ //! the applications. //! //! \param pManager : The managing device manager - simply passed on to the base class. -//! -//! +//! +//! //********************************************************************************************** WCMRNativeAudioNoneDevice::WCMRNativeAudioNoneDevice (WCMRAudioDeviceManager *pManager) : WCMRNativeAudioDevice (pManager, false /*useMultiThreading*/) @@ -155,7 +155,7 @@ WTErr WCMRNativeAudioNoneDevice::SetStreaming (bool newState) std::cerr << "WCMRNativeAudioNoneDevice::SetStreaming (): pthread_attr_init () failed!" << std::endl; return eGenericErr; } - + if (pthread_attr_setstacksize (&attributes, stack_size)) { std::cerr << "WCMRNativeAudioNoneDevice::SetStreaming (): pthread_attr_setstacksize () failed!" << std::endl; return eGenericErr; @@ -203,13 +203,13 @@ void WCMRNativeAudioNoneDevice::_SilenceThread() (const float*)theInpBuffers, _m_outputBuffer, buffer_size, - 0, + 0, 0 }; audioCallbackData.acdCycleStartTimeNanos =__get_time_nanos(); - // VERY ROUGH IMPLEMENTATION: + // VERY ROUGH IMPLEMENTATION: while(Streaming()) { uint64_t cycleEndTimeNanos = audioCallbackData.acdCycleStartTimeNanos + cyclePeriodNanos; @@ -236,13 +236,13 @@ void* WCMRNativeAudioNoneDevice::__SilenceThread(void *This) #if defined(PLATFORM_WINDOWS) void WCMRNativeAudioNoneDevice::_usleep(uint64_t duration_usec) -{ - LARGE_INTEGER ft; +{ + LARGE_INTEGER ft; ft.QuadPart = -(10*duration_usec); // Convert to 100 nanosecond interval, negative value indicates relative time SetWaitableTimer(_waitableTimerForUsleep, &ft, 0, NULL, NULL, 0); - WaitForSingleObject(_waitableTimerForUsleep, INFINITE); + WaitForSingleObject(_waitableTimerForUsleep, INFINITE); } #endif @@ -254,9 +254,9 @@ WCMRNativeAudioNoneDevice::__get_time_nanos () // the API should be a part of WCMRCoreAudioDeviceManager to give a chance of being tied to the // audio device transport timeß. return AudioConvertHostTimeToNanos (AudioGetCurrentHostTime ()); - + #elif PLATFORM_WINDOWS - + LARGE_INTEGER Frequency, Count ; QueryPerformanceFrequency (&Frequency) ; diff --git a/libs/backends/wavesaudio/wavesapi/devicemanager/WCMRPortAudioDeviceManager.cpp b/libs/backends/wavesaudio/wavesapi/devicemanager/WCMRPortAudioDeviceManager.cpp index 35ac18c044..c039b49c0b 100644 --- a/libs/backends/wavesaudio/wavesapi/devicemanager/WCMRPortAudioDeviceManager.cpp +++ b/libs/backends/wavesaudio/wavesapi/devicemanager/WCMRPortAudioDeviceManager.cpp @@ -25,7 +25,7 @@ using namespace wvNS; #define PROPERTY_CHANGE_TIMEOUT_SECONDS 2 #define PROPERTY_CHANGE_RETRIES 3 -///< Supported Sample rates +///< Supported Sample rates static const double gAllSampleRates[] = { 44100.0, 48000.0, 88200.0, 96000.0, 176400.0, 192000.0, -1 /* negative terminated list */ @@ -64,7 +64,7 @@ DWORD WINAPI WCMRPortAudioDevice::__DoIdle__(LPVOID lpThreadParameter) } //********************************************************************************************** -// WCMRPortAudioDevice::WCMRPortAudioDevice +// WCMRPortAudioDevice::WCMRPortAudioDevice // //! Constructor for the audio device. Opens the PA device //! and gets information about the device. @@ -74,9 +74,9 @@ DWORD WINAPI WCMRPortAudioDevice::__DoIdle__(LPVOID lpThreadParameter) //! \param *pManager : The audio device manager that's managing this device. //! \param deviceID : The port audio device ID. //! \param useMultithreading : Whether to use multi-threading for audio processing. Default is true. -//! +//! //! \return Nothing. -//! +//! //********************************************************************************************** WCMRPortAudioDevice::WCMRPortAudioDevice (WCMRPortAudioDeviceManager *pManager, unsigned int deviceID, bool useMultithreading, bool bNoCopy) : WCMRNativeAudioDevice (pManager, useMultithreading, bNoCopy) @@ -230,16 +230,16 @@ void WCMRPortAudioDevice::terminateDevice() //********************************************************************************************** -// WCMRPortAudioDevice::~WCMRPortAudioDevice +// WCMRPortAudioDevice::~WCMRPortAudioDevice // //! Destructor for the audio device. The base release all the connections that were created, if //! they have not been already destroyed! Here we simply stop streaming, and close device //! handles if necessary. //! //! \param none -//! +//! //! \return Nothing. -//! +//! //********************************************************************************************** WCMRPortAudioDevice::~WCMRPortAudioDevice () { @@ -293,13 +293,13 @@ WTErr WCMRPortAudioDevice::UpdateDeviceInfo () //********************************************************************************************** -// WCMRPortAudioDevice::updateDeviceInfo +// WCMRPortAudioDevice::updateDeviceInfo // //! Must be called be device processing thread //! Updates Device Information about channels, sampling rates, buffer sizes. //! //! \return Nothing. -//! +//! //********************************************************************************************** void WCMRPortAudioDevice::updateDeviceInfo (bool callerIsWaiting/*=false*/) { @@ -353,7 +353,7 @@ void WCMRPortAudioDevice::updateDeviceInfo (bool callerIsWaiting/*=false*/) m_BufferSizes.clear(); bool useDefaultBuffers = true; - // In ASIO Windows, the buffer size is set from the sound device manufacturer's control panel + // In ASIO Windows, the buffer size is set from the sound device manufacturer's control panel long minSize, maxSize, preferredSize, granularity; PaError err = PaAsio_GetAvailableBufferSizes(m_DeviceID, &minSize, &maxSize, &preferredSize, &granularity); @@ -486,15 +486,15 @@ PaError WCMRPortAudioDevice::testStateValidness(int sampleRate, int bufferSize) //********************************************************************************************** -// WCMRPortAudioDevice::CurrentSamplingRate +// WCMRPortAudioDevice::CurrentSamplingRate // -//! The device's current sampling rate. This may be overridden, if the device needs to +//! The device's current sampling rate. This may be overridden, if the device needs to //! query the driver for the current rate. //! //! \param none -//! +//! //! \return The device's current sampling rate. -1 on error. -//! +//! //********************************************************************************************** int WCMRPortAudioDevice::CurrentSamplingRate () { @@ -561,14 +561,14 @@ WTErr WCMRPortAudioDevice::ResetDevice() //********************************************************************************************** -// WCMRPortAudioDevice::SetCurrentSamplingRate +// WCMRPortAudioDevice::SetCurrentSamplingRate // -//! Change the sampling rate to be used by the device. +//! Change the sampling rate to be used by the device. //! //! \param newRate : The rate to use (samples per sec). -//! +//! //! \return eNoErr always. The derived classes may return error codes. -//! +//! //********************************************************************************************** WTErr WCMRPortAudioDevice::SetCurrentSamplingRate (int newRate) { @@ -622,13 +622,13 @@ WTErr WCMRPortAudioDevice::SetCurrentSamplingRate (int newRate) //********************************************************************************************** // WCMRPortAudioDevice::CurrentBufferSize // -//! The device's current buffer size in use. This may be overridden, if the device needs to +//! The device's current buffer size in use. This may be overridden, if the device needs to //! query the driver for the current size. //! //! \param none -//! +//! //! \return The device's current buffer size. 0 on error. -//! +//! //********************************************************************************************** int WCMRPortAudioDevice::CurrentBufferSize () { @@ -639,13 +639,13 @@ int WCMRPortAudioDevice::CurrentBufferSize () //********************************************************************************************** // WCMRPortAudioDevice::SetCurrentBufferSize // -//! Change the buffer size to be used by the device. This will most likely be overridden, +//! Change the buffer size to be used by the device. This will most likely be overridden, //! the base class simply updates the member variable. //! //! \param newSize : The buffer size to use (in sample-frames) -//! +//! //! \return eNoErr always. The derived classes may return error codes. -//! +//! //********************************************************************************************** WTErr WCMRPortAudioDevice::SetCurrentBufferSize (int newSize) { @@ -678,15 +678,15 @@ WTErr WCMRPortAudioDevice::SetCurrentBufferSize (int newSize) //********************************************************************************************** -// WCMRPortAudioDevice::ConnectionStatus +// WCMRPortAudioDevice::ConnectionStatus // //! Retrieves the device's current connection status. This will most likely be overridden, //! in case some driver communication is required to query the status. //! //! \param none -//! +//! //! \return A ConnectionStates value. -//! +//! //********************************************************************************************** WCMRPortAudioDevice::ConnectionStates WCMRPortAudioDevice::ConnectionStatus () { @@ -701,7 +701,7 @@ WCMRPortAudioDevice::ConnectionStates WCMRPortAudioDevice::ConnectionStatus () // WCMRPortAudioDevice::activateDevice // //! IS CALLED BY PROCESS THREAD -//! Sets the device into "active" state. Essentially, opens the PA device. +//! Sets the device into "active" state. Essentially, opens the PA device. //! If it's an ASIO device it may result in buffer size change in some cases. //! //********************************************************************************************** @@ -740,7 +740,7 @@ void WCMRPortAudioDevice::activateDevice (bool callerIsWaiting/*=false*/) std::cout << "API::Device " << m_DeviceName << " Opening device stream " << std::endl; std::cout << "Sample rate: " << m_CurrentSamplingRate << " buffer size: " << m_CurrentBufferSize << std::endl; - paErr = Pa_OpenStream(&m_PortAudioStream, + paErr = Pa_OpenStream(&m_PortAudioStream, pInS, pOutS, m_CurrentSamplingRate, @@ -817,7 +817,7 @@ void WCMRPortAudioDevice::activateDevice (bool callerIsWaiting/*=false*/) // WCMRPortAudioDevice::deactivateDevice // //! IS CALLED BY PROCESS THREAD -//! Sets the device into "inactive" state. Essentially, closes the PA device. +//! Sets the device into "inactive" state. Essentially, closes the PA device. //! //********************************************************************************************** void WCMRPortAudioDevice::deactivateDevice (bool callerIsWaiting/*=false*/) @@ -878,7 +878,7 @@ void WCMRPortAudioDevice::deactivateDevice (bool callerIsWaiting/*=false*/) // //! Sets the devices into "streaming" state. Calls PA's Start stream routines. //! This roughly corresponds to calling Start on the lower level interface. -//! +//! //********************************************************************************************** void WCMRPortAudioDevice::startStreaming (bool callerIsWaiting/*=false*/) { @@ -928,7 +928,7 @@ void WCMRPortAudioDevice::startStreaming (bool callerIsWaiting/*=false*/) // //! Sets the devices into "not streaming" state. Calls PA's Stop stream routines. //! This roughly corresponds to calling Stop on the lower level interface. -//! +//! //********************************************************************************************** void WCMRPortAudioDevice::stopStreaming (bool callerIsWaiting/*=false*/) { @@ -963,15 +963,15 @@ void WCMRPortAudioDevice::stopStreaming (bool callerIsWaiting/*=false*/) //********************************************************************************************** -// WCMRPortAudioDevice::resetDevice +// WCMRPortAudioDevice::resetDevice // //! Resets the device, updates device info. Importnat: does PA reinitialization calling //! Pa_terminate/Pa_initialize functions. //! //! \param none -//! +//! //! \return nothing -//! +//! //********************************************************************************************** void WCMRPortAudioDevice::resetDevice (bool callerIsWaiting /*=false*/ ) { @@ -1007,7 +1007,7 @@ void WCMRPortAudioDevice::resetDevice (bool callerIsWaiting /*=false*/ ) if (paErr != paNoError) { continue; - } + } m_CurrentBufferSize = preferredSize; paErr = testStateValidness(m_CurrentSamplingRate, m_CurrentBufferSize); @@ -1115,22 +1115,22 @@ long WCMRPortAudioDevice::ASIOMessageHook (long selector, long WCUNUSEDPARAM(val //********************************************************************************************** -// WCMRPortAudioDevice::DoIdle +// WCMRPortAudioDevice::DoIdle // //! A place for doing idle time processing. The other derived classes will probably do something //! meaningful. //! //! \param none -//! +//! //! \return eNoErr always. -//! +//! //********************************************************************************************** WTErr WCMRPortAudioDevice::DoIdle () { WTErr retVal = eNoErr; std::cout << "WCMRPortAudioDevice::DoIdle ()" << std::endl; - HANDLE hEvents[] = + HANDLE hEvents[] = { m_hUpdateDeviceInfoRequestedEvent, m_hActivateRequestedEvent, @@ -1218,15 +1218,15 @@ WTErr WCMRPortAudioDevice::DoIdle () //********************************************************************************************** -// WCMRPortAudioDevice::SetMonitorChannels +// WCMRPortAudioDevice::SetMonitorChannels // //! Used to set the channels to be used for monitoring. //! //! \param leftChannel : Left monitor channel index. //! \param rightChannel : Right monitor channel index. -//! +//! //! \return eNoErr always, the derived classes may return appropriate errors. -//! +//! //********************************************************************************************** WTErr WCMRPortAudioDevice::SetMonitorChannels (int leftChannel, int rightChannel) { @@ -1241,14 +1241,14 @@ WTErr WCMRPortAudioDevice::SetMonitorChannels (int leftChannel, int rightChannel //********************************************************************************************** -// WCMRPortAudioDevice::SetMonitorGain +// WCMRPortAudioDevice::SetMonitorGain // //! Used to set monitor gain (or atten). //! -//! \param newGain : The new gain or atten. value to use. Specified as a linear multiplier (not dB) -//! +//! \param newGain : The new gain or atten. value to use. Specified as a linear multiplier (not dB) +//! //! \return eNoErr always, the derived classes may return appropriate errors. -//! +//! //********************************************************************************************** WTErr WCMRPortAudioDevice::SetMonitorGain (float newGain) { @@ -1264,15 +1264,15 @@ WTErr WCMRPortAudioDevice::SetMonitorGain (float newGain) //********************************************************************************************** -// WCMRPortAudioDevice::ShowConfigPanel +// WCMRPortAudioDevice::ShowConfigPanel // //! Used to show device specific config/control panel. Some interfaces may not support it. //! Some interfaces may require the device to be active before it can display a panel. //! //! \param pParam : A device/interface specific parameter, should be the app window handle for ASIO. -//! +//! //! \return eNoErr always, the derived classes may return errors. -//! +//! //********************************************************************************************** WTErr WCMRPortAudioDevice::ShowConfigPanel (void *pParam) { @@ -1315,7 +1315,7 @@ WTErr WCMRPortAudioDevice::ShowConfigPanel (void *pParam) //***************************************************************************************************** // WCMRPortAudioDevice::TheCallback // -//! The (static) Port Audio Callback function. This is a static member. It calls on the AudioCallback in the +//! The (static) Port Audio Callback function. This is a static member. It calls on the AudioCallback in the //! WCMRPortAudioDevice to do the real work. //! //! \param pInputBuffer: pointer to input buffer. @@ -1324,10 +1324,10 @@ WTErr WCMRPortAudioDevice::ShowConfigPanel (void *pParam) //! \param pTimeInfo: time info for PaStream callback. //! \param statusFlags: //! \param pUserData: pointer to user data, in our case the WCMRPortAudioDevice object. -//! +//! //! \return true to stop streaming else returns false. //****************************************************************************************************** -int WCMRPortAudioDevice::TheCallback (const void *pInputBuffer, void *pOutputBuffer, unsigned long framesPerBuffer, +int WCMRPortAudioDevice::TheCallback (const void *pInputBuffer, void *pOutputBuffer, unsigned long framesPerBuffer, const PaStreamCallbackTimeInfo* /*pTimeInfo*/, PaStreamCallbackFlags statusFlags, void *pUserData ) { WCMRPortAudioDevice *pMyDevice = (WCMRPortAudioDevice *)pUserData; @@ -1342,10 +1342,10 @@ int WCMRPortAudioDevice::TheCallback (const void *pInputBuffer, void *pOutputBuf //********************************************************************************************** -// WCMRPortAudioDevice::AudoiCallback +// WCMRPortAudioDevice::AudoiCallback // -//! Here's where the actual audio processing happens. We call upon all the active connections' -//! sinks to provide data to us which can be put/mixed in the output buffer! Also, we make the +//! Here's where the actual audio processing happens. We call upon all the active connections' +//! sinks to provide data to us which can be put/mixed in the output buffer! Also, we make the //! input data available to any sources that may call upon us during this time! //! //! \param *pInputBuffer : Points to a buffer with recorded data. @@ -1354,9 +1354,9 @@ int WCMRPortAudioDevice::TheCallback (const void *pInputBuffer, void *pOutputBuf //! which are interleaved, is fixed at Device Open (Active) time. In this implementation, //! the number of channels are fixed to use the maximum available. //! \param dropsDetected : True if dropouts were detected in input or output. Can be used to signal the GUI. -//! +//! //! \return true -//! +//! //********************************************************************************************** int WCMRPortAudioDevice::AudioCallback( const float *pInputBuffer, float *pOutputBuffer, unsigned long framesPerBuffer, bool dropsDetected ) { @@ -1382,7 +1382,7 @@ int WCMRPortAudioDevice::AudioCallback( const float *pInputBuffer, float *pOutpu m_SampleCounter, theStartTime.MicroSeconds()*1000 }; - + m_pMyManager->NotifyClient (WCMRAudioDeviceManagerClient::AudioCallback, (void *)&audioCallbackData ); //Don't try to access after this call returns! @@ -1404,11 +1404,11 @@ int WCMRPortAudioDevice::AudioCallback( const float *pInputBuffer, float *pOutpu //! \param *pTheClient : The manager's client object (which receives notifications). //! \param interfaceType : The PortAudio interface type to use for this manager - acts as a filter. //! \param useMultithreading : Whether to use multi-threading for audio processing. Default is true. -//! +//! //! \return Nothing. -//! +//! //********************************************************************************************** -WCMRPortAudioDeviceManager::WCMRPortAudioDeviceManager (WCMRAudioDeviceManagerClient *pTheClient, +WCMRPortAudioDeviceManager::WCMRPortAudioDeviceManager (WCMRAudioDeviceManagerClient *pTheClient, eAudioDeviceFilter eCurAudioDeviceFilter, bool useMultithreading, bool bNocopy) : WCMRAudioDeviceManager (pTheClient, eCurAudioDeviceFilter) , m_NoneDevice(0) @@ -1436,9 +1436,9 @@ WCMRPortAudioDeviceManager::WCMRPortAudioDeviceManager (WCMRAudioDeviceManagerCl //! It clears the device list, releasing each of the device. //! //! \param none -//! +//! //! \return Nothing. -//! +//! //********************************************************************************************** WCMRPortAudioDeviceManager::~WCMRPortAudioDeviceManager() { @@ -1463,7 +1463,7 @@ WCMRPortAudioDeviceManager::~WCMRPortAudioDeviceManager() WCMRAudioDevice* WCMRPortAudioDeviceManager::initNewCurrentDeviceImpl(const std::string & deviceName) { destroyCurrentDeviceImpl(); - + std::cout << "API::PortAudioDeviceManager::initNewCurrentDevice " << deviceName << std::endl; if (deviceName == m_NoneDevice->DeviceName() ) { @@ -1687,7 +1687,7 @@ WTErr WCMRPortAudioDeviceManager::generateDeviceListImpl() m_DeviceInfoVec.push_back(pDevInfo); break; } - + if(bRejectDevice) { TRACE_MSG ("API::PortAudioDeviceManager::Device " << pDevInfo->m_DeviceName << "Rejected. \ @@ -1721,9 +1721,9 @@ WTErr WCMRPortAudioDeviceManager::generateDeviceListImpl() WTErr WCMRPortAudioDeviceManager::getDeviceSampleRatesImpl(const std::string & deviceName, std::vector<int>& sampleRates) const { sampleRates.clear (); - + WTErr retVal = eNoErr; - + if (m_CurrentDevice && deviceName == m_CurrentDevice->DeviceName() ) { sampleRates=m_CurrentDevice->SamplingRates(); @@ -1732,7 +1732,7 @@ WTErr WCMRPortAudioDeviceManager::getDeviceSampleRatesImpl(const std::string & d DeviceInfo devInfo; retVal = GetDeviceInfoByName(deviceName, devInfo); - + if (eNoErr == retVal) { sampleRates=devInfo.m_AvailableSampleRates; @@ -1765,7 +1765,7 @@ WTErr WCMRPortAudioDeviceManager::getDeviceBufferSizesImpl(const std::string & d return retVal; } - DeviceInfo devInfo; + DeviceInfo devInfo; retVal = GetDeviceInfoByName(deviceName, devInfo); if (eNoErr == retVal) |