2021-07-02 Fred Gleason <fredg@paravelsystems.com>

* Added an 'AUDIO_INPUTS.LABEL' field to the database.
	* Added an 'AUDIO_OUTPUTS.LABEL' field to the database.
	* Incremented the database version to 350.
	* Added 'RDAudioPort::inputPortLabel()',
	'RDAudioPort::setInputPortLabel()' 'RDAudioPort::outputPortLabel()'
	and 'RDAudioPort::setOutputPortLabel()' methods.
	* Added 'Label' fields to the 'Input Port' and 'Output Port'
	sections of the 'Edit Audio Ports' dialog in rdadmin(1).
	* Added code to rdairplay(1) to use port labels on audio meters.

Signed-off-by: Fred Gleason <fredg@paravelsystems.com>
This commit is contained in:
Fred Gleason
2021-07-02 20:00:39 -04:00
parent bff832664d
commit 21d35faa50
16 changed files with 280 additions and 70 deletions

View File

@@ -24,7 +24,7 @@
/*
* Current Database Version
*/
#define RD_VERSION_DATABASE 349
#define RD_VERSION_DATABASE 350
#endif // DBVERSION_H

View File

@@ -83,6 +83,30 @@ void RDAirPlayConf::setPort(RDAirPlayConf::Channel chan,int port) const
}
QString RDAirPlayConf::portLabel(RDAirPlayConf::Channel chan) const
{
QString ret="??";
QString sql;
RDSqlQuery *q=NULL;
sql=QString("select ")+
"`AUDIO_OUTPUTS`.`LABEL` "+ // 00
"from `RDAIRPLAY_CHANNELS` left join `AUDIO_OUTPUTS` "+
"on `RDAIRPLAY_CHANNELS`.`PORT`=`AUDIO_OUTPUTS`.`PORT_NUMBER` where "+
"`AUDIO_OUTPUTS`.`STATION_NAME`='"+RDEscapeString(air_station)+"' && "+
"`AUDIO_OUTPUTS`.`CARD_NUMBER`=`RDAIRPLAY_CHANNELS`.`CARD` && "+
"`AUDIO_OUTPUTS`.`PORT_NUMBER`=`RDAIRPLAY_CHANNELS`.`PORT` && "+
QString().sprintf("`RDAIRPLAY_CHANNELS`.`INSTANCE`=%u",chan);
q=new RDSqlQuery(sql);
if(q->first()) {
ret=q->value(0).toString();
}
delete q;
return ret;
}
QString RDAirPlayConf::startRml(RDAirPlayConf::Channel chan) const
{
return GetChannelValue("START_RML",chan).toString();

View File

@@ -52,6 +52,7 @@ class RDAirPlayConf
void setCard(Channel chan,int card) const;
int port(Channel chan) const;
void setPort(Channel chan,int port) const;
QString portLabel(Channel chan) const;
QString startRml(Channel chan) const;
void setStartRml(Channel chan,QString str) const;
QString stopRml(Channel chan) const;

View File

@@ -44,7 +44,8 @@ RDAudioPort::RDAudioPort(QString station,int card)
"`PORT_NUMBER`,"+ // 00
"`LEVEL`,"+ // 01
"`TYPE`,"+ // 02
"`MODE` "+ // 03
"`MODE`,"+ // 03
"`LABEL` "+ // 04
"from `AUDIO_INPUTS` where "+
"`STATION_NAME`='"+RDEscapeString(port_station)+"' && "+
QString().sprintf("`CARD_NUMBER`=%d",port_card);
@@ -55,18 +56,21 @@ RDAudioPort::RDAudioPort(QString station,int card)
(RDAudioPort::PortType)q->value(2).toInt();
audio_input_port_mode[q->value(0).toInt()]=
(RDCae::ChannelMode)q->value(3).toInt();
audio_input_port_labels[q->value(0).toInt()]=q->value(4).toString();
}
delete q;
sql=QString("select ")+
"`PORT_NUMBER`,"+ // 00
"`LEVEL` "+ // 01
"`LEVEL`,"+ // 01
"`LABEL` "+ // 02
"from `AUDIO_OUTPUTS` where "+
"`STATION_NAME`='"+RDEscapeString(port_station)+"' && "+
QString().sprintf("`CARD_NUMBER`=%d",port_card);
q=new RDSqlQuery(sql);
while(q->next()) {
audio_output_port_level[q->value(0).toInt()]=q->value(1).toInt();
audio_output_port_labels[q->value(0).toInt()]=q->value(2).toString();
}
delete q;
}
@@ -110,6 +114,31 @@ void RDAudioPort::setClockSource(RDCae::ClockSource src)
}
QString RDAudioPort::inputPortLabel(int port) const
{
if(port<0||port>RD_MAX_PORTS) {
return QObject::tr("ERR");
}
return audio_input_port_labels[port];
}
void RDAudioPort::setInputPortLabel(int port,const QString &str)
{
if(port<0||port>RD_MAX_PORTS) {
return;
}
audio_input_port_labels[port]=str;
QString sql=QString("update `AUDIO_INPUTS` set ")+
"`LABEL`='"+RDEscapeString(str)+"' where "+
"`STATION_NAME`='"+RDEscapeString(port_station)+"' && "+
QString().sprintf("`CARD_NUMBER`=%d && ",port_card)+
QString().sprintf("`PORT_NUMBER`=%d",port);
RDSqlQuery::apply(sql);
}
RDAudioPort::PortType RDAudioPort::inputPortType(int port)
{
if(port<0||port>RD_MAX_PORTS) {
@@ -188,6 +217,31 @@ void RDAudioPort::setInputPortLevel(int port,int level)
}
QString RDAudioPort::outputPortLabel(int port) const
{
if(port<0||port>RD_MAX_PORTS) {
return QObject::tr("ERR");
}
return audio_output_port_labels[port];
}
void RDAudioPort::setOutputPortLabel(int port,const QString &str)
{
if(port<0||port>RD_MAX_PORTS) {
return;
}
audio_output_port_labels[port]=str;
QString sql=QString("update `AUDIO_OUTPUTS` set ")+
"`LABEL`='"+RDEscapeString(str)+"' where "+
"`STATION_NAME`='"+RDEscapeString(port_station)+"' && "+
QString().sprintf("`CARD_NUMBER`=%d && ",port_card)+
QString().sprintf("`PORT_NUMBER`=%d",port);
RDSqlQuery::apply(sql);
}
int RDAudioPort::outputPortLevel(int port)
{
if(port<0||port>RD_MAX_PORTS) {

View File

@@ -26,30 +26,36 @@
class RDAudioPort
{
public:
enum PortType {Analog=0,AesEbu=1,SpDiff=2};
RDAudioPort(QString station,int card);
QString station() const;
int card() const;
RDCae::ClockSource clockSource();
void setClockSource(RDCae::ClockSource src);
RDAudioPort::PortType inputPortType(int port);
void setInputPortType(int port,RDAudioPort::PortType type);
RDCae::ChannelMode inputPortMode(int port);
void setInputPortMode(int port,RDCae::ChannelMode mode);
int inputPortLevel(int port);
void setInputPortLevel(int port,int level);
int outputPortLevel(int port);
void setOutputPortLevel(int port,int level);
public:
enum PortType {Analog=0,AesEbu=1,SpDiff=2};
RDAudioPort(QString station,int card);
QString station() const;
int card() const;
RDCae::ClockSource clockSource();
void setClockSource(RDCae::ClockSource src);
QString inputPortLabel(int port) const;
void setInputPortLabel(int port,const QString &str);
RDAudioPort::PortType inputPortType(int port);
void setInputPortType(int port,RDAudioPort::PortType type);
RDCae::ChannelMode inputPortMode(int port);
void setInputPortMode(int port,RDCae::ChannelMode mode);
int inputPortLevel(int port);
void setInputPortLevel(int port,int level);
QString outputPortLabel(int port) const;
void setOutputPortLabel(int port,const QString &str);
int outputPortLevel(int port);
void setOutputPortLevel(int port,int level);
private:
QString port_station;
int port_card;
int audio_input_port_level[RD_MAX_PORTS];
int audio_output_port_level[RD_MAX_PORTS];
RDAudioPort::PortType audio_input_port_type[RD_MAX_PORTS];
RDCae::ChannelMode audio_input_port_mode[RD_MAX_PORTS];
private:
QString port_station;
int port_card;
QString audio_input_port_labels[RD_MAX_PORTS];
int audio_input_port_level[RD_MAX_PORTS];
RDAudioPort::PortType audio_input_port_type[RD_MAX_PORTS];
RDCae::ChannelMode audio_input_port_mode[RD_MAX_PORTS];
int audio_output_port_level[RD_MAX_PORTS];
QString audio_output_port_labels[RD_MAX_PORTS];
};
#endif
#endif // RDAUDIO_PORT_H