2nd attempt at updated Waves audio backend, with added -fms-extensions as previously applied (but not updated in Waves' repo) to allow anonymous unions, as used by PortMidi

This commit is contained in:
Paul Davis 2014-04-30 13:46:41 -04:00
parent 1ac8815296
commit 19d21045af
58 changed files with 9353 additions and 7631 deletions

View file

@ -1,5 +1,5 @@
/*
Copyright (C) 2014 Waves Audio Ltd.
Copyright (C) 2013 Valeriy Kamyshniy
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -30,7 +30,8 @@ void WavesAudioBackend::AudioDeviceManagerNotification (NotificationReason reaso
std::cout << "------------------------------- WCMRAudioDeviceManagerClient::DeviceDebugInfo -- " << (char*)parameter << std::endl;
break;
case WCMRAudioDeviceManagerClient::BufferSizeChanged:
std::cout << "------------------------------- WCMRAudioDeviceManagerClient::BufferSizeChanged" << std::endl;
std::cout << "------------------------------- WCMRAudioDeviceManagerClient::BufferSizeChanged: " << *(uint32_t*)parameter << std::endl;
_buffer_size_change(*(uint32_t*)parameter);
break;
case WCMRAudioDeviceManagerClient::RequestReset:
std::cout << "------------------------------- WCMRAudioDeviceManagerClient::RequestReset" << std::endl;
@ -39,7 +40,8 @@ void WavesAudioBackend::AudioDeviceManagerNotification (NotificationReason reaso
std::cout << "------------------------------- WCMRAudioDeviceManagerClient::RequestResync" << std::endl;
break;
case WCMRAudioDeviceManagerClient::SamplingRateChanged:
std::cout << "------------------------------- WCMRAudioDeviceManagerClient::SamplingRateChanged: " << (int64_t)parameter << std::endl;
std::cout << "------------------------------- WCMRAudioDeviceManagerClient::SamplingRateChanged: " << *(float*)parameter << std::endl;
set_sample_rate(*(float*)parameter);
break;
case WCMRAudioDeviceManagerClient::DeviceDroppedSamples:
std::cout << "------------------------------- WCMRAudioDeviceManagerClient::DeviceDroppedSamples" << std::endl;
@ -47,11 +49,20 @@ void WavesAudioBackend::AudioDeviceManagerNotification (NotificationReason reaso
case WCMRAudioDeviceManagerClient::DeviceStoppedStreaming:
std::cout << "------------------------------- WCMRAudioDeviceManagerClient::DeviceStoppedStreaming" << std::endl;
break;
case WCMRAudioDeviceManagerClient::DeviceStartsStreaming:
std::cout << "------------------------------- WCMRAudioDeviceManagerClient::DeviceStartsStreaming" << std::endl;
_call_thread_init_callback = true; // streaming will be started from device side, just set thread init flag
break;
case WCMRAudioDeviceManagerClient::DeviceConnectionLost:
std::cout << "------------------------------- WCMRAudioDeviceManagerClient::DeviceConnectionLost" << std::endl;
break;
case WCMRAudioDeviceManagerClient::DeviceListChanged:
std::cout << "------------------------------- WCMRAudioDeviceManagerClient::DeviceListChanged" << std::endl;
_device_list_change();
break;
case WCMRAudioDeviceManagerClient::IODeviceDisconnected:
std::cout << "------------------------------- WCMRAudioDeviceManagerClient::DeviceListChanged" << std::endl;
_device_list_change();
break;
case WCMRAudioDeviceManagerClient::AudioCallback:
if (parameter) {
@ -77,6 +88,7 @@ WavesAudioBackend::WavesAudioBackend (AudioEngine& e)
, _audio_device_manager (this)
, _midi_device_manager (*this)
, _device (NULL)
, _sample_format (FormatFloat)
, _interleaved (true)
, _input_channels (0)
, _max_input_channels (0)
@ -87,7 +99,7 @@ WavesAudioBackend::WavesAudioBackend (AudioEngine& e)
, _systemic_input_latency (0)
, _systemic_output_latency (0)
, _call_thread_init_callback (false)
, _use_midi (false)
, _use_midi (true)
, _sample_time_at_cycle_start (0)
, _freewheeling (false)
, _freewheel_thread_active (false)
@ -100,6 +112,7 @@ WavesAudioBackend::WavesAudioBackend (AudioEngine& e)
WavesAudioBackend::~WavesAudioBackend ()
{
}
std::string
@ -150,14 +163,14 @@ WavesAudioBackend::set_driver (const std::string& /*drivername*/)
std::vector<AudioBackend::DeviceStatus>
WavesAudioBackend::enumerate_devices () const
{
/* COMMENTED DBG LOGS */ std::cout << "WavesAudioBackend::enumerate_devices (): " << std::endl;
// COMMENTED DBG LOGS */ std::cout << "WavesAudioBackend::enumerate_devices (): " << std::endl;
std::vector<DeviceStatus> devicesStatus;
const WCMRAudioDeviceList& devices = _audio_device_manager.Devices ();
const DeviceInfoVec& deviceInfoList = _audio_device_manager.DeviceInfoList();
for (WCMRAudioDeviceListConstIter deviceIter = devices.begin (); deviceIter != devices.end (); ++deviceIter) {
/* COMMENTED DBG LOGS */ std::cout << "\t Device found: " << (*deviceIter)->DeviceName () << std::endl;
devicesStatus.push_back (DeviceStatus ((*deviceIter)->DeviceName (), true));
for (DeviceInfoVecConstIter deviceInfoIter = deviceInfoList.begin (); deviceInfoIter != deviceInfoList.end (); ++deviceInfoIter) {
// COMMENTED DBG LOGS */ std::cout << "\t Device found: " << (*deviceInfoIter)->m_DeviceName << std::endl;
devicesStatus.push_back (DeviceStatus ((*deviceInfoIter)->m_DeviceName, true));
}
return devicesStatus;
@ -167,23 +180,21 @@ WavesAudioBackend::enumerate_devices () const
std::vector<float>
WavesAudioBackend::available_sample_rates (const std::string& device_name) const
{
/* COMMENTED DBG LOGS */ std::cout << "WavesAudioBackend::available_sample_rates (): [" << device_name << "]" << std::endl;
// COMMENTED DBG LOGS */ std::cout << "WavesAudioBackend::available_sample_rates (): [" << device_name << "]" << std::endl;
std::vector<int> sr;
DeviceInfo devInfo;
WTErr err = _audio_device_manager.GetDeviceInfoByName(device_name, devInfo);
WCMRAudioDevice * device = _audio_device_manager.GetDeviceByName (device_name);
if (!device) {
if (eNoErr != err) {
std::cerr << "WavesAudioBackend::available_sample_rates (): Failed to find device [" << device_name << "]" << std::endl;
return std::vector<float> ();
}
sr = device->SamplingRates ();
/* COMMENTED DBG LOGS */ std::cout << "\tFound " << sr.size () << " sample rates for " << device->DeviceName () << ":";
// COMMENTED DBG LOGS */ std::cout << "\tFound " << devInfo.m_AvailableSampleRates.size () << " sample rates for " << device_name << ":";
std::vector<float> sample_rates (sr.begin (), sr.end ());
std::vector<float> sample_rates (devInfo.m_AvailableSampleRates.begin (), devInfo.m_AvailableSampleRates.end ());
/* COMMENTED DBG LOGS */ for (std::vector<float>::iterator i = sample_rates.begin (); i != sample_rates.end (); ++i) std::cout << " " << *i; std::cout << std::endl;
// COMMENTED DBG LOGS */ for (std::vector<float>::iterator i = sample_rates.begin (); i != sample_rates.end (); ++i) std::cout << " " << *i; std::cout << std::endl;
return sample_rates;
}
@ -191,7 +202,7 @@ WavesAudioBackend::available_sample_rates (const std::string& device_name) const
float WavesAudioBackend::default_sample_rate () const
{
/* COMMENTED DBG LOGS */ std::cout << "WavesAudioBackend::default_sample_rate ():" << std::endl;
// COMMENTED DBG LOGS */ std::cout << "WavesAudioBackend::default_sample_rate (): " << AudioBackend::default_sample_rate () << std::endl;
return AudioBackend::default_sample_rate ();
}
@ -199,18 +210,22 @@ float WavesAudioBackend::default_sample_rate () const
std::vector<uint32_t>
WavesAudioBackend::available_buffer_sizes (const std::string& device_name) const
{
/* COMMENTED DBG LOGS */ std::cout << "WavesAudioBackend::available_buffer_sizes (): [" << device_name << "]" << std::endl;
// COMMENTED DBG LOGS */ std::cout << "WavesAudioBackend::available_buffer_sizes (): [" << device_name << "]" << std::endl;
WCMRAudioDevice * device = _audio_device_manager.GetDeviceByName (device_name);
if (!device) {
std::cerr << "WavesAudioBackend::available_buffer_sizes (): Failed to find device [" << device_name << "]" << std::endl;
std::vector<int> bs;
WTErr retVal;
retVal = _audio_device_manager.GetDeviceBufferSizes(device_name, bs);
if (retVal != eNoErr) {
std::cerr << "WavesAudioBackend::available_buffer_sizes (): Failed to get buffer size for device [" << device_name << "]" << std::endl;
return std::vector<uint32_t> ();
}
std::vector<uint32_t> buffer_sizes (device->BufferSizes ().begin (), device->BufferSizes ().end ());
std::vector<uint32_t> buffer_sizes (bs.begin (), bs.end ());
/* COMMENTED DBG LOGS */ std::cout << "\tFound " << buffer_sizes.size () << " buffer sizes for " << device->DeviceName () << ":";
/* COMMENTED DBG LOGS */ for (std::vector<uint32_t>::const_iterator i = buffer_sizes.begin (); i != buffer_sizes.end (); ++i) std::cout << " " << *i; std::cout << std::endl;
// COMMENTED DBG LOGS */ std::cout << "\tFound " << buffer_sizes.size () << " buffer sizes for " << device_name << ":";
// COMMENTED DBG LOGS */ for (std::vector<uint32_t>::const_iterator i = buffer_sizes.begin (); i != buffer_sizes.end (); ++i) std::cout << " " << *i; std::cout << std::endl;
return buffer_sizes;
}
@ -219,17 +234,17 @@ WavesAudioBackend::available_buffer_sizes (const std::string& device_name) const
uint32_t
WavesAudioBackend::available_input_channel_count (const std::string& device_name) const
{
DeviceInfo devInfo;
WTErr err = _audio_device_manager.GetDeviceInfoByName(device_name, devInfo);
WCMRAudioDevice * device = _audio_device_manager.GetDeviceByName (device_name);
if (!device) {
if (eNoErr != err) {
std::cerr << "WavesAudioBackend::available_input_channel_count (): Failed to find device [" << device_name << "]" << std::endl;
return 0;
}
uint32_t num_of_input_channels = device->InputChannels ().size ();
uint32_t num_of_input_channels = devInfo.m_MaxInputChannels;
/* COMMENTED DBG LOGS */ std::cout << "WavesAudioBackend::available_input_channel_count (): " << num_of_input_channels << std::endl;
// COMMENTED DBG LOGS */ std::cout << "WavesAudioBackend::available_input_channel_count (): " << num_of_input_channels << std::endl;
return num_of_input_channels;
}
@ -237,17 +252,17 @@ WavesAudioBackend::available_input_channel_count (const std::string& device_name
uint32_t
WavesAudioBackend::available_output_channel_count (const std::string& device_name) const
{
std::vector<std::string> output_channels;
DeviceInfo devInfo;
WTErr err = _audio_device_manager.GetDeviceInfoByName(device_name, devInfo);
WCMRAudioDevice * device = _audio_device_manager.GetDeviceByName (device_name);
if (!device) {
if (eNoErr != err) {
std::cerr << "WavesAudioBackend::available_output_channel_count (): Failed to find device [" << device_name << "]" << std::endl;
return 0;
}
uint32_t num_of_output_channels = device->OutputChannels ().size ();
uint32_t num_of_output_channels = devInfo.m_MaxOutputChannels;
/* COMMENTED DBG LOGS */ std::cout << "WavesAudioBackend::available_output_channel_count (): " << num_of_output_channels << std::endl;
// COMMENTED DBG LOGS */ std::cout << "WavesAudioBackend::available_output_channel_count (): " << num_of_output_channels << std::endl;
return num_of_output_channels;
}
@ -272,7 +287,7 @@ WavesAudioBackend::can_change_buffer_size_when_running () const
int
WavesAudioBackend::set_device_name (const std::string& device_name)
{
/* COMMENTED DBG LOGS */ std::cout << "WavesAudioBackend::set_device_name (): " << device_name << std::endl;
// COMMENTED DBG LOGS */ std::cout << "WavesAudioBackend::set_device_name (): " << device_name << std::endl;
if (_ports.size ()) {
std::cerr << "WavesAudioBackend::set_device_name (): There are unregistered ports left after [" << (_device ? _device->DeviceName () : std::string ("<NULL>")) << "]!" << std::endl;
@ -282,13 +297,12 @@ WavesAudioBackend::set_device_name (const std::string& device_name)
return -1;
}
WCMRAudioDevice * device = _audio_device_manager.GetDeviceByName (device_name);
if (!device) {
std::cerr << "WavesAudioBackend::set_device_name (): Failed to find device [" << device_name << "]!" << std::endl;
return -1;
if (_device && _device->Streaming () ) {
std::cerr << "WavesAudioBackend::set_device_name (): [" << _device->DeviceName () << "] is streaming! Current device must be stopped before setting another device as current" << std::endl;
}
// we must have only one device initialized at a time
// stop current device first
WTErr retVal;
if (_device) {
retVal = _device->SetActive (false);
@ -298,7 +312,17 @@ WavesAudioBackend::set_device_name (const std::string& device_name)
}
}
_device = NULL;
// deinitialize it
_audio_device_manager.DestroyCurrentDevice();
_device = 0;
WCMRAudioDevice * device = _audio_device_manager.InitNewCurrentDevice(device_name);
if (!device) {
std::cerr << "WavesAudioBackend::set_device_name (): Failed to initialize device [" << device_name << "]!" << std::endl;
return -1;
}
retVal = device->SetActive (true);
if (retVal != eNoErr) {
@ -311,10 +335,31 @@ WavesAudioBackend::set_device_name (const std::string& device_name)
}
int
WavesAudioBackend::drop_device()
{
WTErr wtErr = 0;
if (_device)
{
wtErr = _device->SetActive (false);
if (wtErr != eNoErr) {
std::cerr << "WavesAudioBackend::drop_device (): [" << _device->DeviceName () << "]->SetActive () failed!" << std::endl;
return -1;
}
}
_audio_device_manager.DestroyCurrentDevice();
_device = 0;
return 0;
}
int
WavesAudioBackend::set_sample_rate (float sample_rate)
{
/* COMMENTED DBG LOGS */ std::cout << "WavesAudioBackend::set_sample_rate (): " << sample_rate << std::endl;
// COMMENTED DBG LOGS */ std::cout << "WavesAudioBackend::set_sample_rate (): " << sample_rate << std::endl;
WTErr retVal = eNoErr;
@ -328,7 +373,7 @@ WavesAudioBackend::set_sample_rate (float sample_rate)
if (device_needs_restart) {
retVal = _device->SetStreaming (false);
/* COMMENTED DBG LOGS */ std::cout << "\t\t[" << _device->DeviceName() << "]->_device->SetStreaming (false);"<< std::endl;
// COMMENTED DBG LOGS */ std::cout << "\t\t[" << _device->DeviceName() << "]->_device->SetStreaming (false);"<< std::endl;
if (retVal != eNoErr) {
std::cerr << "WavesAudioBackend::set_sample_rate (): [" << _device->DeviceName () << "]->SetStreaming (false) failed (" << retVal << ") !" << std::endl;
return -1;
@ -342,12 +387,10 @@ WavesAudioBackend::set_sample_rate (float sample_rate)
return -1;
}
_sample_rate = sample_rate;
_init_dsp_load_history();
engine.sample_rate_change (sample_rate);
_sample_rate_change(sample_rate);
if (device_needs_restart) {
/* COMMENTED DBG LOGS */ std::cout << "\t\t[" << _device->DeviceName() << "]->SetStreaming (true);"<< std::endl;
// COMMENTED DBG LOGS */ std::cout << "\t\t[" << _device->DeviceName() << "]->SetStreaming (true);"<< std::endl;
_call_thread_init_callback = true;
retVal = _device->SetStreaming (true);
if (retVal != eNoErr) {
@ -362,7 +405,7 @@ WavesAudioBackend::set_sample_rate (float sample_rate)
int
WavesAudioBackend::set_buffer_size (uint32_t buffer_size)
{
/* COMMENTED DBG LOGS */ std::cout << "WavesAudioBackend::set_buffer_size (): " << buffer_size << std::endl;
// COMMENTED DBG LOGS */ std::cout << "WavesAudioBackend::set_buffer_size (" << buffer_size << "):"<< std::endl;
WTErr retVal = eNoErr;
@ -375,7 +418,7 @@ WavesAudioBackend::set_buffer_size (uint32_t buffer_size)
if (device_needs_restart) {
retVal = _device->SetStreaming (false);
/* COMMENTED DBG LOGS */ std::cout << "\t\t[" << _device->DeviceName() << "]->SetStreaming (false);"<< std::endl;
// COMMENTED DBG LOGS */ std::cout << "\t\t[" << _device->DeviceName() << "]->SetStreaming (false);"<< std::endl;
if (retVal != eNoErr) {
std::cerr << "WavesAudioBackend::set_buffer_size (): [" << _device->DeviceName () << "]->SetStreaming (false) failed (" << retVal << ") !" << std::endl;
return -1;
@ -385,16 +428,14 @@ WavesAudioBackend::set_buffer_size (uint32_t buffer_size)
retVal = _device->SetCurrentBufferSize (buffer_size);
if (retVal != eNoErr) {
std::cerr << "WavesAudioBackend::set_sample_rate (): [" << _device->DeviceName() << "]->SetCurrentBufferSize (" << buffer_size << ") failed (" << retVal << ") !" << std::endl;
std::cerr << "WavesAudioBackend::set_buffer_size (): [" << _device->DeviceName() << "]->SetCurrentBufferSize (" << buffer_size << ") failed (" << retVal << ") !" << std::endl;
return -1;
}
_buffer_size = buffer_size;
_init_dsp_load_history();
engine.buffer_size_change (buffer_size);
_buffer_size_change(buffer_size);
if (device_needs_restart) {
/* COMMENTED DBG LOGS */ std::cout << "\t\t[" << _device->DeviceName() << "]->SetStreaming (true);"<< std::endl;
// COMMENTED DBG LOGS */ std::cout << "\t\t[" << _device->DeviceName() << "]->SetStreaming (true);"<< std::endl;
_call_thread_init_callback = true;
retVal = _device->SetStreaming (true);
if (retVal != eNoErr) {
@ -407,6 +448,146 @@ WavesAudioBackend::set_buffer_size (uint32_t buffer_size)
}
int
WavesAudioBackend::set_sample_format (SampleFormat sample_format)
{
// COMMENTED DBG LOGS */ std::cout << "WavesAudioBackend::set_sample_format (): " << sample_format << std::endl;
_sample_format = sample_format;
return 0;
}
int
WavesAudioBackend::_reset_device (uint32_t buffer_size, float sample_rate)
{
// COMMENTED DBG LOGS */ std::cout << "WavesAudioBackend::_reset_device (" << buffer_size <<", " << sample_rate << "):" << std::endl;
WTErr retVal = eNoErr;
if (!_device) {
std::cerr << "WavesAudioBackend::set_buffer_size (): No device is set!" << std::endl;
return -1;
}
bool device_needs_restart = _device->Streaming ();
if (device_needs_restart) {
retVal = _device->SetStreaming (false);
// COMMENTED DBG LOGS */ std::cout << "\t\t[" << _device->DeviceName() << "]->SetStreaming (false);"<< std::endl;
if (retVal != eNoErr) {
std::cerr << "WavesAudioBackend::_reset_device (): [" << _device->DeviceName () << "]->SetStreaming (false) failed (" << retVal << ") !" << std::endl;
return -1;
}
retVal = _device->SetActive (false);
// COMMENTED DBG LOGS */ std::cout << "\t\t[" << _device->DeviceName() << "]->SetActive (false);"<< std::endl;
if (retVal != eNoErr) {
std::cerr << "WavesAudioBackend::_reset_device (): [" << _device->DeviceName () << "]->SetActive (false) failed (" << retVal << ") !" << std::endl;
return -1;
}
}
retVal = _device->UpdateDeviceInfo ();
if (retVal != eNoErr) {
std::cerr << "WavesAudioBackend::_reset_device (): [" << _device->DeviceName() << "]->UpdateDeviceInfo () failed (" << retVal << ") !" << std::endl;
return -1;
}
if (buffer_size != 0)
{
retVal = _device->SetCurrentBufferSize (buffer_size);
if (retVal != eNoErr) {
std::cerr << "WavesAudioBackend::_reset_device (): [" << _device->DeviceName() << "]->SetCurrentBufferSize (" << buffer_size << ") failed (" << retVal << ") !" << std::endl;
return -1;
}
_buffer_size = buffer_size;
}
else
{
uint32_t current_buffer_size = _device->CurrentBufferSize();
// COMMENTED DBG LOGS */ std::cout << "\t\tcurrent_buffer_size: " << current_buffer_size << std::endl;
// COMMENTED DBG LOGS */ std::cout << "\t\t _buffer_size: " << _buffer_size << std::endl;
if(_buffer_size != current_buffer_size)
{
_buffer_size = current_buffer_size;
engine.buffer_size_change (_buffer_size);
// COMMENTED DBG LOGS */ std::cout << "\t\tengine.buffer_size_change (" << buffer_size <<")" << std::endl;
}
}
if(sample_rate > 0.0)
{
retVal = _device->SetCurrentSamplingRate ((int)sample_rate);
if (retVal != eNoErr) {
std::cerr << "WavesAudioBackend::set_sample_rate (): [" << _device->DeviceName() << "]->SetCurrentSamplingRate ((int)" << sample_rate << ") failed (" << retVal << ") !" << std::endl;
return -1;
}
_sample_rate = sample_rate;
}
else
{
float current_sample_rate = _device->CurrentSamplingRate();
// COMMENTED DBG LOGS */ std::cout << "\t\tcurrent_sample_rate: " << current_sample_rate << std::endl;
// COMMENTED DBG LOGS */ std::cout << "\t\t _sample_rate: " << _sample_rate << std::endl;
if(_sample_rate != current_sample_rate)
{
_sample_rate = current_sample_rate;
engine.sample_rate_change (_sample_rate);
// COMMENTED DBG LOGS */ std::cout << "\t\tengine.sample_rate_change (" << _sample_rate <<")" << std::endl;
}
}
_init_dsp_load_history();
if (device_needs_restart) {
// COMMENTED DBG LOGS */ std::cout << "\t\t[" << _device->DeviceName() << "]->SetActive (true);"<< std::endl;
retVal = _device->SetActive (true);
if (retVal != eNoErr) {
std::cerr << "WavesAudioBackend::_reset_device (): [" << _device->DeviceName () << "]->SetActive (true) failed (" << retVal << ") !" << std::endl;
return -1;
}
// COMMENTED DBG LOGS */ std::cout << "\t\t[" << _device->DeviceName() << "]->SetStreaming (true);"<< std::endl;
_call_thread_init_callback = true;
retVal = _device->SetStreaming (true);
if (retVal != eNoErr) {
std::cerr << "WavesAudioBackend::_reset_device (): [" << _device->DeviceName () << "]->SetStreaming (true) failed (" << retVal << ") !" << std::endl;
return -1;
}
}
return 0;
}
int
WavesAudioBackend::_buffer_size_change (uint32_t new_buffer_size)
{
_buffer_size = new_buffer_size;
_init_dsp_load_history();
return engine.buffer_size_change (new_buffer_size);
}
int
WavesAudioBackend::_sample_rate_change (float new_sample_rate)
{
_sample_rate = new_sample_rate;
_init_dsp_load_history();
return engine.sample_rate_change (new_sample_rate);
}
int
WavesAudioBackend::_device_list_change ()
{
// requires GZ changes for device list update
// return engine.device_list_change ();
return 0;
}
int
WavesAudioBackend::set_interleaved (bool yn)
{
@ -419,7 +600,7 @@ WavesAudioBackend::set_interleaved (bool yn)
int
WavesAudioBackend::set_input_channels (uint32_t input_channels)
{
/* COMMENTED DBG LOGS */ std::cout << "WavesAudioBackend::set_input_channels (): " << input_channels << std::endl;
// COMMENTED DBG LOGS */ std::cout << "WavesAudioBackend::set_input_channels (): " << input_channels << std::endl;
_input_channels = input_channels;
return 0;
@ -429,7 +610,7 @@ WavesAudioBackend::set_input_channels (uint32_t input_channels)
int
WavesAudioBackend::set_output_channels (uint32_t output_channels)
{
/* COMMENTED DBG LOGS */ std::cout << "WavesAudioBackend::set_output_channels (): " << output_channels << std::endl;
// COMMENTED DBG LOGS */ std::cout << "WavesAudioBackend::set_output_channels (): " << output_channels << std::endl;
_output_channels = output_channels;
return 0;
@ -439,10 +620,11 @@ WavesAudioBackend::set_output_channels (uint32_t output_channels)
std::string
WavesAudioBackend::device_name () const
{
/* COMMENTED DBG LOGS */ std::cout << "WavesAudioBackend::device_name (): " << _device->DeviceName () << std::endl;
if (!_device) {
return "";
}
// COMMENTED DBG LOGS */ std::cout << "WavesAudioBackend::device_name (): " << _device->DeviceName () << std::endl;
return _device->DeviceName ();
}
@ -450,7 +632,7 @@ WavesAudioBackend::device_name () const
float
WavesAudioBackend::sample_rate () const
{
/* COMMENTED DBG LOGS */ std::cout << "WavesAudioBackend::sample_rate (): " << std::endl;
// COMMENTED DBG LOGS */ std::cout << "WavesAudioBackend::sample_rate (): " << std::endl;
if (!_device) {
std::cerr << "WavesAudioBackend::sample_rate (): No device is set!" << std::endl;
@ -459,7 +641,7 @@ WavesAudioBackend::sample_rate () const
int sample_rate = _device->CurrentSamplingRate ();
/* COMMENTED DBG LOGS */ std::cout << "\t[" << _device->DeviceName () << "]->CurrentSamplingRate () returned " << sample_rate << std::endl;
// COMMENTED DBG LOGS */ std::cout << "\t[" << _device->DeviceName () << "]->CurrentSamplingRate () returned " << sample_rate << std::endl;
return (float)sample_rate;
}
@ -469,7 +651,7 @@ uint32_t
WavesAudioBackend::buffer_size () const
{
/* COMMENTED DBG LOGS */ std::cout << "WavesAudioBackend::buffer_size (): " << std::endl;
// COMMENTED DBG LOGS */ std::cout << "WavesAudioBackend::buffer_size (): " << std::endl;
if (!_device) {
std::cerr << "WavesAudioBackend::buffer_size (): No device is set!" << std::endl;
@ -478,16 +660,24 @@ WavesAudioBackend::buffer_size () const
int size = _device->CurrentBufferSize ();
/* COMMENTED DBG LOGS */ std::cout << "\t[" << _device->DeviceName () << "]->CurrentBufferSize () returned " << size << std::endl;
// COMMENTED DBG LOGS */ std::cout << "\t[" << _device->DeviceName () << "]->CurrentBufferSize () returned " << size << std::endl;
return (uint32_t)size;
}
SampleFormat
WavesAudioBackend::sample_format () const
{
// COMMENTED DBG LOGS */ std::cout << "WavesAudioBackend::sample_format ()" << std::endl;
return _sample_format;
}
bool
WavesAudioBackend::interleaved () const
{
/* COMMENTED DBG LOGS */ std::cout << "WavesAudioBackend::interleaved ()" << std::endl;
// COMMENTED DBG LOGS */ std::cout << "WavesAudioBackend::interleaved ()" << std::endl;
return _interleaved;
}
@ -496,7 +686,7 @@ WavesAudioBackend::interleaved () const
uint32_t
WavesAudioBackend::input_channels () const
{
/* COMMENTED DBG LOGS */ std::cout << "WavesAudioBackend::input_channels ()" << std::endl;
// COMMENTED DBG LOGS */ std::cout << "WavesAudioBackend::input_channels ()" << std::endl;
return _input_channels;
}
@ -505,7 +695,7 @@ WavesAudioBackend::input_channels () const
uint32_t
WavesAudioBackend::output_channels () const
{
/* COMMENTED DBG LOGS */ std::cout << "WavesAudioBackend::output_channels ()" << std::endl;
// COMMENTED DBG LOGS */ std::cout << "WavesAudioBackend::output_channels ()" << std::endl;
return _output_channels;
}
@ -527,7 +717,7 @@ WavesAudioBackend::control_app_name () const
void
WavesAudioBackend::launch_control_app ()
{
/* COMMENTED DBG LOGS */ std::cout << "WavesAudioBackend::launch_control_app ()" << std::endl;
// COMMENTED DBG LOGS */ std::cout << "WavesAudioBackend::launch_control_app ()" << std::endl;
if (!_device) {
std::cerr << "WavesAudioBackend::launch_control_app (): No device is set!" << std::endl;
return;
@ -539,14 +729,14 @@ WavesAudioBackend::launch_control_app ()
std::cerr << "WavesAudioBackend::launch_control_app (): [" << _device->DeviceName () << "]->ShowConfigPanel () failed (" << err << ")!" << std::endl;
}
/* COMMENTED DBG LOGS */ else std::cout << "WavesAudioBackend::launch_control_app (): [" << _device->DeviceName () << "]->ShowConfigPanel () successfully launched!" << std::endl;
// COMMENTED DBG LOGS */ else std::cout << "WavesAudioBackend::launch_control_app (): [" << _device->DeviceName () << "]->ShowConfigPanel () successfully launched!" << std::endl;
}
int
WavesAudioBackend::_start (bool for_latency_measurement)
{
/* COMMENTED DBG LOGS */ std::cout << "WavesAudioBackend::_start ()" << std::endl;
// COMMENTED DBG LOGS */ std::cout << "WavesAudioBackend::_start ()" << std::endl;
if (!_device) {
std::cerr << "WavesAudioBackend::_start (): No device is set!" << std::endl;
@ -606,7 +796,7 @@ WavesAudioBackend::_audio_device_callback (const float* input_buffer,
_cycle_start_time_nanos = cycle_start_time_nanos;
if (_buffer_size != nframes) {
std::cout << _buffer_size << "!=" << nframes << std::endl;
// COMMENTED DBG LOGS */ std::cout << "\tAudioEngine::thread_init_callback() buffer size and nframes are not equal: " << _buffer_size << "!=" << nframes << std::endl;
return;
}
@ -615,7 +805,7 @@ WavesAudioBackend::_audio_device_callback (const float* input_buffer,
if (_call_thread_init_callback) {
_call_thread_init_callback = false;
/* COMMENTED DBG LOGS */ std::cout << "\tAudioEngine::thread_init_callback() invoked for " << std::hex << pthread_self() << std::dec << " !" << std::endl;
// COMMENTED DBG LOGS */ std::cout << "\tAudioEngine::thread_init_callback() invoked for " << std::hex << pthread_self() << std::dec << " !" << std::endl;
AudioEngine::thread_init_callback (this);
}
@ -639,35 +829,34 @@ WavesAudioBackend::_audio_device_callback (const float* input_buffer,
int
WavesAudioBackend::stop ()
{
/* COMMENTED DBG LOGS */ std::cout << "WavesAudioBackend::stop ()" << std::endl;
// COMMENTED DBG LOGS */ std::cout << "WavesAudioBackend::stop ()" << std::endl;
WTErr retVal = eNoErr;
WTErr wtErr = eNoErr;
int retVal = 0;
if (!_device) {
std::cerr << "WavesAudioBackend::stop (): No device is set!" << std::endl;
return -1;
}
// COMMENTED DBG LOGS */ std::cout << "\t[" << _device->DeviceName () << "]" << std::endl;
/* COMMENTED DBG LOGS */ std::cout << "\t[" << _device->DeviceName () << "]" << std::endl;
retVal = _device->SetStreaming (false);
if (retVal != eNoErr) {
if (_device) {
wtErr = _device->SetStreaming (false);
if (wtErr != eNoErr) {
std::cerr << "WavesAudioBackend::stop (): [" << _device->DeviceName () << "]->SetStreaming () failed!" << std::endl;
return -1;
retVal = -1;
}
}
_midi_device_manager.stop ();
_unregister_system_audio_ports ();
_unregister_system_midi_ports ();
return 0;
return retVal;
}
int
WavesAudioBackend::freewheel (bool start_stop)
{
/* COMMENTED DBG LOGS */ std::cout << "WavesAudioBackend::freewheel (" << start_stop << "):" << std::endl;
// COMMENTED DBG LOGS */ std::cout << "WavesAudioBackend::freewheel (" << start_stop << "):" << std::endl;
if (start_stop != _freewheeling) {
if (start_stop == true) {
@ -700,10 +889,10 @@ WavesAudioBackend::freewheel (bool start_stop)
void
WavesAudioBackend::_freewheel_thread ()
{
/* COMMENTED DBG LOGS */ std::cout << "WavesAudioBackend::_freewheel_thread ():" << std::endl;
// COMMENTED DBG LOGS */ std::cout << "WavesAudioBackend::_freewheel_thread ():" << std::endl;
if (!_freewheel_thread_active) { // Lets create it
/* COMMENTED DBG LOGS */ std::cout << "\tCreating the thread _freewheel_thread () . . ." << std::endl;
// COMMENTED DBG LOGS */ std::cout << "\tCreating the thread _freewheel_thread () . . ." << std::endl;
pthread_attr_t attributes;
pthread_t thread_id;
@ -726,7 +915,7 @@ WavesAudioBackend::_freewheel_thread ()
return;
}
/* COMMENTED DBG LOGS */ std::cout << "\t. . . _freewheel_thread () complete." << std::endl;
// COMMENTED DBG LOGS */ std::cout << "\t. . . _freewheel_thread () complete." << std::endl;
return;
}
@ -738,7 +927,7 @@ WavesAudioBackend::_freewheel_thread ()
while (_freewheel_thread_active) {
engine.process_callback (_buffer_size);
}
/* COMMENTED DBG LOGS */ std::cout << "WavesAudioBackend::_freewheel_thread (): FINISHED" << std::endl;
// COMMENTED DBG LOGS */ std::cout << "WavesAudioBackend::_freewheel_thread (): FINISHED" << std::endl;
return;
}
@ -771,7 +960,7 @@ WavesAudioBackend::_init_dsp_load_history()
_dsp_load_accumulator = 0;
_dsp_load_history_length = (_sample_rate + _buffer_size - 1) / _buffer_size;
/* COMMENTED DBG LOGS */ std::cout << "\t\t_dsp_load_history_length = " << _dsp_load_history_length << std::endl;
// COMMENTED DBG LOGS */ std::cout << "\t\t_dsp_load_history_length = " << _dsp_load_history_length << std::endl;
_dsp_load_history = std::list<uint64_t>(_dsp_load_history_length, 0);
}
@ -779,21 +968,21 @@ WavesAudioBackend::_init_dsp_load_history()
void
WavesAudioBackend::transport_start ()
{
/* COMMENTED DBG LOGS */ std::cout << "WavesAudioBackend::transport_start (): " << std::endl;
// COMMENTED DBG LOGS */ std::cout << "WavesAudioBackend::transport_start (): " << std::endl;
}
void
WavesAudioBackend::transport_stop ()
{
/* COMMENTED DBG LOGS */ std::cout << "WavesAudioBackend::transport_stop (): " << std::endl;
// COMMENTED DBG LOGS */ std::cout << "WavesAudioBackend::transport_stop (): " << std::endl;
}
TransportState
WavesAudioBackend::transport_state () const
{
/* COMMENTED DBG LOGS */ std::cout << "WavesAudioBackend::transport_state (): " << std::endl;
// COMMENTED DBG LOGS */ std::cout << "WavesAudioBackend::transport_state (): " << std::endl;
return TransportStopped;
}
@ -801,14 +990,14 @@ WavesAudioBackend::transport_state () const
void
WavesAudioBackend::transport_locate (framepos_t pos)
{
/* COMMENTED DBG LOGS */ std::cout << "WavesAudioBackend::transport_locate (" << pos << "): " << std::endl;
// COMMENTED DBG LOGS */ std::cout << "WavesAudioBackend::transport_locate (" << pos << "): " << std::endl;
}
framepos_t
WavesAudioBackend::transport_frame () const
{
/* COMMENTED DBG LOGS */ std::cout << "WavesAudioBackend::transport_frame (): " << std::endl;
// COMMENTED DBG LOGS */ std::cout << "WavesAudioBackend::transport_frame (): " << std::endl;
return 0;
}
@ -816,7 +1005,7 @@ WavesAudioBackend::transport_frame () const
int
WavesAudioBackend::set_time_master (bool yn)
{
/* COMMENTED DBG LOGS */ std::cout << "WavesAudioBackend::set_time_master (): " << yn << std::endl;
// COMMENTED DBG LOGS */ std::cout << "WavesAudioBackend::set_time_master (): " << yn << std::endl;
return 0;
}
@ -824,7 +1013,7 @@ WavesAudioBackend::set_time_master (bool yn)
int
WavesAudioBackend::usecs_per_cycle () const
{
/* COMMENTED DBG LOGS */ std::cout << "WavesAudioBackend::usecs_per_cycle (): " << std::endl;
// COMMENTED DBG LOGS */ std::cout << "WavesAudioBackend::usecs_per_cycle (): " << std::endl;
return (1000000 * _sample_rate) / _buffer_size;
}
@ -890,7 +1079,7 @@ WavesAudioBackend::samples_since_cycle_start ()
{
pframes_t diff_sample_time;
diff_sample_time = sample_time () - _sample_time_at_cycle_start;
/* COMMENTED DBG LOGS */ std::cout << "samples_since_cycle_start: " << diff_sample_time << std::endl;
// COMMENTED DBG LOGS */ std::cout << "samples_since_cycle_start: " << diff_sample_time << std::endl;
return diff_sample_time;
}
@ -899,7 +1088,7 @@ WavesAudioBackend::samples_since_cycle_start ()
bool
WavesAudioBackend::get_sync_offset (pframes_t& /*offset*/) const
{
/* COMMENTED DBG LOGS */ std::cout << "get_sync_offset: false" << std::endl;
// COMMENTED DBG LOGS */ std::cout << "get_sync_offset: false" << std::endl;
return false;
}
@ -908,7 +1097,7 @@ WavesAudioBackend::get_sync_offset (pframes_t& /*offset*/) const
int
WavesAudioBackend::create_process_thread (boost::function<void ()> func)
{
/* COMMENTED DBG LOGS */ std::cout << "WavesAudioBackend::create_process_thread ():" << std::endl;
// COMMENTED DBG LOGS */ std::cout << "WavesAudioBackend::create_process_thread ():" << std::endl;
int retVal;
pthread_attr_t attributes;
size_t stacksize_aligned;
@ -935,7 +1124,7 @@ WavesAudioBackend::create_process_thread (boost::function<void ()> func)
}
_backend_threads.push_back (thread_id);
/* COMMENTED DBG LOGS */ std::cout << "\t\t\t. . . thread " << std::hex << thread_id << " has been created" << std::endl;
// COMMENTED DBG LOGS */ std::cout << "\t\t\t. . . thread " << std::hex << thread_id << std::dec << " has been created" << std::endl;
return 0;
}
@ -944,7 +1133,7 @@ WavesAudioBackend::create_process_thread (boost::function<void ()> func)
void*
WavesAudioBackend::__start_process_thread (void* arg)
{
/* COMMENTED DBG LOGS */ std::cout << "WavesAudioBackend::__start_process_thread ():" << std::endl;
// COMMENTED DBG LOGS */ std::cout << "WavesAudioBackend::__start_process_thread ():" << std::endl;
ThreadData* td = reinterpret_cast<ThreadData*> (arg);
boost::function<void ()> f = td->f;
delete td;
@ -956,24 +1145,24 @@ WavesAudioBackend::__start_process_thread (void* arg)
int
WavesAudioBackend::join_process_threads ()
{
/* COMMENTED DBG LOGS */ std::cout << "WavesAudioBackend::join_process_thread ()" << std::endl;
// COMMENTED DBG LOGS */ std::cout << "WavesAudioBackend::join_process_thread ()" << std::endl;
int ret = 0;
for (std::vector<pthread_t>::const_iterator i = _backend_threads.begin ();
i != _backend_threads.end ();
++i) {
/* COMMENTED DBG LOGS */ std::cout << "\t\t\tstopping thread " << std::hex << *i << std::dec << "...\n";
// COMMENTED DBG LOGS */ std::cout << "\t\t\tstopping thread " << std::hex << *i << std::dec << "...\n";
void* status;
if (pthread_join (*i, &status) != 0) {
std::cerr << "AudioEngine: cannot stop process thread !" << std::endl;
ret += -1;
}
/* COMMENTED DBG LOGS */ std::cout << "\t\t\t\t...done" << std::endl;
// COMMENTED DBG LOGS */ std::cout << "\t\t\t\t...done" << std::endl;
}
/* COMMENTED DBG LOGS */ std::cout << "\t\t\tall threads finished..." << std::endl;
// COMMENTED DBG LOGS */ std::cout << "\t\t\tall threads finished..." << std::endl;
_backend_threads.clear ();
/* COMMENTED DBG LOGS */ std::cout << "\t\t\tthread list cleared..." << std::endl;
// COMMENTED DBG LOGS */ std::cout << "\t\t\tthread list cleared..." << std::endl;
return ret;
}
@ -982,7 +1171,7 @@ WavesAudioBackend::join_process_threads ()
bool
WavesAudioBackend::in_process_thread ()
{
/* COMMENTED DBG LOGS */ std::cout << "WavesAudioBackend::in_process_thread ()" << std::endl;
// COMMENTED DBG LOGS */ std::cout << "WavesAudioBackend::in_process_thread ()" << std::endl;
for (std::vector<pthread_t>::const_iterator i = _backend_threads.begin ();
i != _backend_threads.end (); i++) {
if (pthread_equal (*i, pthread_self ()) != 0) {
@ -1008,7 +1197,7 @@ WavesAudioBackend::__thread_stack_size ()
uint32_t
WavesAudioBackend::process_thread_count ()
{
/* COMMENTED DBG LOGS */ std::cout << "WavesAudioBackend::process_thread_count (): returns " << _backend_threads.size () << std::endl;
// COMMENTED DBG LOGS */ std::cout << "WavesAudioBackend::process_thread_count (): returns " << _backend_threads.size () << std::endl;
return _backend_threads.size ();
}
@ -1083,7 +1272,7 @@ static boost::shared_ptr<WavesAudioBackend> __instance;
boost::shared_ptr<AudioBackend>
WavesAudioBackend::__waves_backend_factory (AudioEngine& e)
{
/* COMMENTED DBG LOGS */ std::cout << "WavesAudioBackend::__waves_backend_factory ():" << std::endl;
// COMMENTED DBG LOGS */ std::cout << "WavesAudioBackend::__waves_backend_factory ():" << std::endl;
if (!__instance) {
__instance.reset (new WavesAudioBackend (e));
}
@ -1100,7 +1289,7 @@ uint64_t WavesAudioBackend::__performance_counter_frequency;
int
WavesAudioBackend::__instantiate (const std::string& arg1, const std::string& arg2)
{
/* COMMENTED DBG LOGS */ std::cout << "WavesAudioBackend::__instantiate ():" << "[" << arg1 << "], [" << arg2 << "]" << std::endl;
// COMMENTED DBG LOGS */ std::cout << "WavesAudioBackend::__instantiate ():" << "[" << arg1 << "], [" << arg2 << "]" << std::endl;
__instantiated_name = arg1;
#if defined(_WINDOWS)
@ -1117,7 +1306,7 @@ WavesAudioBackend::__instantiate (const std::string& arg1, const std::string& ar
int
WavesAudioBackend::__deinstantiate ()
{
/* COMMENTED DBG LOGS */ std::cout << "WavesAudioBackend::__deinstantiate ():" << std::endl;
// COMMENTED DBG LOGS */ std::cout << "WavesAudioBackend::__deinstantiate ():" << std::endl;
__instance.reset ();
return 0;
}
@ -1126,7 +1315,7 @@ WavesAudioBackend::__deinstantiate ()
bool
WavesAudioBackend::__already_configured ()
{
/* COMMENTED DBG LOGS */ std::cout << "WavesAudioBackend::__already_configured ():" << std::endl;
// COMMENTED DBG LOGS */ std::cout << "WavesAudioBackend::__already_configured ():" << std::endl;
return false;
}
@ -1134,7 +1323,7 @@ WavesAudioBackend::__already_configured ()
void*
WavesAudioBackend::private_handle () const
{
/* COMMENTED DBG LOGS */ std::cout << "WHY DO CALL IT: WavesAudioBackend::private_handle: " << std::endl;
// COMMENTED DBG LOGS */ std::cout << "WHY DO CALL IT: WavesAudioBackend::private_handle: " << std::endl;
return NULL;
}
@ -1158,7 +1347,7 @@ WavesAudioBackend::my_name () const
bool
WavesAudioBackend::can_monitor_input () const
{
/* COMMENTED DBG LOGS */ std::cout << "WavesAudioBackend::can_monitor_input: " << std::endl;
// COMMENTED DBG LOGS */ std::cout << "WavesAudioBackend::can_monitor_input: " << std::endl;
return false;
}
@ -1176,9 +1365,12 @@ AudioBackendInfo WavesAudioBackend::__backend_info = {
WavesAudioBackend::__already_configured,
};
extern "C" ARDOURBACKEND_API ARDOUR::AudioBackendInfo* descriptor ()
#ifdef __MINGW64__
extern "C" __declspec(dllexport) ARDOUR::AudioBackendInfo* descriptor ()
#else
extern "C" ARDOURBACKEND_API ARDOUR::AudioBackendInfo* descriptor ()
#endif
{
/* COMMENTED DBG LOGS */ std::cout << "waves_backend.dll : ARDOUR::AudioBackendInfo* descriptor (): " << std::endl;
// COMMENTED DBG LOGS */ std::cout << "waves_backend.dll : ARDOUR::AudioBackendInfo* descriptor (): " << std::endl;
return &WavesAudioBackend::backend_info ();
}

View file

@ -1,5 +1,5 @@
/*
Copyright (C) 2014 Waves Audio Ltd.
Copyright (C) 2013 Valeriy Kamyshniy
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -41,7 +41,7 @@
class ArdourAudioDeviceManager : public WCMRCoreAudioDeviceManager
{
public:
ArdourAudioDeviceManager (WCMRAudioDeviceManagerClient *client) : WCMRCoreAudioDeviceManager (client, eFullDuplexDevices, true, eCABS_Simple, false) {};
ArdourAudioDeviceManager (WCMRAudioDeviceManagerClient *client) : WCMRCoreAudioDeviceManager (client, eAllDevices) {};
};
#elif defined (_WINDOWS)
@ -51,7 +51,7 @@ class ArdourAudioDeviceManager : public WCMRCoreAudioDeviceManager
class ArdourAudioDeviceManager : public WCMRPortAudioDeviceManager
{
public:
ArdourAudioDeviceManager (WCMRAudioDeviceManagerClient *client) : WCMRPortAudioDeviceManager (client, eFullDuplexDevices, paASIO) {};
ArdourAudioDeviceManager (WCMRAudioDeviceManagerClient *client) : WCMRPortAudioDeviceManager (client, eAllDevices) {};
};
#endif
@ -103,10 +103,14 @@ class WavesMidiPort;
virtual int set_device_name (const std::string& name);
virtual int drop_device();
virtual int set_sample_rate (float);
virtual int set_buffer_size (uint32_t);
virtual int set_sample_format (SampleFormat);
virtual int set_interleaved (bool yn);
virtual int set_input_channels (uint32_t);
@ -123,6 +127,8 @@ class WavesMidiPort;
virtual uint32_t buffer_size () const;
virtual SampleFormat sample_format () const;
virtual bool interleaved () const;
virtual uint32_t input_channels () const;
@ -275,6 +281,7 @@ class WavesMidiPort;
WavesMidiDeviceManager _midi_device_manager;
WCMRAudioDevice *_device;
SampleFormat _sample_format;
bool _interleaved;
static std::string __instantiated_name;
uint32_t _input_channels;
@ -317,8 +324,15 @@ class WavesMidiPort;
pframes_t sample_time,
uint64_t cycle_start_time_nanos);
int _reset_device (uint32_t buffer_size, float sample_rate);
void _changed_midi_devices ();
// DO change sample rate and buffer size
int _buffer_size_change(uint32_t new_buffer_size);
int _sample_rate_change(float new_sample_rate);
int _device_list_change();
int _register_system_audio_ports ();
int _register_system_midi_ports ();

View file

@ -1,5 +1,5 @@
/*
Copyright (C) 2014 Waves Audio Ltd.
Copyright (C) 2013 Valeriy Kamyshniy
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by

View file

@ -1,5 +1,5 @@
/*
Copyright (C) 2014 Waves Audio Ltd.
Copyright (C) 2013 Valeriy Kamyshniy
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -16,7 +16,6 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <boost/assign/list_of.hpp>
#include "waves_audiobackend.h"

View file

@ -1,5 +1,5 @@
/*
Copyright (C) 2014 Waves Audio Ltd.
Copyright (C) 2013 Valeriy Kamyshniy
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by

View file

@ -1,5 +1,5 @@
/*
Copyright (C) 2014 Waves Audio Ltd.
Copyright (C) 2013 Valeriy Kamyshniy
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by

View file

@ -1,5 +1,5 @@
/*
Copyright (C) 2014 Waves Audio Ltd.
Copyright (C) 2013 Paul Davis
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by

View file

@ -1,5 +1,5 @@
/*
Copyright (C) 2014 Waves Audio Ltd.
Copyright (C) 2013 Valeriy Kamyshniy
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by

View file

@ -1,5 +1,5 @@
/*
Copyright (C) 2014 Waves Audio Ltd.
Copyright (C) 2013 Paul Davis
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by

View file

@ -1,5 +1,5 @@
/*
Copyright (C) 2014 Waves Audio Ltd.
Copyright (C) 2013 Valeriy amyshniy
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -16,7 +16,6 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "waves_midi_buffer.h"
#include "waves_midi_event.h"

View file

@ -1,5 +1,5 @@
/*
Copyright (C) 2014 Waves Audio Ltd.
Copyright (C) 2013 Valeriy amyshniy
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -16,6 +16,7 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef __libardour_waves_midi_buffer_h__
#define __libardour_waves_midi_buffer_h__

View file

@ -1,5 +1,5 @@
/*
Copyright (C) 2014 Waves Audio Ltd.
Copyright (C) 2013 Gorobchenko Dmytro
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by

View file

@ -1,5 +1,5 @@
/*
Copyright (C) 2014 Waves Audio Ltd.
Copyright (C) 2013 Gorobchenko Dmytro
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by

View file

@ -1,5 +1,5 @@
/*
Copyright (C) 2014 Waves Audio Ltd.
Copyright (C) 2013 Paul Davis
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by

View file

@ -1,5 +1,5 @@
/*
Copyright (C) 2014 Waves Audio Ltd.
Copyright (C) 2013 Gorobchenko Dmytro
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by

View file

@ -1,5 +1,5 @@
/*
Copyright (C) 2014 Waves Audio Ltd.
Copyright (C) 2013 Valeriy amyshniy
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -16,7 +16,6 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "memory.h"
#include "waves_midi_event.h"

View file

@ -1,5 +1,5 @@
/*
Copyright (C) 2014 Waves Audio Ltd.
Copyright (C) 2013 Valeriy amyshniy
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by

View file

@ -1,5 +1,5 @@
/*
Copyright (C) 2014 Waves Audio Ltd.
Copyright (C) 2013 Gorobchenko Dmytro
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by

View file

@ -1,5 +1,5 @@
/*
Copyright (C) 2014 Waves Audio Ltd.
Copyright (C) 2013 Gorobchenko Dmytro
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by

View file

@ -1,21 +1,3 @@
/*
Copyright (C) 2013 Waves Audio Ltd.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef __WCFourCC_h__
#define __WCFourCC_h__

View file

@ -1,21 +1,3 @@
/*
Copyright (C) 2013 Waves Audio Ltd.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#if !defined(__WTByteOrder_h__)
#define __WTByteOrder_h__

View file

@ -1,21 +1,3 @@
/*
Copyright (C) 2013 Waves Audio Ltd.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef __WUComPtr_h__
#define __WUComPtr_h__

View file

@ -1,21 +1,3 @@
/*
Copyright (C) 2013 Waves Audio Ltd.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef __WUDefines_h__
#define __WUDefines_h__

View file

@ -1,21 +1,3 @@
/*
Copyright (C) 2013 Waves Audio Ltd.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef __WUMathConsts_h__
#define __WUMathConsts_h__

View file

@ -1,21 +1,3 @@
/*
Copyright (C) 2013 Waves Audio Ltd.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef __WUTypes_h__
#define __WUTypes_h__

View file

@ -1,21 +1,3 @@
/*
Copyright (C) 2013 Waves Audio Ltd.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef __IncludeWindows_h__
#define __IncludeWindows_h__

View file

@ -1,23 +1,6 @@
/*
Copyright (C) 2013 Waves Audio Ltd.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
//----------------------------------------------------------------------------------
//
// Copyright (c) 2008 Waves Audio Ltd. All rights reserved.
//
//! \file WCMRAudioDeviceManager.cpp
//!
@ -27,10 +10,6 @@
#include "WCMRAudioDeviceManager.h"
//**********************************************************************************************
// WCMRAudioDevice::WCMRAudioDevice
//
@ -39,27 +18,21 @@
//! and streaming will also be provided by the derived implementations.
//!
//! \param *pManager : The audio device manager that's managing this device.
//!
//! \return Nothing.
//!
//**********************************************************************************************
WCMRAudioDevice::WCMRAudioDevice (WCMRAudioDeviceManager *pManager)
WCMRAudioDevice::WCMRAudioDevice (WCMRAudioDeviceManager *pManager) :
m_pMyManager (pManager)
, m_ConnectionStatus (DeviceDisconnected)
, m_IsActive (false)
, m_IsStreaming (false)
, m_CurrentSamplingRate (-1)
, m_CurrentBufferSize (0)
, m_LeftMonitorChannel (-1)
, m_RightMonitorChannel (-1)
, m_MonitorGain (1.0f)
{
m_pMyManager = pManager;
m_DeviceName = "Unknown";
m_ConnectionStatus = DeviceDisconnected;
m_IsActive = false;
m_IsStreaming = false;
m_CurrentSamplingRate = -1;
m_CurrentBufferSize = 0;
m_LeftMonitorChannel = -1;
m_RightMonitorChannel = -1;
m_MonitorGain = 1.0f;
}
@ -565,6 +538,7 @@ uint32_t WCMRAudioDevice::GetLatency (bool isInput)
return 0;
}
//**********************************************************************************************
// WCMRAudioDeviceManager::WCMRAudioDeviceManager
//
@ -576,15 +550,13 @@ uint32_t WCMRAudioDevice::GetLatency (bool isInput)
//!
//**********************************************************************************************
WCMRAudioDeviceManager::WCMRAudioDeviceManager(WCMRAudioDeviceManagerClient *pTheClient, eAudioDeviceFilter eCurAudioDeviceFilter)
: m_pTheClient (pTheClient)
, m_eAudioDeviceFilter(eCurAudioDeviceFilter)
: m_eAudioDeviceFilter(eCurAudioDeviceFilter)
, m_CurrentDevice(0)
, m_pTheClient (pTheClient)
{
//The derived classes will do lot more init!
return;
}
//**********************************************************************************************
// WCMRAudioDeviceManager::~WCMRAudioDeviceManager
//
@ -599,19 +571,21 @@ WCMRAudioDeviceManager::~WCMRAudioDeviceManager()
{
AUTO_FUNC_DEBUG;
std::cout << "API::Destroying AudioDeviceManager " << std::endl;
try
{
//Need to call release on our devices, and erase them from list
std::vector<WCMRAudioDevice*>::iterator deviceIter;
while (m_Devices.size())
// clean up device info list
{
WCMRAudioDevice *pDeviceToRelease = m_Devices.back();
m_Devices.pop_back();
if (pDeviceToRelease)
SAFE_RELEASE (pDeviceToRelease);
wvNS::wvThread::ThreadMutex::lock theLock(m_AudioDeviceInfoVecMutex);
while( m_DeviceInfoVec.size() )
{
DeviceInfo* devInfo = m_DeviceInfoVec.back();
m_DeviceInfoVec.pop_back();
delete devInfo;
}
}
delete m_CurrentDevice;
//The derived classes may want to do additional de-int!
}
catch (...)
{
@ -621,107 +595,46 @@ WCMRAudioDeviceManager::~WCMRAudioDeviceManager()
}
//**********************************************************************************************
// WCMRAudioDeviceManager::DoIdle_Private
//
//! Used for idle time processing. This calls each device's DoIdle so that it can perform it's own idle processing.
//!
//! \param none
//!
//! \return noErr if no devices have returned an error. An error code if any of the devices returned error.
//!
//**********************************************************************************************
WTErr WCMRAudioDeviceManager::DoIdle_Private()
WCMRAudioDevice* WCMRAudioDeviceManager::InitNewCurrentDevice(const std::string & deviceName)
{
WTErr retVal = eNoErr;
//Need to call DoIdle of all our devices...
std::vector<WCMRAudioDevice*>::iterator deviceIter;
for (deviceIter = m_Devices.begin(); deviceIter != m_Devices.end(); deviceIter++)
{
WTErr thisDeviceErr = (*deviceIter)->DoIdle();
if (thisDeviceErr != eNoErr)
retVal = thisDeviceErr;
}
return (retVal);
return initNewCurrentDeviceImpl(deviceName);
}
//**********************************************************************************************
// WCMRAudioDeviceManager::Devices_Private
//
//! Retrieve list of devices managed by this manager.
//!
//! \param none
//!
//! \return A vector containing the list of devices.
//!
//**********************************************************************************************
const WCMRAudioDeviceList& WCMRAudioDeviceManager::Devices_Private() const
void WCMRAudioDeviceManager::DestroyCurrentDevice()
{
return (m_Devices);
return destroyCurrentDeviceImpl();
}
//**********************************************************************************************
// *WCMRAudioDeviceManager::GetDeviceByName_Private
//
//! Locates a device based on device name.
//!
//! \param nameToMatch : Device to look for.
//!
//! \return Pointer to the device object if found, NULL otherwise.
//!
//**********************************************************************************************
WCMRAudioDevice *WCMRAudioDeviceManager::GetDeviceByName_Private(const std::string& nameToMatch) const
const DeviceInfoVec WCMRAudioDeviceManager::DeviceInfoList() const
{
//Need to check all our devices...
WCMRAudioDevice *pRetVal = NULL;
WCMRAudioDeviceListConstIter deviceIter;
for (deviceIter = m_Devices.begin(); deviceIter != m_Devices.end(); deviceIter++)
{
if ((*deviceIter)->DeviceName() == nameToMatch)
{
pRetVal = *deviceIter;
break;
}
}
return (pRetVal);
}
//**********************************************************************************************
// *WCMRAudioDeviceManager::GetDefaultDevice
//
//! Locates a device based on device name.
//!
//! \param nameToMatch : Device to look for.
//!
//! \return Pointer to the device object if found, NULL otherwise.
//!
//**********************************************************************************************
WCMRAudioDevice *WCMRAudioDeviceManager::GetDefaultDevice_Private()
{
//Need to check all our devices...
WCMRAudioDevice *pRetVal = NULL;
WCMRAudioDeviceListIter deviceIter = m_Devices.begin();
if(deviceIter != m_Devices.end())
{
pRetVal = *deviceIter;
}
return (pRetVal);
wvNS::wvThread::ThreadMutex::lock theLock(m_AudioDeviceInfoVecMutex);
return m_DeviceInfoVec;
}
WTErr WCMRAudioDeviceManager::GetDeviceInfoByName(const std::string & nameToMatch, DeviceInfo & devInfo) const
{
wvNS::wvThread::ThreadMutex::lock theLock(m_AudioDeviceInfoVecMutex);
DeviceInfoVecConstIter iter = m_DeviceInfoVec.begin();
for (; iter != m_DeviceInfoVec.end(); ++iter)
{
if (nameToMatch == (*iter)->m_DeviceName)
{
devInfo = *(*iter);
return eNoErr;
}
}
return eRMResNotFound;
}
WTErr WCMRAudioDeviceManager::GetDeviceBufferSizes(const std::string & nameToMatch, std::vector<int>& bufferSizes) const
{
return getDeviceBufferSizesImpl(nameToMatch, bufferSizes);
}
//**********************************************************************************************

View file

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

View file

@ -1,23 +1,6 @@
/*
Copyright (C) 2013 Waves Audio Ltd.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
//----------------------------------------------------------------------------------
//
// Copyright (c) 2008 Waves Audio Ltd. All rights reserved.
//
//! \file WCMRCoreAudioDeviceManager.cpp
//!
@ -58,6 +41,8 @@ static const int DEFAULT_SR = 44100;
///< The default buffer size.
static const int DEFAULT_BUFFERSIZE = 128;
static const int NONE_DEVICE_ID = -1;
///< Number of stalls to wait before notifying user...
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.
@ -166,7 +151,7 @@ WCMRCoreAudioDevice::WCMRCoreAudioDevice (WCMRCoreAudioDeviceManager *pManager,
m_CurrentBufferSize = (int)bufferSize;
UpdateDeviceInfo(true /*updateSRSupported*/, true /* updateBufferSizes */);
UpdateDeviceInfo();
//should use a valid current SR...
if (m_SamplingRates.size())
@ -253,13 +238,10 @@ WCMRCoreAudioDevice::~WCMRCoreAudioDevice ()
//
//! Updates Device Information about channels, sampling rates, buffer sizes.
//!
//! \param updateSRSupported : Is Sampling Rate support needs to be updated.
//! \param updateBufferSizes : Is buffer size support needs to be updated.
//!
//! \return WTErr.
//!
//**********************************************************************************************
WTErr WCMRCoreAudioDevice::UpdateDeviceInfo (bool updateSRSupported, bool updateBufferSizes)
WTErr WCMRCoreAudioDevice::UpdateDeviceInfo ()
{
AUTO_FUNC_DEBUG;
@ -272,17 +254,8 @@ WTErr WCMRCoreAudioDevice::UpdateDeviceInfo (bool updateSRSupported, bool update
WTErr errSR = eNoErr;
WTErr errBS = eNoErr;
if (updateSRSupported)
{
errSR = UpdateDeviceSampleRates();
}
//update SR list... This is done conditionally, because some devices may not like
//changing the SR later on, just to check on things.
if (updateBufferSizes)
{
errBS = UpdateDeviceBufferSizes();
}
if(errName != eNoErr || errIn != eNoErr || errOut != eNoErr || errSR != eNoErr || errBS != eNoErr)
{
@ -786,7 +759,7 @@ WTErr WCMRCoreAudioDevice::SetCurrentSamplingRate (int newRate)
retVal = SetAndCheckCurrentSamplingRate (newRate);
if(retVal == eNoErr)
{
retVal = UpdateDeviceInfo (false/*updateSRSupported*/, true/*updateBufferSizes*/);
retVal = UpdateDeviceInfo ();
}
//reactivate it.
@ -1759,7 +1732,7 @@ WTErr WCMRCoreAudioDevice::SetActive (bool newState)
m_DropsReported = 0;
m_IgnoreThisDrop = true;
UpdateDeviceInfo(true /*updateSRSupported */, true /* updateBufferSizes#*/);
UpdateDeviceInfo();
}
@ -2317,14 +2290,10 @@ OSStatus WCMRCoreAudioDevice::GetStreamLatency(AudioDeviceID device, bool isInpu
//! \return Nothing.
//!
//**********************************************************************************************
WCMRCoreAudioDeviceManager::WCMRCoreAudioDeviceManager(WCMRAudioDeviceManagerClient *pTheClient, eAudioDeviceFilter eCurAudioDeviceFilter
, bool useMultithreading, eCABS_Method eCABS_method, bool bNocopy)
: WCMRAudioDeviceManager (pTheClient, eCurAudioDeviceFilter
)
, m_UpdateDeviceListRequested(0)
, m_UpdateDeviceListProcessed(0)
WCMRCoreAudioDeviceManager::WCMRCoreAudioDeviceManager(WCMRAudioDeviceManagerClient *pTheClient,
eAudioDeviceFilter eCurAudioDeviceFilter, bool useMultithreading, bool bNocopy)
: WCMRAudioDeviceManager (pTheClient, eCurAudioDeviceFilter)
, m_UseMultithreading (useMultithreading)
, m_eCABS_Method(eCABS_method)
, m_bNoCopyAudioBuffer(bNocopy)
{
AUTO_FUNC_DEBUG;
@ -2347,13 +2316,13 @@ WCMRCoreAudioDeviceManager::WCMRCoreAudioDeviceManager(WCMRAudioDeviceManagerCli
}
//add a listener to find out when devices change...
AudioHardwareAddPropertyListener (kAudioHardwarePropertyDevices, StaticPropertyChangeProc, this);
AudioHardwareAddPropertyListener (kAudioHardwarePropertyDevices, DevicePropertyChangeCallback, this);
//Always add the None device first...
m_Devices.push_back (new WCMRNativeAudioNoneDevice(this));
m_NoneDevice = new WCMRNativeAudioNoneDevice(this);
//prepare our initial list...
UpdateDeviceList_Private();
generateDeviceListImpl();
return;
}
@ -2376,25 +2345,7 @@ WCMRCoreAudioDeviceManager::~WCMRCoreAudioDeviceManager()
try
{
AudioHardwareRemovePropertyListener (kAudioHardwarePropertyDevices, StaticPropertyChangeProc);
//Note: We purposely release the device list here, instead of
//depending on the superclass to do it, as by the time the superclass'
//destructor executes, we will have called Pa_Terminate()!
//Need to call release on our devices, and erase them from list
std::vector<WCMRAudioDevice*>::iterator deviceIter;
while (m_Devices.size())
{
WCMRAudioDevice *pDeviceToRelease = m_Devices.back();
m_Devices.pop_back();
SAFE_RELEASE (pDeviceToRelease);
}
//The derived classes may want to do additional de-int!
delete m_NoneDevice;
}
catch (...)
{
@ -2405,119 +2356,241 @@ WCMRCoreAudioDeviceManager::~WCMRCoreAudioDeviceManager()
}
//**********************************************************************************************
// WCMRCoreAudioDeviceManager::StaticPropertyChangeProc
//
//! The property change listener for the Audio Device Manager. It calls upon (non-static) PropertyChangeProc
//! to do the actual work.
//!
//! \param iPropertyID : the property that has changed.
//! \param inClientData : What was supplied at init time.
//!
//! \return if parameters are incorrect, or the value returned by PropertyChangeProc.
//!
//**********************************************************************************************
OSStatus WCMRCoreAudioDeviceManager::StaticPropertyChangeProc (AudioHardwarePropertyID inPropertyID, void* inClientData)
WCMRAudioDevice* WCMRCoreAudioDeviceManager::initNewCurrentDeviceImpl(const std::string & deviceName)
{
WCMRCoreAudioDeviceManager *pMyManager = (WCMRCoreAudioDeviceManager *)inClientData;
destroyCurrentDeviceImpl();
if (pMyManager)
return pMyManager->PropertyChangeProc (inPropertyID);
std::cout << "API::PortAudioDeviceManager::initNewCurrentDevice " << deviceName << std::endl;
if (deviceName == m_NoneDevice->DeviceName() )
{
m_CurrentDevice = m_NoneDevice;
return m_CurrentDevice;
}
return 0;
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 (...)
{
std::cout << "Unabled to create PA Device: " << devInfo.m_DeviceId << std::endl;
DEBUG_MSG ("Unabled to create PA Device: " << devInfo.m_DeviceId);
}
}
return m_CurrentDevice;
}
//**********************************************************************************************
// WCMRCoreAudioDeviceManager::PropertyChangeProc
//
//! The property change listener for the Audio Device Manager. Currently we only listen for the
//! device list change (device arrival/removal, and accordingly cause an update to the device list.
//! Note that the actual update happens from the DoIdle() call to prevent multi-threading related issues.
//!
//! \param
//!
//! \return Nothing.
//!
//**********************************************************************************************
OSStatus WCMRCoreAudioDeviceManager::PropertyChangeProc (AudioHardwarePropertyID inPropertyID)
void WCMRCoreAudioDeviceManager::destroyCurrentDeviceImpl()
{
OSStatus retVal = 0;
switch (inPropertyID)
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)
{
case kAudioHardwarePropertyDevices:
m_UpdateDeviceListRequested++;
break;
default:
//! 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(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]) &&
(supportedRates[deviceSR].mMaximum >= gAllSampleRates[ourSR]))
{
sampleRates.push_back ((int)gAllSampleRates[ourSR]);
break;
}
}
}
}
else
{
retVal = eCoreAudioFailed;
DEBUG_MSG("Failed to get device Sample rates. Device Name: " << m_DeviceName.c_str());
}
delete [] supportedRates;
}
else
{
retVal = eCoreAudioFailed;
DEBUG_MSG("Failed to get device Sample rates property size. Device Name: " << m_DeviceName.c_str());
}
return retVal;
}
//**********************************************************************************************
// WCMRCoreAudioDeviceManager::remove_pattern
//
//! remove a substring from a given string
//!
//! \param original_str - original string
//! \param pattern_str - pattern to find
//! \param return_str - the return string - without the pattern substring
//!
//! \return Nothing.
//!
//**********************************************************************************************
void WCMRCoreAudioDeviceManager::remove_pattern(const std::string& original_str, const std::string& pattern_str, std::string& return_str)
{
char *orig_c_str = new char[original_str.size() + 1];
char* strSavePtr;
strcpy(orig_c_str, original_str.c_str());
char *p_splited_orig_str = strtok_r(orig_c_str," ", &strSavePtr);
std::ostringstream stream_str;
while (p_splited_orig_str != 0)
WTErr WCMRCoreAudioDeviceManager::getDeviceMaxInputChannels(DeviceID deviceId, unsigned int& inputChannels)
{
AUTO_FUNC_DEBUG;
WTErr retVal = eNoErr;
OSStatus err = kAudioHardwareNoError;
UInt32 propSize = 0;
inputChannels = 0;
// 1. Get property cannels input size.
err = AudioDeviceGetPropertyInfo (deviceId, 0, 1/* Input */, kAudioDevicePropertyStreamConfiguration, &propSize, NULL);
if (err == kAudioHardwareNoError)
{
int cmp_res = strcmp(p_splited_orig_str, pattern_str.c_str()); // might need Ignore case ( stricmp OR strcasecmp)
if ( cmp_res != 0)
stream_str << p_splited_orig_str << " ";
p_splited_orig_str = strtok_r(NULL," ", &strSavePtr);
//! 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)
{
// Calculate the number of input channels
for (UInt32 streamIndex = 0; streamIndex < pStreamBuffers->mNumberBuffers; streamIndex++)
{
inputChannels += pStreamBuffers->mBuffers[streamIndex].mNumberChannels;
}
delete[] orig_c_str;
return_str = stream_str.str();
}
else
{
retVal = eCoreAudioFailed;
DEBUG_MSG("Failed to get device Input channels. Device Name: " << m_DeviceName.c_str());
}
free (pStreamBuffers);
}
else
{
retVal = eMemOutOfMemory;
DEBUG_MSG("Faild to allocate memory. Device Name: " << m_DeviceName.c_str());
}
}
else
{
retVal = eCoreAudioFailed;
DEBUG_MSG("Failed to get device Input channels property size. Device Name: " << m_DeviceName.c_str());
}
return retVal;
}
//**********************************************************************************************
// WCMRCoreAudioDeviceManager::UpdateDeviceList_Private
//
//! Updates the list of devices maintained by the manager. If devices have gone away, they are removed
//! if new devices have been connected, they are added to the list.
//!
//! \param none
//!
//! \return eNoErr on success, an error code on failure.
//!
//**********************************************************************************************
WTErr WCMRCoreAudioDeviceManager::UpdateDeviceList_Private()
WTErr WCMRCoreAudioDeviceManager::getDeviceMaxOutputChannels(DeviceID deviceId, unsigned int& outputChannels)
{
AUTO_FUNC_DEBUG;
WTErr retVal = eNoErr;
OSStatus err = kAudioHardwareNoError;
UInt32 propSize = 0;
outputChannels = 0;
//! 1. Get property cannels output size.
err = AudioDeviceGetPropertyInfo (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 (deviceId, 0, 0/* Output */, kAudioDevicePropertyStreamConfiguration, &propSize, pStreamBuffers);
if (err == kAudioHardwareNoError)
{
// Calculate the number of output channels
for (UInt32 streamIndex = 0; streamIndex < pStreamBuffers->mNumberBuffers; streamIndex++)
{
outputChannels += pStreamBuffers->mBuffers[streamIndex].mNumberChannels;
}
}
else
{
retVal = eCoreAudioFailed;
DEBUG_MSG("Failed to get device Output channels. Device Name: " << m_DeviceName.c_str());
}
free (pStreamBuffers);
}
else
{
retVal = eMemOutOfMemory;
DEBUG_MSG("Faild to allocate memory. Device Name: " << m_DeviceName.c_str());
}
}
else
{
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)
{
DeviceInfo *pDevInfo = new DeviceInfo(NONE_DEVICE_ID, m_NoneDevice->DeviceName() );
pDevInfo->m_AvailableSampleRates = m_NoneDevice->SamplingRates();
m_DeviceInfoVec.push_back(pDevInfo);
}
WTErr retVal = eNoErr;
OSStatus osErr = noErr;
AudioDeviceID* deviceIDs = 0;
size_t reportedDeviceIndex = 0;
openlog("WCMRCoreAudioDeviceManager", LOG_PID | LOG_CONS, LOG_USER);
try
{
// Define 2 vectors for input and output - only for eMatchedDuplexDevices case
WCMRAudioDeviceList adOnlyIn;
WCMRAudioDeviceList adOnlyOut;
//Get device count...
UInt32 propSize = 0;
osErr = AudioHardwareGetPropertyInfo (kAudioHardwarePropertyDevices, &propSize, NULL);
@ -2535,140 +2608,140 @@ WTErr WCMRCoreAudioDeviceManager::UpdateDeviceList_Private()
if (WUIsError(osErr))
throw osErr;
//first go through our list of devices, remove the ones that are no longer present...
std::vector<WCMRAudioDevice*>::iterator deviceIter;
for (deviceIter = m_Devices.begin(); deviceIter != m_Devices.end(); /*This is purposefully blank*/)
//now add the ones that are not there...
for (size_t deviceIndex = 0; deviceIndex < numDevices; deviceIndex++)
{
WCMRCoreAudioDevice *pDeviceToWorkUpon = dynamic_cast<WCMRCoreAudioDevice *>(*deviceIter);
DeviceInfo* pDevInfo = 0;
//it's possible that the device is actually not a core audio device - perhaps a none device...
if (!pDeviceToWorkUpon)
//Get device name and create new DeviceInfo entry
//Get property name size.
osErr = AudioDeviceGetPropertyInfo(deviceIDs[deviceIndex], 0, 0, kAudioDevicePropertyDeviceName, &propSize, NULL);
if (osErr == kAudioHardwareNoError)
{
deviceIter++;
continue;
}
AudioDeviceID myDeviceID = pDeviceToWorkUpon->DeviceID();
bool deviceFound = false;
for (reportedDeviceIndex = 0; reportedDeviceIndex < numDevices; reportedDeviceIndex++)
//Get property: name.
char* deviceName = new char[propSize];
osErr = AudioDeviceGetProperty(deviceIDs[deviceIndex], 0, 0, kAudioDevicePropertyDeviceName, &propSize, deviceName);
if (osErr == kAudioHardwareNoError)
{
if (myDeviceID == deviceIDs[reportedDeviceIndex])
{
deviceFound = true;
break;
}
}
if (!deviceFound)
{
//it's no longer there, need to remove it!
WCMRAudioDevice *pTheDeviceToErase = *deviceIter;
deviceIter = m_Devices.erase (deviceIter);
if (pTheDeviceToErase->Active())
{
NotifyClient (WCMRAudioDeviceManagerClient::DeviceConnectionLost);
}
SAFE_RELEASE (pTheDeviceToErase);
pDevInfo = new DeviceInfo(deviceIDs[deviceIndex], deviceName);
}
else
deviceIter++;
{
retVal = eCoreAudioFailed;
DEBUG_MSG("Failed to get device name. Device ID: " << m_DeviceID);
}
//now add the ones that are not there...
for (reportedDeviceIndex = 0; reportedDeviceIndex < numDevices; reportedDeviceIndex++)
{
bool deviceFound = false;
for (deviceIter = m_Devices.begin(); deviceIter != m_Devices.end(); deviceIter++)
{
WCMRCoreAudioDevice *pDeviceToWorkUpon = dynamic_cast<WCMRCoreAudioDevice *>(*deviceIter);
//it's possible that the device is actually not a core audio device - perhaps a none device...
if (!pDeviceToWorkUpon)
continue;
if (pDeviceToWorkUpon->DeviceID() == deviceIDs[reportedDeviceIndex])
{
deviceFound = true;
break;
delete [] deviceName;
}
else
{
retVal = eCoreAudioFailed;
DEBUG_MSG("Failed to get device name property size. Device ID: " << m_DeviceID);
}
if (!deviceFound)
if (pDevInfo)
{
//add it to our list...
//build a device object...
WCMRCoreAudioDevice *pNewDevice = new WCMRCoreAudioDevice (this, deviceIDs[reportedDeviceIndex], m_UseMultithreading, m_bNoCopyAudioBuffer);
bool bDeleteNewDevice = true;
//Retrieve all the information we need for the device
WTErr wErr = eNoErr;
if (pNewDevice)
//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
}
// Don't delete the new device by default, since most cases use it
bDeleteNewDevice = false;
pDevInfo->m_AvailableSampleRates = availableSampleRates;
// Insert the new device to the device list according to its enum
//Get max input channels
uint32 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 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)
{
case eInputOnlyDevices:
if ((int) pNewDevice->InputChannels().size() != 0)
if (pDevInfo->m_MaxInputChannels != 0)
{
m_Devices.push_back (pNewDevice);
m_DeviceInfoVec.push_back(pDevInfo);
}
else
{
// Delete unnecesarry device
bDeleteNewDevice = true;
bRejectDevice = true;
}
break;
case eOutputOnlyDevices:
if ((int) pNewDevice->OutputChannels().size() != 0)
if (pDevInfo->m_MaxOutputChannels != 0)
{
m_Devices.push_back (pNewDevice);
m_DeviceInfoVec.push_back(pDevInfo);
}
else
{
// Delete unnecesarry device
bDeleteNewDevice = true;
bRejectDevice = true;
}
break;
case eFullDuplexDevices:
if ((int) pNewDevice->InputChannels().size() != 0 && (int) pNewDevice->OutputChannels().size() != 0)
if (pDevInfo->m_MaxInputChannels != 0 && pDevInfo->m_MaxOutputChannels != 0)
{
m_Devices.push_back (pNewDevice);
m_DeviceInfoVec.push_back(pDevInfo);
}
else
{
// Delete unnecesarry device
bDeleteNewDevice = true;
bRejectDevice = true;
}
break;
case eAllDevices:
default:
m_Devices.push_back (pNewDevice);
m_DeviceInfoVec.push_back(pDevInfo);
break;
}
}
if(bDeleteNewDevice)
if(bRejectDevice)
{
syslog (LOG_NOTICE, "%s rejected, In Channels = %d, Out Channels = %d\n",
pNewDevice->DeviceName().c_str(), (int) pNewDevice->InputChannels().size(),
(int) pNewDevice->OutputChannels().size());
pDevInfo->m_DeviceName.c_str(), pDevInfo->m_MaxInputChannels, pDevInfo->m_MaxOutputChannels);
// In case of Input and Output both channels being Zero, we will release memory; since we created CoreAudioDevice but we are Not adding it in list.
SAFE_RELEASE(pNewDevice);
delete pDevInfo;
}
}
}
//If no devices were found, that's not a good thing!
if (m_Devices.empty())
if (m_DeviceInfoVec.empty())
{
DEBUG_MSG ("No matching CoreAudio devices were found\n");
}
m_UpdateDeviceListRequested = m_UpdateDeviceListProcessed = 0;
}
catch (...)
{
@ -2676,42 +2749,118 @@ WTErr WCMRCoreAudioDeviceManager::UpdateDeviceList_Private()
retVal = eCoreAudioFailed;
}
safe_delete_array(deviceIDs);
delete[] deviceIDs;
closelog();
return retVal;
}
//**********************************************************************************************
// WCMRCoreAudioDeviceManager::DoIdle
//
//! Used for idle time processing. This calls each device's DoIdle so that it can perform it's own idle processing.
//! Also, if a device list change is detected, it updates the device list.
//!
//! \param none
//!
//! \return noErr if no devices have returned an error. An error code if any of the devices returned error.
//!
//**********************************************************************************************
WTErr WCMRCoreAudioDeviceManager::DoIdle()
WTErr WCMRCoreAudioDeviceManager::updateDeviceListImpl()
{
//WTErr retVal = eNoErr;
wvNS::wvThread::ThreadMutex::lock theLock(m_AudioDeviceInfoVecMutex);
WTErr err = generateDeviceListImpl();
if (eNoErr != err)
{
//wvThread::ThreadMutex::lock theLock(m_AudioDeviceManagerMutex);
std::cout << "API::PortAudioDeviceManager::updateDeviceListImpl: Device list update error: "<< err << std::endl;
return err;
}
//If there's something specific to CoreAudio manager idle handling do it here...
if (m_UpdateDeviceListRequested != m_UpdateDeviceListProcessed)
if (m_CurrentDevice)
{
m_UpdateDeviceListProcessed = m_UpdateDeviceListRequested;
UpdateDeviceList_Private();
// 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;
}
}
NotifyClient (WCMRAudioDeviceManagerClient::DeviceListChanged);
}
}
//Note that the superclass is going to call all the devices' DoIdle() anyway...
return (WCMRAudioDeviceManager::DoIdle());
return err;
}
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;
}
DeviceInfo devInfo;
retVal = GetDeviceInfoByName(deviceName, devInfo);
if (eNoErr == retVal)
{
// 1. Get buffer size range
AudioValueRange bufferSizesRange;
propSize = sizeof (AudioValueRange);
err = AudioDeviceGetProperty (devInfo.m_DeviceId, 0, 0, kAudioDevicePropertyBufferFrameSizeRange, &propSize, &bufferSizesRange);
if(err == kAudioHardwareNoError)
{
// 2. Run on all ranges and add them to the list
for(int bsize=0; gAllBufferSizes[bsize] > 0; bsize++)
{
if ((bufferSizesRange.mMinimum <= gAllBufferSizes[bsize]) && (bufferSizesRange.mMaximum >= gAllBufferSizes[bsize]))
{
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())
{
bufferSizes.push_back ((int)bufferSizesRange.mMinimum);
bufferSizes.push_back ((int)bufferSizesRange.mMaximum);
}
}
else
{
retVal = eCoreAudioFailed;
DEBUG_MSG("Failed to get device buffer sizes range. Device Name: " << m_DeviceName.c_str());
}
}
else
{
retVal = eRMResNotFound;
std::cout << "API::PortAudioDeviceManager::GetBufferSizes: Device not found: "<< deviceName << std::endl;
}
return retVal;
}
OSStatus WCMRCoreAudioDeviceManager::DevicePropertyChangeCallback (AudioHardwarePropertyID inPropertyID, void* inClientData)
{
switch (inPropertyID)
{
case kAudioHardwarePropertyDevices:
{
WCMRCoreAudioDeviceManager* pManager = (WCMRCoreAudioDeviceManager*)inClientData;
if (pManager)
pManager->updateDeviceListImpl();
}
break;
default:
break;
}
return 0;
}

View file

@ -1,23 +1,6 @@
/*
Copyright (C) 2013 Waves Audio Ltd.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
//----------------------------------------------------------------------------------
//
// Copyright (c) 2008 Waves Audio Ltd. All rights reserved.
//
//! \file WCMRCoreAudioDeviceManager.h
//!
@ -138,7 +121,7 @@ protected:
uint32_t m_NextSampleToUse;
#endif //WV_USE_TONE_GEN
WTErr UpdateDeviceInfo (bool updateSRSupported, bool updateBufferSizes);
WTErr UpdateDeviceInfo ();
WTErr UpdateDeviceName();
WTErr UpdateDeviceInputs();
WTErr UpdateDeviceOutputs();
@ -181,40 +164,28 @@ class WCMRCoreAudioDeviceManager : public WCMRAudioDeviceManager
public:
WCMRCoreAudioDeviceManager(WCMRAudioDeviceManagerClient *pTheClient, eAudioDeviceFilter eCurAudioDeviceFilter,
bool useMultithreading = true, eCABS_Method eCABS_method = eCABS_Simple, bool bNocopy = false); ///< constructor
bool useMultithreading = true, bool bNocopy = false); ///< constructor
virtual ~WCMRCoreAudioDeviceManager(void); ///< Destructor
virtual WTErr UpdateDeviceList() //has to be overridden!
{
//wvNS::wvThread::ThreadMutex::lock theLock(m_AudioDeviceManagerMutex);
return UpdateDeviceList_Private();
}
virtual eCABS_Method GetBufferSizeMethod()
{
//wvNS::wvThread::ThreadMutex::lock theLock(m_AudioDeviceManagerMutex);
return GetBufferSizeMethod_Private();
}
virtual WTErr DoIdle();
private:
WTErr UpdateDeviceList_Private();
eCABS_Method GetBufferSizeMethod_Private() { return m_eCABS_Method; }
protected:
static OSStatus DevicePropertyChangeCallback (AudioHardwarePropertyID inPropertyID, void* inClientData);
virtual WCMRAudioDevice* initNewCurrentDeviceImpl(const std::string & deviceName);
virtual void destroyCurrentDeviceImpl();
virtual WTErr generateDeviceListImpl();
virtual WTErr updateDeviceListImpl();
virtual WTErr getDeviceBufferSizesImpl(const std::string & deviceName, std::vector<int>& bufferSizes) const;
int m_UpdateDeviceListRequested; ///< Number of times device list change has been detected.
int m_UpdateDeviceListProcessed; ///< Number of times device list change has been processed.
bool m_UseMultithreading; ///< Flag indicates whether to use multi-threading for audio processing.
bool m_bNoCopyAudioBuffer;
eCABS_Method m_eCABS_Method; // Type of core audio buffer size list method
static OSStatus StaticPropertyChangeProc (AudioHardwarePropertyID inPropertyID, void* inClientData);
OSStatus PropertyChangeProc (AudioHardwarePropertyID inPropertyID);
private:
// helper functions for this class only
WTErr getDeviceAvailableSampleRates(DeviceID deviceId, std::vector<int>& sampleRates);
WTErr getDeviceMaxInputChannels(DeviceID deviceId, unsigned int& inputChannels);
WTErr getDeviceMaxOutputChannels(DeviceID deviceId, unsigned int& outputChannels);
void remove_pattern(const std::string& original_str, const std::string& pattern_str, std::string& return_str);
WCMRAudioDevice* m_NoneDevice;
};
#endif //#ifndef __WCMRCoreAudioDeviceManager_h_

View file

@ -1,23 +1,6 @@
/*
Copyright (C) 2013 Waves Audio Ltd.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
//----------------------------------------------------------------------------------
//
// Copyright (c) 2008 Waves Audio Ltd. All rights reserved.
//
//! \file WCMRNativeAudio.cpp
//!
@ -136,6 +119,12 @@ WTErr WCMRNativeAudioNoneDevice::SetCurrentBufferSize (int newSize)
}
WTErr WCMRNativeAudioNoneDevice::UpdateDeviceInfo ()
{
return eNoErr;
}
WTErr WCMRNativeAudioNoneDevice::SetStreaming (bool newState)
{
if (Streaming() == newState)
@ -144,7 +133,8 @@ WTErr WCMRNativeAudioNoneDevice::SetStreaming (bool newState)
}
WCMRAudioDevice::SetStreaming(newState);
if(Streaming())
if (Streaming())
{
if (m_SilenceThread)
std::cerr << "\t\t\t\t\t !!!!!!!!!!!!!!! Warning: the inactive NONE-DEVICE was streaming!" << std::endl;

View file

@ -1,23 +1,6 @@
/*
Copyright (C) 2013 Waves Audio Ltd.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
//----------------------------------------------------------------------------------
//
// Copyright (c) 2008 Waves Audio Ltd. All rights reserved.
//
//! \file WCMRNativeAudio.h
//!
@ -42,9 +25,10 @@ class WCMRNativeAudioDevice : public WCMRAudioDevice
{
public:
WCMRNativeAudioDevice (WCMRAudioDeviceManager *pManager, bool useMultithreading = true, bool bNoCopy = false) : WCMRAudioDevice (pManager),
m_UseMultithreading (useMultithreading),
m_bNoCopyAudioBuffer(bNoCopy)
WCMRNativeAudioDevice (WCMRAudioDeviceManager *pManager, bool useMultithreading = true, bool bNoCopy = false) :
WCMRAudioDevice (pManager)
, m_UseMultithreading (useMultithreading)
, m_bNoCopyAudioBuffer(bNoCopy)
{}
virtual ~WCMRNativeAudioDevice () {}
@ -52,7 +36,6 @@ protected:
bool m_UseMultithreading;
bool m_bNoCopyAudioBuffer; ///< This flag determines whether the audio callback performs a copy of audio, or the source/sink perform the copy. It should be true to let source/sink do the copies.
};
@ -65,6 +48,7 @@ public:
virtual WTErr SetActive (bool newState);///<Prepare/Activate device.
virtual WTErr SetStreaming (bool newState);///<Start/Stop Streaming - should reconnect connections when streaming starts!
virtual WTErr SetCurrentBufferSize (int newSize);///<Change Current Buffer Size : This is a requset, might not be successful at run time!
virtual WTErr UpdateDeviceInfo ();
private:
@ -75,8 +59,8 @@ private:
#else
inline void _usleep(uint64_t usec) { ::usleep(usec); }
#endif
static const size_t __m_NumInputChannels = 32;
static const size_t __m_NumOutputChannels = 32;
static const size_t __m_NumInputChannels = 0;
static const size_t __m_NumOutputChannels = 0;
pthread_t m_SilenceThread;
float *_m_inputBuffer;
float *_m_outputBuffer;

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,160 @@
//----------------------------------------------------------------------------------
//
// Copyright (c) 2008 Waves Audio Ltd. All rights reserved.
//
//! \file WCMRPortAudioDeviceManager.h
//!
//! WCMRPortAudioDeviceManager and related class declarations
//!
//---------------------------------------------------------------------------------*/
#ifndef __WCMRPortAudioDeviceManager_h_
#define __WCMRPortAudioDeviceManager_h_
#include "WCMRAudioDeviceManager.h"
#include "WCMRNativeAudio.h"
#include "portaudio.h"
//forward decl.
class WCMRPortAudioDeviceManager;
//! Manages a port audio device, providing information
//! about the device, and managing audio callbacks.
class WCMRPortAudioDevice : public WCMRNativeAudioDevice
{
public:
WCMRPortAudioDevice (WCMRPortAudioDeviceManager *pManager, unsigned int deviceID, bool useMultiThreading = true, bool bNoCopy = false);///<Constructor
virtual ~WCMRPortAudioDevice ();///<Destructor
virtual int CurrentSamplingRate(); ///<Current Sampling rate.?
virtual WTErr SetCurrentSamplingRate(int newRate);///<Change Current Sampling Rate : This is a requset, might not be successful at run time!
virtual int CurrentBufferSize();///<Current Buffer Size.? - note that this may change with change in sampling rate.
virtual WTErr SetCurrentBufferSize (int newSize);///<Change Current Buffer Size : This is a requset, might not be successful at run time!
virtual ConnectionStates ConnectionStatus();///< Connection Status - device available, gone, disconnected
virtual WTErr SetActive (bool newState);///<Prepare/Activate device.
virtual WTErr SetStreaming (bool newState);///<Start/Stop Streaming - should reconnect connections when streaming starts!
virtual WTErr SetMonitorChannels (int leftChannel, int rightChannel);///<Set monitor channels. - optional, will not be available with AG
virtual WTErr SetMonitorGain (float newGain);///<Set monitor gain. - optional, will not be available with AG
virtual WTErr ShowConfigPanel (void *pParam);///< Show Control Panel - in case of ASIO this will work only with Active device!
virtual int AudioCallback (const float *pInputBuffer, float *pOutputBuffer, unsigned long framesPerBuffe, bool dropsDetectedr);
virtual WTErr UpdateDeviceInfo ();
virtual WTErr ResetDevice();
#ifdef _WINDOWS
static long StaticASIOMessageHook (void *pRefCon, long selector, long value, void* message, double* opt);
long ASIOMessageHook (long selector, long value, void* message, double* opt);
#endif //_WINDOWS
protected:
static DWORD WINAPI __DoIdle__(LPVOID lpThreadParameter);
// Methods which are executed by device processing thread
WTErr DoIdle();///<Do Idle Processing
void initDevice();
void terminateDevice();
void updateDeviceInfo(bool callerIsWaiting = false);
void activateDevice(bool callerIsWaiting = false);
void deactivateDevice(bool callerIsWaiting = false);
void startStreaming(bool callerIsWaiting = false);
void stopStreaming(bool callerIsWaiting = false);
void resetDevice (bool callerIsWaiting = false);///<Reset device - close and reopen stream, update device information!
PaError testStateValidness(int sampleRate, int bufferSize);
///////////////////////////////////////////////////////////
static int TheCallback (const void *pInputBuffer, void *pOutputBuffer, unsigned long framesPerBuffer,
const PaStreamCallbackTimeInfo* /*pTimeInfo*/, PaStreamCallbackFlags /*statusFlags*/, void *pUserData );
unsigned int m_DeviceID; ///< The PA device id
PaStream* m_PortAudioStream; ///< Port audio stream, when the device is active!
bool m_StopRequested; ///< should be set to true when want to stop, set to false otherwise.
const float *m_pInputData; ///< This is what came in with the most recent callback.
int m_SampleCounter; ///< The current running sample counter, updated by the audio callback.
int m_SampleCountAtLastIdle;
int m_DropsDetected; ///< Number of times audio drops have been detected so far.
int m_DropsReported; ///< Number of times audio drops have been reported so far to the client.
bool m_IgnoreThisDrop; ///< Allows disregarding the first drop
int m_BufferSizeChangeRequested;
int m_BufferSizeChangeReported;
int m_ResetRequested;
int m_ResetReported;
int m_ResyncRequested;
int m_ResyncReported;
HANDLE m_hDeviceProcessingThread;
DWORD m_DeviceProcessingThreadID;
///< Backend request events
HANDLE m_hResetRequestedEvent;
HANDLE m_hResetDone;
HANDLE m_hUpdateDeviceInfoRequestedEvent;
HANDLE m_hUpdateDeviceInfoDone;
HANDLE m_hActivateRequestedEvent;
HANDLE m_hActivationDone;
HANDLE m_hDeActivateRequestedEvent;
HANDLE m_hDeActivationDone;
HANDLE m_hStartStreamingRequestedEvent;
HANDLE m_hStartStreamingDone;
HANDLE m_hStopStreamingRequestedEvent;
HANDLE m_hStopStreamingDone;
/////////////////////////
///< Device request events
HANDLE m_hResetFromDevRequestedEvent;
HANDLE m_hBufferSizeChangedEvent;
HANDLE m_hSampleRateChangedEvent;
/////////////////////////////
///< Sync events
HANDLE m_hDeviceInitialized;
HANDLE m_hExitIdleThread;
//Should be set if the device connection status is "DeviceErrors"
WTErr m_lastErr;
};
//! WCMRPortAudioDeviceManager
/*! The PortAudio Device Manager class */
class WCMRPortAudioDeviceManager : public WCMRAudioDeviceManager
{
public:
WCMRPortAudioDeviceManager(WCMRAudioDeviceManagerClient *pTheClient, eAudioDeviceFilter eCurAudioDeviceFilter,
bool useMultithreading = true, bool bNocopy = false); ///< constructor
virtual ~WCMRPortAudioDeviceManager(void); ///< destructor
protected:
virtual WCMRAudioDevice* initNewCurrentDeviceImpl(const std::string & deviceName);
virtual void destroyCurrentDeviceImpl();
virtual WTErr generateDeviceListImpl(); // use this in derived class to fill device list
virtual WTErr updateDeviceListImpl() {return eNoErr; } // not supported
virtual WTErr getDeviceBufferSizesImpl(const std::string & deviceName, std::vector<int>& buffers) const;
bool m_UseMultithreading; ///< Flag indicates whether to use multi-threading for audio processing.
bool m_bNoCopyAudioBuffer;
private:
// helper functions for this class only
WTErr getDeviceAvailableSampleRates(DeviceID deviceId, std::vector<int>& sampleRates);
WCMRAudioDevice* m_NoneDevice;
};
#endif //#ifndef __WCMRPortAudioDeviceManager_h_

View file

@ -1,21 +1,3 @@
/*
Copyright (C) 2013 Waves Audio Ltd.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef __MinMaxUtilities_h__
#define __MinMaxUtilities_h__

View file

@ -1,21 +1,3 @@
/*
Copyright (C) 2013 Waves Audio Ltd.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifdef _WINDOWS
#include "IncludeWindows.h"
#endif

View file

@ -1,21 +1,3 @@
/*
Copyright (C) 2013 Waves Audio Ltd.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef __UMicroseconds_h__
#define __UMicroseconds_h__

View file

@ -1,21 +1,3 @@
/*
Copyright (C) 2013 Waves Audio Ltd.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef __WCFixedString_h__
#define __WCFixedString_h__

View file

@ -1,21 +1,3 @@
/*
Copyright (C) 2013 Waves Audio Ltd.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef __WUErrors_h__
#define __WUErrors_h__
@ -53,6 +35,7 @@ const WTErr eAppTerminateFailed = -23; //!< failed to terminate an appl
const WTErr eAppReturnedError = -24; //!< Non zero exit code from application
const WTErr eNotImplemented = -25; //!< Function is not implmemented
const WTErr eNotEmpty = -26; //!< Something was expected to be empty but is not
const WTErr eAsioFailed = -27;
// File Manager errors
const WTErr eFMNoSuchVolume = -1001;

View file

@ -1,21 +1,3 @@
/*
Copyright (C) 2013 Waves Audio Ltd.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef __safe_delete_h__
#define __safe_delete_h__

View file

@ -1,21 +1,3 @@
/*
Copyright (C) 2013 Waves Audio Ltd.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "WCRefManager.h"
/// Construcotr.

View file

@ -1,21 +1,3 @@
/*
Copyright (C) 2013 Waves Audio Ltd.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef WCREFMANAGER_H
#define WCREFMANAGER_H

View file

@ -1,21 +1,3 @@
/*
Copyright (C) 2013 Waves Audio Ltd.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "Threads/WCThreadSafe.h"
#if XPLATFORMTHREADS_WINDOWS

View file

@ -1,21 +1,3 @@
/*
Copyright (C) 2013 Waves Audio Ltd.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef __WCThreadSafe_h_
#define __WCThreadSafe_h_

View file

@ -1,21 +1,3 @@
/*
Copyright (C) 2013 Waves Audio Ltd.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef __WavesPublicAPI_Defines_h__
#define __WavesPublicAPI_Defines_h__

View file

@ -1,22 +1,5 @@
/*
Copyright (C) 2013 Waves Audio Ltd.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
///////////////////////////////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2011 Waves Audio Ltd. All rights reserved.
// \file WTErr.h, defines basic error type and "No Error" code
// All users may use their own error codes with this type, as long as eNoErr remains defined here
///////////////////////////////////////////////////////////////////////////////////////////////////////

View file

@ -1,21 +1,3 @@
/*
Copyright (C) 2013 Waves Audio Ltd.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef __stdint_h__
#define __stdint_h__

46
libs/backends/wavesaudio/wscript Normal file → Executable file
View file

@ -19,14 +19,18 @@ def options(opt):
autowaf.set_options(opt)
def configure(conf):
if conf.options.dist_target == 'mingw':
autowaf.check_pkg(conf, 'portaudio-2.0', uselib_store='PORTAUDIO',
atleast_version='19')
autowaf.configure(conf)
def build(bld):
obj = bld(features = 'c cxx cxxshlib')
if bld.env['build_target'] == 'mountain_lion':
obj.framework = 'CoreMidi'
if bld.env['build_target'] == 'mingw':
obj = bld(features = 'cxx cxxshlib')
else:
obj.framework = 'CoreMIDI'
obj = bld(features = 'cxx cxxshlib', framework = ["CoreMidi"])
obj.source = [
'waves_audiobackend.cc',
'waves_audiobackend.latency.cc',
@ -41,33 +45,59 @@ def build(bld):
'waves_midi_buffer.cc',
'wavesapi/refmanager/WCRefManager.cpp',
'wavesapi/devicemanager/WCMRAudioDeviceManager.cpp',
'wavesapi/devicemanager/WCMRCoreAudioDeviceManager.cpp',
'wavesapi/devicemanager/WCMRNativeAudio.cpp',
'wavesapi/threads/WCThreadSafe.cpp',
'portmidi/src/pm_common/pmutil.c',
'portmidi/src/pm_common/portmidi.c',
'portmidi/src/pm_common/portmidi.c'
]
if bld.env['build_target'] == 'mingw':
platform_dependent = [
'wavesapi/miscutils/UMicroseconds.cpp',
'wavesapi/devicemanager/WCMRPortAudioDeviceManager.cpp',
'portmidi/src/pm_win/pmwin.c',
'portmidi/src/pm_win/pmwinmm.c',
'portmidi/src/porttime/ptwinmm.c'
]
else:
platform_dependent = [
'wavesapi/devicemanager/WCMRCoreAudioDeviceManager.cpp',
'portmidi/src/pm_mac/pmmac.c',
'portmidi/src/pm_mac/pmmacosxcm.c',
'portmidi/src/pm_mac/finddefault.c',
'portmidi/src/pm_mac/readbinaryplist.c',
'portmidi/src/porttime/ptmacosx_mach.c'
]
obj.source.extend(platform_dependent)
obj.includes = ['.',
'wavesapi',
'wavesapi/refmanager',
'wavesapi/wavespublicapi',
'wavesapi/devicemanager',
'wavesapi/miscutils',
'wavesapi/threads',
'portmidi',
'portmidi/src/pm_common'
]
obj.cxxflags = [ '-fPIC' ]
obj.cflags = [ '-fPIC', '-fms-extensions' ]
obj.name = 'waves_audiobackend'
obj.target = 'waves_audiobackend'
obj.use = [ 'libardour', 'libpbd' ]
obj.use = 'libardour libpbd'
if bld.env['build_target'] == 'mingw':
obj.uselib = ['PORTAUDIO']
obj.vnum = WAVESAUDIOBACKEND_VERSION
obj.install_path = os.path.join(bld.env['LIBDIR'], 'backends')
obj.install_path = os.path.join(bld.env['LIBDIR'], 'ardour3', 'backends')
if bld.env['build_target']== 'mingw':
obj.defines = ['PACKAGE="' + I18N_PACKAGE + '"',
'_WINDOWS',
'ARDOURBACKEND_DLL_EXPORTS'
]
else:
obj.defines = ['PACKAGE="' + I18N_PACKAGE + '"',
'__MACOS__',
'ARDOURBACKEND_DLL_EXPORTS'