Rework latency settings in netjack.
This commit is contained in:
parent
01d182a314
commit
1ad17b48ec
|
@ -232,6 +232,27 @@ namespace Jack
|
|||
fNetTimeMon = NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
void JackNetDriver::UpdateLatencies()
|
||||
{
|
||||
jack_latency_range_t input_range;
|
||||
jack_latency_range_t output_range;
|
||||
jack_latency_range_t monitor_range;
|
||||
|
||||
for (int i = 0; i < fCaptureChannels; i++) {
|
||||
input_range.max = input_range.min = 0;
|
||||
fGraphManager->GetPort(fCapturePortList[i])->SetLatencyRange(JackCaptureLatency, &input_range);
|
||||
}
|
||||
|
||||
for (int i = 0; i < fPlaybackChannels; i++) {
|
||||
output_range.max = output_range.min = 0;
|
||||
fGraphManager->GetPort(fPlaybackPortList[i])->SetLatencyRange(JackPlaybackLatency, &output_range);
|
||||
if (fWithMonitorPorts) {
|
||||
monitor_range.min = monitor_range.max = 0;
|
||||
fGraphManager->GetPort(fMonitorPortList[i])->SetLatencyRange(JackCaptureLatency, &monitor_range);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//jack ports and buffers--------------------------------------------------------------
|
||||
int JackNetDriver::AllocPorts()
|
||||
|
@ -253,8 +274,7 @@ namespace Jack
|
|||
char alias[REAL_JACK_PORT_NAME_SIZE];
|
||||
int audio_port_index;
|
||||
int midi_port_index;
|
||||
jack_latency_range_t range;
|
||||
|
||||
|
||||
//audio
|
||||
for (audio_port_index = 0; audio_port_index < fCaptureChannels; audio_port_index++) {
|
||||
snprintf(alias, sizeof(alias), "%s:%s:out%d", fAliasName, fCaptureDriverName, audio_port_index + 1);
|
||||
|
@ -265,11 +285,8 @@ namespace Jack
|
|||
return -1;
|
||||
}
|
||||
|
||||
//port latency
|
||||
port = fGraphManager->GetPort(port_index);
|
||||
port->SetAlias(alias);
|
||||
range.min = range.max = fEngineControl->fBufferSize;
|
||||
port->SetLatencyRange(JackCaptureLatency, &range);
|
||||
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());
|
||||
}
|
||||
|
@ -283,11 +300,8 @@ namespace Jack
|
|||
return -1;
|
||||
}
|
||||
|
||||
//port latency
|
||||
port = fGraphManager->GetPort(port_index);
|
||||
port->SetAlias(alias);
|
||||
range.min = range.max = (fParams.fNetworkLatency * fEngineControl->fBufferSize + ((fEngineControl->fSyncMode) ? 0 : fEngineControl->fBufferSize));
|
||||
port->SetLatencyRange(JackPlaybackLatency, &range);
|
||||
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());
|
||||
}
|
||||
|
@ -302,10 +316,7 @@ namespace Jack
|
|||
return -1;
|
||||
}
|
||||
|
||||
//port latency
|
||||
port = fGraphManager->GetPort(port_index);
|
||||
range.min = range.max = fEngineControl->fBufferSize;
|
||||
port->SetLatencyRange(JackCaptureLatency, &range);
|
||||
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());
|
||||
}
|
||||
|
@ -319,10 +330,7 @@ namespace Jack
|
|||
return -1;
|
||||
}
|
||||
|
||||
//port latency
|
||||
port = fGraphManager->GetPort(port_index);
|
||||
range.min = range.max = (fParams.fNetworkLatency * fEngineControl->fBufferSize + ((fEngineControl->fSyncMode) ? 0 : fEngineControl->fBufferSize));
|
||||
port->SetLatencyRange(JackPlaybackLatency, &range);
|
||||
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());
|
||||
}
|
||||
|
|
|
@ -64,6 +64,8 @@ namespace Jack
|
|||
JackMidiBuffer* GetMidiOutputBuffer(int port_index);
|
||||
|
||||
void SaveConnections();
|
||||
|
||||
void UpdateLatencies();
|
||||
|
||||
public:
|
||||
|
||||
|
|
|
@ -176,48 +176,37 @@ namespace Jack
|
|||
int JackNetMaster::AllocPorts()
|
||||
{
|
||||
int i;
|
||||
char name[24];
|
||||
jack_nframes_t port_latency = jack_get_buffer_size(fClient);
|
||||
jack_latency_range_t range;
|
||||
|
||||
char name[32];
|
||||
jack_log("JackNetMaster::AllocPorts");
|
||||
|
||||
//audio
|
||||
for (i = 0; i < fParams.fSendAudioChannels; i++) {
|
||||
snprintf(name, sizeof(name), "to_slave_%d", i+1);
|
||||
if ((fAudioCapturePorts[i] = jack_port_register(fClient, name, JACK_DEFAULT_AUDIO_TYPE, JackPortIsInput | JackPortIsTerminal, 0)) == NULL)
|
||||
if ((fAudioCapturePorts[i] = jack_port_register(fClient, name, JACK_DEFAULT_AUDIO_TYPE, JackPortIsInput | JackPortIsTerminal, 0)) == NULL) {
|
||||
return -1;
|
||||
//port latency
|
||||
range.min = range.max = 0;
|
||||
jack_port_set_latency_range(fAudioCapturePorts[i], JackCaptureLatency, &range);
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < fParams.fReturnAudioChannels; i++) {
|
||||
snprintf(name, sizeof(name), "from_slave_%d", i+1);
|
||||
if ((fAudioPlaybackPorts[i] = jack_port_register(fClient, name, JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput | JackPortIsTerminal, 0)) == NULL)
|
||||
if ((fAudioPlaybackPorts[i] = jack_port_register(fClient, name, JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput | JackPortIsTerminal, 0)) == NULL) {
|
||||
return -1;
|
||||
//port latency
|
||||
range.min = range.max = fParams.fNetworkLatency * port_latency + ((fParams.fSlaveSyncMode) ? 0 : port_latency);
|
||||
jack_port_set_latency_range(fAudioPlaybackPorts[i], JackPlaybackLatency, &range);
|
||||
}
|
||||
}
|
||||
|
||||
//midi
|
||||
for (i = 0; i < fParams.fSendMidiChannels; i++) {
|
||||
snprintf(name, sizeof(name), "midi_to_slave_%d", i+1);
|
||||
if ((fMidiCapturePorts[i] = jack_port_register(fClient, name, JACK_DEFAULT_MIDI_TYPE, JackPortIsInput | JackPortIsTerminal, 0)) == NULL)
|
||||
if ((fMidiCapturePorts[i] = jack_port_register(fClient, name, JACK_DEFAULT_MIDI_TYPE, JackPortIsInput | JackPortIsTerminal, 0)) == NULL) {
|
||||
return -1;
|
||||
//port latency
|
||||
range.min = range.max = 0;
|
||||
jack_port_set_latency_range(fMidiCapturePorts[i], JackCaptureLatency, &range);
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < fParams.fReturnMidiChannels; i++) {
|
||||
snprintf(name, sizeof(name), "midi_from_slave_%d", i+1);
|
||||
if ((fMidiPlaybackPorts[i] = jack_port_register(fClient, name, JACK_DEFAULT_MIDI_TYPE, JackPortIsOutput | JackPortIsTerminal, 0)) == NULL)
|
||||
if ((fMidiPlaybackPorts[i] = jack_port_register(fClient, name, JACK_DEFAULT_MIDI_TYPE, JackPortIsOutput | JackPortIsTerminal, 0)) == NULL) {
|
||||
return -1;
|
||||
//port latency
|
||||
range.min = range.max = fParams.fNetworkLatency * port_latency + ((fParams.fSlaveSyncMode) ? 0 : port_latency);
|
||||
jack_port_set_latency_range(fMidiPlaybackPorts[i], JackPlaybackLatency, &range);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue