Browse Source

SaveConnections/RestoreConnections moved in JackAudioDriver.

git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@4454 0c269be4-1314-0410-8aa9-9f06e86f4224
tags/1.9.8
sletz 14 years ago
parent
commit
68ec29c2d0
6 changed files with 60 additions and 39 deletions
  1. +1
    -0
      ChangeLog
  2. +40
    -0
      common/JackAudioDriver.cpp
  3. +5
    -0
      common/JackAudioDriver.h
  4. +0
    -11
      common/JackNetDriver.cpp
  5. +0
    -3
      common/JackNetDriver.h
  6. +14
    -25
      common/JackNetInterface.cpp

+ 1
- 0
ChangeLog View File

@@ -38,6 +38,7 @@ Chris Caudle
2011-06-10 Stephane Letz <letz@grame.fr>

* SaveConnections/RestoreConnections in NetDriver.
* SaveConnections/RestoreConnections moved in JackAudioDriver.

2011-06-09 Stephane Letz <letz@grame.fr>



+ 40
- 0
common/JackAudioDriver.cpp View File

@@ -29,6 +29,8 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#include "JackException.h"
#include <assert.h>

using namespace std;

namespace Jack
{

@@ -448,4 +450,42 @@ void JackAudioDriver::HandleLatencyCallback(int status)
}
}

void JackAudioDriver::SaveConnections()
{
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);
}
}
}

void JackAudioDriver::RestoreConnections()
{
list<pair<string, string> >::const_iterator it;

for (it = fConnections.begin(); it != fConnections.end(); it++) {
pair<string, string> connection = *it;
jack_info("Restore connection: %s %s", connection.first.c_str(), connection.second.c_str());
fEngine->PortConnect(fClientControl.fRefNum, connection.first.c_str(), connection.second.c_str());
}
}


} // end of namespace

+ 5
- 0
common/JackAudioDriver.h View File

@@ -57,6 +57,8 @@ class SERVER_EXPORT JackAudioDriver : public JackDriver

bool fWithMonitorPorts;

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);
@@ -105,6 +107,9 @@ class SERVER_EXPORT JackAudioDriver : public JackDriver
virtual int SetBufferSize(jack_nframes_t buffer_size);
virtual int SetSampleRate(jack_nframes_t sample_rate);

virtual void SaveConnections();
virtual void RestoreConnections();

virtual int ClientNotify(int refnum, const char* name, int notify, int sync, const char* message, int value1, int value2);

};


+ 0
- 11
common/JackNetDriver.cpp View File

@@ -450,17 +450,6 @@ namespace Jack
free(connections);
}
}
}

void JackNetDriver::RestoreConnections()
{
list<pair<string, string> >::const_iterator it;

for (it = fConnections.begin(); it != fConnections.end(); it++) {
pair<string, string> connection = *it;
jack_info("Restore connection: %s %s", connection.first.c_str(), connection.second.c_str());
fEngine->PortConnect(fClientControl.fRefNum, connection.first.c_str(), connection.second.c_str());
}
}

JackMidiBuffer* JackNetDriver::GetMidiInputBuffer(int port_index)


+ 0
- 3
common/JackNetDriver.h View File

@@ -47,8 +47,6 @@ namespace Jack
int fLastTransportState;
int fLastTimebaseMaster;

std::list<std::pair<std::string, std::string> > fConnections; // Connections list

//monitoring
#ifdef JACK_MONITOR
JackGnuPlotMonitor<float>* fNetTimeMon;
@@ -69,7 +67,6 @@ namespace Jack
JackMidiBuffer* GetMidiOutputBuffer(int port_index);

void SaveConnections();
void RestoreConnections();

public:



+ 14
- 25
common/JackNetInterface.cpp View File

@@ -618,11 +618,9 @@ namespace Jack

