From 7ec9befe2f3f535bd7c425cc039b37406ffa5633 Mon Sep 17 00:00:00 2001 From: Gerasim Troeglazov <3dEyes@gmail.com> Date: Sat, 27 Feb 2021 23:58:00 +1000 Subject: [PATCH] OpenAL: fix disconnect audio nodes --- media-libs/openal/openal-1.21.1.recipe | 2 +- .../openal/patches/openal-1.21.1.patchset | 131 ++++++++++++++++++ 2 files changed, 132 insertions(+), 1 deletion(-) diff --git a/media-libs/openal/openal-1.21.1.recipe b/media-libs/openal/openal-1.21.1.recipe index 2e9ca3a82..0b4104a81 100644 --- a/media-libs/openal/openal-1.21.1.recipe +++ b/media-libs/openal/openal-1.21.1.recipe @@ -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" diff --git a/media-libs/openal/patches/openal-1.21.1.patchset b/media-libs/openal/patches/openal-1.21.1.patchset index 871ca06d3..7e1e4b911 100644 --- a/media-libs/openal/patches/openal-1.21.1.patchset +++ b/media-libs/openal/patches/openal-1.21.1.patchset @@ -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(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(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(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 +