diff --git a/ChangeLog b/ChangeLog index 695de273..2606c337 100644 --- a/ChangeLog +++ b/ChangeLog @@ -4,10 +4,14 @@ 2007-08-21 Stephane Letz - * Automatic server launch. Removes unneeded 'volatile' for JackTransportEngine::fWriteCounter. + * Fix backend port alias management (renaming in system:xxx). 2007-08-20 Stephane Letz + * Automatic server launch. Removes unneeded 'volatile' for JackTransportEngine::fWriteCounter. + +2007-08-19 Stephane Letz + * Add "systemic" latencies management in CoreAudio driver. 2007-08-16 Stephane Letz diff --git a/common/JackAudioDriver.cpp b/common/JackAudioDriver.cpp index ddff1c81..878f9bc9 100644 --- a/common/JackAudioDriver.cpp +++ b/common/JackAudioDriver.cpp @@ -78,7 +78,7 @@ int JackAudioDriver::Attach() { JackPort* port; jack_port_id_t port_index; - char buf[JACK_PORT_NAME_SIZE]; + char buf[JACK_CLIENT_NAME_SIZE + JACK_PORT_NAME_SIZE]; unsigned long port_flags = JackPortIsOutput | JackPortIsPhysical | JackPortIsTerminal; int i; @@ -224,6 +224,27 @@ int JackAudioDriver::ProcessSync() return 0; } +void JackAudioDriver::RenamePorts() +{ + JackPort* port; + char buf[JACK_CLIENT_NAME_SIZE + JACK_PORT_NAME_SIZE]; + int i; + + for (i = 0; i < fCaptureChannels; i++) { + port = fGraphManager->GetPort(fCapturePortList[i]); + port->SetAlias(port->GetName()); + snprintf(buf, sizeof(buf) - 1, "system:capture_%d", i + 1); + port->SetFullName(buf); + } + + for (i = 0; i < fPlaybackChannels; i++) { + port = fGraphManager->GetPort(fPlaybackPortList[i]); + port->SetAlias(port->GetName()); + snprintf(buf, sizeof(buf) - 1, "system:playback_%d", i + 1); + port->SetFullName(buf); + } +} + void JackAudioDriver::NotifyXRun(jack_time_t callback_usecs) { fEngine->NotifyXRun(callback_usecs); diff --git a/common/JackAudioDriver.h b/common/JackAudioDriver.h index d3c86da6..5ea6432e 100644 --- a/common/JackAudioDriver.h +++ b/common/JackAudioDriver.h @@ -55,6 +55,8 @@ class EXPORT JackAudioDriver : public JackDriver int ProcessAsync(); int ProcessSync(); + + void RenamePorts(); public: diff --git a/common/JackDriver.h b/common/JackDriver.h index 14472457..2024241a 100644 --- a/common/JackDriver.h +++ b/common/JackDriver.h @@ -65,9 +65,12 @@ class EXPORT JackDriverInterface virtual int Attach() = 0; virtual int Detach() = 0; + + virtual void RenamePorts() = 0; virtual int Read() = 0; virtual int Write() = 0; + virtual int Start() = 0; virtual int Stop() = 0; virtual int SetBufferSize(jack_nframes_t buffer_size) = 0; diff --git a/common/JackFreewheelDriver.h b/common/JackFreewheelDriver.h index f2f54d5a..867c310b 100644 --- a/common/JackFreewheelDriver.h +++ b/common/JackFreewheelDriver.h @@ -44,8 +44,11 @@ class JackFreewheelDriver : public JackDriver { return false; } - - int Process(); + + void RenamePorts() + {} + + int Process(); }; } // end of namespace diff --git a/common/JackPort.cpp b/common/JackPort.cpp index 8e975497..a7848433 100644 --- a/common/JackPort.cpp +++ b/common/JackPort.cpp @@ -52,6 +52,8 @@ void JackPort::Release() fLocked = false; fLatency = 0; fTied = NO_PORT; + fAlias1[0] = '\0'; + fAlias2[0] = '\0'; } bool JackPort::IsUsed() const @@ -184,6 +186,13 @@ int JackPort::SetName(const char* new_name) return 0; } +int JackPort::SetFullName(const char* new_name) +{ + assert(strlen(new_name) < JACK_CLIENT_NAME_SIZE + JACK_PORT_NAME_SIZE); + strcpy(fName, new_name); + return 0; +} + bool JackPort::NameEquals(const char* target) { return (strcmp(fName, target) == 0 diff --git a/common/JackPort.h b/common/JackPort.h index 4fa5b430..45748f61 100644 --- a/common/JackPort.h +++ b/common/JackPort.h @@ -78,6 +78,7 @@ class JackPort const char* GetName() const; const char* GetShortName() const; int SetName(const char* name); + int SetFullName(const char* new_name); int GetAliases(char* const aliases[2]); int SetAlias(const char* alias); diff --git a/common/JackServer.cpp b/common/JackServer.cpp index b4e2926d..99cae9a7 100644 --- a/common/JackServer.cpp +++ b/common/JackServer.cpp @@ -122,6 +122,8 @@ int JackServer::Open(jack_driver_desc_t* driver_desc, JSList* driver_params) jack_error("Cannot attach audio driver"); return -1; } + + fAudioDriver->RenamePorts(); if (fLoopback > 0 && fLoopbackDriver->Attach() != 0) { jack_error("Cannot attach loopback driver"); diff --git a/common/JackThreadedDriver.h b/common/JackThreadedDriver.h index 60d302d6..c5aa0b3f 100644 --- a/common/JackThreadedDriver.h +++ b/common/JackThreadedDriver.h @@ -82,6 +82,11 @@ class JackThreadedDriver : public JackDriverClientInterface, public JackRunnable { return fDriver->Detach(); } + + virtual void RenamePorts() + { + fDriver->RenamePorts(); + } virtual int Read() { diff --git a/linux/alsa/JackAlsaDriver.cpp b/linux/alsa/JackAlsaDriver.cpp index 59a1628a..74bf7cdd 100644 --- a/linux/alsa/JackAlsaDriver.cpp +++ b/linux/alsa/JackAlsaDriver.cpp @@ -2074,7 +2074,7 @@ int JackAlsaDriver::Attach() int port_index; unsigned long port_flags; - char buf[JACK_PORT_NAME_SIZE]; + char buf[JACK_CLIENT_NAME_SIZE + JACK_PORT_NAME_SIZE]; port_flags = JackPortIsOutput | JackPortIsPhysical | JackPortIsTerminal; diff --git a/macosx/JackCoreAudioDriver.cpp b/macosx/JackCoreAudioDriver.cpp index 6ede9ead..e6ea8928 100644 --- a/macosx/JackCoreAudioDriver.cpp +++ b/macosx/JackCoreAudioDriver.cpp @@ -800,7 +800,7 @@ int JackCoreAudioDriver::Attach() UInt32 size; Boolean isWritable; char channel_name[64]; - char buf[JACK_PORT_NAME_SIZE]; + char buf[JACK_CLIENT_NAME_SIZE + JACK_PORT_NAME_SIZE]; unsigned long port_flags = JackPortIsOutput | JackPortIsPhysical | JackPortIsTerminal; JackLog("JackCoreAudioDriver::Attach fBufferSize %ld fSampleRate %ld\n", fEngineControl->fBufferSize, fEngineControl->fSampleRate);