//init loop : get a master and start, do it until connection is ok
net_status_t status;
do
{
do {
//first, get a master, do it until a valid connection is running
do
{
do {
status = SendAvailableToMaster();
if (status == NET_SOCKET_ERROR)
return false;
@@ -652,8 +650,7 @@ namespace Jack
SetPacketType(&fParams, SLAVE_AVAILABLE);

net_status_t status;
do
{
do {
//get a master
status = SendAvailableToMaster(try_count);
if (status == NET_SOCKET_ERROR)
@@ -669,8 +666,7 @@ namespace Jack
jack_log("JackNetSlaveInterface::InitRendering()");

net_status_t status;
do
{
do {
//then tell the master we are ready
jack_info("Initializing connection with %s...", fParams.fMasterNetName);
status = SendStartToMaster();
@@ -711,8 +707,7 @@ namespace Jack

//send 'AVAILABLE' until 'SLAVE_SETUP' received
jack_info("Waiting for a master...");
do
{
do {
//send 'available'
session_params_t net_params;
memset(&net_params, 0, sizeof(session_params_t));
@@ -724,8 +719,7 @@ namespace Jack
memset(&net_params, 0, sizeof(session_params_t));
rx_bytes = fSocket.CatchHost(&net_params, sizeof(session_params_t), 0);
SessionParamsNToH(&net_params, &host_params);
if ((rx_bytes == SOCKET_ERROR) && (fSocket.GetError() != NET_NO_DATA))
{
if ((rx_bytes == SOCKET_ERROR) && (fSocket.GetError() != NET_NO_DATA)) {
jack_error("Can't receive : %s", StrError(NET_ERROR_CODE));
return NET_RECV_ERROR;
}
@@ -758,8 +752,7 @@ namespace Jack
memset(&net_params, 0, sizeof(session_params_t));
SetPacketType(&fParams, START_MASTER);
SessionParamsHToN(&fParams, &net_params);
if (fSocket.Send(&net_params, sizeof(session_params_t), 0) == SOCKET_ERROR)
{
if (fSocket.Send(&net_params, sizeof(session_params_t), 0) == SOCKET_ERROR) {
jack_error("Error in send : %s", StrError(NET_ERROR_CODE));
return (fSocket.GetError() == NET_CONN_ERROR) ? NET_ERROR : NET_SEND_ERROR;
}
@@ -852,8 +845,7 @@ namespace Jack
{
int rx_bytes = fSocket.Recv(fRxBuffer, size, flags);
//handle errors
if (rx_bytes == SOCKET_ERROR)
{
if (rx_bytes == SOCKET_ERROR) {
net_error_t error = fSocket.GetError();
//no data isn't really an error in realtime processing, so just return 0
if (error == NET_NO_DATA) {
@@ -879,8 +871,7 @@ namespace Jack
int tx_bytes = fSocket.Send(fTxBuffer, size, flags);

//handle errors
if (tx_bytes == SOCKET_ERROR)
{
if (tx_bytes == SOCKET_ERROR) {
net_error_t error = fSocket.GetError();
//if a network error occurs, this exception will restart the driver
if (error == NET_CONN_ERROR) {
@@ -899,8 +890,7 @@ namespace Jack
packet_header_t* rx_head = reinterpret_cast<packet_header_t*>(fRxBuffer);

//receive sync (launch the cycle)
do
{
do {
rx_bytes = Recv(fParams.fMtu, 0);
//connection issue, send will detect it, so don't skip the cycle (return 0)
if (rx_bytes == SOCKET_ERROR)
@@ -918,8 +908,7 @@ namespace Jack
uint recvd_midi_pckt = 0;
packet_header_t* rx_head = reinterpret_cast<packet_header_t*>(fRxBuffer);

while (!fRxHeader.fIsLastPckt)
{
while (!fRxHeader.fIsLastPckt) {
//how much data is queued on the rx buffer ?
rx_bytes = Recv(fParams.fMtu, MSG_PEEK);

@@ -975,7 +964,7 @@ namespace Jack
}
fTxHeader.fSubCycle = 0;
fTxHeader.fDataType = 's';
fTxHeader.fIsLastPckt = (fParams.fReturnMidiChannels == 0 && fParams.fReturnAudioChannels == 0) ? 1 : 0;
fTxHeader.fIsLastPckt = (fParams.fReturnMidiChannels == 0 && fParams.fReturnAudioChannels == 0) ? 1 : 0;
fTxHeader.fPacketSize = fParams.fMtu;

memcpy(fTxBuffer, &fTxHeader, HEADER_SIZE);
@@ -984,8 +973,7 @@ namespace Jack

int JackNetSlaveInterface::DataSend()
{
uint subproc;
uint data_size;
uint subproc, data_size;

//midi
if (fParams.fReturnMidiChannels > 0) {
@@ -1009,6 +997,7 @@ namespace Jack
fTxHeader.fDataType = 'a';
data_size = fNetAudioPlaybackBuffer->RenderFromJackPorts();
fTxHeader.fNumPacket = fNetAudioPlaybackBuffer->GetNumPackets();

for (subproc = 0; subproc < fTxHeader.fNumPacket; subproc++) {
fTxHeader.fSubCycle = subproc;
fTxHeader.fIsLastPckt = (subproc == (fTxHeader.fNumPacket - 1)) ? 1 : 0;


Loading…
Cancel
Save