diff --git a/ChangeLog b/ChangeLog index 8075abcb..9e761b33 100644 --- a/ChangeLog +++ b/ChangeLog @@ -21141,3 +21141,5 @@ * Removed the 'Q3Frame' dependency from 'RDCueEdit'. * Removed the 'Q3Frame' dependency from 'RDMarkerBar'. * Removed the 'Q3Frame' dependency from 'RDTimeEdit'. +2021-02-15 Fred Gleason + * Reverted the removal of 'Q3SocketDevice' from 'RDCae'. diff --git a/lib/rdcae.cpp b/lib/rdcae.cpp index 6e9970e2..30ff95f0 100644 --- a/lib/rdcae.cpp +++ b/lib/rdcae.cpp @@ -2,7 +2,7 @@ // // Connection to the Rivendell Core Audio Engine // -// (C) Copyright 2002-2021 Fred Gleason +// (C) Copyright 2002-2019 Fred Gleason // // 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 @@ -48,19 +48,16 @@ RDCae::RDCae(RDStation *station,RDConfig *config,QObject *parent) // // TCP Connection // - cae_socket=new QTcpSocket(this); - connect(cae_socket,SIGNAL(connected()),this,SLOT(caeSocketConnected())); - cae_socket_count=10; - cae_socket_timer=new QTimer(this); - cae_socket_timer->setSingleShot(true); - connect(cae_socket_timer,SIGNAL(timeout()),this,SLOT(caeSocketTimeout())); + cae_socket=new Q3SocketDevice(Q3SocketDevice::Stream); + cae_socket->setBlocking(false); // // Meter Connection // - cae_meter_socket=new QUdpSocket(this); + cae_meter_socket=new Q3SocketDevice(Q3SocketDevice::Datagram); + cae_meter_socket->setBlocking(false); for(Q_INT16 i=30000;i<30100;i++) { - if(cae_meter_socket->bind(i)) { + if(cae_meter_socket->bind(QHostAddress(),i)) { i=31000; } } @@ -100,9 +97,35 @@ RDCae::~RDCae() { } +void RDCae::connectHost() +{ + int count=10; + // QHostAddress addr; + QTimer *timer=new QTimer(this,"read_timer"); + + connect(timer,SIGNAL(timeout()),this,SLOT(readyData())); + timer->start(CAE_POLL_INTERVAL); + while((!cae_socket->connect(cae_station->caeAddress(cae_config), + CAED_TCP_PORT))&&(--count>0)) { + usleep(100000); + } + usleep(100000); + if(count>0) { + SendCommand(QString().sprintf("PW %s!", + (const char *)cae_config->password())); + for(int i=0;i *cards) { - QString cmd=QString().sprintf("ME %u",cae_meter_socket->localPort()); + QString cmd=QString().sprintf("ME %u",cae_meter_socket->port()); for(int i=0;isize();i++) { if(cards->at(i)>=0) { bool found=false; @@ -354,42 +377,6 @@ void RDCae::setPlayPortActive(int card,int port,int stream) } -void RDCae::connectHost() -{ - cae_socket_count=100; - cae_socket_timer->start(100000); - cae_socket->connectToHost(cae_station->caeAddress(cae_config),CAED_TCP_PORT); -} - - -void RDCae::caeSocketConnected() -{ - cae_socket_timer->stop(); - SendCommand("PW "+cae_config->password()+"!"); - for(int i=0;idisconnectFromHost(); - if(--cae_socket_count==0) { - emit isConnected(false); - return; - } - delete cae_socket; - cae_socket=new QTcpSocket(this); - connect(cae_socket,SIGNAL(connected()),this,SLOT(caeSocketConnected())); - cae_socket_timer->start(100000); - cae_socket->connectToHost(cae_station->caeAddress(cae_config),CAED_TCP_PORT); -} - - void RDCae::readyData() { readyData(0,0,""); @@ -655,7 +642,7 @@ void RDCae::UpdateMeters() int n; QStringList args; - while((n=cae_meter_socket->readDatagram(msg,1500))>0) { + while((n=cae_meter_socket->readBlock(msg,1500))>0) { msg[n]=0; args=QString(msg).split(" "); if(args[0]=="ML") { diff --git a/lib/rdcae.h b/lib/rdcae.h index ae78e665..f86eeff3 100644 --- a/lib/rdcae.h +++ b/lib/rdcae.h @@ -2,7 +2,7 @@ // // Connection to the Rivendell Core Audio Engine // -// (C) Copyright 2002-2021 Fred Gleason +// (C) Copyright 2002-2016 Fred Gleason // // 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,8 +21,7 @@ #ifndef RDCAE_H #define RDCAE_H -#include -#include +#include #include #include @@ -43,6 +42,7 @@ class RDCae : public QObject enum AudioCoding {Pcm16=0,MpegL1=1,MpegL2=2,MpegL3=3,Pcm24=4}; RDCae(RDStation *station,RDConfig *config,QObject *parent=0); ~RDCae(); + void connectHost(); void enableMetering(QList *cards); bool loadPlay(int card,QString name,int *stream,int *handle); void unloadPlay(int handle); @@ -91,12 +91,7 @@ class RDCae : public QObject void playPositionChanged(int handle,unsigned sample); void timescalingSupported(int card,bool state); - public slots: - void connectHost(); - private slots: - void caeSocketConnected(); - void caeSocketTimeout(); void readyData(); void readyData(int *stream,int *handle,QString name); void clockData(); @@ -108,9 +103,7 @@ class RDCae : public QObject int StreamNumber(const char *arg); int GetHandle(const char *arg); void UpdateMeters(); - QTcpSocket *cae_socket; - QTimer *cae_socket_timer; - int cae_socket_count; + Q3SocketDevice *cae_socket; bool debug; char args[CAE_MAX_ARGS][CAE_MAX_LENGTH]; int argnum; @@ -119,7 +112,7 @@ class RDCae : public QObject bool input_status[RD_MAX_CARDS][RD_MAX_PORTS]; int cae_handle[RD_MAX_CARDS][RD_MAX_STREAMS]; unsigned cae_pos[RD_MAX_CARDS][RD_MAX_STREAMS]; - QUdpSocket *cae_meter_socket; + Q3SocketDevice *cae_meter_socket; short cae_input_levels[RD_MAX_CARDS][RD_MAX_PORTS][2]; short cae_output_levels[RD_MAX_CARDS][RD_MAX_PORTS][2]; short cae_stream_output_levels[RD_MAX_CARDS][RD_MAX_PORTS][2];