Merged 'stable'

This commit is contained in:
Fred Gleason
2018-08-23 16:02:45 +00:00
24 changed files with 1100 additions and 84 deletions

View File

@@ -21,7 +21,7 @@
## Use automake to process this into a Makefile.in
AM_CPPFLAGS = -Wall -DPREFIX=\"$(prefix)\" -I$(top_srcdir)/lib @QT4_CFLAGS@ -I/usr/include/Qt3Support
LIBS = -L$(top_srcdir)/lib
LIBS = -L$(top_srcdir)/lib -L$(top_srcdir)/rdhpi
MOC = @QT_MOC@
# The dependency for qt's Meta Object Compiler (moc)
@@ -42,6 +42,7 @@ dist_ripcd_SOURCES = acu1p.cpp acu1p.h\
btgpi16.cpp btgpi16.h\
btsentinel4web.cpp btsentinel4web.h\
btss124.cpp btss124.h\
btss21.cpp btss21.h\
btss164.cpp btss164.h\
btss41mlr.cpp btss41mlr.h\
btss42.cpp btss42.h\
@@ -94,6 +95,7 @@ nodist_ripcd_SOURCES = moc_am16.cpp\
moc_btsrc8iii.cpp\
moc_btss124.cpp\
moc_btss164.cpp\
moc_btss21.cpp\
moc_btss41mlr.cpp\
moc_btss42.cpp\
moc_btss44.cpp\
@@ -124,7 +126,7 @@ nodist_ripcd_SOURCES = moc_am16.cpp\
moc_wheatnet_lio.cpp\
moc_wheatnet_slio.cpp
ripcd_LDADD = @LIB_RDLIBS@ @LIBVORBIS@ @QT4_LIBS@ -lQt3Support
ripcd_LDADD = @LIB_RDLIBS@ @LIBVORBIS@ @QT4_LIBS@ @LIBHPI@ -lQt3Support
EXTRA_DIST = ripcd.pro

123
ripcd/btss21.cpp Normal file
View File

@@ -0,0 +1,123 @@
// btss21.cpp
//
// A Rivendell switcher driver for the BroadcastTools SS 2.1
//
// (C) Copyright 2002-2018 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
// published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//
#include <qstringlist.h>
#include <qtimer.h>
#include <stdlib.h>
#include <rdapplication.h>
#include "btss21.h"
#include "globals.h"
BtSs21::BtSs21(RDMatrix *matrix,QObject *parent)
: Switcher(matrix,parent)
{
//
// Get Matrix Parameters
//
bt_matrix=matrix->matrix();
bt_inputs=matrix->inputs();
bt_outputs=matrix->outputs();
//
// Initialize the TTY Port
//
RDTty *tty=new RDTty(rda->station()->name(),matrix->port(RDMatrix::Primary));
bt_device=new RDTTYDevice();
if(tty->active()) {
bt_device->setName(tty->port());
bt_device->setSpeed(tty->baudRate());
bt_device->setWordLength(tty->dataBits());
bt_device->setParity(tty->parity());
bt_device->open(QIODevice::IO_ReadWrite);
}
delete tty;
}
BtSs21::~BtSs21()
{
delete bt_device;
}
RDMatrix::Type BtSs21::type()
{
return RDMatrix::BtSs21;
}
unsigned BtSs21::gpiQuantity()
{
return 0;
}
unsigned BtSs21::gpoQuantity()
{
return 0;
}
bool BtSs21::primaryTtyActive()
{
return true;
}
bool BtSs21::secondaryTtyActive()
{
return false;
}
void BtSs21::processCommand(RDMacro *cmd)
{
QString str;
switch(cmd->command()) {
case RDMacro::ST:
if((cmd->arg(1).toInt()<0)||(cmd->arg(1).toInt()>bt_inputs)||
(cmd->arg(2).toInt()<1)||(cmd->arg(2).toInt()>1)) {
cmd->acknowledge(false);
emit rmlEcho(cmd);
return;
}
if(cmd->arg(1).toInt()==0) {
str=QString().sprintf("*%dM",BTSS21_UNIT_ID);
bt_device->writeBlock(str,str.length());
}
else {
str=QString().sprintf("*%d%d",BTSS21_UNIT_ID,
cmd->arg(1).toInt());
bt_device->writeBlock(str,str.length());
}
cmd->acknowledge(true);
emit rmlEcho(cmd);
break;
default:
cmd->acknowledge(false);
emit rmlEcho(cmd);
break;
}
}

55
ripcd/btss21.h Normal file
View File

@@ -0,0 +1,55 @@
// btss21.h
//
// A Rivendell switcher driver for the BroadcastTools SS 2.1
//
// (C) Copyright 2002-2018 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
// published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//
#ifndef BTSS21_H
#define BTSS21_H
#include <rd.h>
#include <rdmatrix.h>
#include <rdmacro.h>
#include <rdtty.h>
#include <rdoneshot.h>
#include <switcher.h>
#define BTSS21_UNIT_ID 0
class BtSs21 : public Switcher
{
Q_OBJECT
public:
BtSs21(RDMatrix *matrix,QObject *parent=0);
~BtSs21();
RDMatrix::Type type();
unsigned gpiQuantity();
unsigned gpoQuantity();
bool primaryTtyActive();
bool secondaryTtyActive();
void processCommand(RDMacro *cmd);
private:
RDTTYDevice *bt_device;
int bt_matrix;
int bt_inputs;
int bt_outputs;
};
#endif // BTSS21_H

425
ripcd/hpigpio.cpp Normal file
View File

@@ -0,0 +1,425 @@
// hpigpio.cpp
//
// A Rivendell switcher driver for AudioScience HPI GPIO devices
//
// (C) Copyright 2002-2018 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
// published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//
#include <qtimer.h>
#include <stdlib.h>
#include "globals.h"
#include "hpigpio.h"
HpiGpio::HpiGpio(RDMatrix *matrix,QObject *parent)
: Switcher(matrix,parent)
{
/*
//
// Initialize Data Structures
//
hpi_istate=0;
for(int i=0;i<HPIGPIO_GPIO_PINS;i++) {
hpi_gpi_state[i]=false;
hpi_gpi_mask[i]=false;
}
*/
//
// Get Matrix Parameters
//
hpi_matrix=matrix->matrix();
hpi_card=matrix->card();
hpi_gpis=0;
hpi_gpos=0;
#ifdef HPI
struct hpi_control_t cntl;
hpi_handle_t block;
size_t value_size=0;
size_t value_items=0;
uint8_t *value;
//
// Open Mixer
//
if(LogHpi(HPI_MixerOpen(NULL,hpi_card,&hpi_mixer),__LINE__)!=0) {
UpdateDb(matrix);
return;
}
memset(&cntl,0,sizeof(cntl));
cntl.wSrcNodeType=HPI_SOURCENODE_ADAPTER;
if(LogHpi(HPI_Object_BlockHandle(hpi_mixer,HPI_SOURCENODE_ADAPTER,0,0,0,
"GPIO",&block),__LINE__)!=0) {
UpdateDb(matrix);
return;
}
//
// GPIs Handle
//
if(LogHpi(HPI_Object_ParameterHandle(hpi_mixer,block,"Inputs",&hpi_gpis_param),__LINE__)!=0) {
UpdateDb(matrix);
return;
}
if(LogHpi(HPI_Object_GetInfo(hpi_gpis_param,entity_type_boolean,
entity_role_value,NULL,&value_size,&value_items),
__LINE__)!=0) {
UpdateDb(matrix);
return;
}
hpi_gpis=value_items;
//
// GPOs Handle
//
if(LogHpi(HPI_Object_ParameterHandle(hpi_mixer,block,"Outputs",&hpi_gpos_param),__LINE__)!=0) {
return;
}
if(LogHpi(HPI_Object_GetInfo(hpi_gpos_param,entity_type_boolean,
entity_role_value,NULL,&value_size,&value_items),
__LINE__)!=0) {
hpi_gpis=0;
UpdateDb(matrix);
return;
}
hpi_gpos=value_items;
UpdateDb(matrix);
/*
//
// Interval OneShots
//
hpi_gpi_oneshot=new RDOneShot(this);
connect(hpi_gpi_oneshot,SIGNAL(timeout(int)),this,SLOT(gpiOneshotData(int)));
hpi_gpo_oneshot=new RDOneShot(this);
connect(hpi_gpo_oneshot,SIGNAL(timeout(int)),this,SLOT(gpoOneshotData(int)));
//
// The Poll Timer
//
QTimer *timer=new QTimer(this,"poll_timer");
connect(timer,SIGNAL(timeout()),this,SLOT(processStatus()));
timer->start(HPIGPIO_POLL_INTERVAL);
*/
#endif // HPI
}
HpiGpio::~HpiGpio()
{
#ifdef HPI
/*
delete hpi_device;
delete hpi_gpi_oneshot;
delete hpi_gpo_oneshot;
*/
#endif // HPI
}
RDMatrix::Type HpiGpio::type()
{
return RDMatrix::HpiGpio;
}
unsigned HpiGpio::gpiQuantity()
{
return hpi_gpis;
}
unsigned HpiGpio::gpoQuantity()
{
return hpi_gpos;
}
bool HpiGpio::primaryTtyActive()
{
return false;
}
bool HpiGpio::secondaryTtyActive()
{
return false;
}
void HpiGpio::processCommand(RDMacro *cmd)
{
#ifdef HPI
/*
char str[20];
switch(cmd->command()) {
case RDMacro::GO:
if((cmd->argQuantity()!=5)||
((cmd->arg(1).toString().lower()!="i")&&
(cmd->arg(1).toString().lower()!="o"))||
(cmd->arg(2).toInt()<1)||(cmd->arg(3).toInt()>hpi_gpos)||
(cmd->arg(2).toInt()>hpi_gpos)||
((cmd->arg(3).toInt()!=1)&&(cmd->arg(3).toInt()!=0)&&
(cmd->arg(1).toString().lower()!="i"))||
((cmd->arg(3).toInt()!=1)&&(cmd->arg(3).toInt()!=0)&&
(cmd->arg(3).toInt()!=-1)&&(cmd->arg(1).toString().lower()=="i"))||
(cmd->arg(4).toInt()<0)) {
cmd->acknowledge(false);
emit rmlEcho(cmd);
return;
}
if(cmd->arg(3).toInt()==0) { // Turn OFF
if(cmd->arg(4).toInt()==0) {
if(cmd->arg(1).toString().lower()=="i") {
if(hpi_gpi_state[cmd->arg(2).toInt()-1]) {
emit gpiChanged(hpi_matrix,cmd->arg(2).toInt()-1,false);
hpi_gpi_state[cmd->arg(2).toInt()-1]=false;
}
hpi_gpi_mask[cmd->arg(2).toInt()-1]=true;
}
if(cmd->arg(1).toString().lower()=="o") {
sprintf(str,"*%dOR%02dF\r\n",HPIGPIO_UNIT_ID,cmd->arg(2).toInt());
hpi_device->writeBlock(str,9);
emit gpoChanged(hpi_matrix,cmd->arg(2).toInt()-1,false);
}
}
else {
if(cmd->echoRequested()) {
cmd->acknowledge(false);
emit rmlEcho(cmd);
}
return;
}
}
else {
if(cmd->arg(3).toInt()==-1) { // Clear input
hpi_gpi_mask[cmd->arg(2).toInt()-1]=false;
hpi_device->writeBlock("*0SPA\r\n",7);
}
else {
if(cmd->arg(4).toInt()==0) { // Turn ON
if(cmd->arg(1).toString().lower()=="i") {
if(!hpi_gpi_state[cmd->arg(2).toInt()-1]) {
emit gpiChanged(hpi_matrix,cmd->arg(2).toInt()-1,true);
hpi_gpi_state[cmd->arg(2).toInt()-1]=true;
}
hpi_gpi_mask[cmd->arg(2).toInt()-1]=true;
}
if(cmd->arg(1).toString().lower()=="o") {
sprintf(str,"*%dOR%02dL\r\n",
HPIGPIO_UNIT_ID,cmd->arg(2).toInt());
hpi_device->writeBlock(str,9);
emit gpoChanged(hpi_matrix,cmd->arg(2).toInt()-1,true);
}
}
else { // Pulse
if(cmd->arg(1).toString().lower()=="i") {
if(!hpi_gpi_state[cmd->arg(2).toInt()-1]) {
emit gpiChanged(hpi_matrix,cmd->arg(2).toInt()-1,true);
hpi_gpi_state[cmd->arg(2).toInt()-1]=true;
}
hpi_gpi_mask[cmd->arg(2).toInt()-1]=true;
hpi_gpi_oneshot->start(cmd->arg(2).toInt()-1,500);
}
if(cmd->arg(1).toString().lower()=="o") {
sprintf(str,"*%dOR%02dP%02d\r\n",
HPIGPIO_UNIT_ID,cmd->arg(2).toInt(),
cmd->arg(4).toInt()/100+1);
hpi_device->writeBlock(str,11);
emit gpoChanged(hpi_matrix,cmd->arg(2).toInt()-1,true);
hpi_gpo_oneshot->start(cmd->arg(2).toInt()-1,500);
}
}
}
}
if(cmd->echoRequested()) {
cmd->acknowledge(true);
emit rmlEcho(cmd);
}
break;
default:
cmd->acknowledge(false);
emit rmlEcho(cmd);
break;
}
*/
#endif // HPI
}
void HpiGpio::processStatus()
{
#ifdef HPI
/*
char buffer[256];
int n;
int gpi;
while((n=hpi_device->readBlock(buffer,255))>0) {
for(int i=0;i<n;i++) {
switch(hpi_istate) {
case 0:
if(buffer[i]=='S') {
hpi_istate=1;
}
break;
case 1:
if(buffer[i]==(HPIGPIO_UNIT_ID+'0')) {
hpi_istate=2;
}
else {
hpi_istate=0;
}
break;
case 2:
if(buffer[i]=='P') {
hpi_istate=3;
}
else {
hpi_istate=0;
}
break;
case 3:
if(buffer[i]==',') {
hpi_istate=4;
}
else {
hpi_istate=0;
}
break;
case 4:
if(buffer[i]=='A') {
hpi_istate=5;
}
else {
hpi_istate=0;
}
break;
case 5:
case 7:
case 9:
case 11:
case 13:
case 15:
case 17:
case 19:
case 21:
case 23:
case 25:
case 27:
case 29:
case 31:
case 33:
case 35:
if(buffer[i]==',') {
hpi_istate++;
}
else {
hpi_istate=0;
}
break;
case 6:
case 8:
case 10:
case 12:
case 14:
case 16:
case 18:
case 20:
case 22:
case 24:
case 26:
case 28:
case 30:
case 32:
case 34:
case 36:
if(buffer[i]=='1') {
gpi=(hpi_istate-6)/2;
if(hpi_gpi_state[gpi]&&(!hpi_gpi_mask[gpi])) {
emit gpiChanged(hpi_matrix,gpi,false);
hpi_gpi_state[gpi]=false;
}
hpi_istate++;
}
if(buffer[i]=='0') {
gpi=(hpi_istate-6)/2;
if((!hpi_gpi_state[gpi])&&(!hpi_gpi_mask[gpi])) {
emit gpiChanged(hpi_matrix,gpi,true);
hpi_gpi_state[gpi]=true;
}
hpi_istate++;
}
break;
default:
hpi_istate=0;
}
}
}
*/
#endif // HPI
}
void HpiGpio::gpiOneshotData(int value)
{
#ifdef HPI
/*
hpi_gpi_mask[value]=false;
hpi_device->writeBlock("*0SPA",5);
*/
#endif // HPI
}
void HpiGpio::gpoOneshotData(int value)
{
#ifdef HPI
// emit gpoChanged(hpi_matrix,value,false);
#endif // HPI
}
void HpiGpio::UpdateDb(RDMatrix *matrix) const
{
matrix->setGpis(hpi_gpis);
matrix->setGpos(hpi_gpos);
}
#ifdef HPI
hpi_err_t HpiGpio::LogHpi(hpi_err_t err,int lineno)
{
char err_txt[200];
if(err!=0) {
HPI_GetErrorText(err,err_txt);
syslog(LOG_NOTICE,"HPI Error: %s, %s line %d",err_txt,__FILE__,lineno);
}
return err;
}
#endif // HPI

