mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-20 21:56:30 +01:00
mo' better coreaudio device enumeration and usage by JACK control panel
git-svn-id: svn://localhost/ardour2/branches/2.0-ongoing@2313 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
f810616e1d
commit
43a43437bc
3 changed files with 71 additions and 35 deletions
|
|
@ -163,6 +163,7 @@ ARDOUR_UI::ARDOUR_UI (int *argcp, char **argvp[])
|
||||||
ui_config = new UIConfiguration();
|
ui_config = new UIConfiguration();
|
||||||
theme_manager = new ThemeManager();
|
theme_manager = new ThemeManager();
|
||||||
|
|
||||||
|
engine = 0;
|
||||||
editor = 0;
|
editor = 0;
|
||||||
mixer = 0;
|
mixer = 0;
|
||||||
session = 0;
|
session = 0;
|
||||||
|
|
@ -256,8 +257,9 @@ ARDOUR_UI::create_engine ()
|
||||||
engine = new ARDOUR::AudioEngine (ARDOUR_COMMAND_LINE::jack_client_name);
|
engine = new ARDOUR::AudioEngine (ARDOUR_COMMAND_LINE::jack_client_name);
|
||||||
} catch (AudioEngine::NoBackendAvailable& err) {
|
} catch (AudioEngine::NoBackendAvailable& err) {
|
||||||
backend_audio_error ();
|
backend_audio_error ();
|
||||||
|
cerr << "engine not started\n";
|
||||||
error << string_compose (_("Could not connect to JACK server as \"%1\""), ARDOUR_COMMAND_LINE::jack_client_name) << endmsg;
|
error << string_compose (_("Could not connect to JACK server as \"%1\""), ARDOUR_COMMAND_LINE::jack_client_name) << endmsg;
|
||||||
quit ();
|
exit (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
engine->Stopped.connect (mem_fun(*this, &ARDOUR_UI::engine_stopped));
|
engine->Stopped.connect (mem_fun(*this, &ARDOUR_UI::engine_stopped));
|
||||||
|
|
@ -1977,6 +1979,8 @@ ARDOUR_UI::new_session (Glib::ustring predetermined_path, bool have_engine)
|
||||||
have_engine = true;
|
have_engine = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cerr << "startingengine\n";
|
||||||
|
|
||||||
create_engine ();
|
create_engine ();
|
||||||
|
|
||||||
/* now handle possible affirmative responses */
|
/* now handle possible affirmative responses */
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,10 @@
|
||||||
#include <pbd/convert.h>
|
#include <pbd/convert.h>
|
||||||
#include <pbd/error.h>
|
#include <pbd/error.h>
|
||||||
|
|
||||||
|
#ifdef __APPLE
|
||||||
|
#include <CFBundle.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "engine_dialog.h"
|
#include "engine_dialog.h"
|
||||||
#include "i18n.h"
|
#include "i18n.h"
|
||||||
|
|
||||||
|
|
@ -81,12 +85,12 @@ EngineControl::EngineControl ()
|
||||||
basic_packer.set_spacings (6);
|
basic_packer.set_spacings (6);
|
||||||
|
|
||||||
strings.clear ();
|
strings.clear ();
|
||||||
#ifndef __APPLE__
|
#ifdef __APPLE__
|
||||||
|
strings.push_back (X_("CoreAudio"));
|
||||||
|
#else
|
||||||
strings.push_back (X_("ALSA"));
|
strings.push_back (X_("ALSA"));
|
||||||
strings.push_back (X_("OSS"));
|
strings.push_back (X_("OSS"));
|
||||||
strings.push_back (X_("FFADO"));
|
strings.push_back (X_("FFADO"));
|
||||||
#else
|
|
||||||
strings.push_back (X_("CoreAudio"));
|
|
||||||
#endif
|
#endif
|
||||||
strings.push_back (X_("NetJACK"));
|
strings.push_back (X_("NetJACK"));
|
||||||
strings.push_back (X_("Dummy"));
|
strings.push_back (X_("Dummy"));
|
||||||
|
|
@ -213,6 +217,8 @@ EngineControl::EngineControl ()
|
||||||
set_popdown_strings (serverpath_combo, strings);
|
set_popdown_strings (serverpath_combo, strings);
|
||||||
serverpath_combo.set_active_text (strings.front());
|
serverpath_combo.set_active_text (strings.front());
|
||||||
|
|
||||||
|
cerr << "we have " << strings.size() << " possible Jack servers\n";
|
||||||
|
|
||||||
if (strings.size() > 1) {
|
if (strings.size() > 1) {
|
||||||
label = manage (new Label (_("Server:")));
|
label = manage (new Label (_("Server:")));
|
||||||
options_packer.attach (*label, 0, 1, 11, 12, (AttachOptions) 0, (AttachOptions) 0);
|
options_packer.attach (*label, 0, 1, 11, 12, (AttachOptions) 0, (AttachOptions) 0);
|
||||||
|
|
@ -260,6 +266,7 @@ void
|
||||||
EngineControl::build_command_line (vector<string>& cmd)
|
EngineControl::build_command_line (vector<string>& cmd)
|
||||||
{
|
{
|
||||||
string str;
|
string str;
|
||||||
|
string driver;
|
||||||
bool using_oss = false;
|
bool using_oss = false;
|
||||||
bool using_alsa = false;
|
bool using_alsa = false;
|
||||||
bool using_coreaudio = false;
|
bool using_coreaudio = false;
|
||||||
|
|
@ -311,20 +318,20 @@ EngineControl::build_command_line (vector<string>& cmd)
|
||||||
|
|
||||||
cmd.push_back ("-d");
|
cmd.push_back ("-d");
|
||||||
|
|
||||||
str = driver_combo.get_active_text ();
|
driver = driver_combo.get_active_text ();
|
||||||
if (str == X_("ALSA")) {
|
if (driver == X_("ALSA")) {
|
||||||
using_alsa = true;
|
using_alsa = true;
|
||||||
cmd.push_back ("alsa");
|
cmd.push_back ("alsa");
|
||||||
} else if (str == X_("OSS")) {
|
} else if (driver == X_("OSS")) {
|
||||||
using_oss = true;
|
using_oss = true;
|
||||||
cmd.push_back ("oss");
|
cmd.push_back ("oss");
|
||||||
} else if (str == X_("CoreAudio")) {
|
} else if (driver == X_("CoreAudio")) {
|
||||||
using_coreaudio = true;
|
using_coreaudio = true;
|
||||||
cmd.push_back ("coreaudio");
|
cmd.push_back ("coreaudio");
|
||||||
} else if (str == X_("NetJACK")) {
|
} else if (driver == X_("NetJACK")) {
|
||||||
using_netjack = true;
|
using_netjack = true;
|
||||||
cmd.push_back ("netjack");
|
cmd.push_back ("netjack");
|
||||||
} else if (str == X_("FFADO")) {
|
} else if (driver == X_("FFADO")) {
|
||||||
using_ffado = true;
|
using_ffado = true;
|
||||||
cmd.push_back ("ffado");
|
cmd.push_back ("ffado");
|
||||||
}
|
}
|
||||||
|
|
@ -340,8 +347,10 @@ EngineControl::build_command_line (vector<string>& cmd)
|
||||||
cmd.push_back ("-C");
|
cmd.push_back ("-C");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!using_coreaudio) {
|
||||||
cmd.push_back ("-n");
|
cmd.push_back ("-n");
|
||||||
cmd.push_back (to_string ((uint32_t) floor (periods_spinner.get_value()), std::dec));
|
cmd.push_back (to_string ((uint32_t) floor (periods_spinner.get_value()), std::dec));
|
||||||
|
}
|
||||||
|
|
||||||
cmd.push_back ("-r");
|
cmd.push_back ("-r");
|
||||||
cmd.push_back (to_string (get_rate(), std::dec));
|
cmd.push_back (to_string (get_rate(), std::dec));
|
||||||
|
|
@ -382,8 +391,26 @@ EngineControl::build_command_line (vector<string>& cmd)
|
||||||
|
|
||||||
} else if (using_coreaudio) {
|
} else if (using_coreaudio) {
|
||||||
|
|
||||||
cmd.push_back ("-I");
|
#ifdef __APPLE__
|
||||||
cmd.push_back (interface_combo.get_active_text());
|
cmd.push_back ("-n");
|
||||||
|
|
||||||
|
Glib::ustring str = interface_combo.get_active_text();
|
||||||
|
vector<string>::iterator n;
|
||||||
|
vector<string>::iterator i;
|
||||||
|
|
||||||
|
for (i = devices[driver].begin(), n = coreaudio_devs.begin(); i != devices[driver].end(); ++i, ++n) {
|
||||||
|
if (str == (*i)) {
|
||||||
|
cerr << "for " << str << " use " << (*n) << endl;
|
||||||
|
cmd.push_back (*n);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (i == devices[driver].end()) {
|
||||||
|
fatal << string_compose (_("programming error: %1"), "coreaudio device ID missing") << endmsg;
|
||||||
|
/*NOTREACHED*/
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
} else if (using_oss) {
|
} else if (using_oss) {
|
||||||
|
|
||||||
|
|
@ -423,10 +450,13 @@ EngineControl::start_engine ()
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cerr << "will execute ...\n";
|
||||||
for (vector<string>::iterator i = args.begin(); i != args.end(); ++i) {
|
for (vector<string>::iterator i = args.begin(); i != args.end(); ++i) {
|
||||||
jackdrc << (*i) << ' ';
|
jackdrc << (*i) << ' ';
|
||||||
|
cerr << (*i) << ' ';
|
||||||
}
|
}
|
||||||
jackdrc << endl;
|
jackdrc << endl;
|
||||||
|
cerr << endl;
|
||||||
jackdrc.close ();
|
jackdrc.close ();
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
|
|
@ -477,6 +507,19 @@ EngineControl::enumerate_devices ()
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
|
static OSStatus
|
||||||
|
getDeviceUIDFromID( AudioDeviceID id, char *name, size_t nsize)
|
||||||
|
{
|
||||||
|
UInt32 size = sizeof(CFStringRef);
|
||||||
|
CFStringRef UI;
|
||||||
|
OSStatus res = AudioDeviceGetProperty(id, 0, false,
|
||||||
|
kAudioDevicePropertyDeviceUID, &size, &UI);
|
||||||
|
if (res == noErr)
|
||||||
|
CFStringGetCString(UI,name,nsize,CFStringGetSystemEncoding());
|
||||||
|
CFRelease(UI);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
vector<string>
|
vector<string>
|
||||||
EngineControl::enumerate_coreaudio_devices ()
|
EngineControl::enumerate_coreaudio_devices ()
|
||||||
{
|
{
|
||||||
|
|
@ -485,9 +528,11 @@ EngineControl::enumerate_coreaudio_devices ()
|
||||||
// Find out how many Core Audio devices are there, if any...
|
// Find out how many Core Audio devices are there, if any...
|
||||||
// (code snippet gently "borrowed" from St?hane Letz jackdmp;)
|
// (code snippet gently "borrowed" from St?hane Letz jackdmp;)
|
||||||
OSStatus err;
|
OSStatus err;
|
||||||
bool isWritable;
|
Boolean isWritable;
|
||||||
size_t outSize = sizeof(isWritable);
|
size_t outSize = sizeof(isWritable);
|
||||||
|
|
||||||
|
coreaudio_devs.clear ();
|
||||||
|
|
||||||
err = AudioHardwareGetPropertyInfo(kAudioHardwarePropertyDevices,
|
err = AudioHardwareGetPropertyInfo(kAudioHardwarePropertyDevices,
|
||||||
&outSize, &isWritable);
|
&outSize, &isWritable);
|
||||||
if (err == noErr) {
|
if (err == noErr) {
|
||||||
|
|
@ -517,24 +562,9 @@ EngineControl::enumerate_coreaudio_devices ()
|
||||||
// that must be used on the commandline for jack
|
// that must be used on the commandline for jack
|
||||||
|
|
||||||
if (getDeviceUIDFromID(coreDeviceIDs[i], drivername, sizeof (drivername)) == noErr) {
|
if (getDeviceUIDFromID(coreDeviceIDs[i], drivername, sizeof (drivername)) == noErr) {
|
||||||
sName = drivername;
|
devs.push_back (coreDeviceName);
|
||||||
} else {
|
coreaudio_devs.push_back (drivername);
|
||||||
sName = "Error";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
devs.push_back (sName);
|
|
||||||
#if 0
|
|
||||||
|
|
||||||
coreaudioIdMap[sName] = coreDeviceIDs[i];
|
|
||||||
// TODO: hide this ugly ID from the user,
|
|
||||||
// only show human readable name
|
|
||||||
// humanreadable \t UID
|
|
||||||
sText = QString(coreDeviceName) + '\t' + sName;
|
|
||||||
pAction = menu.addAction(sText);
|
|
||||||
pAction->setCheckable(true);
|
|
||||||
pAction->setChecked(sCurName == sName);
|
|
||||||
++iCards;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -81,8 +81,10 @@ class EngineControl : public Gtk::VBox {
|
||||||
|
|
||||||
std::map<std::string,std::vector<std::string> > devices;
|
std::map<std::string,std::vector<std::string> > devices;
|
||||||
void enumerate_devices ();
|
void enumerate_devices ();
|
||||||
#ifdef __APPLE
|
|
||||||
|
#ifdef __APPLE__
|
||||||
std::vector<std::string> enumerate_coreaudio_devices ();
|
std::vector<std::string> enumerate_coreaudio_devices ();
|
||||||
|
std::vector<std::string> coreaudio_devs;
|
||||||
#else
|
#else
|
||||||
std::vector<std::string> enumerate_alsa_devices ();
|
std::vector<std::string> enumerate_alsa_devices ();
|
||||||
std::vector<std::string> enumerate_oss_devices ();
|
std::vector<std::string> enumerate_oss_devices ();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue