Fixed on-demand transcoding.

This commit is contained in:
casey langen 2020-10-21 10:54:35 -07:00
parent 24e4680bde
commit a844b31819
2 changed files with 3 additions and 4 deletions

View File

@ -59,7 +59,6 @@ TranscodingAudioDataStream::TranscodingAudioDataStream(
this->bitrate = bitrate;
this->interrupted = false;
this->eof = false;
this->encoder = nullptr;
this->outFile = nullptr;
this->detachTolerance = 0;
this->format = format;
@ -196,10 +195,10 @@ PositionType TranscodingAudioDataStream::Read(void *buffer, PositionType bytesTo
bool hasBuffer = false;
/* init */
if (this->decoder && !this->encoder) {
if (!this->encoderInitialized) {
hasBuffer = this->decoder->GetBuffer(this->pcmBuffer);
if (hasBuffer) {
this->encoder->Initialize(
this->encoderInitialized = this->encoder->Initialize(
this->pcmBuffer->SampleRate(),
this->pcmBuffer->Channels(),
this->bitrate);

View File

@ -98,6 +98,6 @@ class TranscodingAudioDataStream : public musik::core::sdk::IDataStream {
FILE* outFile;
std::string tempFilename, finalFilename;
std::string format;
bool interrupted;
bool interrupted{ false }, encoderInitialized{ false };
long detachTolerance;
};