2019-08-06 Fred Gleason <fredg@paravelsystems.com>

* Refactored ripcd(8) to manage JACK port [dis]connections directly,
	rather than by delegation to caed(8).
This commit is contained in:
Fred Gleason 2019-08-06 19:54:38 -04:00
parent 102623e63b
commit 37da80e1c3
13 changed files with 188 additions and 148 deletions

View File

@ -18901,3 +18901,6 @@
2019-08-05 Fred Gleason <fredg@paravelsystems.com>
* Fixed a bug in rdvairplayd(8) where only the first log machine
set to 'load specified log' would do so.
2019-08-06 Fred Gleason <fredg@paravelsystems.com>
* Refactored ripcd(8) to manage JACK port [dis]connections directly,
rather than by delegation to caed(8).

View File

@ -222,14 +222,6 @@ MainObject::MainObject(QObject *parent,const char *name)
this,
SLOT(openRtpCaptureChannelData(int,unsigned,unsigned,uint16_t,
unsigned,unsigned)));
connect(cae_server,
SIGNAL(jackConnectPortsReq(int,const QString &,const QString &)),
this,
SLOT(jackConnectPortsData(int,const QString &,const QString &)));
connect(cae_server,
SIGNAL(jackDisconnectPortsReq(int,const QString &,const QString &)),
this,
SLOT(jackDisconnectPortsData(int,const QString &,const QString &)));
connect(cae_server,
SIGNAL(meterEnableReq(int,uint16_t,const QList<unsigned> &)),
this,
@ -1424,20 +1416,6 @@ void MainObject::openRtpCaptureChannelData(int id,unsigned card,unsigned port,
}
void MainObject::jackConnectPortsData(int id,const QString &out_name,
const QString &in_name)
{
jackConnectPorts(out_name,in_name);
}
void MainObject::jackDisconnectPortsData(int id,const QString &out_name,
const QString &in_name)
{
jackDisconnectPorts(out_name,in_name);
}
void MainObject::meterEnableData(int id,uint16_t udp_port,
const QList<unsigned> &cards)
{

View File

@ -142,10 +142,6 @@ class MainObject : public QObject
void openRtpCaptureChannelData(int id,unsigned card,unsigned port,
uint16_t udp_port,unsigned samprate,
unsigned chans);
void jackConnectPortsData(int id,const QString &out_name,
const QString &in_name);
void jackDisconnectPortsData(int id,const QString &out_name,
const QString &in_name);
void meterEnableData(int id,uint16_t udp_port,const QList<unsigned> &cards);
void statePlayUpdate(int card,int stream,int state);
void stateRecordUpdate(int card,int stream,int state);

View File

@ -1370,28 +1370,6 @@ bool MainObject::jackSetPassthroughLevel(int card,int in_port,int out_port,
}
void MainObject::jackConnectPorts(const QString &out,const QString &in)
{
#ifdef JACK
if(jack_card<0) {
return;
}
jack_connect(jack_client,(const char *)in,(const char *)out);
#endif // JACK
}
void MainObject::jackDisconnectPorts(const QString &out,const QString &in)
{
#ifdef JACK
if(jack_card<0) {
return;
}
jack_disconnect(jack_client,(const char *)in,(const char *)out);
#endif // JACK
}
int MainObject::GetJackOutputStream()
{
#ifdef JACK

View File

@ -542,14 +542,7 @@ bool CaeServer::ProcessCommand(int id,const QString &cmd)
}
}
}
if((f0.at(0)=="JC")&&(f0.size()==3)) { // Connect Jack Ports
emit jackConnectPortsReq(id,f0.at(1),f0.at(2));
was_processed=true;
}
if((f0.at(0)=="JD")&&(f0.size()==3)) { // Disconnect Jack Ports
emit jackDisconnectPortsReq(id,f0.at(1),f0.at(2));
was_processed=true;
}
if((f0.at(0)=="ME")&&(f0.size()>=3)) { // Meter Enable
uint16_t udp_port=0xFFFF&f0.at(1).toUInt(&ok);
if(ok) {

View File

@ -97,8 +97,6 @@ class CaeServer : public QObject
unsigned stream,bool state);
void openRtpCaptureChannelReq(int id,unsigned card,unsigned port,uint16_t udp_port,
unsigned samprate,unsigned chans);
void jackConnectPortsReq(int id,const QString &out_name,const QString &in_name);
void jackDisconnectPortsReq(int id,const QString &out_name,const QString &in_name);
void meterEnableReq(int id,uint16_t udp_port,const QList<unsigned> &cards);
private slots:

View File

@ -1416,77 +1416,6 @@
</sect2>
</sect1>
<sect1>
<title>JACK Operations</title>
<sect2>
<title><command>Connect Ports</command></title>
<para>
Connect a JACK input port to an output port. If the connection was
successfully added, returns:
</para>
<para>
<userinput>JC <replaceable>output-name</replaceable>
<replaceable>input-name</replaceable>!</userinput>
</para>
<variablelist>
<varlistentry>
<term>
<replaceable>output-name</replaceable>
</term>
<listitem>
<para>
The name of the JACK output port, in format CLIENTNAME:PORTNAME.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<replaceable>input-name</replaceable>
</term>
<listitem>
<para>
The name of the JACK input port, in format CLIENTNAME:PORTNAME.
</para>
</listitem>
</varlistentry>
</variablelist>
</sect2>
<sect2>
<title><command>Disconnect Ports</command></title>
<para>
Disconnect a JACK input port from an output port. If the connection was
successfully removed, returns:
</para>
<para>
<userinput>JD <replaceable>output-name</replaceable>
<replaceable>input-name</replaceable>!</userinput>
</para>
<variablelist>
<varlistentry>
<term>
<replaceable>output-name</replaceable>
</term>
<listitem>
<para>
The name of the JACK output port, in format CLIENTNAME:PORTNAME.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<replaceable>input-name</replaceable>
</term>
<listitem>
<para>
The name of the JACK input port, in format CLIENTNAME:PORTNAME.
</para>
</listitem>
</varlistentry>
</variablelist>
</sect2>
</sect1>
<sect1>
<title>Meter Commands</title>
<sect2>

View File

@ -377,18 +377,6 @@ void RDCae::setPlayPortActive(int card,int port,int stream)
}
void RDCae::connectJackPorts(const QString &out,const QString &in)
{
SendCommand(QString("JC ")+out+" "+in+"!");
}
void RDCae::disconnectJackPorts(const QString &out,const QString &in)
{
SendCommand(QString("JD ")+out+" "+in+"!");
}
void RDCae::readyData()
{
readyData(0,0,"");

View File

@ -75,8 +75,6 @@ class RDCae : public QObject
void requestTimescale(int card);
bool playPortActive(int card,int port,int except_stream=-1);
void setPlayPortActive(int card,int port,int stream);
void connectJackPorts(const QString &out,const QString &in);
void disconnectJackPorts(const QString &out,const QString &in);
signals:
void isConnected(bool state);

View File

@ -129,7 +129,12 @@ nodist_ripcd_SOURCES = moc_am16.cpp\
moc_wheatnet_lio.cpp\
moc_wheatnet_slio.cpp
ripcd_LDADD = @LIB_RDLIBS@ @LIBVORBIS@ @QT4_LIBS@ @LIBHPI@ -lQt3Support
ripcd_LDADD = @LIB_RDLIBS@\
@LIBVORBIS@\
@QT4_LIBS@\
@LIBHPI@\
@LIBJACK@\
-lQt3Support
CLEANFILES = *~\
*.idb\

View File

@ -242,6 +242,7 @@ void MainObject::RunLocalMacros(RDMacro *rml_in)
int d;
RDMatrix::GpioType gpio_type;
QByteArray data;
int err;
rda->syslog(LOG_INFO,"received rml: \"%s\" from %s",
(const char *)rml_in->toString().toUtf8(),
@ -399,6 +400,7 @@ void MainObject::RunLocalMacros(RDMacro *rml_in)
break;
case RDMacro::JC:
#ifdef JACK
if(rml->argQuantity()!=2) {
if(rml->echoRequested()) {
rml->acknowledge(false);
@ -406,14 +408,45 @@ void MainObject::RunLocalMacros(RDMacro *rml_in)
}
return;
}
rda->cae()->connectJackPorts(rml->arg(0),rml->arg(1));
if(ripcd_jack_client!=NULL) {
if((err=jack_connect(ripcd_jack_client,rml->arg(1).toUtf8(),
rml->arg(0).toUtf8()))==0) {
rda->syslog(LOG_DEBUG,
"executed JACK port connection \"%s %s\"",
(const char *)rml->arg(0).toUtf8(),
(const char *)rml->arg(1).toUtf8());
}
else {
if(err!=EEXIST) {
rda->syslog(LOG_WARNING,
"JACK port connection \"%s %s\" failed, err: %d",
(const char *)rml->arg(0).toUtf8(),
(const char *)rml->arg(1).toUtf8(),
err);
}
}
}
else {
if(rml->echoRequested()) {
rml->acknowledge(false);
sendRml(rml);
}
return;
}
if(rml->echoRequested()) {
rml->acknowledge(true);
sendRml(rml);
}
#else
if(rml->echoRequested()) {
rml->acknowledge(false);
sendRml(rml);
}
#endif // JACK
break;
case RDMacro::JD:
#ifdef JACK
if(rml->argQuantity()!=2) {
if(rml->echoRequested()) {
rml->acknowledge(false);
@ -421,11 +454,39 @@ void MainObject::RunLocalMacros(RDMacro *rml_in)
}
return;
}
rda->cae()->disconnectJackPorts(rml->arg(0),rml->arg(1));
if(ripcd_jack_client!=NULL) {
if((err=jack_disconnect(ripcd_jack_client,rml->arg(1).toUtf8(),
rml->arg(0).toUtf8()))==0) {
rda->syslog(LOG_DEBUG,
"executed JACK port disconnection \"%s %s\"",
(const char *)rml->arg(0).toUtf8(),
(const char *)rml->arg(1).toUtf8());
}
else {
rda->syslog(LOG_WARNING,
"JACK port disconnection \"%s %s\" failed, err: %d",
(const char *)rml->arg(0).toUtf8(),
(const char *)rml->arg(1).toUtf8(),
err);
}
}
else {
if(rml->echoRequested()) {
rml->acknowledge(false);
sendRml(rml);
}
return;
}
if(rml->echoRequested()) {
rml->acknowledge(true);
sendRml(rml);
}
#else
if(rml->echoRequested()) {
rml->acknowledge(false);
sendRml(rml);
}
#endif // JACK
break;
case RDMacro::LO:

View File

@ -188,6 +188,17 @@ MainObject::MainObject(QObject *parent)
ripcd_garbage_timer=new QTimer(this);
connect(ripcd_garbage_timer,SIGNAL(timeout()),this,SLOT(garbageData()));
//
// JACK
//
#ifdef JACK
ripcd_start_jack_timer=new QTimer(this);
ripcd_start_jack_timer->setSingleShot(true);
connect(ripcd_start_jack_timer, SIGNAL(timeout()),this,SLOT(startJackData()));
ripcd_start_jack_timer->start(5000);
#endif // JACK
rda->syslog(LOG_INFO,"started");
}
@ -337,7 +348,7 @@ void MainObject::exitTimerData()
delete ripcd_switcher[i];
}
}
rda->syslog(LOG_INFO,"ripcd exiting normally");
rda->syslog(LOG_INFO,"exiting normally");
exit(0);
}
}
@ -357,6 +368,99 @@ void MainObject::garbageData()
}
void MainObject::startJackData()
{
#ifdef JACK
jack_options_t jackopts=JackNullOption;
jack_status_t jackstat=JackFailure;
//
// Attempt to Connect to Jack Server
//
jackopts=JackNoStartServer;
if(rda->station()->jackServerName().isEmpty()) {
ripcd_jack_client=jack_client_open("rivendell-ripcd",jackopts,&jackstat);
}
else {
ripcd_jack_client=
jack_client_open("rivendell-ripcd",jackopts,&jackstat,
(const char *)rda->station()->jackServerName());
}
if(ripcd_jack_client==NULL) {
if((jackstat&JackInvalidOption)!=0) {
fprintf (stderr, "invalid or unsupported JACK option\n");
rda->syslog(LOG_WARNING,"invalid or unsupported JACK option");
}
if((jackstat&JackServerError)!=0) {
fprintf (stderr, "communication error with the JACK server\n");
rda->syslog(LOG_WARNING,"communication error with the JACK server");
}
if((jackstat&JackNoSuchClient)!=0) {
fprintf (stderr, "requested JACK client does not exist\n");
rda->syslog(LOG_WARNING,"requested JACK client does not exist");
}
if((jackstat&JackLoadFailure)!=0) {
fprintf (stderr, "unable to load internal JACK client\n");
rda->syslog(LOG_WARNING,"unable to load internal JACK client");
}
if((jackstat&JackInitFailure)!=0) {
fprintf (stderr, "unable to initialize JACK client\n");
rda->syslog(LOG_WARNING,"unable to initialize JACK client");
}
if((jackstat&JackShmFailure)!=0) {
fprintf (stderr, "unable to access JACK shared memory\n");
rda->syslog(LOG_WARNING,"unable to access JACK shared memory");
}
if((jackstat&JackVersionError)!=0) {
fprintf (stderr, "JACK protocol version mismatch\n");
rda->syslog(LOG_WARNING,"JACK protocol version mismatch");
}
if((jackstat&JackServerStarted)!=0) {
fprintf (stderr, "JACK server started\n");
rda->syslog(LOG_WARNING,"JACK server started");
}
if((jackstat&JackServerFailed)!=0) {
fprintf (stderr, "unable to communication with JACK server\n");
rda->syslog(LOG_WARNING,"unable to communicate with JACK server");
}
if((jackstat&JackNameNotUnique)!=0) {
fprintf (stderr, "JACK client name not unique\n");
rda->syslog(LOG_WARNING,"JACK client name not unique");
}
if((jackstat&JackFailure)!=0) {
fprintf (stderr, "JACK general failure\n");
rda->syslog(LOG_WARNING,"JACK general failure");
}
fprintf (stderr, "no connection to JACK server\n");
rda->syslog(LOG_WARNING,"no connection to JACK server");
return;
}
// jack_connected=true;
// jack_set_process_callback(jack_client,JackProcess,0);
// jack_set_sample_rate_callback(jack_client,JackSampleRate,0);
//jack_set_port_connect_callback(jack_client,JackPortConnectCB,this);
#ifdef HAVE_JACK_INFO_SHUTDOWN
// jack_on_info_shutdown(jack_client,JackInfoShutdown,0);
#else
// jack_on_shutdown(jack_client,JackShutdown,0);
#endif // HAVE_JACK_INFO_SHUTDOWN
rda->syslog(LOG_INFO,"connected to JACK server");
#endif // JACK
}
void MainObject::SetUser(QString username)
{
rda->station()->setUserName(username);

View File

@ -2,7 +2,7 @@
//
// Rivendell Interprocess Communication Daemon
//
// (C) Copyright 2002-2018 Fred Gleason <fredg@paravelsystems.com>
// (C) Copyright 2002-2019 Fred Gleason <fredg@paravelsystems.com>
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2 as
@ -32,6 +32,10 @@
#include <qtimer.h>
#include <qudpsocket.h>
#ifdef JACK
#include <jack/jack.h>
#endif // JACK
#include <rdnotification.h>
#include <rdsocket.h>
#include <rdttydevice.h>
@ -79,6 +83,7 @@ class MainObject : public QObject
void killData(int conn_id);
void exitTimerData();
void garbageData();
void startJackData();
private:
void SetUser(QString username);
@ -132,6 +137,10 @@ class MainObject : public QObject
unsigned ripc_macro_cart[RD_MAX_MACRO_TIMERS];
RDMulticaster *ripcd_notification_mcaster;
QTimer *ripcd_garbage_timer;
#ifdef JACK
jack_client_t *ripcd_jack_client;
QTimer *ripcd_start_jack_timer;
#endif // JACK
};