From d44e932fe3d66fd496155ad083532d56b8a5c1ab Mon Sep 17 00:00:00 2001 From: Fred Gleason Date: Thu, 21 Apr 2022 13:19:24 -0400 Subject: [PATCH] 2022-04-21 Fred Gleason * Fixed bug in the RDCatch subsystem that caused audio format parameters to be confounded between uploaded and audio store files. Signed-off-by: Fred Gleason --- ChangeLog | 4 ++ docs/tables/recordings.txt | 2 +- lib/rddeck.cpp | 8 +-- lib/rddeck.h | 5 +- lib/rdexport_settings_dialog.cpp | 2 +- rdadmin/edit_decks.cpp | 29 +++++++---- rdcatch/edit_recording.cpp | 2 + rdcatchd/batch.cpp | 18 +------ rdcatchd/catch_event.cpp | 8 +-- rdcatchd/catch_event.h | 8 +-- rdcatchd/rdcatchd.cpp | 86 ++++++++++++-------------------- rdcatchd/rdcatchd.h | 4 +- 12 files changed, 80 insertions(+), 96 deletions(-) diff --git a/ChangeLog b/ChangeLog index dd84cd7e..a976b30d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -22987,3 +22987,7 @@ * Fixed a regression in rdcatch(1) that caused the 'Sample Rate' dropdown in the 'Edit Audio Settings' dialog to always be set to '32000' regardless of the actual value in the record. +2022-04-21 Fred Gleason + * Fixed bug in the RDCatch subsystem that caused audio format + parameters to be confounded between uploaded and audio store + files. diff --git a/docs/tables/recordings.txt b/docs/tables/recordings.txt index 4719af7e..740bb4b9 100644 --- a/docs/tables/recordings.txt +++ b/docs/tables/recordings.txt @@ -45,7 +45,7 @@ NORMALIZE_LEVEL int(11) in 1/100 dBFS STARTDATE_OFFSET int(10) unsigned ENDDATE_OFFSET int(10) unsigned EVENTDATE_OFFSET int(11) -FORMAT int(11) signed 0 = PCM16, 2 = Layer 2, 3 = Layer 3 +FORMAT int(11) signed RDSettings::Format CHANNELS int(11) signed SAMPRATE int(11) signed BITRATE int(11) signed diff --git a/lib/rddeck.cpp b/lib/rddeck.cpp index 991b1e37..878d52c8 100644 --- a/lib/rddeck.cpp +++ b/lib/rddeck.cpp @@ -145,15 +145,15 @@ void RDDeck::setDefaultMonitorOn(bool state) const } -RDSettings::Format RDDeck::defaultFormat() const +RDCae::AudioCoding RDDeck::defaultFormat() const { - return (RDSettings::Format)GetIntValue("DEFAULT_FORMAT"); + return (RDCae::AudioCoding)GetIntValue("DEFAULT_FORMAT"); } -void RDDeck::setDefaultFormat(RDSettings::Format format) const +void RDDeck::setDefaultFormat(RDCae::AudioCoding coding) const { - SetRow("DEFAULT_FORMAT",(int)format); + SetRow("DEFAULT_FORMAT",(int)coding); } diff --git a/lib/rddeck.h b/lib/rddeck.h index ed0113d0..de7a06ab 100644 --- a/lib/rddeck.h +++ b/lib/rddeck.h @@ -24,6 +24,7 @@ #include #include +#include #include class RDDeck @@ -44,8 +45,8 @@ class RDDeck void setMonitorPortNumber(int port) const; bool defaultMonitorOn() const; void setDefaultMonitorOn(bool state) const; - RDSettings::Format defaultFormat() const; - void setDefaultFormat(RDSettings::Format format) const; + RDCae::AudioCoding defaultFormat() const; + void setDefaultFormat(RDCae::AudioCoding coding) const; int defaultChannels() const; void setDefaultChannels(int chan) const; int defaultBitrate() const; diff --git a/lib/rdexport_settings_dialog.cpp b/lib/rdexport_settings_dialog.cpp index ab3f60a4..a146ef86 100644 --- a/lib/rdexport_settings_dialog.cpp +++ b/lib/rdexport_settings_dialog.cpp @@ -2,7 +2,7 @@ // // Edit Audio Export Settings // -// (C) Copyright 2002-2021\2 Fred Gleason +// (C) Copyright 2002-2022 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 diff --git a/rdadmin/edit_decks.cpp b/rdadmin/edit_decks.cpp index 97bffdc8..90636e05 100644 --- a/rdadmin/edit_decks.cpp +++ b/rdadmin/edit_decks.cpp @@ -324,9 +324,12 @@ EditDecks::EditDecks(RDStation *station,RDStation *cae_station,QWidget *parent) } edit_record_channel=edit_record_deck_box->currentIndex()+1; edit_play_channel=edit_play_deck_box->currentIndex()+129; - edit_format_box->insertItem(edit_format_box->count(),tr("PCM16")); - edit_format_box->insertItem(edit_format_box->count(),tr("PCM24")); - edit_format_box->insertItem(edit_format_box->count(),tr("MPEG Layer 2")); + edit_format_box-> + insertItem(edit_format_box->count(),tr("PCM16"),RDCae::Pcm16); + edit_format_box-> + insertItem(edit_format_box->count(),tr("PCM24"),RDCae::Pcm24); + edit_format_box-> + insertItem(edit_format_box->count(),tr("MPEG Layer 2"),RDCae::MpegL2); edit_channels_box->insertItem(0,"1"); edit_channels_box->insertItem(1,"2"); edit_bitrate_box->insertItem(edit_bitrate_box->count(),tr("32 kbps/chan"),32); @@ -582,26 +585,27 @@ void EditDecks::ReadRecord(int chan) edit_default_on_box->setCurrentIndex(0); } switch(edit_record_deck->defaultFormat()) { - case RDSettings::Pcm16: + case RDCae::Pcm16: edit_format_box->setCurrentIndex(0); edit_bitrate_box->setDisabled(true); break; - case RDSettings::Pcm24: + case RDCae::Pcm24: edit_format_box->setCurrentIndex(1); edit_bitrate_box->setDisabled(true); break; - case RDSettings::MpegL2: - case RDSettings::MpegL2Wav: + case RDCae::MpegL2: + // case RDSettings::MpegL2Wav: edit_format_box->setCurrentIndex(2); edit_bitrate_box->setEnabled(true); break; - case RDSettings::MpegL1: + // case RDSettings::MpegL1: + case RDCae::MpegL1: case RDSettings::MpegL3: - case RDSettings::Flac: - case RDSettings::OggVorbis: + // case RDSettings::Flac: + // case RDSettings::OggVorbis: break; } edit_channels_box->setCurrentIndex(edit_record_deck->defaultChannels()-1); @@ -725,6 +729,7 @@ void EditDecks::WriteRecord(int chan) edit_record_deck->setDefaultMonitorOn(true); } } + /* switch(edit_format_box->currentIndex()) { case 0: edit_record_deck->setDefaultFormat(RDSettings::Pcm16); @@ -738,6 +743,10 @@ void EditDecks::WriteRecord(int chan) edit_record_deck->setDefaultFormat(RDSettings::MpegL2); break; } + */ + edit_record_deck-> + setDefaultFormat((RDCae::AudioCoding)edit_format_box-> + itemData(edit_format_box->currentIndex()).toInt()); edit_record_deck->setDefaultChannels(edit_channels_box->currentIndex()+1); edit_record_deck->setDefaultBitrate(1000*edit_bitrate_box-> itemData(edit_bitrate_box->currentIndex()).toInt()); diff --git a/rdcatch/edit_recording.cpp b/rdcatch/edit_recording.cpp index 5e729497..839f3ac5 100644 --- a/rdcatch/edit_recording.cpp +++ b/rdcatch/edit_recording.cpp @@ -809,6 +809,7 @@ void EditRecording::Save() edit_recording->setSwitchSource(GetSource()); edit_recording->setStartdateOffset(edit_startoffset_box->value()); edit_recording->setEnddateOffset(edit_endoffset_box->value()); + /* edit_recording->setFormat(edit_deck->defaultFormat()); if(edit_deck->defaultFormat()>0) { edit_recording->setBitrate(edit_deck->defaultBitrate()* @@ -817,6 +818,7 @@ void EditRecording::Save() else { edit_recording->setBitrate(0); } + */ edit_recording->setChannels(edit_channels_box->currentIndex()+1); if(edit_autotrim_box->isChecked()) { edit_recording->setTrimThreshold(-100*edit_autotrim_spin->value()); diff --git a/rdcatchd/batch.cpp b/rdcatchd/batch.cpp index 31005218..7e41cf1b 100644 --- a/rdcatchd/batch.cpp +++ b/rdcatchd/batch.cpp @@ -2,7 +2,7 @@ // // Batch Routines for the Rivendell netcatcher daemon // -// (C) Copyright 2002-2021 Fred Gleason +// (C) Copyright 2002-2022 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 @@ -481,21 +481,7 @@ bool MainObject::Import(CatchEvent *evt) conv->setSourceFile(RDEscapeString(evt->tempName())); conv->setDestinationFile(RDCut::pathName(evt->cutName())); RDSettings *settings=new RDSettings(); - switch(evt->format()) { - case RDCae::Pcm16: - settings->setFormat(RDSettings::Pcm16); - break; - - case RDCae::Pcm24: - settings->setFormat(RDSettings::Pcm24); - break; - - case RDCae::MpegL1: - case RDCae::MpegL2: - case RDCae::MpegL3: - settings->setFormat(RDSettings::MpegL2Wav); - break; - } + settings->setFormat(evt->format()); settings->setChannels(evt->channels()); settings->setSampleRate(rda->system()->sampleRate()); settings->setBitRate(evt->bitrate()); diff --git a/rdcatchd/catch_event.cpp b/rdcatchd/catch_event.cpp index d62d255a..73c07f36 100644 --- a/rdcatchd/catch_event.cpp +++ b/rdcatchd/catch_event.cpp @@ -2,7 +2,7 @@ // // A container class for a Rivendell netcatch event. // -// (C) Copyright 2002-2004,2016 Fred Gleason +// (C) Copyright 2002-2022 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 @@ -354,13 +354,13 @@ void CatchEvent::setEnddateOffset(unsigned offset) } -RDCae::AudioCoding CatchEvent::format() const +RDSettings::Format CatchEvent::format() const { return catch_format; } -void CatchEvent::setFormat(RDCae::AudioCoding fmt) +void CatchEvent::setFormat(RDSettings::Format fmt) { catch_format=fmt; } @@ -694,7 +694,7 @@ void CatchEvent::clear() catch_trim_threshold=0; catch_startdate_offset=0; catch_enddate_offset=0; - catch_format=RDCae::Pcm16; + catch_format=RDSettings::Pcm16; catch_channels=0; catch_samplerate=0; catch_bitrate=0; diff --git a/rdcatchd/catch_event.h b/rdcatchd/catch_event.h index 4dd4b19a..49700872 100644 --- a/rdcatchd/catch_event.h +++ b/rdcatchd/catch_event.h @@ -2,7 +2,7 @@ // // A container class for a Rivendell netcatch event. // -// (C) Copyright 2002-2004,2016 Fred Gleason +// (C) Copyright 2002-2022 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 @@ -87,8 +87,8 @@ class CatchEvent void setStartdateOffset(unsigned offset); unsigned enddateOffset() const; void setEnddateOffset(unsigned offset); - RDCae::AudioCoding format() const; - void setFormat(RDCae::AudioCoding fmt); + RDSettings::Format format() const; + void setFormat(RDSettings::Format fmt); int channels() const; void setChannels(int chans); int sampleRate() const; @@ -166,7 +166,7 @@ class CatchEvent unsigned catch_trim_threshold; unsigned catch_startdate_offset; unsigned catch_enddate_offset; - RDCae::AudioCoding catch_format; + RDSettings::Format catch_format; int catch_channels; int catch_samplerate; int catch_bitrate; diff --git a/rdcatchd/rdcatchd.cpp b/rdcatchd/rdcatchd.cpp index 0095187c..0a295140 100644 --- a/rdcatchd/rdcatchd.cpp +++ b/rdcatchd/rdcatchd.cpp @@ -2,7 +2,7 @@ // // The Rivendell Netcatcher Daemon // -// (C) Copyright 2002-2021 Fred Gleason +// (C) Copyright 2002-2022 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 @@ -639,31 +639,34 @@ void MainObject::engineData(int id) sql=QString("select ")+ "`CARD_NUMBER`,"+ // 00 "`PORT_NUMBER`,"+ // 01 - "`SWITCH_STATION`,"+ // 02 - "`SWITCH_MATRIX`,"+ // 03 - "`SWITCH_OUTPUT`,"+ // 04 - "`SWITCH_DELAY` "+ // 05 + "`DEFAULT_FORMAT`,"+ // 02 + "`DEFAULT_BITRATE`," // 03 + "`SWITCH_STATION`,"+ // 04 + "`SWITCH_MATRIX`,"+ // 05 + "`SWITCH_OUTPUT`,"+ // 06 + "`SWITCH_DELAY` "+ // 07 "from `DECKS` where "+ "(`STATION_NAME`='"+RDEscapeString(rda->config()->stationName())+"')&&"+ QString::asprintf("(`CHANNEL`=%d)",catch_events[event].channel()); q=new RDSqlQuery(sql); if(q->first()) { - catch_record_card[catch_events[event].channel()-1]= - q->value(0).toInt(); - catch_record_stream[catch_events[event].channel()-1]= - q->value(1).toInt(); - if(q->value(2).toString()==QString("[none]")) { + catch_record_card[catch_events[event].channel()-1]=q->value(0).toInt(); + catch_record_stream[catch_events[event].channel()-1]=q->value(1).toInt(); + catch_record_coding[catch_events[event].channel()-1]= + (RDCae::AudioCoding)q->value(2).toInt(); + catch_record_bitrate[catch_events[event].channel()-1]=q->value(3).toInt(); + if(q->value(4).toString()==QString("[none]")) { catch_swaddress[catch_events[event].channel()-1]=QHostAddress(); } else { - rdstation=new RDStation(q->value(2).toString()); + rdstation=new RDStation(q->value(4).toString()); catch_swaddress[catch_events[event].channel()-1]= rdstation->address(); delete rdstation; } - catch_swmatrix[catch_events[event].channel()-1]=q->value(3).toInt(); - catch_swoutput[catch_events[event].channel()-1]=q->value(4).toInt(); - catch_swdelay[catch_events[event].channel()-1]=q->value(5).toInt(); + catch_swmatrix[catch_events[event].channel()-1]=q->value(5).toInt(); + catch_swoutput[catch_events[event].channel()-1]=q->value(6).toInt(); + catch_swdelay[catch_events[event].channel()-1]=q->value(7).toInt(); } else { rda->syslog(LOG_INFO,"id %d specified non-existent record deck, ignored", @@ -1282,7 +1285,6 @@ bool MainObject::StartRecording(int event) // // Set Temp Name // - RDCae::AudioCoding format=catch_events[event].format(); QString cut_name; if(catch_events[event].normalizeLevel()==0) { cut_name=catch_events[event].cutName(); @@ -1292,19 +1294,19 @@ bool MainObject::StartRecording(int event) catch_events[event]. setTempName(GetTempRecordingName(catch_events[event].id())); catch_events[event].setDeleteTempFile(true); - format=RDCae::Pcm24; } // // Start the recording // rda->cae()->loadRecord(catch_record_card[deck-1], - catch_record_stream[deck-1], - cut_name, - format, - catch_events[event].channels(), - catch_events[event].sampleRate(), - catch_events[event].bitrate()); + catch_record_stream[deck-1], + cut_name, + catch_record_coding[deck-1], + catch_events[event].channels(), + rda->system()->sampleRate(), + // catch_events[event].bitrate()); + catch_record_bitrate[deck-1]); rda->cae()->record(catch_record_card[deck-1],catch_record_stream[deck-1], length,0); catch_events[event].setStatus(RDDeck::Recording); @@ -1344,7 +1346,7 @@ bool MainObject::StartRecording(int event) break; } cut->setChannels(catch_events[event].channels()); - cut->setSampleRate(catch_events[event].sampleRate()); + cut->setSampleRate(rda->system()->sampleRate()); cut->setBitRate(catch_events[event].bitrate()); cut->setPlayCounter(0); cut->setSegueStartPoint(-1); @@ -1923,29 +1925,7 @@ void MainObject::LoadEvent(RDSqlQuery *q,CatchEvent *e,bool add) e->setTrimThreshold(q->value(16).toUInt()); e->setStartdateOffset(q->value(17).toUInt()); e->setEnddateOffset(q->value(18).toUInt()); - switch((RDSettings::Format)q->value(19).toInt()) { - case RDSettings::Pcm16: - e->setFormat(RDCae::Pcm16); - break; - - case RDSettings::Pcm24: - e->setFormat(RDCae::Pcm24); - break; - - case RDSettings::MpegL2: - case RDSettings::MpegL2Wav: - e->setFormat(RDCae::MpegL2); - break; - - case RDSettings::MpegL3: - e->setFormat(RDCae::MpegL3); - break; - - case RDSettings::MpegL1: - case RDSettings::Flac: - case RDSettings::OggVorbis: - break; - } + e->setFormat((RDSettings::Format)q->value(19).toInt()); e->setChannels(q->value(20).toInt()); e->setSampleRate(q->value(21).toUInt()); e->setBitrate(q->value(22).toInt()); @@ -2011,7 +1991,9 @@ void MainObject::LoadDeckList() "`CHANNEL`,"+ // 00 "`CARD_NUMBER`,"+ // 01 "`PORT_NUMBER`,"+ // 02 - "`MON_PORT_NUMBER` "+ // 03 + "`MON_PORT_NUMBER`,"+ // 03 + "`DEFAULT_FORMAT`,"+ // 04 + "`DEFAULT_BITRATE` " // 05 "from `DECKS` where "+ "(`STATION_NAME`='"+RDEscapeString(rda->config()->stationName())+"')&&"+ "(`CARD_NUMBER`!=-1)&&(`CHANNEL`>0)&&(`CHANNEL`<9)"; @@ -2021,6 +2003,9 @@ void MainObject::LoadDeckList() catch_record_card[q->value(0).toUInt()-1]=q->value(1).toInt(); catch_record_stream[q->value(0).toUInt()-1]=q->value(2).toInt(); catch_monitor_port[q->value(0).toUInt()-1]=q->value(3).toInt(); + catch_record_coding[q->value(0).toUInt()-1]= + (RDCae::AudioCoding)q->value(4).toInt(); + catch_record_bitrate[q->value(0).toInt()-1]=q->value(5).toInt(); } delete q; for(int i=0;isetFormat((RDSettings::Format)evt->format()); - s->setSampleRate(evt->sampleRate()); + s->setSampleRate(rda->system()->sampleRate()); s->setBitRate(evt->bitrate()); s->setChannels(evt->channels()); cut->checkInRecording(rda->config()->stationName(),"", @@ -2552,11 +2536,7 @@ void MainObject::StartRmlRecording(int chan,int cartnum,int cutnum,int maxlen) catch_events.back().setStartTime(dt.time()); catch_events.back().setEndType(RDRecording::LengthEnd); catch_events.back().setLength(maxlen); - catch_events.back(). - setFormat((RDCae::AudioCoding)deck->defaultFormat()); catch_events.back().setChannels(deck->defaultChannels()); - catch_events.back().setSampleRate(rda->system()->sampleRate()); - catch_events.back().setBitrate(deck->defaultBitrate()); catch_events.back().setNormalizeLevel(0); StartRecording(catch_events.size()-1); delete cut; diff --git a/rdcatchd/rdcatchd.h b/rdcatchd/rdcatchd.h index c6862f4e..52eeb94f 100644 --- a/rdcatchd/rdcatchd.h +++ b/rdcatchd/rdcatchd.h @@ -2,7 +2,7 @@ // // The Rivendell Netcatcher. // -// (C) Copyright 2002-2021 Fred Gleason +// (C) Copyright 2002-2022 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 @@ -202,6 +202,8 @@ class MainObject : public QObject bool catch_record_status[MAX_DECKS]; int catch_record_card[MAX_DECKS]; int catch_record_stream[MAX_DECKS]; + RDCae::AudioCoding catch_record_coding[MAX_DECKS]; + int catch_record_bitrate[MAX_DECKS]; RDDeck::Status catch_record_deck_status[MAX_DECKS]; int catch_record_id[MAX_DECKS]; QString catch_record_name[MAX_DECKS];