1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-09-27 15:26:33 -04:00

Audio UDP/RTP: Opus: delete and re-create encoder state when changing its parameters

This commit is contained in:
f4exb 2019-02-19 08:41:23 +01:00
parent bd48a2feb5
commit 765ee4a8ba

View File

@ -45,16 +45,12 @@ void AudioOpus::setEncoder(int32_t fs, int nChannels)
bool newInstance = true;
QMutexLocker mutexLocker(&m_mutex);
if (m_encoderState)
{
error = opus_encoder_init(m_encoderState, fs, nChannels, OPUS_APPLICATION_AUDIO);
newInstance = false;
}
else
{
m_encoderState = opus_encoder_create(fs, nChannels, OPUS_APPLICATION_AUDIO, &error);
if (m_encoderState) {
opus_encoder_destroy(m_encoderState);
}
m_encoderState = opus_encoder_create(fs, nChannels, OPUS_APPLICATION_AUDIO, &error);
if (error != OPUS_OK)
{
qWarning("AudioOpus::setEncoder: %s error: %s", newInstance ? "create" : "init", opus_strerror(error));