From c393740b0a8cba7edfd6032ec7165a496b7a91b8 Mon Sep 17 00:00:00 2001 From: Bill Somerville Date: Sat, 11 May 2019 01:57:56 +0100 Subject: [PATCH] Fix an off by error --- Audio/tools/record_time_signal.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Audio/tools/record_time_signal.cpp b/Audio/tools/record_time_signal.cpp index 8cd4f8ee1..c128e34ff 100644 --- a/Audio/tools/record_time_signal.cpp +++ b/Audio/tools/record_time_signal.cpp @@ -112,10 +112,10 @@ public: sink_.setNotifyInterval (notify_interval); connect (&sink_, &QAudioOutput::notify, this, &Playback::notify); } + connect (&sink_, &QAudioOutput::stateChanged, this, &Playback::sink_state_changed); if (start == -1) { start_playback (); - } else { @@ -136,7 +136,6 @@ private: qtout << "started playback at " << QDateTime::currentDateTimeUtc ().toString ("hh:mm:ss.zzz UTC") << endl; sink_.start (input_); qtout << QString {"buffer size used is: %1 (%2 frames)"}.arg (sink_.bufferSize ()).arg (sink_.format ().framesForBytes (sink_.bufferSize ())) << endl; - connect (&sink_, &QAudioOutput::stateChanged, this, &Playback::sink_state_changed); } Q_SLOT void notify () @@ -160,6 +159,7 @@ private: break; case QAudio::IdleState: stop_playback (); + qtout << "\naudio output state changed to idle\n"; break; #if QT_VERSION >= QT_VERSION_CHECK (5, 10, 0) case QAudio::InterruptedState: @@ -276,6 +276,7 @@ int main(int argc, char *argv[]) { start = parser.value ("s").toInt (&ok); if (!ok) throw std::invalid_argument {"start time not a number"}; + if (0 > start || start > 59) throw std::invalid_argument {"0 > start > 59"}; } int sample_rate {48000}; if (parser.isSet ("r")) @@ -344,7 +345,7 @@ int main(int argc, char *argv[]) audio_format.setSampleType (QAudioFormat::SignedInt); audio_format.setCodec ("audio/pcm"); - auto source = input_device ? input_devices[input_device] : QAudioDeviceInfo::defaultInputDevice (); + auto source = input_device ? input_devices[input_device - 1] : QAudioDeviceInfo::defaultInputDevice (); if (!source.isFormatSupported (audio_format)) { qtout << "warning, requested format not supported, using nearest" << endl; @@ -367,7 +368,7 @@ int main(int argc, char *argv[]) } BWFFile input_file {audio_format, ifi.filePath ()}; if (!input_file.open (BWFFile::ReadOnly)) throw std::invalid_argument {QString {"cannot open input file \"%1\""}.arg (ifi.filePath ()).toStdString ()}; - auto sink = output_device ? output_devices[output_device] : QAudioDeviceInfo::defaultOutputDevice (); + auto sink = output_device ? output_devices[output_device - 1] : QAudioDeviceInfo::defaultOutputDevice (); if (!sink.isFormatSupported (input_file.format ())) { throw std::invalid_argument {"audio output device does not support input file audio format"};