Commit 2f143cb0 authored by sletz's avatar sletz
Browse files

NetJack2 now only send data on network for connected ports.

git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@4481 0c269be4-1314-0410-8aa9-9f06e86f4224
parent 0969f631
......@@ -35,6 +35,18 @@ Chris Caudle
Jackdmp changes log
---------------------------
2011-07-08 Stephane Letz <letz@grame.fr>
* NetJack2 now only send data on network for connected ports.
2011-07-03 Stephane Letz <letz@grame.fr>
* More debug code in JackMMCSS class.
2011-07-03 Stephane Letz <letz@grame.fr>
* -l in JackCoreAudioDriver now display devices names and then quit.
2011-07-01 Stephane Letz <letz@grame.fr>
* Fix bugs in JackNetAdapter.
......
......@@ -127,6 +127,7 @@ extern "C"
unsigned long buffer_size);
EXPORT int jack_port_unregister(jack_client_t *, jack_port_t *);
EXPORT void * jack_port_get_buffer(jack_port_t *, jack_nframes_t);
EXPORT void * jack_port_get_buffer_nulled(jack_port_t *, jack_nframes_t);
EXPORT const char* jack_port_name(const jack_port_t *port);
EXPORT const char* jack_port_short_name(const jack_port_t *port);
EXPORT int jack_port_flags(const jack_port_t *port);
......@@ -349,6 +350,22 @@ EXPORT void* jack_port_get_buffer(jack_port_t* port, jack_nframes_t frames)
}
}
EXPORT void* jack_port_get_buffer_nulled(jack_port_t* port, jack_nframes_t frames)
{
#ifdef __CLIENTDEBUG__
JackGlobals::CheckContext("jack_port_get_buffer");
#endif
uintptr_t port_aux = (uintptr_t)port;
jack_port_id_t myport = (jack_port_id_t)port_aux;
if (!CheckPort(myport)) {
jack_error("jack_port_get_buffer called with an incorrect port %ld", myport);
return NULL;
} else {
JackGraphManager* manager = GetGraphManager();
return (manager ? manager->GetBuffer(myport, frames, true) : NULL);
}
}
EXPORT const char* jack_port_name(const jack_port_t* port)
{
#ifdef __CLIENTDEBUG__
......
......@@ -41,12 +41,22 @@ namespace Jack
// Always clear output
for (int i = 0; i < adapter->fAudioAdapter->GetInputs(); i++) {
#ifdef OPTIMIZED_PROTOCOL
inputBuffer[i] = (jack_default_audio_sample_t*)jack_port_get_buffer_nulled(adapter->fCapturePortList[i], frames);
if (inputBuffer[i])
memset(inputBuffer[i], 0, frames * sizeof(jack_default_audio_sample_t));
#else
inputBuffer[i] = (jack_default_audio_sample_t*)jack_port_get_buffer(adapter->fCapturePortList[i], frames);
memset(inputBuffer[i], 0, frames * sizeof(jack_default_audio_sample_t));
#endif
}
for (int i = 0; i < adapter->fAudioAdapter->GetOutputs(); i++) {
#ifdef OPTIMIZED_PROTOCOL
outputBuffer[i] = (jack_default_audio_sample_t*)jack_port_get_buffer_nulled(adapter->fPlaybackPortList[i], frames);
#else
outputBuffer[i] = (jack_default_audio_sample_t*)jack_port_get_buffer(adapter->fPlaybackPortList[i], frames);
#endif
}
adapter->fAudioAdapter->PullAndPush(inputBuffer, outputBuffer, frames);
......
......@@ -34,9 +34,9 @@ namespace Jack
{
private:
static int Process ( jack_nframes_t, void* arg );
static int BufferSize ( jack_nframes_t buffer_size, void *arg );
static int SampleRate ( jack_nframes_t sample_rate, void *arg );
static int Process(jack_nframes_t, void* arg);
static int BufferSize(jack_nframes_t buffer_size, void* arg);
static int SampleRate(jack_nframes_t sample_rate, void* arg);
jack_port_t** fCapturePortList;
jack_port_t** fPlaybackPortList;
......
......@@ -396,24 +396,24 @@ void JackAudioDriver::WaitUntilNextCycle()
JackSleep(wait_time_usec);
}
jack_default_audio_sample_t* JackAudioDriver::GetInputBuffer(int port_index)
jack_default_audio_sample_t* JackAudioDriver::GetInputBuffer(int port_index, bool nulled)
{
return fCapturePortList[port_index]
? (jack_default_audio_sample_t*)fGraphManager->GetBuffer(fCapturePortList[port_index], fEngineControl->fBufferSize)
? (jack_default_audio_sample_t*)fGraphManager->GetBuffer(fCapturePortList[port_index], fEngineControl->fBufferSize, nulled)
: NULL;
}
jack_default_audio_sample_t* JackAudioDriver::GetOutputBuffer(int port_index)
jack_default_audio_sample_t* JackAudioDriver::GetOutputBuffer(int port_index, bool nulled)
{
return fPlaybackPortList[port_index]
? (jack_default_audio_sample_t*)fGraphManager->GetBuffer(fPlaybackPortList[port_index], fEngineControl->fBufferSize)
? (jack_default_audio_sample_t*)fGraphManager->GetBuffer(fPlaybackPortList[port_index], fEngineControl->fBufferSize, nulled)
: NULL;
}
jack_default_audio_sample_t* JackAudioDriver::GetMonitorBuffer(int port_index)
jack_default_audio_sample_t* JackAudioDriver::GetMonitorBuffer(int port_index, bool nulled)
{
return fPlaybackPortList[port_index]
? (jack_default_audio_sample_t*)fGraphManager->GetBuffer(fMonitorPortList[port_index], fEngineControl->fBufferSize)
? (jack_default_audio_sample_t*)fGraphManager->GetBuffer(fMonitorPortList[port_index], fEngineControl->fBufferSize, nulled)
: NULL;
}
......
......@@ -59,9 +59,9 @@ class SERVER_EXPORT JackAudioDriver : public JackDriver
std::list<std::pair<std::string, std::string> > fConnections; // Connections list
jack_default_audio_sample_t* GetInputBuffer(int port_index);
jack_default_audio_sample_t* GetOutputBuffer(int port_index);
jack_default_audio_sample_t* GetMonitorBuffer(int port_index);
jack_default_audio_sample_t* GetInputBuffer(int port_index, bool nulled = false);
jack_default_audio_sample_t* GetOutputBuffer(int port_index, bool nulled = false);
jack_default_audio_sample_t* GetMonitorBuffer(int port_index, bool nulled = false);
void HandleLatencyCallback(int status);
void UpdateLatencies();
......
......@@ -166,7 +166,7 @@ bool JackGraphManager::IsDirectConnection(int ref1, int ref2)
}
// RT
void* JackGraphManager::GetBuffer(jack_port_id_t port_index, jack_nframes_t buffer_size)
void* JackGraphManager::GetBuffer(jack_port_id_t port_index, jack_nframes_t buffer_size, bool nulled)
{
AssertPort(port_index);
AssertBufferSize(buffer_size);
......@@ -191,7 +191,7 @@ void* JackGraphManager::GetBuffer(jack_port_id_t port_index, jack_nframes_t buff
// No connections : return a zero-filled buffer
if (len == 0) {
port->ClearBuffer(buffer_size);
return port->GetBuffer();
return (nulled) ? NULL : port->GetBuffer();
// One connection
} else if (len == 1) {
......@@ -791,9 +791,9 @@ const char** JackGraphManager::GetConnections(jack_port_id_t port_index)
next_index = GetCurrentIndex();
} while (cur_index != next_index); // Until a coherent state has been read
if (res[0]) { // at least one connection
if (res[0]) { // At least one connection
return res;
} else { // empty array, should return NULL
} else { // Empty array, should return NULL
free(res);
return NULL;
}
......@@ -874,10 +874,10 @@ const char** JackGraphManager::GetPorts(const char* port_name_pattern, const cha
next_index = GetCurrentIndex();
} while (cur_index != next_index); // Until a coherent state has been read
if (res[0]) { // at least one port
if (res[0]) { // At least one port
return res;
} else {
free(res); // empty array, should return NULL
free(res); // Empty array, should return NULL
return NULL;
}
}
......
......@@ -113,7 +113,7 @@ class SERVER_EXPORT JackGraphManager : public JackShmMem, public JackAtomicState
int GetOutputRefNum(jack_port_id_t port_index);
// Buffer management
void* GetBuffer(jack_port_id_t port_index, jack_nframes_t frames);
void* GetBuffer(jack_port_id_t port_index, jack_nframes_t frames, bool nulled = false);
// Activation management
void RunCurrentGraph();
......
......@@ -59,13 +59,14 @@ namespace Jack
for (node = params; node; node = jack_slist_next(node))
{
param = (const jack_driver_param_t*) node->data;
switch (param->character)
{
switch (param->character) {
case 'a' :
if (strlen(param->value.str) < 32)
if (strlen(param->value.str) < 32) {
strcpy(fMulticastIP, param->value.str);
else
} else {
jack_error("Can't use multicast address %s, using default %s", param->value.ui, DEFAULT_MULTICAST_IP);
}
break;
case 'p' :
fSocket.SetPort(param->value.ui);
......@@ -94,14 +95,15 @@ namespace Jack
break;
#endif
case 'm' :
if (strcmp(param->value.str, "normal") == 0)
if (strcmp(param->value.str, "normal") == 0) {
fParams.fNetworkMode = 'n';
else if (strcmp(param->value.str, "slow") == 0)
} else if (strcmp(param->value.str, "slow") == 0) {
fParams.fNetworkMode = 's';
else if (strcmp(param->value.str, "fast") == 0)
} else if (strcmp(param->value.str, "fast") == 0) {
fParams.fNetworkMode = 'f';
else
} else {
jack_error("Unknown network mode, using 'normal' mode.");
}
break;
case 'q':
fQuality = param->value.ui;
......
......@@ -124,28 +124,28 @@ namespace Jack
SaveConnections();
FreePorts();
//new loading, but existing socket, restart the driver
// New loading, but existing socket, restart the driver
if (fSocket.IsSocket()) {
jack_info("Restarting driver...");
FreeAll();
}
//set the parameters to send
// Set the parameters to send
fParams.fSendAudioChannels = fCaptureChannels;
fParams.fReturnAudioChannels = fPlaybackChannels;
fParams.fSlaveSyncMode = fEngineControl->fSyncMode;
//display some additional infos
// Display some additional infos
jack_info("NetDriver started in %s mode %s Master's transport sync.",
(fParams.fSlaveSyncMode) ? "sync" : "async", (fParams.fTransportSync) ? "with" : "without");
//init network
// Init network
if (!JackNetSlaveInterface::Init()) {
jack_error("Starting network fails...");
return false;
}
//set global parameters
// Set global parameters
if (!SetParams()) {
jack_error("SetParams error...");
return false;
......@@ -155,7 +155,7 @@ namespace Jack
fCaptureChannels = fParams.fSendAudioChannels;
fPlaybackChannels = fParams.fReturnAudioChannels;
//allocate midi ports lists
// Allocate midi ports lists
fMidiCapturePortList = new jack_port_id_t [fParams.fSendMidiChannels];
fMidiPlaybackPortList = new jack_port_id_t [fParams.fReturnMidiChannels];
......@@ -169,19 +169,19 @@ namespace Jack
fMidiPlaybackPortList[midi_port_index] = 0;
}
//register jack ports
// Register jack ports
if (AllocPorts() != 0) {
jack_error("Can't allocate ports.");
return false;
}
//init done, display parameters
// Init done, display parameters
SessionParamsDisplay(&fParams);
//monitor
// Monitor
#ifdef JACK_MONITOR
string plot_name;
//NetTimeMon
// NetTimeMon
plot_name = string(fParams.fName);
plot_name += string("_slave");
plot_name += (fEngineControl->fSyncMode) ? string("_sync") : string("_async");
......@@ -215,14 +215,14 @@ namespace Jack
};
fNetTimeMon->SetPlotFile(net_time_mon_options, 2, net_time_mon_fields, 5);
#endif
//driver parametering
// Driver parametering
JackAudioDriver::SetBufferSize(fParams.fPeriodSize);
JackAudioDriver::SetSampleRate(fParams.fSampleRate);
JackDriver::NotifyBufferSize(fParams.fPeriodSize);
JackDriver::NotifySampleRate(fParams.fSampleRate);
//transport engine parametering
// Transport engine parametering
fEngineControl->fTransport.SetNetworkSync(fParams.fTransportSync);
RestoreConnections();
......@@ -413,25 +413,7 @@ namespace Jack
const char** connections;
fConnections.clear();
for (int i = 0; i < fCaptureChannels; ++i) {
if (fCapturePortList[i] && (connections = fGraphManager->GetConnections(fCapturePortList[i])) != 0) {
for (int j = 0; connections[j]; j++) {
fConnections.push_back(make_pair(fGraphManager->GetPort(fCapturePortList[i])->GetName(), connections[j]));
jack_info("Save connection: %s %s", fGraphManager->GetPort(fCapturePortList[i])->GetName(), connections[j]);
}
free(connections);
}
}
for (int i = 0; i < fPlaybackChannels; ++i) {
if (fPlaybackPortList[i] && (connections = fGraphManager->GetConnections(fPlaybackPortList[i])) != 0) {
for (int j = 0; connections[j]; j++) {
fConnections.push_back(make_pair(connections[j], fGraphManager->GetPort(fPlaybackPortList[i])->GetName()));
jack_info("Save connection: %s %s", connections[j], fGraphManager->GetPort(fPlaybackPortList[i])->GetName());
}
free(connections);
}
}
JackAudioDriver::SaveConnections();
for (int i = 0; i < fParams.fSendMidiChannels; ++i) {
if (fCapturePortList[i] && (connections = fGraphManager->GetConnections(fMidiCapturePortList[i])) != 0) {
......@@ -546,7 +528,11 @@ namespace Jack
for (midi_port_index = 0; midi_port_index < fParams.fSendMidiChannels; midi_port_index++)
fNetMidiCaptureBuffer->SetBuffer(midi_port_index, GetMidiInputBuffer(midi_port_index));
for (audio_port_index = 0; audio_port_index < fParams.fSendAudioChannels; audio_port_index++)
#ifdef OPTIMIZED_PROTOCOL
fNetAudioCaptureBuffer->SetBuffer(audio_port_index, GetInputBuffer(audio_port_index, true));
#else
fNetAudioCaptureBuffer->SetBuffer(audio_port_index, GetInputBuffer(audio_port_index));
#endif
#ifdef JACK_MONITOR
fNetTimeMon->New();
......@@ -589,9 +575,13 @@ namespace Jack
//buffers
for (midi_port_index = 0; midi_port_index < fParams.fReturnMidiChannels; midi_port_index++)
fNetMidiPlaybackBuffer->SetBuffer(midi_port_index, GetMidiOutputBuffer (midi_port_index));
fNetMidiPlaybackBuffer->SetBuffer(midi_port_index, GetMidiOutputBuffer(midi_port_index));
for (audio_port_index = 0; audio_port_index < fPlaybackChannels; audio_port_index++)
fNetAudioPlaybackBuffer->SetBuffer(audio_port_index, GetOutputBuffer (audio_port_index));
#ifdef OPTIMIZED_PROTOCOL
fNetAudioPlaybackBuffer->SetBuffer(audio_port_index, GetOutputBuffer(audio_port_index, true));
#else
fNetAudioPlaybackBuffer->SetBuffer(audio_port_index, GetOutputBuffer(audio_port_index));
#endif
#ifdef JACK_MONITOR
fNetTimeMon->Add(((float) (GetMicroSeconds() - fRcvSyncUst) / (float)fEngineControl->fPeriodUsecs) * 100.f);
......
......@@ -92,12 +92,12 @@ namespace Jack
return true;
}
int SetBufferSize ( jack_nframes_t buffer_size )
int SetBufferSize(jack_nframes_t buffer_size)
{
return -1;
}
int SetSampleRate ( jack_nframes_t sample_rate )
int SetSampleRate(jack_nframes_t sample_rate)
{
return -1;
}
......
......@@ -455,8 +455,9 @@ namespace Jack
for (subproc = 0; subproc < fTxHeader.fNumPacket; subproc++) {
fTxHeader.fSubCycle = subproc;
fTxHeader.fIsLastPckt = (subproc == (fTxHeader.fNumPacket - 1)) ? 1 : 0;
fTxHeader.fPacketSize = HEADER_SIZE + fNetAudioCaptureBuffer->RenderToNetwork(subproc, data_size);
fTxHeader.fPacketSize = HEADER_SIZE + fNetAudioCaptureBuffer->RenderToNetwork(subproc, data_size, fTxHeader.fActivePorts);
memcpy(fTxBuffer, &fTxHeader, HEADER_SIZE);
//PacketHeaderDisplay(&fTxHeader);
if (Send(fTxHeader.fPacketSize, 0) == SOCKET_ERROR)
return SOCKET_ERROR;
}
......@@ -570,7 +571,8 @@ namespace Jack
fRxHeader.fCycle = rx_head->fCycle;
fRxHeader.fSubCycle = rx_head->fSubCycle;
fRxHeader.fIsLastPckt = rx_head->fIsLastPckt;
fNetAudioPlaybackBuffer->RenderFromNetwork(rx_head->fCycle, rx_head->fSubCycle, rx_bytes - HEADER_SIZE);
fRxHeader.fActivePorts = rx_head->fActivePorts;
fNetAudioPlaybackBuffer->RenderFromNetwork(rx_head->fCycle, rx_head->fSubCycle, rx_bytes - HEADER_SIZE, fRxHeader.fActivePorts);
// Last audio packet is received, so finish rendering...
if (fRxHeader.fIsLastPckt)
fNetAudioPlaybackBuffer->RenderToJackPorts();
......@@ -962,7 +964,8 @@ namespace Jack
fRxHeader.fCycle = rx_head->fCycle;
fRxHeader.fSubCycle = rx_head->fSubCycle;
fRxHeader.fIsLastPckt = rx_head->fIsLastPckt;
fNetAudioCaptureBuffer->RenderFromNetwork(rx_head->fCycle, rx_head->fSubCycle, rx_bytes - HEADER_SIZE);
fRxHeader.fActivePorts = rx_head->fActivePorts;
fNetAudioCaptureBuffer->RenderFromNetwork(rx_head->fCycle, rx_head->fSubCycle, rx_bytes - HEADER_SIZE, fRxHeader.fActivePorts);
// Last audio packet is received, so finish rendering...
if (fRxHeader.fIsLastPckt)
fNetAudioCaptureBuffer->RenderToJackPorts();
......@@ -1028,8 +1031,9 @@ namespace Jack
for (subproc = 0; subproc < fTxHeader.fNumPacket; subproc++) {
fTxHeader.fSubCycle = subproc;
fTxHeader.fIsLastPckt = (subproc == (fTxHeader.fNumPacket - 1)) ? 1 : 0;
fTxHeader.fPacketSize = HEADER_SIZE + fNetAudioPlaybackBuffer->RenderToNetwork(subproc, data_size);
fTxHeader.fPacketSize = HEADER_SIZE + fNetAudioPlaybackBuffer->RenderToNetwork(subproc, data_size, fTxHeader.fActivePorts);
memcpy(fTxBuffer, &fTxHeader, HEADER_SIZE);
//PacketHeaderDisplay(&fTxHeader);
if (Send(fTxHeader.fPacketSize, 0) == SOCKET_ERROR)
return SOCKET_ERROR;
}
......
......@@ -22,6 +22,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
using namespace std;
namespace Jack
{
//JackNetMaster******************************************************************************************************
......@@ -428,9 +429,19 @@ namespace Jack
fParams.fPeriodSize)));
}
for (int port_index = 0; port_index < fParams.fSendAudioChannels; port_index++) {
#ifdef OPTIMIZED_PROTOCOL
fNetAudioCaptureBuffer->SetBuffer(port_index,
static_cast<sample_t*>(jack_port_get_buffer_nulled(fAudioCapturePorts[port_index],
fParams.fPeriodSize)));
#else
fNetAudioCaptureBuffer->SetBuffer(port_index,
static_cast<sample_t*>(jack_port_get_buffer(fAudioCapturePorts[port_index],
fParams.fPeriodSize)));
#endif
}
for (int port_index = 0; port_index < fParams.fReturnMidiChannels; port_index++) {
fNetMidiPlaybackBuffer->SetBuffer(port_index,
......@@ -438,9 +449,18 @@ namespace Jack
fParams.fPeriodSize)));
}
for (int port_index = 0; port_index < fParams.fReturnAudioChannels; port_index++) {
/*
*/
#ifdef OPTIMIZED_PROTOCOL
fNetAudioPlaybackBuffer->SetBuffer(port_index,
static_cast<sample_t*>(jack_port_get_buffer_nulled(fAudioPlaybackPorts[port_index],
fParams.fPeriodSize)));
#else
fNetAudioPlaybackBuffer->SetBuffer(port_index,
static_cast<sample_t*>(jack_port_get_buffer(fAudioPlaybackPorts[port_index],
fParams.fPeriodSize)));
#endif
}
if (IsSynched()) { // only send if connection is "synched"
......
......@@ -133,13 +133,13 @@ namespace Jack
void NetMidiBuffer::DisplayEvents()
{
for (int port_index = 0; port_index < fNPorts; port_index++)
{
for (uint event = 0; event < fPortBuffer[port_index]->event_count; event++)
for (int port_index = 0; port_index < fNPorts; port_index++) {
for (uint event = 0; event < fPortBuffer[port_index]->event_count; event++) {
if (fPortBuffer[port_index]->IsValid())
jack_info("port %d : midi event %u/%u -> time : %u, size : %u",
port_index + 1, event + 1, fPortBuffer[port_index]->event_count,
fPortBuffer[port_index]->events[event].time, fPortBuffer[port_index]->events[event].size);
}
}
}
......@@ -147,8 +147,8 @@ namespace Jack
{
int pos = 0;
size_t copy_size;
for (int port_index = 0; port_index < fNPorts; port_index++)
{
for (int port_index = 0; port_index < fNPorts; port_index++) {
char* write_pos = fBuffer + pos;
copy_size = sizeof(JackMidiBuffer) + fPortBuffer[port_index]->event_count * sizeof(JackMidiEvent);
memcpy(fBuffer + pos, fPortBuffer[port_index], copy_size);
......@@ -167,8 +167,8 @@ namespace Jack
{
int pos = 0;
int copy_size;
for (int port_index = 0; port_index < fNPorts; port_index++)
{
for (int port_index = 0; port_index < fNPorts; port_index++) {
JackMidiBuffer* midi_buffer = reinterpret_cast<JackMidiBuffer*>(fBuffer + pos);
MidiBufferNToH(midi_buffer, midi_buffer);
copy_size = sizeof(JackMidiBuffer) + reinterpret_cast<JackMidiBuffer*>(fBuffer + pos)->event_count * sizeof(JackMidiEvent);
......@@ -181,17 +181,17 @@ namespace Jack
return pos;
}
int NetMidiBuffer::RenderFromNetwork(int subcycle, size_t copy_size)
int NetMidiBuffer::RenderFromNetwork(int sub_cycle, size_t copy_size)
{
memcpy(fBuffer + subcycle * fMaxPcktSize, fNetBuffer, copy_size);
memcpy(fBuffer + sub_cycle * fMaxPcktSize, fNetBuffer, copy_size);
return copy_size;
}
int NetMidiBuffer::RenderToNetwork(int subcycle, size_t total_size)
int NetMidiBuffer::RenderToNetwork(int sub_cycle, size_t total_size)
{
int size = total_size - subcycle * fMaxPcktSize;
int size = total_size - sub_cycle * fMaxPcktSize;
int copy_size = (size <= fMaxPcktSize) ? size : fMaxPcktSize;
memcpy(fNetBuffer, fBuffer + subcycle * fMaxPcktSize, copy_size);
memcpy(fNetBuffer, fBuffer + sub_cycle * fMaxPcktSize, copy_size);
return copy_size;
}
......@@ -219,25 +219,25 @@ namespace Jack
return fPortBuffer.GetBuffer(index);
}
int NetFloatAudioBuffer::RenderFromJackPorts ()
int NetFloatAudioBuffer::RenderFromJackPorts()
{
return fPortBuffer.RenderFromJackPorts();
}
int NetFloatAudioBuffer::RenderToJackPorts ()
int NetFloatAudioBuffer::RenderToJackPorts()
{
return fPortBuffer.RenderToJackPorts();
}
//network<->buffer
int NetFloatAudioBuffer::RenderFromNetwork(int cycle, int subcycle, size_t copy_size)
int NetFloatAudioBuffer::RenderFromNetwork(int cycle, int sub_cycle, size_t copy_size, uint32_t port_num)
{
return fPortBuffer.RenderFromNetwork(fNetBuffer, cycle, subcycle, copy_size);
return fPortBuffer.RenderFromNetwork(fNetBuffer, cycle, sub_cycle, copy_size, port_num);
}
int NetFloatAudioBuffer::RenderToNetwork (int subcycle, size_t total_size)
int NetFloatAudioBuffer::RenderToNetwork(int sub_cycle, size_t total_size, uint32_t& port_num)
{
return fPortBuffer.RenderToNetwork(fNetBuffer, subcycle, total_size);
return fPortBuffer.RenderToNetwork(fNetBuffer, sub_cycle, total_size, port_num);
}
// Celt audio buffer *********************************************************************************
......@@ -443,36 +443,36 @@ namespace Jack
}
//network<->buffer
int NetCeltAudioBuffer::RenderFromNetwork(int cycle, int subcycle, size_t copy_size)
int NetCeltAudioBuffer::RenderFromNetwork(int cycle, int sub_cycle, size_t copy_size, uint32_t port_num)
{
if (subcycle == fNumPackets - 1) {
if (sub_cycle == fNumPackets - 1) {
for (int port_index = 0; port_index < fNPorts; port_index++)
memcpy(fCompressedBuffer[port_index] + subcycle * fSubPeriodBytesSize, fNetBuffer + port_index * fLastSubPeriodBytesSize, fLastSubPeriodBytesSize);
memcpy(fCompressedBuffer[port_index] + sub_cycle * fSubPeriodBytesSize, fNetBuffer + port_index * fLastSubPeriodBytesSize, fLastSubPeriodBytesSize);
} else {
for (int port_index = 0; port_index < fNPorts; port_index++)
memcpy(fCompressedBuffer[port_index] + subcycle * fSubPeriodBytesSize, fNetBuffer + port_index * fSubPeriodBytesSize, fSubPeriodBytesSize);
memcpy(fCompressedBuffer[port_index] + sub_cycle * fSubPeriodBytesSize, fNetBuffer + port_index * fSubPeriodBytesSize, fSubPeriodBytesSize);
}
if (subcycle != fLastSubCycle + 1)
jack_error("Packet(s) missing from... %d %d", fLastSubCycle, subcycle);
if (sub_cycle != fLastSubCycle + 1)
jack_error("Packet(s) missing from... %d %d", fLastSubCycle, sub_cycle);
fLastSubCycle = subcycle;
fLastSubCycle = sub_cycle;
return copy_size;
}
int NetCeltAudioBuffer::RenderToNetwork(int subcycle, size_t total_size)
int NetCeltAudioBuffer::RenderToNetwork(int sub_cycle, size_t total_size, uint32_t& port_num)
{
if (subcycle == fNumPackets - 1) {
port_num = fNPorts;
if (sub_cycle == fNumPackets - 1) {
for (int port_index = 0; port_index < fNPorts; port_index++)
memcpy(fNetBuffer + port_index * fLastSubPeriodBytesSize, fCompressedBuffer[port_index] + subcycle * fSubPeriodBytesSize, fLastSubPeriodBytesSize);