OpenAL: fix disconnect audio nodes

This commit is contained in:
Gerasim Troeglazov
2021-02-27 23:58:00 +10:00
parent 884a119a70
commit 7ec9befe2f
2 changed files with 132 additions and 1 deletions

View File

@@ -8,7 +8,7 @@ HOMEPAGE="https://kcat.strangesoft.net/openal.html"
COPYRIGHT="1999-2000 Loki Software
2005-2021 OpenAL Soft team"
LICENSE="GNU LGPL v2.1"
REVISION="2"
REVISION="3"
SOURCE_URI="https://www.openal-soft.org/openal-releases/openal-soft-$portVersion.tar.bz2"
CHECKSUM_SHA256="c8ad767e9a3230df66756a21cc8ebf218a9d47288f2514014832204e666af5d8"
SOURCE_DIR="openal-soft-$portVersion"

View File

@@ -689,3 +689,134 @@ index 0052a64..0159c0e 100644
--
2.30.0
From 46088757c5fddd671e2b1d7c79ca8e02075e62e4 Mon Sep 17 00:00:00 2001
From: Gerasim Troeglazov <3dEyes@gmail.com>
Date: Sat, 27 Feb 2021 23:49:01 +1000
Subject: Move create/delete BSoundPlayer to play()/stop() funcs
diff --git a/alc/backends/haiku.cpp b/alc/backends/haiku.cpp
index 0159c0e..08ebf48 100644
--- a/alc/backends/haiku.cpp
+++ b/alc/backends/haiku.cpp
@@ -73,18 +73,15 @@ struct HaikuPlayback final : public BackendBase {
void stop() override;
BSoundPlayer *haikuSoundPlayer{0u};
+ BString processName;
+ media_raw_audio_format format;
DEF_NEWDEL(HaikuPlayback)
};
HaikuPlayback::~HaikuPlayback()
{
- if(haikuSoundPlayer) {
- haikuSoundPlayer->SetHasData(false);
- haikuSoundPlayer->Stop();
- delete haikuSoundPlayer;
- }
- haikuSoundPlayer = 0;
+ stop();
}
void HaikuPlayback::audioCallback(void *stream, size_t len) noexcept
@@ -102,7 +99,14 @@ void HaikuPlayback::open(const char *name)
name};
}
- media_raw_audio_format format = {
+ processName.SetTo(defualtProcessName);
+ app_info appInfo;
+ if (be_app->GetAppInfo(&appInfo) == B_OK) {
+ BPath path(&appInfo.ref);
+ processName.SetTo(path.Leaf());
+ }
+
+ format = {
static_cast<float>(mDevice->Frequency),
mDevice->channelsFromFmt(),
media_raw_audio_format::B_AUDIO_SHORT,
@@ -143,17 +147,6 @@ void HaikuPlayback::open(const char *name)
format.buffer_size = mDevice->UpdateSize * mDevice->frameSizeFromFmt();
- BString processName(defualtProcessName);
- app_info appInfo;
- if (be_app->GetAppInfo(&appInfo) == B_OK) {
- BPath path(&appInfo.ref);
- processName.SetTo(path.Leaf());
- }
-
- haikuSoundPlayer = new BSoundPlayer(&format, processName.String(), audioCallbackC, NULL, static_cast<void*>(this));
- if(haikuSoundPlayer->InitCheck() != B_OK)
- throw al::backend_exception{al::backend_error::NoDevice, "Failed to create BSoundPlayer"};
-
mDevice->DeviceName = name;
}
@@ -165,10 +158,15 @@ bool HaikuPlayback::reset()
void HaikuPlayback::start()
{
- if(haikuSoundPlayer) {
- haikuSoundPlayer->Start();
- haikuSoundPlayer->SetHasData(true);
- }
+ if (haikuSoundPlayer)
+ stop();
+
+ haikuSoundPlayer = new BSoundPlayer(&format, processName.String(), audioCallbackC, NULL, static_cast<void*>(this));
+ if(haikuSoundPlayer->InitCheck() != B_OK)
+ throw al::backend_exception{al::backend_error::NoDevice, "Failed to create BSoundPlayer"};
+
+ haikuSoundPlayer->Start();
+ haikuSoundPlayer->SetHasData(true);
}
void HaikuPlayback::stop()
@@ -176,7 +174,9 @@ void HaikuPlayback::stop()
if(haikuSoundPlayer) {
haikuSoundPlayer->SetHasData(false);
haikuSoundPlayer->Stop();
+ delete haikuSoundPlayer;
}
+ haikuSoundPlayer = 0;
}
struct HaikuCapture final : public BackendBase {
@@ -212,6 +212,7 @@ struct HaikuCapture final : public BackendBase {
bool isRecording{false};
+ BString processName;
BMediaRoster *fRoster{0u};
BMediaRecorder *fRecorder{0u};
media_format fRecordFormat;
@@ -274,6 +275,13 @@ void HaikuCapture::open(const char *name)
name};
}
+ processName.SetTo(defualtProcessName);
+ app_info appInfo;
+ if (be_app->GetAppInfo(&appInfo) == B_OK) {
+ BPath path(&appInfo.ref);
+ processName.SetTo(path.Leaf());
+ }
+
status_t error;
fRoster = BMediaRoster::Roster(&error);
@@ -288,7 +296,7 @@ void HaikuCapture::open(const char *name)
if (error < B_OK)
throw al::backend_exception{al::backend_error::NoDevice, "Failed to open audio mixer"};
- fRecorder = new BMediaRecorder(defualtProcessName, B_MEDIA_RAW_AUDIO);
+ fRecorder = new BMediaRecorder(processName, B_MEDIA_RAW_AUDIO);
if (fRecorder->InitCheck() < B_OK)
throw al::backend_exception{al::backend_error::NoDevice, "Failed to create BMediaRecorder"};
--
2.30.0