Skip to content
Snippets Groups Projects
Commit beac042f authored by Kateryna Kostiuk's avatar Kateryna Kostiuk Committed by Kateryna Kostiuk
Browse files

core layer: do not destroy stream when in use

When we stop playback stream we should check current audio category.
If it is AVAudioSessionCategoryPlayAndRecord it is means we also have
capture stream running and we should not destroy it.

Change-Id: I4cc0f2ddcd8b26840f4b2968a890c4803c187448
parent 48f10e20
No related branches found
No related tags found
No related merge requests found
......@@ -145,7 +145,6 @@ CoreLayer::initAudioLayerIO(AudioDeviceType stream)
default:
break;
}
setupOutputBus();
if (setUpInput) {
setupInputBus();
......@@ -327,9 +326,9 @@ CoreLayer::startStream(AudioDeviceType stream)
{
dispatch_async(audioConfigurationQueueIOS(), ^{
JAMI_DBG("iOS CoreLayer - Start Stream");
auto currentCategoty = [[AVAudioSession sharedInstance] category];
auto currentCategory = [[AVAudioSession sharedInstance] category];
bool updateStream = currentCategoty == AVAudioSessionCategoryPlayback && (stream == AudioDeviceType::CAPTURE || stream == AudioDeviceType::ALL);
bool updateStream = currentCategory == AVAudioSessionCategoryPlayback && (stream == AudioDeviceType::CAPTURE || stream == AudioDeviceType::ALL);
if (status_ == Status::Started) {
if (updateStream)
destroyAudioLayer();
......@@ -349,6 +348,7 @@ CoreLayer::startStream(AudioDeviceType stream)
void
CoreLayer::destroyAudioLayer()
{
JAMI_DBG("iOS CoreLayer - destroy Audio layer");
AudioOutputUnitStop(ioUnit_);
AudioUnitUninitialize(ioUnit_);
AudioComponentInstanceDispose(ioUnit_);
......@@ -360,7 +360,9 @@ CoreLayer::stopStream(AudioDeviceType stream)
{
dispatch_async(audioConfigurationQueueIOS(), ^{
JAMI_DBG("iOS CoreLayer - Stop Stream");
if (status_ != Status::Started)
auto currentCategory = [[AVAudioSession sharedInstance] category];
bool keepCurrentStream = currentCategory == AVAudioSessionCategoryPlayAndRecord && (stream == AudioDeviceType::PLAYBACK);
if (status_ != Status::Started || keepCurrentStream)
return;
status_ = Status::Idle;
destroyAudioLayer();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment