diff --git a/src/AudioGeneratorTalkie.cpp b/src/AudioGeneratorTalkie.cpp index 7f1a704..da1ce8b 100644 --- a/src/AudioGeneratorTalkie.cpp +++ b/src/AudioGeneratorTalkie.cpp @@ -72,6 +72,21 @@ bool AudioGeneratorTalkie::begin(AudioFileSource *source, AudioOutput *output) { return false; } this->output = output; + + if (!output->SetBitsPerSample(16)) { + return false; + } + if (!output->SetChannels(2)) { + return false; + } + if (!output->begin()) { + return false; + } + if (!output->SetRate(8000)) { + return false; + } + + if (source) { file = source; if (!file->isOpen()) { @@ -95,20 +110,6 @@ bool AudioGeneratorTalkie::begin(AudioFileSource *source, AudioOutput *output) { running = false; } - if (!output->SetRate(8000)) { - return false; - } - if (!output->SetBitsPerSample(16)) { - return false; - } - if (!output->SetChannels(2)) { - return false; - } - if (!output->begin()) { - return false; - } - - return true; }