77
ripcd/hpigpio.h Normal file
View File

@@ -0,0 +1,77 @@
// hpigpio.h
//
// A Rivendell switcher driver for AudioScience HPI GPIO devices
//
// (C) Copyright 2002-2018 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
// published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//
#ifndef HPIGPIO_H
#define HPIGPIO_H
#include <rd.h>
#include <rdmatrix.h>
#include <rdmacro.h>
#include <rdtty.h>
#include <rdoneshot.h>
#ifdef HPI
#include <asihpi/hpi.h>
#endif // HPI
#include "switcher.h"
#define HPIGPIO_POLL_INTERVAL 100
#define HPIGPIO_GPIO_PINS 16
class HpiGpio : public Switcher
{
Q_OBJECT
public:
HpiGpio(RDMatrix *matrix,QObject *parent=0);
~HpiGpio();
RDMatrix::Type type();
unsigned gpiQuantity();
unsigned gpoQuantity();
bool primaryTtyActive();
bool secondaryTtyActive();
void processCommand(RDMacro *cmd);
private slots:
void processStatus();
void gpiOneshotData(int value);
void gpoOneshotData(int value);
private:
#ifdef HPI
void UpdateDb(RDMatrix *matrix) const;
hpi_err_t LogHpi(hpi_err_t err,int lineno);
hpi_handle_t hpi_mixer;
hpi_handle_t hpi_gpis_param;
hpi_handle_t hpi_gpos_param;
#endif // HPI
RDOneShot *hpi_gpi_oneshot;
RDOneShot *hpi_gpo_oneshot;
int hpi_matrix;
int hpi_card;
int hpi_gpis;
int hpi_gpos;
int hpi_istate;
bool hpi_gpi_state[HPIGPIO_GPIO_PINS];
bool hpi_gpi_mask[HPIGPIO_GPIO_PINS];
};
#endif // HPIGPIO_H

