mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-12 17:46:34 +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
|
|
@ -47,7 +47,8 @@ using namespace Glib;
|
|||
|
||||
namespace {
|
||||
|
||||
static const char* audio_port_name_prefix = "system:";
|
||||
static const char* audio_capture_name_prefix = "system:capture:";
|
||||
static const char* audio_playback_name_prefix = "system:playback:";
|
||||
static const char* midi_port_name_prefix = "system_midi:";
|
||||
static const char* midi_capture_suffix = " capture";
|
||||
static const char* midi_playback_suffix = " playback";
|
||||
|
|
@ -142,7 +143,7 @@ TracksControlPanel::init ()
|
|||
DeviceConnectionControl& TracksControlPanel::add_device_capture_control(std::string port_name, bool active, uint16_t capture_number, std::string track_name)
|
||||
{
|
||||
std::string device_capture_name("");
|
||||
std::string pattern(audio_port_name_prefix);
|
||||
std::string pattern(audio_capture_name_prefix);
|
||||
remove_pattern_from_string(port_name, pattern, device_capture_name);
|
||||
|
||||
DeviceConnectionControl &capture_control = *manage (new DeviceConnectionControl(device_capture_name, active, capture_number, track_name));
|
||||
|
|
@ -159,7 +160,7 @@ DeviceConnectionControl& TracksControlPanel::add_device_capture_control(std::str
|
|||
DeviceConnectionControl& TracksControlPanel::add_device_playback_control(std::string port_name, bool active, uint16_t playback_number)
|
||||
{
|
||||
std::string device_playback_name("");
|
||||
std::string pattern(audio_port_name_prefix);
|
||||
std::string pattern(audio_playback_name_prefix);
|
||||
remove_pattern_from_string(port_name, pattern, device_playback_name);
|
||||
|
||||
DeviceConnectionControl &playback_control = *manage (new DeviceConnectionControl(device_playback_name, active, playback_number));
|
||||
|
|
@ -350,7 +351,7 @@ TracksControlPanel::populate_input_channels()
|
|||
if (input_iter->active) {
|
||||
|
||||
std::string port_name("");
|
||||
std::string pattern(audio_port_name_prefix);
|
||||
std::string pattern(audio_capture_name_prefix);
|
||||
remove_pattern_from_string(input_iter->name, pattern, port_name);
|
||||
|
||||
number = number_count++;
|
||||
|
|
|
|||
|
|
@ -379,7 +379,7 @@ Session::Session (AudioEngine &eng,
|
|||
for( int i = 0; i < inputs.size(); ++i)
|
||||
{
|
||||
string track_name;
|
||||
remove_pattern_from_string(inputs[i], "system:", track_name);
|
||||
remove_pattern_from_string(inputs[i], "system:capture:", track_name);
|
||||
|
||||
list<boost::shared_ptr<AudioTrack> > single_track = new_audio_track (1, 1, Normal, 0, 1, track_name);
|
||||
tracks.insert(tracks.begin(), single_track.front());
|
||||
|
|
|
|||
|
|
@ -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
|
||||
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
|
||||
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