fixed crash when switching streams

This commit is contained in:
badaix 2016-02-06 12:51:20 +01:00
parent 060e52aeee
commit 3a5af32d98
5 changed files with 14 additions and 2 deletions

View file

@ -94,14 +94,18 @@ void Controller::onMessageReceived(ClientConnection* connection, const msg::Base
headerChunk_->deserialize(baseMessage, buffer);
logO << "Codec: " << headerChunk_->codec << "\n";
decoder_.reset(nullptr);
if (headerChunk_->codec == "pcm")
decoder_.reset(new PcmDecoder());
#ifndef ANDROID
if (headerChunk_->codec == "ogg")
else if (headerChunk_->codec == "ogg")
decoder_.reset(new OggDecoder());
#endif
else if (headerChunk_->codec == "flac")
decoder_.reset(new FlacDecoder());
else
throw SnapException("codec not supported: \"" + headerChunk_->codec + "\"");
sampleFormat_ = decoder_->setHeader(headerChunk_.get());
logO << "sample rate: " << sampleFormat_.rate << "Hz\n";
logO << "bits/sample: " << sampleFormat_.bits << "\n";