Fix an off by error

This commit is contained in:
Bill Somerville 2019-05-11 01:57:56 +01:00
parent 8d6c7649e0
commit c393740b0a

View File

@ -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"};