diff --git a/common/JackAudioDriver.cpp b/common/JackAudioDriver.cpp index 31b8a51b..00b004f7 100644 --- a/common/JackAudioDriver.cpp +++ b/common/JackAudioDriver.cpp @@ -141,7 +141,7 @@ int JackAudioDriver::Attach() for (i = 0; i < fCaptureChannels; i++) { snprintf(alias, sizeof(alias) - 1, "%s:%s:out%d", fAliasName, fCaptureDriverName, i + 1); snprintf(name, sizeof(name) - 1, "%s:capture_%d", fClientControl.fName, i + 1); - if ((port_index = fGraphManager->AllocatePort(fClientControl.fRefNum, name, JACK_DEFAULT_AUDIO_TYPE, CaptureDriverFlags, fEngineControl->fBufferSize)) == NO_PORT) { + if (fEngine->PortRegister(fClientControl.fRefNum, name, JACK_DEFAULT_AUDIO_TYPE, CaptureDriverFlags, fEngineControl->fBufferSize, &port_index) < 0) { jack_error("driver: cannot register port for %s", name); return -1; } @@ -154,7 +154,7 @@ int JackAudioDriver::Attach() for (i = 0; i < fPlaybackChannels; i++) { snprintf(alias, sizeof(alias) - 1, "%s:%s:in%d", fAliasName, fPlaybackDriverName, i + 1); snprintf(name, sizeof(name) - 1, "%s:playback_%d", fClientControl.fName, i + 1); - if ((port_index = fGraphManager->AllocatePort(fClientControl.fRefNum, name, JACK_DEFAULT_AUDIO_TYPE, PlaybackDriverFlags, fEngineControl->fBufferSize)) == NO_PORT) { + if (fEngine->PortRegister(fClientControl.fRefNum, name, JACK_DEFAULT_AUDIO_TYPE, PlaybackDriverFlags, fEngineControl->fBufferSize, &port_index) < 0) { jack_error("driver: cannot register port for %s", name); return -1; } @@ -167,7 +167,7 @@ int JackAudioDriver::Attach() if (fWithMonitorPorts) { jack_log("Create monitor port"); snprintf(name, sizeof(name) - 1, "%s:monitor_%u", fClientControl.fName, i + 1); - if ((port_index = fGraphManager->AllocatePort(fClientControl.fRefNum, name, JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput, fEngineControl->fBufferSize)) == NO_PORT) { + if (fEngine->PortRegister(fClientControl.fRefNum, name, JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput, fEngineControl->fBufferSize, &port_index) < 0) { jack_error("Cannot register monitor port for %s", name); return -1; } else { @@ -186,13 +186,14 @@ int JackAudioDriver::Detach() jack_log("JackAudioDriver::Detach"); for (i = 0; i < fCaptureChannels; i++) { - fGraphManager->ReleasePort(fClientControl.fRefNum, fCapturePortList[i]); + fEngine->PortUnRegister(fClientControl.fRefNum, fCapturePortList[i]); } for (i = 0; i < fPlaybackChannels; i++) { - fGraphManager->ReleasePort(fClientControl.fRefNum, fPlaybackPortList[i]); - if (fWithMonitorPorts) - fGraphManager->ReleasePort(fClientControl.fRefNum, fMonitorPortList[i]); + fEngine->PortUnRegister(fClientControl.fRefNum, fPlaybackPortList[i]); + if (fWithMonitorPorts) { + fEngine->PortUnRegister(fClientControl.fRefNum, fMonitorPortList[i]); + } } return 0; diff --git a/common/JackEngine.cpp b/common/JackEngine.cpp index 2c7db9e3..998cb651 100644 --- a/common/JackEngine.cpp +++ b/common/JackEngine.cpp @@ -804,7 +804,7 @@ int JackEngine::PortRegister(int refnum, const char* name, const char *type, uns return -1; } - *port_index = fGraphManager->AllocatePort(refnum, name, type, (JackPortFlags)flags, fEngineControl->fBufferSize); + *port_index = fGraphManager->AllocatePort(refnum, name, type, (JackPortFlags)flags, buffer_size); if (*port_index != NO_PORT) { if (client->GetClientControl()->fActive) NotifyPortRegistation(*port_index, true); diff --git a/common/JackLockedEngine.h b/common/JackLockedEngine.h index c311f57d..45b1c6a0 100644 --- a/common/JackLockedEngine.h +++ b/common/JackLockedEngine.h @@ -261,6 +261,7 @@ class SERVER_EXPORT JackLockedEngine fEngine.NotifyGraphReorder(); CATCH_EXCEPTION } + void NotifyBufferSize(jack_nframes_t buffer_size) { TRY_CALL diff --git a/common/JackMidiDriver.cpp b/common/JackMidiDriver.cpp index 1fbd1e38..86001ae2 100644 --- a/common/JackMidiDriver.cpp +++ b/common/JackMidiDriver.cpp @@ -67,7 +67,7 @@ int JackMidiDriver::Attach() for (i = 0; i < fCaptureChannels; i++) { snprintf(alias, sizeof(alias) - 1, "%s:%s:out%d", fAliasName, fCaptureDriverName, i + 1); snprintf(name, sizeof(name) - 1, "%s:capture_%d", fClientControl.fName, i + 1); - if ((port_index = fGraphManager->AllocatePort(fClientControl.fRefNum, name, JACK_DEFAULT_MIDI_TYPE, CaptureDriverFlags, fEngineControl->fBufferSize)) == NO_PORT) { + if (fEngine->PortRegister(fClientControl.fRefNum, name, JACK_DEFAULT_MIDI_TYPE, CaptureDriverFlags, fEngineControl->fBufferSize, &port_index) < 0) { jack_error("driver: cannot register port for %s", name); return -1; } @@ -80,7 +80,7 @@ int JackMidiDriver::Attach() for (i = 0; i < fPlaybackChannels; i++) { snprintf(alias, sizeof(alias) - 1, "%s:%s:in%d", fAliasName, fPlaybackDriverName, i + 1); snprintf(name, sizeof(name) - 1, "%s:playback_%d", fClientControl.fName, i + 1); - if ((port_index = fGraphManager->AllocatePort(fClientControl.fRefNum, name, JACK_DEFAULT_MIDI_TYPE, PlaybackDriverFlags, fEngineControl->fBufferSize)) == NO_PORT) { + if (fEngine->PortRegister(fClientControl.fRefNum, name, JACK_DEFAULT_MIDI_TYPE, PlaybackDriverFlags, fEngineControl->fBufferSize, &port_index) < 0) { jack_error("driver: cannot register port for %s", name); return -1; } @@ -100,11 +100,11 @@ int JackMidiDriver::Detach() jack_log("JackMidiDriver::Detach"); for (i = 0; i < fCaptureChannels; i++) { - fGraphManager->ReleasePort(fClientControl.fRefNum, fCapturePortList[i]); + fEngine->PortUnRegister(fClientControl.fRefNum, fCapturePortList[i]); } for (i = 0; i < fPlaybackChannels; i++) { - fGraphManager->ReleasePort(fClientControl.fRefNum, fPlaybackPortList[i]); + fEngine->PortUnRegister(fClientControl.fRefNum, fPlaybackPortList[i]); } return 0; diff --git a/common/JackNetDriver.cpp b/common/JackNetDriver.cpp index 6726c0a7..b68cc107 100644 --- a/common/JackNetDriver.cpp +++ b/common/JackNetDriver.cpp @@ -19,10 +19,10 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. #include "JackNetDriver.h" #include "JackEngineControl.h" +#include "JackLockedEngine.h" #include "JackGraphManager.h" #include "JackWaitThreadedDriver.h" - using namespace std; namespace Jack @@ -268,7 +268,7 @@ namespace Jack jack_log("JackNetDriver::AllocPorts fBufferSize = %ld fSampleRate = %ld", fEngineControl->fBufferSize, fEngineControl->fSampleRate); JackPort* port; - jack_port_id_t port_id; + jack_port_id_t port_index; char name[JACK_CLIENT_NAME_SIZE + JACK_PORT_NAME_SIZE]; char alias[JACK_CLIENT_NAME_SIZE + JACK_PORT_NAME_SIZE]; unsigned long port_flags; @@ -282,32 +282,32 @@ namespace Jack { snprintf(alias, sizeof(alias) - 1, "%s:%s:out%d", fAliasName, fCaptureDriverName, audio_port_index + 1); snprintf(name, sizeof(name) - 1, "%s:capture_%d", fClientControl.fName, audio_port_index + 1); - if ((port_id = fGraphManager->AllocatePort(fClientControl.fRefNum, name, JACK_DEFAULT_AUDIO_TYPE, - static_cast(port_flags), fEngineControl->fBufferSize)) == NO_PORT) + if (fEngine->PortRegister(fClientControl.fRefNum, name, JACK_DEFAULT_AUDIO_TYPE, + static_cast(port_flags), fEngineControl->fBufferSize, &port_index) < 0) { jack_error("driver: cannot register port for %s", name); return -1; } - port = fGraphManager->GetPort(port_id); + port = fGraphManager->GetPort(port_index); port->SetAlias(alias); //port latency range.min = range.max = fEngineControl->fBufferSize; port->SetLatencyRange(JackCaptureLatency, &range); - fCapturePortList[audio_port_index] = port_id; - jack_log("JackNetDriver::AllocPorts() fCapturePortList[%d] audio_port_index = %ld fPortLatency = %ld", audio_port_index, port_id, port->GetLatency()); + fCapturePortList[audio_port_index] = port_index; + jack_log("JackNetDriver::AllocPorts() fCapturePortList[%d] audio_port_index = %ld fPortLatency = %ld", audio_port_index, port_index, port->GetLatency()); } port_flags = JackPortIsInput | JackPortIsPhysical | JackPortIsTerminal; for (audio_port_index = 0; audio_port_index < fPlaybackChannels; audio_port_index++) { snprintf(alias, sizeof(alias) - 1, "%s:%s:in%d", fAliasName, fPlaybackDriverName, audio_port_index + 1); snprintf(name, sizeof(name) - 1, "%s:playback_%d",fClientControl.fName, audio_port_index + 1); - if ((port_id = fGraphManager->AllocatePort(fClientControl.fRefNum, name, JACK_DEFAULT_AUDIO_TYPE, - static_cast(port_flags), fEngineControl->fBufferSize)) == NO_PORT) + if (fEngine->PortRegister(fClientControl.fRefNum, name, JACK_DEFAULT_AUDIO_TYPE, + static_cast(port_flags), fEngineControl->fBufferSize, &port_index) < 0) { jack_error("driver: cannot register port for %s", name); return -1; } - port = fGraphManager->GetPort(port_id); + port = fGraphManager->GetPort(port_index); port->SetAlias(alias); //port latency switch (fParams.fNetworkMode) @@ -323,8 +323,8 @@ namespace Jack break; } port->SetLatencyRange(JackPlaybackLatency, &range); - fPlaybackPortList[audio_port_index] = port_id; - jack_log("JackNetDriver::AllocPorts() fPlaybackPortList[%d] audio_port_index = %ld fPortLatency = %ld", audio_port_index, port_id, port->GetLatency()); + fPlaybackPortList[audio_port_index] = port_index; + jack_log("JackNetDriver::AllocPorts() fPlaybackPortList[%d] audio_port_index = %ld fPortLatency = %ld", audio_port_index, port_index, port->GetLatency()); } //midi port_flags = JackPortIsOutput | JackPortIsPhysical | JackPortIsTerminal; @@ -332,18 +332,18 @@ namespace Jack { snprintf(alias, sizeof(alias) - 1, "%s:%s:out%d", fAliasName, fCaptureDriverName, midi_port_index + 1); snprintf(name, sizeof (name) - 1, "%s:midi_capture_%d", fClientControl.fName, midi_port_index + 1); - if ((port_id = fGraphManager->AllocatePort(fClientControl.fRefNum, name, JACK_DEFAULT_MIDI_TYPE, - static_cast(port_flags), fEngineControl->fBufferSize)) == NO_PORT) + if (fEngine->PortRegister(fClientControl.fRefNum, name, JACK_DEFAULT_MIDI_TYPE, + static_cast(port_flags), fEngineControl->fBufferSize, &port_index) < 0) { jack_error("driver: cannot register port for %s", name); return -1; } - port = fGraphManager->GetPort(port_id); + port = fGraphManager->GetPort(port_index); //port latency range.min = range.max = fEngineControl->fBufferSize; port->SetLatencyRange(JackCaptureLatency, &range); - fMidiCapturePortList[midi_port_index] = port_id; - jack_log("JackNetDriver::AllocPorts() fMidiCapturePortList[%d] midi_port_index = %ld fPortLatency = %ld", midi_port_index, port_id, port->GetLatency()); + fMidiCapturePortList[midi_port_index] = port_index; + jack_log("JackNetDriver::AllocPorts() fMidiCapturePortList[%d] midi_port_index = %ld fPortLatency = %ld", midi_port_index, port_index, port->GetLatency()); } port_flags = JackPortIsInput | JackPortIsPhysical | JackPortIsTerminal; @@ -351,13 +351,13 @@ namespace Jack { snprintf(alias, sizeof(alias) - 1, "%s:%s:in%d", fAliasName, fPlaybackDriverName, midi_port_index + 1); snprintf(name, sizeof(name) - 1, "%s:midi_playback_%d", fClientControl.fName, midi_port_index + 1); - if ((port_id = fGraphManager->AllocatePort(fClientControl.fRefNum, name, JACK_DEFAULT_MIDI_TYPE, - static_cast(port_flags), fEngineControl->fBufferSize)) == NO_PORT) + if (fEngine->PortRegister(fClientControl.fRefNum, name, JACK_DEFAULT_MIDI_TYPE, + static_cast(port_flags), fEngineControl->fBufferSize, &port_index) < 0) { jack_error("driver: cannot register port for %s", name); return -1; } - port = fGraphManager->GetPort(port_id); + port = fGraphManager->GetPort(port_index); //port latency switch (fParams.fNetworkMode) { @@ -372,8 +372,8 @@ namespace Jack break; } port->SetLatencyRange(JackPlaybackLatency, &range); - fMidiPlaybackPortList[midi_port_index] = port_id; - jack_log("JackNetDriver::AllocPorts() fMidiPlaybackPortList[%d] midi_port_index = %ld fPortLatency = %ld", midi_port_index, port_id, port->GetLatency()); + fMidiPlaybackPortList[midi_port_index] = port_index; + jack_log("JackNetDriver::AllocPorts() fMidiPlaybackPortList[%d] midi_port_index = %ld fPortLatency = %ld", midi_port_index, port_index, port->GetLatency()); } return 0; @@ -385,14 +385,14 @@ namespace Jack for (int audio_port_index = 0; audio_port_index < fCaptureChannels; audio_port_index++) { if (fCapturePortList[audio_port_index] > 0) { - fGraphManager->ReleasePort(fClientControl.fRefNum, fCapturePortList[audio_port_index]); + fEngine->PortUnRegister(fClientControl.fRefNum, fCapturePortList[audio_port_index]); fCapturePortList[audio_port_index] = 0; } } for (int audio_port_index = 0; audio_port_index < fPlaybackChannels; audio_port_index++) { if (fPlaybackPortList[audio_port_index] > 0) { - fGraphManager->ReleasePort(fClientControl.fRefNum, fPlaybackPortList[audio_port_index]); + fEngine->PortUnRegister(fClientControl.fRefNum, fPlaybackPortList[audio_port_index]); fPlaybackPortList[audio_port_index] = 0; } } @@ -406,7 +406,7 @@ namespace Jack for (int midi_port_index = 0; midi_port_index < fParams.fReturnMidiChannels; midi_port_index++) { if (fMidiPlaybackPortList && fMidiPlaybackPortList[midi_port_index] > 0) { - fGraphManager->ReleasePort(fClientControl.fRefNum, fMidiPlaybackPortList[midi_port_index]); + fEngine->PortUnRegister(fClientControl.fRefNum, fMidiPlaybackPortList[midi_port_index]); fMidiPlaybackPortList[midi_port_index] = 0; } } diff --git a/common/JackNetOneDriver.cpp b/common/JackNetOneDriver.cpp index 7da0ad8c..d0d5974d 100644 --- a/common/JackNetOneDriver.cpp +++ b/common/JackNetOneDriver.cpp @@ -23,6 +23,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. #include "JackNetOneDriver.h" #include "JackEngineControl.h" +#include "JackLockedEngine.h" #include "JackGraphManager.h" #include "JackWaitThreadedDriver.h" #include "JackTools.h" @@ -135,7 +136,7 @@ int JackNetOneDriver::Detach() int JackNetOneDriver::AllocPorts() { - jack_port_id_t port_id; + jack_port_id_t port_index; char buf[64]; unsigned int chn; @@ -145,16 +146,16 @@ int JackNetOneDriver::AllocPorts() for (chn = 0; chn < netj.capture_channels_audio; chn++) { snprintf (buf, sizeof(buf) - 1, "system:capture_%u", chn + 1); - if ( ( port_id = fGraphManager->AllocatePort ( fClientControl.fRefNum, buf, JACK_DEFAULT_AUDIO_TYPE, - CaptureDriverFlags, fEngineControl->fBufferSize ) ) == NO_PORT ) { + if (fEngine->PortRegister(fClientControl.fRefNum, buf, JACK_DEFAULT_AUDIO_TYPE, + CaptureDriverFlags, fEngineControl->fBufferSize, &port_index) < 0) { jack_error ( "driver: cannot register port for %s", buf ); return -1; } - //port = fGraphManager->GetPort ( port_id ); + //port = fGraphManager->GetPort ( port_index ); - netj.capture_ports = jack_slist_append (netj.capture_ports, (void *)(intptr_t)port_id); + netj.capture_ports = jack_slist_append (netj.capture_ports, (void *)(intptr_t)port_index); - if( netj.bitdepth == CELT_MODE ) { + if (netj.bitdepth == CELT_MODE) { #if HAVE_CELT #if HAVE_CELT_API_0_11 celt_int32 lookahead; @@ -178,31 +179,32 @@ int JackNetOneDriver::AllocPorts() #endif } } + for (chn = netj.capture_channels_audio; chn < netj.capture_channels; chn++) { snprintf (buf, sizeof(buf) - 1, "system:capture_%u", chn + 1); - if ( ( port_id = fGraphManager->AllocatePort ( fClientControl.fRefNum, buf, JACK_DEFAULT_MIDI_TYPE, - CaptureDriverFlags, fEngineControl->fBufferSize ) ) == NO_PORT ) { + if (fEngine->PortRegister(fClientControl.fRefNum, buf, JACK_DEFAULT_MIDI_TYPE, + CaptureDriverFlags, fEngineControl->fBufferSize, &port_index) < 0) { jack_error ( "driver: cannot register port for %s", buf ); return -1; } - //port = fGraphManager->GetPort ( port_id ); + //port = fGraphManager->GetPort ( port_index ); netj.capture_ports = - jack_slist_append (netj.capture_ports, (void *)(intptr_t)port_id); + jack_slist_append (netj.capture_ports, (void *)(intptr_t)port_index); } for (chn = 0; chn < netj.playback_channels_audio; chn++) { snprintf (buf, sizeof(buf) - 1, "system:playback_%u", chn + 1); - if ( ( port_id = fGraphManager->AllocatePort ( fClientControl.fRefNum, buf, JACK_DEFAULT_AUDIO_TYPE, - PlaybackDriverFlags, fEngineControl->fBufferSize ) ) == NO_PORT ) { + if (fEngine->PortRegister(fClientControl.fRefNum, buf, JACK_DEFAULT_AUDIO_TYPE, + PlaybackDriverFlags, fEngineControl->fBufferSize, &port_index) < 0) { jack_error ( "driver: cannot register port for %s", buf ); return -1; } - //port = fGraphManager->GetPort ( port_id ); + //port = fGraphManager->GetPort ( port_index ); - netj.playback_ports = jack_slist_append (netj.playback_ports, (void *)(intptr_t)port_id); + netj.playback_ports = jack_slist_append (netj.playback_ports, (void *)(intptr_t)port_index); if( netj.bitdepth == CELT_MODE ) { #if HAVE_CELT #if HAVE_CELT_API_0_11 @@ -225,15 +227,15 @@ int JackNetOneDriver::AllocPorts() for (chn = netj.playback_channels_audio; chn < netj.playback_channels; chn++) { snprintf (buf, sizeof(buf) - 1, "system:playback_%u", chn + 1); - if ( ( port_id = fGraphManager->AllocatePort ( fClientControl.fRefNum, buf, JACK_DEFAULT_MIDI_TYPE, - PlaybackDriverFlags, fEngineControl->fBufferSize ) ) == NO_PORT ) { + if (fEngine->PortRegister(fClientControl.fRefNum, buf, JACK_DEFAULT_MIDI_TYPE, + PlaybackDriverFlags, fEngineControl->fBufferSize, &port_index) < 0) { jack_error ( "driver: cannot register port for %s", buf ); return -1; } - //port = fGraphManager->GetPort ( port_id ); + //port = fGraphManager->GetPort ( port_index ); netj.playback_ports = - jack_slist_append (netj.playback_ports, (void *)(intptr_t)port_id); + jack_slist_append (netj.playback_ports, (void *)(intptr_t)port_index); } return 0; } @@ -435,20 +437,20 @@ JackNetOneDriver::FreePorts () while( node != NULL ) { JSList *this_node = node; - jack_port_id_t port_id = (jack_port_id_t)(intptr_t) node->data; + jack_port_id_t port_index = (jack_port_id_t)(intptr_t) node->data; node = jack_slist_remove_link( node, this_node ); jack_slist_free_1( this_node ); - fGraphManager->ReleasePort( fClientControl.fRefNum, port_id ); + fEngine->PortUnRegister(fClientControl.fRefNum, port_index); } netj.capture_ports = NULL; node = netj.playback_ports; while( node != NULL ) { JSList *this_node = node; - jack_port_id_t port_id = (jack_port_id_t)(intptr_t) node->data; + jack_port_id_t port_index = (jack_port_id_t)(intptr_t) node->data; node = jack_slist_remove_link( node, this_node ); jack_slist_free_1( this_node ); - fGraphManager->ReleasePort( fClientControl.fRefNum, port_id ); + fEngine->PortUnRegister(fClientControl.fRefNum, port_index); } netj.playback_ports = NULL; @@ -522,11 +524,11 @@ JackNetOneDriver::render_payload_to_jack_ports_float ( void *packet_payload, jac #if HAVE_SAMPLERATE SRC_DATA src; #endif - jack_port_id_t port_id = (jack_port_id_t)(intptr_t) node->data; - JackPort *port = fGraphManager->GetPort( port_id ); + jack_port_id_t port_index = (jack_port_id_t)(intptr_t) node->data; + JackPort *port = fGraphManager->GetPort( port_index ); jack_default_audio_sample_t* buf = - (jack_default_audio_sample_t*)fGraphManager->GetBuffer(port_id, fEngineControl->fBufferSize); + (jack_default_audio_sample_t*)fGraphManager->GetBuffer(port_index, fEngineControl->fBufferSize); const char *porttype = port->GetType(); @@ -594,11 +596,11 @@ JackNetOneDriver::render_jack_ports_to_payload_float (JSList *playback_ports, JS #endif unsigned int i; int_float_t val; - jack_port_id_t port_id = (jack_port_id_t)(intptr_t) node->data; - JackPort *port = fGraphManager->GetPort( port_id ); + jack_port_id_t port_index = (jack_port_id_t)(intptr_t) node->data; + JackPort *port = fGraphManager->GetPort( port_index ); jack_default_audio_sample_t* buf = - (jack_default_audio_sample_t*)fGraphManager->GetBuffer(port_id, fEngineControl->fBufferSize); + (jack_default_audio_sample_t*)fGraphManager->GetBuffer(port_index, fEngineControl->fBufferSize); const char *porttype = port->GetType(); @@ -661,11 +663,11 @@ JackNetOneDriver::render_payload_to_jack_ports_celt (void *packet_payload, jack_ unsigned char *packet_bufX = (unsigned char *)packet_payload; while (node != NULL) { - jack_port_id_t port_id = (jack_port_id_t) (intptr_t)node->data; - JackPort *port = fGraphManager->GetPort( port_id ); + jack_port_id_t port_index = (jack_port_id_t) (intptr_t)node->data; + JackPort *port = fGraphManager->GetPort( port_index ); jack_default_audio_sample_t* buf = - (jack_default_audio_sample_t*)fGraphManager->GetBuffer(port_id, fEngineControl->fBufferSize); + (jack_default_audio_sample_t*)fGraphManager->GetBuffer(port_index, fEngineControl->fBufferSize); const char *portname = port->GetType(); @@ -710,11 +712,11 @@ JackNetOneDriver::render_jack_ports_to_payload_celt (JSList *playback_ports, JSL unsigned char *packet_bufX = (unsigned char *)packet_payload; while (node != NULL) { - jack_port_id_t port_id = (jack_port_id_t) (intptr_t) node->data; - JackPort *port = fGraphManager->GetPort( port_id ); + jack_port_id_t port_index = (jack_port_id_t) (intptr_t) node->data; + JackPort *port = fGraphManager->GetPort( port_index ); jack_default_audio_sample_t* buf = - (jack_default_audio_sample_t*)fGraphManager->GetBuffer(port_id, fEngineControl->fBufferSize); + (jack_default_audio_sample_t*)fGraphManager->GetBuffer(port_index, fEngineControl->fBufferSize); const char *portname = port->GetType(); diff --git a/linux/alsa/JackAlsaDriver.cpp b/linux/alsa/JackAlsaDriver.cpp index 87338000..9f5c49e1 100644 --- a/linux/alsa/JackAlsaDriver.cpp +++ b/linux/alsa/JackAlsaDriver.cpp @@ -94,7 +94,7 @@ void JackAlsaDriver::UpdateLatencies() int JackAlsaDriver::Attach() { JackPort* port; - int port_index; + jack_port_id_t port_index; unsigned long port_flags = (unsigned long)CaptureDriverFlags; char name[JACK_CLIENT_NAME_SIZE + JACK_PORT_NAME_SIZE]; char alias[JACK_CLIENT_NAME_SIZE + JACK_PORT_NAME_SIZE]; @@ -116,7 +116,7 @@ int JackAlsaDriver::Attach() for (int i = 0; i < fCaptureChannels; i++) { snprintf(alias, sizeof(alias) - 1, "%s:%s:out%d", fAliasName, fCaptureDriverName, i + 1); snprintf(name, sizeof(name) - 1, "%s:capture_%d", fClientControl.fName, i + 1); - if ((port_index = fGraphManager->AllocatePort(fClientControl.fRefNum, name, JACK_DEFAULT_AUDIO_TYPE, (JackPortFlags)port_flags, fEngineControl->fBufferSize)) == NO_PORT) { + if (fEngine->PortRegister(fClientControl.fRefNum, name, JACK_DEFAULT_AUDIO_TYPE, (JackPortFlags)port_flags, fEngineControl->fBufferSize, &port_index) < 0) { jack_error("driver: cannot register port for %s", name); return -1; } @@ -131,7 +131,7 @@ int JackAlsaDriver::Attach() for (int i = 0; i < fPlaybackChannels; i++) { snprintf(alias, sizeof(alias) - 1, "%s:%s:in%d", fAliasName, fPlaybackDriverName, i + 1); snprintf(name, sizeof(name) - 1, "%s:playback_%d", fClientControl.fName, i + 1); - if ((port_index = fGraphManager->AllocatePort(fClientControl.fRefNum, name, JACK_DEFAULT_AUDIO_TYPE, (JackPortFlags)port_flags, fEngineControl->fBufferSize)) == NO_PORT) { + if (fEngine->PortRegister(fClientControl.fRefNum, name, JACK_DEFAULT_AUDIO_TYPE, (JackPortFlags)port_flags, fEngineControl->fBufferSize, &port_index) < 0) { jack_error("driver: cannot register port for %s", name); return -1; } @@ -144,8 +144,8 @@ int JackAlsaDriver::Attach() if (fWithMonitorPorts) { jack_log("Create monitor port"); snprintf(name, sizeof(name) - 1, "%s:monitor_%d", fClientControl.fName, i + 1); - if ((port_index = fGraphManager->AllocatePort(fClientControl.fRefNum, name, JACK_DEFAULT_AUDIO_TYPE, MonitorDriverFlags, fEngineControl->fBufferSize)) == NO_PORT) { - jack_error ("ALSA: cannot register monitor port for %s", name); + if (fEngine->PortRegister(fClientControl.fRefNum, name, JACK_DEFAULT_AUDIO_TYPE, MonitorDriverFlags, fEngineControl->fBufferSize, &port_index) < 0) { + jack_error("ALSA: cannot register monitor port for %s", name); } else { fMonitorPortList[i] = port_index; } diff --git a/linux/alsarawmidi/JackALSARawMidiDriver.cpp b/linux/alsarawmidi/JackALSARawMidiDriver.cpp index 6eabd866..011c8931 100644 --- a/linux/alsarawmidi/JackALSARawMidiDriver.cpp +++ b/linux/alsarawmidi/JackALSARawMidiDriver.cpp @@ -68,9 +68,9 @@ JackALSARawMidiDriver::Attach() for (int i = 0; i < fCaptureChannels; i++) { JackALSARawMidiInputPort *input_port = input_ports[i]; name = input_port->GetName(); - index = fGraphManager->AllocatePort(fClientControl.fRefNum, name, - JACK_DEFAULT_MIDI_TYPE, - CaptureDriverFlags, buffer_size); + fEngine->PortRegister(fClientControl.fRefNum, name, + JACK_DEFAULT_MIDI_TYPE, + CaptureDriverFlags, buffer_size, &index); if (index == NO_PORT) { jack_error("JackALSARawMidiDriver::Attach - cannot register input " "port with name '%s'.", name); @@ -85,7 +85,6 @@ JackALSARawMidiDriver::Attach() jack_info("JackALSARawMidiDriver::Attach - input port registered " "(name='%s', alias='%s').", name, alias); - } if (! fEngineControl->fSyncMode) { latency += buffer_size; @@ -95,9 +94,9 @@ JackALSARawMidiDriver::Attach() for (int i = 0; i < fPlaybackChannels; i++) { JackALSARawMidiOutputPort *output_port = output_ports[i]; name = output_port->GetName(); - index = fGraphManager->AllocatePort(fClientControl.fRefNum, name, - JACK_DEFAULT_MIDI_TYPE, - PlaybackDriverFlags, buffer_size); + fEngine->PortRegister(fClientControl.fRefNum, name, + JACK_DEFAULT_MIDI_TYPE, + PlaybackDriverFlags, buffer_size, &index); if (index == NO_PORT) { jack_error("JackALSARawMidiDriver::Attach - cannot register " "output port with name '%s'.", name); @@ -112,7 +111,6 @@ JackALSARawMidiDriver::Attach() jack_info("JackALSARawMidiDriver::Attach - output port registered " "(name='%s', alias='%s').", name, alias); - } return 0; } @@ -156,7 +154,7 @@ JackALSARawMidiDriver::Execute() // called. This means that the amount of time that passes between // 'GetMicroSeconds()' and 'ppoll()' is time that will be lost // while waiting for 'poll() to timeout. - // + // // I tried to replace the timeout with a 'timerfd' with absolute // times, but, strangely, it actually slowed things down, and made // the code a lot more complicated. diff --git a/linux/firewire/JackFFADODriver.cpp b/linux/firewire/JackFFADODriver.cpp index 96e0c37c..db04ed3c 100644 --- a/linux/firewire/JackFFADODriver.cpp +++ b/linux/firewire/JackFFADODriver.cpp @@ -43,6 +43,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. #include "JackPort.h" #include "JackGraphManager.h" #include "JackCompilerDeps.h" +#include "JackLockedEngine.h" namespace Jack { @@ -345,7 +346,7 @@ JackFFADODriver::ffado_driver_delete (ffado_driver_t *driver) int JackFFADODriver::Attach() { JackPort* port; - int port_index; + jack_port_id_t port_index; char buf[JACK_PORT_NAME_SIZE]; char portname[JACK_PORT_NAME_SIZE]; jack_latency_range_t range; @@ -419,10 +420,10 @@ int JackFFADODriver::Attach() if (driver->capture_channels[chn].stream_type == ffado_stream_type_audio) { snprintf(buf, sizeof(buf) - 1, "firewire_pcm:%s_in", portname); printMessage ("Registering audio capture port %s", buf); - if ((port_index = fGraphManager->AllocatePort(fClientControl.fRefNum, buf, + if (fEngine->PortRegister(fClientControl.fRefNum, buf, JACK_DEFAULT_AUDIO_TYPE, CaptureDriverFlags, - fEngineControl->fBufferSize)) == NO_PORT) { + fEngineControl->fBufferSize, &port_index) < 0) { jack_error("driver: cannot register port for %s", buf); return -1; } @@ -442,14 +443,13 @@ int JackFFADODriver::Attach() fCapturePortList[chn] = port_index; jack_log("JackFFADODriver::Attach fCapturePortList[i] %ld ", port_index); fCaptureChannels++; - } else if (driver->capture_channels[chn].stream_type == ffado_stream_type_midi) { snprintf(buf, sizeof(buf) - 1, "firewire_pcm:%s_in", portname); printMessage ("Registering midi capture port %s", buf); - if ((port_index = fGraphManager->AllocatePort(fClientControl.fRefNum, buf, + if (fEngine->PortRegister(fClientControl.fRefNum, buf, JACK_DEFAULT_MIDI_TYPE, CaptureDriverFlags, - fEngineControl->fBufferSize)) == NO_PORT) { + fEngineControl->fBufferSize, &port_index) < 0) { jack_error("driver: cannot register port for %s", buf); return -1; } @@ -494,10 +494,10 @@ int JackFFADODriver::Attach() if (driver->playback_channels[chn].stream_type == ffado_stream_type_audio) { snprintf(buf, sizeof(buf) - 1, "firewire_pcm:%s_out", portname); printMessage ("Registering audio playback port %s", buf); - if ((port_index = fGraphManager->AllocatePort(fClientControl.fRefNum, buf, + if (fEngine->PortRegister(fClientControl.fRefNum, buf, JACK_DEFAULT_AUDIO_TYPE, PlaybackDriverFlags, - fEngineControl->fBufferSize)) == NO_PORT) { + fEngineControl->fBufferSize, &port_index) < 0) { jack_error("driver: cannot register port for %s", buf); return -1; } @@ -523,10 +523,11 @@ int JackFFADODriver::Attach() } else if (driver->playback_channels[chn].stream_type == ffado_stream_type_midi) { snprintf(buf, sizeof(buf) - 1, "firewire_pcm:%s_out", portname); printMessage ("Registering midi playback port %s", buf); - if ((port_index = fGraphManager->AllocatePort(fClientControl.fRefNum, buf, + + if (fEngine->PortRegister(fClientControl.fRefNum, buf, JACK_DEFAULT_MIDI_TYPE, PlaybackDriverFlags, - fEngineControl->fBufferSize)) == NO_PORT) { + fEngineControl->fBufferSize, &port_index) < 0) { jack_error("driver: cannot register port for %s", buf); return -1; } diff --git a/linux/freebob/JackFreebobDriver.cpp b/linux/freebob/JackFreebobDriver.cpp index 14f34815..b9e6ce38 100644 --- a/linux/freebob/JackFreebobDriver.cpp +++ b/linux/freebob/JackFreebobDriver.cpp @@ -39,6 +39,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. #include "JackClientControl.h" #include "JackPort.h" #include "JackGraphManager.h" +#include "JackLockedEngine.h" namespace Jack { @@ -666,7 +667,7 @@ JackFreebobDriver::freebob_driver_midi_finish (freebob_driver_midi_handle_t *m) int JackFreebobDriver::Attach() { JackPort* port; - int port_index; + jack_port_id_t port_index; char buf[JACK_PORT_NAME_SIZE]; char portname[JACK_PORT_NAME_SIZE]; @@ -730,10 +731,10 @@ int JackFreebobDriver::Attach() } else { printMessage ("Registering capture port %s", buf); - if ((port_index = fGraphManager->AllocatePort(fClientControl.fRefNum, buf, + if (fEngine->PortRegister(fClientControl.fRefNum, buf, JACK_DEFAULT_AUDIO_TYPE, CaptureDriverFlags, - fEngineControl->fBufferSize)) == NO_PORT) { + fEngineControl->fBufferSize, &port_index) < 0) { jack_error("driver: cannot register port for %s", buf); return -1; } @@ -759,10 +760,10 @@ int JackFreebobDriver::Attach() printMessage ("Don't register playback port %s", buf); } else { printMessage ("Registering playback port %s", buf); - if ((port_index = fGraphManager->AllocatePort(fClientControl.fRefNum, buf, + if (fEngine->PortRegister(fClientControl.fRefNum, buf, JACK_DEFAULT_AUDIO_TYPE, PlaybackDriverFlags, - fEngineControl->fBufferSize)) == NO_PORT) { + fEngineControl->fBufferSize, &port_index) < 0) { jack_error("driver: cannot register port for %s", buf); return -1; } diff --git a/macosx/coreaudio/JackCoreAudioDriver.cpp b/macosx/coreaudio/JackCoreAudioDriver.cpp index 49a9f5d6..5122feb8 100644 --- a/macosx/coreaudio/JackCoreAudioDriver.cpp +++ b/macosx/coreaudio/JackCoreAudioDriver.cpp @@ -27,6 +27,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. #include "JackGlobals.h" #include "JackTools.h" #include "JackCompilerDeps.h" +#include "JackLockedEngine.h" #include #include @@ -1642,7 +1643,7 @@ int JackCoreAudioDriver::Attach() snprintf(name, sizeof(name) - 1, "%s:capture_%d", fClientControl.fName, i + 1); - if ((port_index = fGraphManager->AllocatePort(fClientControl.fRefNum, name, JACK_DEFAULT_AUDIO_TYPE, CaptureDriverFlags, fEngineControl->fBufferSize)) == NO_PORT) { + if (fEngine->PortRegister(fClientControl.fRefNum, name, JACK_DEFAULT_AUDIO_TYPE, CaptureDriverFlags, fEngineControl->fBufferSize, &port_index) < 0) { jack_error("Cannot register port for %s", name); return -1; } @@ -1668,7 +1669,7 @@ int JackCoreAudioDriver::Attach() snprintf(name, sizeof(name) - 1, "%s:playback_%d", fClientControl.fName, i + 1); - if ((port_index = fGraphManager->AllocatePort(fClientControl.fRefNum, name, JACK_DEFAULT_AUDIO_TYPE, PlaybackDriverFlags, fEngineControl->fBufferSize)) == NO_PORT) { + if (fEngine->PortRegister(fClientControl.fRefNum, name, JACK_DEFAULT_AUDIO_TYPE, PlaybackDriverFlags, fEngineControl->fBufferSize, &port_index) < 0) { jack_error("Cannot register port for %s", name); return -1; } @@ -1681,7 +1682,7 @@ int JackCoreAudioDriver::Attach() if (fWithMonitorPorts) { jack_log("Create monitor port"); snprintf(name, sizeof(name) - 1, "%s:monitor_%u", fClientControl.fName, i + 1); - if ((port_index = fGraphManager->AllocatePort(fClientControl.fRefNum, name, JACK_DEFAULT_AUDIO_TYPE, MonitorDriverFlags, fEngineControl->fBufferSize)) == NO_PORT) { + if (fEngine->PortRegister(fClientControl.fRefNum, name, JACK_DEFAULT_AUDIO_TYPE, MonitorDriverFlags, fEngineControl->fBufferSize, &port_index) < 0) { jack_error("Cannot register monitor port for %s", name); return -1; } else { diff --git a/macosx/coremidi/JackCoreMidiDriver.cpp b/macosx/coremidi/JackCoreMidiDriver.cpp index 092aaa61..c1470f98 100644 --- a/macosx/coremidi/JackCoreMidiDriver.cpp +++ b/macosx/coremidi/JackCoreMidiDriver.cpp @@ -94,9 +94,9 @@ JackCoreMidiDriver::Attach() for (int i = 0; i < num_physical_inputs; i++) { port_obj = physical_input_ports[i]; name = port_obj->GetName(); - index = fGraphManager->AllocatePort(fClientControl.fRefNum, name, - JACK_DEFAULT_MIDI_TYPE, - CaptureDriverFlags, buffer_size); + fEngine->PortRegister(fClientControl.fRefNum, name, + JACK_DEFAULT_MIDI_TYPE, + CaptureDriverFlags, buffer_size, &index); if (index == NO_PORT) { jack_error("JackCoreMidiDriver::Attach - cannot register physical " "input port with name '%s'.", name); @@ -113,9 +113,9 @@ JackCoreMidiDriver::Attach() for (int i = 0; i < num_virtual_inputs; i++) { port_obj = virtual_input_ports[i]; name = port_obj->GetName(); - index = fGraphManager->AllocatePort(fClientControl.fRefNum, name, - JACK_DEFAULT_MIDI_TYPE, - CaptureDriverFlags, buffer_size); + fEngine->PortRegister(fClientControl.fRefNum, name, + JACK_DEFAULT_MIDI_TYPE, + CaptureDriverFlags, buffer_size, &index); if (index == NO_PORT) { jack_error("JackCoreMidiDriver::Attach - cannot register virtual " "input port with name '%s'.", name); @@ -138,9 +138,9 @@ JackCoreMidiDriver::Attach() for (int i = 0; i < num_physical_outputs; i++) { port_obj = physical_output_ports[i]; name = port_obj->GetName(); - index = fGraphManager->AllocatePort(fClientControl.fRefNum, name, - JACK_DEFAULT_MIDI_TYPE, - PlaybackDriverFlags, buffer_size); + fEngine->PortRegister(fClientControl.fRefNum, name, + JACK_DEFAULT_MIDI_TYPE, + PlaybackDriverFlags, buffer_size, &index); if (index == NO_PORT) { jack_error("JackCoreMidiDriver::Attach - cannot register physical " "output port with name '%s'.", name); @@ -157,9 +157,9 @@ JackCoreMidiDriver::Attach() for (int i = 0; i < num_virtual_outputs; i++) { port_obj = virtual_output_ports[i]; name = port_obj->GetName(); - index = fGraphManager->AllocatePort(fClientControl.fRefNum, name, - JACK_DEFAULT_MIDI_TYPE, - PlaybackDriverFlags, buffer_size); + fEngine->PortRegister(fClientControl.fRefNum, name, + JACK_DEFAULT_MIDI_TYPE, + PlaybackDriverFlags, buffer_size, &index); if (index == NO_PORT) { jack_error("JackCoreMidiDriver::Attach - cannot register virtual " "output port with name '%s'.", name); diff --git a/windows/winmme/JackWinMMEDriver.cpp b/windows/winmme/JackWinMMEDriver.cpp index b05d36e6..58c056b7 100644 --- a/windows/winmme/JackWinMMEDriver.cpp +++ b/windows/winmme/JackWinMMEDriver.cpp @@ -74,6 +74,7 @@ JackWinMMEDriver::Attach() port->SetAlias(input_port->GetAlias()); port->SetLatencyRange(JackCaptureLatency, &latency_range); fCapturePortList[i] = index; + fEngine->NotifyPortRegistration(index, true); } if (! fEngineControl->fSyncMode) { @@ -99,6 +100,7 @@ JackWinMMEDriver::Attach() port->SetAlias(output_port->GetAlias()); port->SetLatencyRange(JackPlaybackLatency, &latency_range); fPlaybackPortList[i] = index; + fEngine->NotifyPortRegistration(index, true); } return 0;