View File

@@ -39,6 +39,7 @@
#include "btsrc8iii.h"
#include "btss124.h"
#include "btss164.h"
#include "btss21.h"
#include "btss41mlr.h"
#include "btss42.h"
#include "btss44.h"
@@ -128,6 +129,10 @@ bool MainObject::LoadSwitchDriver(int matrix_num)
ripcd_switcher[matrix_num]=new BtSs164(matrix,this);
break;
case RDMatrix::BtSs21:
ripcd_switcher[matrix_num]=new BtSs21(matrix,this);
break;
case RDMatrix::BtSs41Mlr:
ripcd_switcher[matrix_num]=new BtSs41Mlr(matrix,this);
break;

View File

@@ -1,8 +1,8 @@
// local_audio.cpp
//
// A Rivendell switcher driver for the BroadcastTools 10x1
// A Rivendell switcher driver for local audio cards.
//
// (C) Copyright 2002-2003,2016-2018 Fred Gleason <fredg@paravelsystems.com>
// (C) Copyright 2002-2018 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
@@ -29,17 +29,40 @@
LocalAudio::LocalAudio(RDMatrix *matrix,QObject *parent)
: Switcher(matrix,parent)
{
bt_poll_timer=NULL;
bt_gpi_values=NULL;
bt_gpo_values=NULL;
//
// Get Matrix Parameters
//
bt_inputs=matrix->inputs();
bt_outputs=matrix->outputs();
bt_card=matrix->card();
bt_gpis=0;
bt_gpos=0;
//
// Interval OneShot
//
bt_gpo_oneshot=new RDOneShot(this);
connect(bt_gpo_oneshot,SIGNAL(timeout(int)),this,SLOT(gpoOneshotData(int)));
InitializeHpi(matrix);
}
LocalAudio::~LocalAudio()
{
if(bt_poll_timer!=NULL) {
delete bt_poll_timer;
}
if(bt_gpi_values!=NULL) {
delete bt_gpi_values;
}
if(bt_gpo_values!=NULL) {
delete bt_gpo_values;
}
}
@@ -76,78 +99,276 @@ bool LocalAudio::secondaryTtyActive()
void LocalAudio::processCommand(RDMacro *cmd)
{
switch(cmd->command()) {
case RDMacro::ST:
if((cmd->arg(1).toInt()<0)||(cmd->arg(1).toInt()>bt_inputs)||
(cmd->arg(2).toInt()<=0)||(cmd->arg(2).toInt()>bt_outputs)) {
case RDMacro::GO:
if((cmd->argQuantity()!=5)||
((cmd->arg(1).lower()!="i")&&
(cmd->arg(1).lower()!="o"))||
(cmd->arg(2).toInt()<1)||(cmd->arg(3).toInt()>bt_gpos)||
(cmd->arg(2).toInt()>bt_gpos)||
((cmd->arg(3).toInt()!=1)&&(cmd->arg(3).toInt()!=0)&&
(cmd->arg(1).lower()!="i"))||
((cmd->arg(3).toInt()!=1)&&(cmd->arg(3).toInt()!=0)&&
(cmd->arg(3).toInt()!=-1)&&(cmd->arg(1).lower()=="i"))||
(cmd->arg(4).toInt()<0)) {
cmd->acknowledge(false);
emit rmlEcho(cmd);
return;
}
if(cmd->arg(3).toInt()==0) { // Turn OFF
if(cmd->arg(4).toInt()==0) {
if(cmd->arg(1).lower()=="o") {
SetGpo(cmd->arg(2).toInt()-1,false);
emit gpoChanged(matrixNumber(),cmd->arg(2).toInt()-1,false);
}
}
else {
if(cmd->echoRequested()) {
cmd->acknowledge(false);
emit rmlEcho(cmd);
return;
}
if(cmd->arg(1).toInt()==0) {
for(int i=0;i<bt_inputs;i++) {
rda->cae()->
setPassthroughVolume(bt_card,i,cmd->arg(2).toInt()-1,-10000);
return;
}
}
else {
if(cmd->arg(3).toInt()!=-1) {
if(cmd->arg(4).toInt()==0) { // Turn ON
if(cmd->arg(1).lower()=="o") {
SetGpo(cmd->arg(2).toInt()-1,true);
emit gpoChanged(matrixNumber(),cmd->arg(2).toInt()-1,true);
}
}
else {
rda->cae()->setPassthroughVolume(bt_card,cmd->arg(1).toInt()-1,
cmd->arg(2).toInt()-1,0);
for(int i=0;i<(cmd->arg(1).toInt()-1);i++) {
rda->cae()->
setPassthroughVolume(bt_card,i,cmd->arg(2).toInt()-1,-10000);
}
for(int i=cmd->arg(1).toInt();i<bt_inputs;i++) {
rda->cae()->
setPassthroughVolume(bt_card,i,cmd->arg(2).toInt()-1,-10000);
else { // Pulse
if(cmd->arg(1).lower()=="o") {
SetGpo(cmd->arg(2).toInt()-1,true);
emit gpoChanged(matrixNumber(),cmd->arg(2).toInt()-1,true);
bt_gpo_oneshot->
start(cmd->arg(2).toInt()-1,cmd->arg(4).toInt());
}
}
cmd->acknowledge(true);
emit rmlEcho(cmd);
break;
}
}
if(cmd->echoRequested()) {
cmd->acknowledge(true);
emit rmlEcho(cmd);
}
break;
case RDMacro::SA:
if((cmd->arg(1).toInt()<=0)||(cmd->arg(1).toInt()>bt_inputs)||
(cmd->arg(2).toInt()<=0)||(cmd->arg(2).toInt()>bt_outputs)) {
cmd->acknowledge(false);
emit rmlEcho(cmd);
return;
}
rda->cae()->setPassthroughVolume(bt_card,cmd->arg(1).toInt()-1,
cmd->arg(2).toInt()-1,0);
cmd->acknowledge(true);
emit rmlEcho(cmd);
break;
case RDMacro::ST:
if((cmd->arg(1).toInt()<0)||(cmd->arg(1).toInt()>bt_inputs)||
(cmd->arg(2).toInt()<=0)||(cmd->arg(2).toInt()>bt_outputs)) {
cmd->acknowledge(false);
emit rmlEcho(cmd);
return;
}
if(cmd->arg(1).toInt()==0) {
for(int i=0;i<bt_inputs;i++) {
rda->cae()->
setPassthroughVolume(bt_card,i,cmd->arg(2).toInt()-1,-10000);
}
}
else {
rda->cae()->setPassthroughVolume(bt_card,cmd->arg(1).toInt()-1,
cmd->arg(2).toInt()-1,0);
for(int i=0;i<(cmd->arg(1).toInt()-1);i++) {
rda->cae()->
setPassthroughVolume(bt_card,i,cmd->arg(2).toInt()-1,-10000);
}
for(int i=cmd->arg(1).toInt();i<bt_inputs;i++) {
rda->cae()->
setPassthroughVolume(bt_card,i,cmd->arg(2).toInt()-1,-10000);
}
}
cmd->acknowledge(true);
emit rmlEcho(cmd);
break;
case RDMacro::SR:
if((cmd->arg(1).toInt()<=0)||(cmd->arg(1).toInt()>bt_inputs)||
(cmd->arg(2).toInt()<=0)||(cmd->arg(2).toInt()>bt_outputs)) {
cmd->acknowledge(false);
emit rmlEcho(cmd);
return;
}
rda->cae()->setPassthroughVolume(bt_card,cmd->arg(1).toInt()-1,
cmd->arg(2).toInt()-1,RD_MUTE_DEPTH);
cmd->acknowledge(true);
emit rmlEcho(cmd);
break;
case RDMacro::SA:
if((cmd->arg(1).toInt()<=0)||(cmd->arg(1).toInt()>bt_inputs)||
(cmd->arg(2).toInt()<=0)||(cmd->arg(2).toInt()>bt_outputs)) {
cmd->acknowledge(false);
emit rmlEcho(cmd);
return;
}
rda->cae()->setPassthroughVolume(bt_card,cmd->arg(1).toInt()-1,
cmd->arg(2).toInt()-1,0);
cmd->acknowledge(true);
emit rmlEcho(cmd);
break;
case RDMacro::SX:
if((cmd->arg(1).toInt()<=0)||(cmd->arg(1).toInt()>bt_inputs)||
(cmd->arg(2).toInt()<=0)||(cmd->arg(2).toInt()>bt_outputs)||
(cmd->arg(3).toInt()<RD_MUTE_DEPTH)||(cmd->arg(3).toInt()>0)) {
cmd->acknowledge(false);
emit rmlEcho(cmd);
return;
}
rda->cae()->setPassthroughVolume(bt_card,cmd->arg(1).toInt()-1,
cmd->arg(2).toInt()-1,cmd->arg(3).toInt());
cmd->acknowledge(true);
emit rmlEcho(cmd);
break;
case RDMacro::SR:
if((cmd->arg(1).toInt()<=0)||(cmd->arg(1).toInt()>bt_inputs)||
(cmd->arg(2).toInt()<=0)||(cmd->arg(2).toInt()>bt_outputs)) {
cmd->acknowledge(false);
emit rmlEcho(cmd);
return;
}
rda->cae()->setPassthroughVolume(bt_card,cmd->arg(1).toInt()-1,
cmd->arg(2).toInt()-1,RD_MUTE_DEPTH);
cmd->acknowledge(true);
emit rmlEcho(cmd);
break;
default:
cmd->acknowledge(false);
emit rmlEcho(cmd);
break;
case RDMacro::SX:
if((cmd->arg(1).toInt()<=0)||(cmd->arg(1).toInt()>bt_inputs)||
(cmd->arg(2).toInt()<=0)||(cmd->arg(2).toInt()>bt_outputs)||
(cmd->arg(3).toInt()<RD_MUTE_DEPTH)||(cmd->arg(3).toInt()>0)) {
cmd->acknowledge(false);
emit rmlEcho(cmd);
return;
}
rda->cae()->setPassthroughVolume(bt_card,cmd->arg(1).toInt()-1,
cmd->arg(2).toInt()-1,cmd->arg(3).toInt());
cmd->acknowledge(true);
emit rmlEcho(cmd);
break;
default:
cmd->acknowledge(false);
emit rmlEcho(cmd);
break;
}
}
void LocalAudio::pollData()
{
#ifdef HPI
if(LogHpi(HPI_Object_GetValue(bt_gpis_param,entity_type_boolean,
bt_gpis,bt_gpi_values,
bt_gpis),__LINE__)==0) {
for(int i=0;i<bt_gpis;i++) {
if((bt_gpi_values[i]=='T')!=bt_gpi_states[i]) {
bt_gpi_states[i]=(bt_gpi_values[i]=='T');
emit gpiChanged(matrixNumber(),i,bt_gpi_states[i]);
}
}
}
#endif // HPI
}
void LocalAudio::gpoOneshotData(int value)
{
SetGpo(value,false);
emit gpoChanged(matrixNumber(),value,false);
}
void LocalAudio::InitializeHpi(RDMatrix *matrix)
{
#ifdef HPI
struct hpi_control_t cntl;
hpi_handle_t block;
size_t value_size=0;
size_t value_items=0;
bt_gpis=0;
bt_gpos=0;
//
// Open Mixer
//
if(HPI_MixerOpen(NULL,bt_card,&bt_mixer)!=0) {
UpdateDb(matrix);
return;
}
memset(&cntl,0,sizeof(cntl));
cntl.wSrcNodeType=HPI_SOURCENODE_ADAPTER;
if(HPI_Object_BlockHandle(bt_mixer,HPI_SOURCENODE_ADAPTER,0,0,0,
"GPIO",&block)!=0) {
UpdateDb(matrix);
return;
}
//
// GPIs Handle
//
if(LogHpi(HPI_Object_ParameterHandle(bt_mixer,block,"Inputs",&bt_gpis_param),__LINE__)!=0) {
UpdateDb(matrix);
return;
}
if(LogHpi(HPI_Object_GetInfo(bt_gpis_param,entity_type_boolean,
entity_role_value,NULL,&value_size,&value_items),
__LINE__)!=0) {
UpdateDb(matrix);
return;
}
bt_gpis=value_items;
bt_gpi_values=new uint8_t[bt_gpis];
if(LogHpi(HPI_Object_GetValue(bt_gpis_param,entity_type_boolean,value_items,bt_gpi_values,value_size),__LINE__)!=0) {
bt_gpis=0;
UpdateDb(matrix);
return;
}
for(int i=0;i<bt_gpis;i++) {
bt_gpi_states.push_back(bt_gpi_values[i]=='T');
}
bt_poll_timer=new QTimer(this);
connect(bt_poll_timer,SIGNAL(timeout()),this,SLOT(pollData()));
bt_poll_timer->start(LOCALAUDIO_POLL_INTERVAL);
//
// GPOs Handle
//
if(LogHpi(HPI_Object_ParameterHandle(bt_mixer,block,"Outputs",&bt_gpos_param),__LINE__)!=0) {
return;
}
if(LogHpi(HPI_Object_GetInfo(bt_gpos_param,entity_type_boolean,
entity_role_value,NULL,&value_size,&value_items),
__LINE__)!=0) {
bt_gpis=0;
UpdateDb(matrix);
return;
}
bt_gpos=value_items;
bt_gpo_values=new uint8_t[bt_gpos];
if(LogHpi(HPI_Object_GetValue(bt_gpos_param,entity_type_boolean,value_items,bt_gpo_values,value_size),__LINE__)!=0) {
bt_gpis=0;
bt_gpos=0;
UpdateDb(matrix);
return;
}
UpdateDb(matrix);
#endif // HPI
}
void LocalAudio::SetGpo(int line,bool state)
{
#ifdef HPI
if(LogHpi(HPI_Object_GetValue(bt_gpos_param,entity_type_boolean,
bt_gpos,bt_gpo_values,
bt_gpos),__LINE__)==0) {
if(state) {
bt_gpo_values[line]='T';
}
else {
bt_gpo_values[line]='F';
}
LogHpi(HPI_Object_SetValue(bt_gpos_param,entity_type_boolean,bt_gpos,
bt_gpo_values,bt_gpos),__LINE__);
}
#endif // HPI
}
void LocalAudio::UpdateDb(RDMatrix *matrix) const
{
matrix->setGpis(bt_gpis);
matrix->setGpos(bt_gpos);
}
#ifdef HPI
hpi_err_t LocalAudio::LogHpi(hpi_err_t err,int lineno)
{
char err_txt[200];
if(err!=0) {
HPI_GetErrorText(err,err_txt);
syslog(LOG_NOTICE,"HPI Error: %s, %s line %d",err_txt,__FILE__,lineno);
}
return err;
}
#endif // HPI

View File

@@ -1,8 +1,8 @@
// local_audio.h
//
// A Rivendell switcher driver for the BroadcastTools 10x1
// A Rivendell switcher driver for local audio cards.
//
// (C) Copyright 2002-2003,2016 Fred Gleason <fredg@paravelsystems.com>
// (C) Copyright 2002-2018 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
@@ -21,12 +21,23 @@
#ifndef LOCAL_AUDIO_H
#define LOCAL_AUDIO_H
#include <vector>
#include <qtimer.h>
#include <rd.h>
#include <rdmatrix.h>
#include <rdmacro.h>
#include <rdoneshot.h>
#include <rdtty.h>
#include <switcher.h>
#ifdef HPI
#include <asihpi/hpi.h>
#endif // HPI
#include "switcher.h"
#define LOCALAUDIO_POLL_INTERVAL 100
class LocalAudio : public Switcher
{
@@ -41,9 +52,29 @@ class LocalAudio : public Switcher
bool secondaryTtyActive();
void processCommand(RDMacro *cmd);
private slots:
void pollData();
void gpoOneshotData(int value);
private:
void InitializeHpi(RDMatrix *matrix);
void SetGpo(int line,bool state);
void UpdateDb(RDMatrix *matrix) const;
#ifdef HPI
hpi_err_t LogHpi(hpi_err_t err,int lineno);
hpi_handle_t bt_mixer;
hpi_handle_t bt_gpis_param;
hpi_handle_t bt_gpos_param;
std::vector<uint8_t> bt_gpi_states;
#endif // HPI
RDOneShot *bt_gpo_oneshot;
uint8_t *bt_gpi_values;
uint8_t *bt_gpo_values;
QTimer *bt_poll_timer;
int bt_inputs;
int bt_outputs;
int bt_gpis;
int bt_gpos;
int bt_card;
};