mirror of
https://github.com/ElvishArtisan/rivendell.git
synced 2025-10-16 15:41:13 +02:00
2022-11-02 Fred Gleason <fredg@paravelsystems.com>
* Refactored rdcatch(1) and rdcatchd(8) to use the notification mechanism instead for distributing meter updates instead of the 'Enable Metering' catch command. Signed-off-by: Fred Gleason <fredg@paravelsystems.com>
This commit is contained in:
@@ -23,6 +23,43 @@
|
||||
#include "rdcatchevent.h"
|
||||
#include "rdapplication.h"
|
||||
|
||||
RDCatchMeterLevel::RDCatchMeterLevel(int deck,int16_t *lvls)
|
||||
{
|
||||
d_deck_channel=deck;
|
||||
for(int i=0;i<RDCatchMeterLevel::LastChannel;i++) {
|
||||
d_levels[i]=-lvls[i];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
unsigned RDCatchMeterLevel::deckChannel() const
|
||||
{
|
||||
return d_deck_channel;
|
||||
}
|
||||
|
||||
|
||||
int16_t RDCatchMeterLevel::level(Channel chan) const
|
||||
{
|
||||
return -d_levels[chan];
|
||||
}
|
||||
|
||||
|
||||
QString RDCatchMeterLevel::dump() const
|
||||
{
|
||||
QString lvls;
|
||||
QString ret;
|
||||
|
||||
for(int j=0;j<RDCatchMeterLevel::LastChannel;j++) {
|
||||
lvls+=QString::asprintf(":%04X",d_levels[j]);
|
||||
}
|
||||
ret+=QString::asprintf("%u",d_deck_channel)+lvls;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
RDCatchEvent::RDCatchEvent(RDDeck::Status status)
|
||||
{
|
||||
clear();
|
||||
@@ -157,6 +194,18 @@ void RDCatchEvent::setInputMonitorActive(bool state)
|
||||
}
|
||||
|
||||
|
||||
QList<RDCatchMeterLevel> RDCatchEvent::meterLevels() const
|
||||
{
|
||||
return d_meter_levels;
|
||||
}
|
||||
|
||||
|
||||
void RDCatchEvent::setMeterLevels(const QList<RDCatchMeterLevel> &lvls)
|
||||
{
|
||||
d_meter_levels=lvls;
|
||||
}
|
||||
|
||||
|
||||
bool RDCatchEvent::read(const QString &str)
|
||||
{
|
||||
// printf("RDCatchEvent::read(\"%s\")\n",str.toUtf8().constData());
|
||||
@@ -205,6 +254,32 @@ bool RDCatchEvent::read(const QString &str)
|
||||
}
|
||||
break;
|
||||
|
||||
case RDCatchEvent::SendMeterLevelsOp:
|
||||
for(int i=2;i<f0.size();i++) {
|
||||
QStringList f1=f0.at(i).split(":",QString::KeepEmptyParts);
|
||||
if(f1.size()==(1+RDCatchMeterLevel::LastChannel)) {
|
||||
chan=f1.at(0).toUInt(&ok);
|
||||
if(chan>=255) {
|
||||
d_meter_levels.clear();
|
||||
return false;
|
||||
}
|
||||
int16_t lvls[RDCatchMeterLevel::LastChannel];
|
||||
for(int j=0;j<RDCatchMeterLevel::LastChannel;j++) {
|
||||
int lvl=f1.at(1+j).toInt(&ok,16);
|
||||
if((!ok)||(lvl>0xFFFF)) {
|
||||
d_meter_levels.clear();
|
||||
return false;
|
||||
}
|
||||
lvls[j]=-(int16_t)lvl;
|
||||
}
|
||||
d_meter_levels.push_back(RDCatchMeterLevel(chan,lvls));
|
||||
}
|
||||
}
|
||||
d_operation=op;
|
||||
d_host_name=f0.at(1);
|
||||
return true;
|
||||
break;
|
||||
|
||||
case RDCatchEvent::DeckStatusQueryOp:
|
||||
if(f0.size()!=3) {
|
||||
return false;
|
||||
@@ -347,6 +422,12 @@ QString RDCatchEvent::write() const
|
||||
case RDCatchEvent::LastOp:
|
||||
break;
|
||||
|
||||
case RDCatchEvent::SendMeterLevelsOp:
|
||||
for(int i=0;i<d_meter_levels.size();i++) {
|
||||
ret+=" "+d_meter_levels.at(i).dump();
|
||||
}
|
||||
break;
|
||||
|
||||
case RDCatchEvent::SetInputMonitorOp:
|
||||
ret+=" "+d_target_host_name;
|
||||
ret+=QString::asprintf(" %u",d_deck_channel);
|
||||
@@ -391,6 +472,12 @@ QString RDCatchEvent::dump() const
|
||||
ret+=QString::asprintf("event number: %u\n",d_event_number);
|
||||
break;
|
||||
|
||||
case RDCatchEvent::SendMeterLevelsOp:
|
||||
for(int i=0;i<d_meter_levels.size();i++) {
|
||||
ret+="meter level: "+d_meter_levels.at(i).dump()+"\n";
|
||||
}
|
||||
break;
|
||||
|
||||
case RDCatchEvent::DeckStatusQueryOp:
|
||||
ret+="operation: RDCatchEvent::DeckStatusQueryOp\n";
|
||||
break;
|
||||
@@ -449,4 +536,5 @@ void RDCatchEvent::clear()
|
||||
d_event_number=0;
|
||||
d_input_monitor_active=false;
|
||||
d_deck_status=RDDeck::Offline;
|
||||
d_meter_levels.clear();
|
||||
}
|
||||
|
@@ -21,18 +21,36 @@
|
||||
#ifndef RDCATCHEVENT_H
|
||||
#define RDCATCHEVENT_H
|
||||
|
||||
#include <QList>
|
||||
#include <QString>
|
||||
#include <QVariant>
|
||||
|
||||
#include <rddeck.h>
|
||||
|
||||
class RDCatchMeterLevel
|
||||
{
|
||||
public:
|
||||
enum Channel {Left=0,Right=1,LastChannel=2};
|
||||
RDCatchMeterLevel(int deck,int16_t *lvls);
|
||||
unsigned deckChannel() const;
|
||||
int16_t level(Channel chan) const;
|
||||
QString dump() const;
|
||||
|
||||
private:
|
||||
unsigned d_deck_channel;
|
||||
int16_t d_levels[Channel::LastChannel];
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
class RDCatchEvent
|
||||
{
|
||||
public:
|
||||
enum Operation {NullOp=0,DeckEventProcessedOp=1,
|
||||
DeckStatusQueryOp=2,DeckStatusResponseOp=3,
|
||||
StopDeckOp=4,SetInputMonitorOp=5,SetInputMonitorResponseOp=6,
|
||||
ReloadDecksOp=7,LastOp=8};
|
||||
ReloadDecksOp=7,SendMeterLevelsOp=8,LastOp=9};
|
||||
RDCatchEvent(RDDeck::Status status);
|
||||
RDCatchEvent();
|
||||
Operation operation() const;
|
||||
@@ -55,6 +73,8 @@ class RDCatchEvent
|
||||
void setDeckStatus(RDDeck::Status status);
|
||||
bool inputMonitorActive() const;
|
||||
void setInputMonitorActive(bool state);
|
||||
QList<RDCatchMeterLevel> meterLevels() const;
|
||||
void setMeterLevels(const QList<RDCatchMeterLevel> &lvls);
|
||||
bool read(const QString &str);
|
||||
QString write() const;
|
||||
QString dump() const;
|
||||
@@ -70,6 +90,7 @@ class RDCatchEvent
|
||||
unsigned d_deck_channel;
|
||||
int d_event_number;
|
||||
bool d_input_monitor_active;
|
||||
QList<RDCatchMeterLevel> d_meter_levels;
|
||||
RDDeck::Status d_deck_status;
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user