mirror of
https://github.com/Ardour/ardour.git
synced 2026-01-08 06:35:46 +01:00
Added Device channel names retrieving on MAC.
This commit is contained in:
parent
913d5a04b3
commit
3493d2ccb3
4 changed files with 82 additions and 17 deletions
|
|
@ -594,10 +594,11 @@ WavesAudioBackend::_register_system_audio_ports ()
|
|||
for (std::vector<std::string>::iterator it = input_channels.begin ();
|
||||
(port_number < channels) && (it != input_channels.end ());
|
||||
++it) {
|
||||
std::ostringstream port_name;
|
||||
port_name << "capture_" << ++port_number;
|
||||
|
||||
WavesDataPort* port = _register_port ("system:" + port_name.str (), DataType::AUDIO , static_cast<PortFlags> (IsOutput | IsPhysical | IsTerminal));
|
||||
|
||||
std::ostringstream port_name(*it);
|
||||
WavesDataPort* port = _register_port ("system:capture:" + port_name.str (), DataType::AUDIO ,
|
||||
static_cast<PortFlags> (IsOutput | IsPhysical | IsTerminal));
|
||||
|
||||
if (port == NULL) {
|
||||
std::cerr << "WavesAudioBackend::_create_system_audio_ports (): Failed registering port [" << port_name << "] for [" << _device->DeviceName () << "]" << std::endl;
|
||||
return-1;
|
||||
|
|
@ -616,9 +617,11 @@ WavesAudioBackend::_register_system_audio_ports ()
|
|||
for (std::vector<std::string>::iterator it = output_channels.begin ();
|
||||
(port_number < channels) && (it != output_channels.end ());
|
||||
++it) {
|
||||
std::ostringstream port_name;
|
||||
port_name << "playback_" << ++port_number;
|
||||
WavesDataPort* port = _register_port ("system:" + port_name.str (), DataType::AUDIO , static_cast<PortFlags> (IsInput| IsPhysical | IsTerminal));
|
||||
|
||||
std::ostringstream port_name(*it);
|
||||
WavesDataPort* port = _register_port ("system:playback:" + port_name.str (), DataType::AUDIO ,
|
||||
static_cast<PortFlags> (IsInput| IsPhysical | IsTerminal));
|
||||
|
||||
if (port == NULL) {
|
||||
std::cerr << "WavesAudioBackend::_create_system_audio_ports (): Failed registering port ]" << port_name << "] for [" << _device->DeviceName () << "]" << std::endl;
|
||||
return-1;
|
||||
|
|
|
|||
|
|
@ -356,7 +356,7 @@ WTErr WCMRCoreAudioDevice::UpdateDeviceInputs()
|
|||
memset (pStreamBuffers, 0, propSize);
|
||||
|
||||
// Get the Input channels
|
||||
err = AudioDeviceGetProperty (m_DeviceID, 0, 1/* Input */, kAudioDevicePropertyStreamConfiguration, &propSize, pStreamBuffers);
|
||||
err = AudioDeviceGetProperty (m_DeviceID, 0, true/* Input */, kAudioDevicePropertyStreamConfiguration, &propSize, pStreamBuffers);
|
||||
if (err == kAudioHardwareNoError)
|
||||
{
|
||||
// Calculate the number of input channels
|
||||
|
|
@ -387,11 +387,42 @@ WTErr WCMRCoreAudioDevice::UpdateDeviceInputs()
|
|||
|
||||
// Update input channels
|
||||
m_InputChannels.clear();
|
||||
|
||||
for (int channel = 0; channel < maxInputChannels; channel++)
|
||||
{
|
||||
AudioObjectPropertyAddress pa;
|
||||
pa.mSelector = kAudioObjectPropertyElementName;
|
||||
pa.mScope = kAudioObjectPropertyScopeInput;
|
||||
pa.mElement = channel + 1;
|
||||
|
||||
CFStringRef cfName;
|
||||
std::stringstream chNameStream;
|
||||
//A better implementation would be to retrieve the names from ASIO or CoreAudio interfaces
|
||||
chNameStream << "Input " << (channel+1);
|
||||
UInt32 nameSize = 0;
|
||||
OSStatus error = kAudioHardwareNoError;
|
||||
|
||||
bool hasChannelNames = AudioObjectHasProperty(m_DeviceID, &pa);
|
||||
|
||||
if (hasChannelNames) {
|
||||
error = AudioObjectGetPropertyDataSize(m_DeviceID, &pa, 0, 0, &nameSize );
|
||||
|
||||
if (error == kAudioHardwareNoError) {
|
||||
error = AudioObjectGetPropertyData (m_DeviceID, &pa, 0, 0, &nameSize, &cfName);
|
||||
}
|
||||
}
|
||||
|
||||
if (hasChannelNames && (error == kAudioHardwareNoError) )
|
||||
{
|
||||
CFIndex length = CFStringGetLength(cfName);
|
||||
CFIndex maxSize = CFStringGetMaximumSizeForEncoding(length, kCFStringEncodingUTF8);
|
||||
|
||||
char* cstr_name = new char[maxSize];
|
||||
CFStringGetCString(cfName, cstr_name, maxSize, kCFStringEncodingUTF8);
|
||||
|
||||
chNameStream << cstr_name;
|
||||
} else {
|
||||
chNameStream << "Input " << (channel+1);
|
||||
}
|
||||
|
||||
m_InputChannels.push_back (chNameStream.str());
|
||||
}
|
||||
|
||||
|
|
@ -470,9 +501,39 @@ WTErr WCMRCoreAudioDevice::UpdateDeviceOutputs()
|
|||
m_OutputChannels.clear();
|
||||
for (int channel = 0; channel < maxOutputChannels; channel++)
|
||||
{
|
||||
AudioObjectPropertyAddress pa;
|
||||
pa.mSelector = kAudioObjectPropertyElementName;
|
||||
pa.mScope = kAudioObjectPropertyScopeOutput;
|
||||
pa.mElement = channel + 1;
|
||||
|
||||
CFStringRef cfName;
|
||||
std::stringstream chNameStream;
|
||||
//A better implementation would be to retrieve the names from ASIO or CoreAudio interfaces
|
||||
chNameStream << "Output " << (channel+1);
|
||||
UInt32 nameSize = 0;
|
||||
OSStatus error = kAudioHardwareNoError;
|
||||
|
||||
bool hasChannelNames = AudioObjectHasProperty(m_DeviceID, &pa);
|
||||
|
||||
if (hasChannelNames) {
|
||||
error = AudioObjectGetPropertyDataSize(m_DeviceID, &pa, 0, 0, &nameSize );
|
||||
|
||||
if (error == kAudioHardwareNoError) {
|
||||
error = AudioObjectGetPropertyData (m_DeviceID, &pa, 0, 0, &nameSize, &cfName);
|
||||
}
|
||||
}
|
||||
|
||||
if (hasChannelNames && (error == kAudioHardwareNoError) )
|
||||
{
|
||||
CFIndex length = CFStringGetLength(cfName);
|
||||
CFIndex maxSize = CFStringGetMaximumSizeForEncoding(length, kCFStringEncodingUTF8);
|
||||
|
||||
char* cstr_name = new char[maxSize];
|
||||
CFStringGetCString(cfName, cstr_name, maxSize, kCFStringEncodingUTF8);
|
||||
|
||||
chNameStream << cstr_name;
|
||||
} else {
|
||||
chNameStream << "Output " << (channel+1);
|
||||
}
|
||||
|
||||
m_OutputChannels.push_back (chNameStream.str());
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue