--- linuxsampler/trunk/src/drivers/audio/AudioOutputDeviceJack.cpp 2004/10/19 14:41:38 289 +++ linuxsampler/trunk/src/drivers/audio/AudioOutputDeviceJack.cpp 2005/02/12 00:36:08 374 @@ -29,7 +29,10 @@ namespace LinuxSampler { -// *************** ParameterName *************** + /// number of currently existing JACK audio output devices in LinuxSampler + static int existingJackDevices = 0; + +// *************** AudioChannelJack::ParameterName *************** // * AudioOutputDeviceJack::AudioChannelJack::ParameterName::ParameterName(AudioChannelJack* pChannel) : AudioChannel::ParameterName(ToString(pChannel->ChannelNr)) { @@ -42,7 +45,7 @@ -// *************** ParameterJackBindings *************** +// *************** AudioChannelJack::ParameterJackBindings *************** // * AudioOutputDeviceJack::AudioChannelJack::ParameterJackBindings::ParameterJackBindings(AudioChannelJack* pChannel) : DeviceRuntimeParameterStrings(std::vector()) { @@ -106,6 +109,50 @@ +// *************** AudioOutputDeviceJack::ParameterName *************** +// * + + AudioOutputDeviceJack::ParameterName::ParameterName() : DeviceCreationParameterString() { + InitWithDefault(); // use default name + } + + AudioOutputDeviceJack::ParameterName::ParameterName(String s) throw (LinuxSamplerException) : DeviceCreationParameterString(s) { + } + + String AudioOutputDeviceJack::ParameterName::Description() { + return "Arbitrary JACK client name"; + } + + bool AudioOutputDeviceJack::ParameterName::Fix() { + return true; + } + + bool AudioOutputDeviceJack::ParameterName::Mandatory() { + return false; + } + + std::map AudioOutputDeviceJack::ParameterName::DependsAsParameters() { + return std::map(); // no dependencies + } + + std::vector AudioOutputDeviceJack::ParameterName::PossibilitiesAsString(std::map Parameters) { + return std::vector(); + } + + optional AudioOutputDeviceJack::ParameterName::DefaultAsString(std::map Parameters) { + return (existingJackDevices) ? "LinuxSampler" + ToString(existingJackDevices) : "LinuxSampler"; + } + + void AudioOutputDeviceJack::ParameterName::OnSetValue(String s) throw (LinuxSamplerException) { + // not possible, as parameter is fix + } + + String AudioOutputDeviceJack::ParameterName::Name() { + return "NAME"; + } + + + // *************** AudioOutputDeviceJack *************** // * @@ -117,9 +164,14 @@ * @see AcquireChannels() */ AudioOutputDeviceJack::AudioOutputDeviceJack(std::map Parameters) : AudioOutputDevice(Parameters) { - if ((hJackClient = jack_client_new("LinuxSampler")) == 0) + if (((DeviceCreationParameterString*)Parameters["NAME"])->ValueAsString().size() >= jack_client_name_size()) + throw LinuxSamplerException("JACK client name too long"); + + if ((hJackClient = jack_client_new(((DeviceCreationParameterString*)Parameters["NAME"])->ValueAsString().c_str())) == 0) throw AudioOutputException("Seems Jack server not running."); + existingJackDevices++; + jack_set_process_callback(hJackClient, __libjack_process_callback, this); jack_on_shutdown(hJackClient, __libjack_shutdown_callback, this); if (jack_activate(hJackClient)) @@ -137,6 +189,7 @@ AudioOutputDeviceJack::~AudioOutputDeviceJack() { // destroy jack client jack_client_close(hJackClient); + existingJackDevices--; } /** @@ -191,7 +244,7 @@ } String AudioOutputDeviceJack::Version() { - String s = "$Revision: 1.14 $"; + String s = "$Revision: 1.15 $"; return s.substr(11, s.size() - 13); // cut dollar signs, spaces and CVS macro keyword }