Update audioengine.cpp

Signed-off-by: rohithzmoi <166651631+rohithzmoi@users.noreply.github.com>
This commit is contained in:
rohithzmoi 2024-09-03 14:52:12 +05:30 committed by GitHub
parent 73e197486c
commit 44fcb5ace8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 20 additions and 9 deletions

View File

@ -1,6 +1,7 @@
/*
Copyright (C) 2019-2021 Doug McLain
Modified Copyright (C) 2024 Rohith Namboothiri
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
@ -372,29 +373,39 @@ void AudioEngine::process_audio(int16_t *pcm, size_t s)
void AudioEngine::handleStateChanged(QAudio::State newState)
{
static bool isSessionActive = false;
switch (newState) {
case QAudio::ActiveState:
qDebug() << "AudioOut state active";
setupAVAudioSession();
if (!isSessionActive) {
setupAVAudioSession();
isSessionActive = true;
}
break;
case QAudio::SuspendedState:
qDebug() << "AudioOut state suspended";
//setupBackgroundAudio();
if (isSessionActive) {
deactivateAVAudioSession();
isSessionActive = false;
}
break;
case QAudio::IdleState:
qDebug() << "AudioOut state idle";
setupBackgroundAudio();
setupBackgroundAudio();
break;
case QAudio::StoppedState:
qDebug() << "AudioOut state stopped";
if (isSessionActive) {
deactivateAVAudioSession();
isSessionActive = false;
}
break;
default:
break;
}
}