~aleteoryx/muditaos

d1d311c4c547784882789a92f3f8bb5115da1ea5 — Lefucjusz 4 years ago 3454dad
[MOS-331] Fix audio resuming after headset unplugging

Fix of the audio playback bug, which
prevented playback resuming after
unplugging the headset when playback
was paused.
1 files changed, 8 insertions(+), 3 deletions(-)

M module-audio/Audio/Operation/PlaybackOperation.cpp
M module-audio/Audio/Operation/PlaybackOperation.cpp => module-audio/Audio/Operation/PlaybackOperation.cpp +8 -3
@@ 1,4 1,4 @@
// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#include "PlaybackOperation.hpp"


@@ 47,7 47,7 @@ namespace audio

    audio::RetCode PlaybackOperation::Start(audio::Token token)
    {
        if (state == State::Active || state == State::Paused) {
        if (state == State::Active || (state == State::Paused && outputConnection != nullptr)) {
            return RetCode::InvokedInIncorrectState;
        }



@@ 108,9 108,14 @@ namespace audio

    audio::RetCode PlaybackOperation::Resume()
    {
        if (state == State::Active || state == State::Idle || outputConnection == nullptr) {
        if (state == State::Active || state == State::Idle) {
            return RetCode::InvokedInIncorrectState;
        }

        if (outputConnection == nullptr) {
            Start(operationToken);
        }

        state = State::Active;
        outputConnection->enable();
        return GetDeviceError(audioDevice->Resume());