aboutsummaryrefslogtreecommitdiffstats
path: root/alc/backends/jack.cpp
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2023-11-28 12:51:46 +0100
committerSven Gothel <[email protected]>2023-11-28 12:51:46 +0100
commit1aaf4f070011490bcece50394b9b32dfa593fd9e (patch)
tree17d68284e401a35eea3d3a574d986d446a60763a /alc/backends/jack.cpp
parent6e7cee4fa9a8af03f28ca26cd89f8357390dfc90 (diff)
parent571b546f35eead77ce109f8d4dd6c3de3199d573 (diff)
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'alc/backends/jack.cpp')
-rw-r--r--alc/backends/jack.cpp37
1 files changed, 20 insertions, 17 deletions
diff --git a/alc/backends/jack.cpp b/alc/backends/jack.cpp
index 791002ca..a0a5c440 100644
--- a/alc/backends/jack.cpp
+++ b/alc/backends/jack.cpp
@@ -22,23 +22,26 @@
#include "jack.h"
+#include <array>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <memory.h>
-
-#include <array>
+#include <mutex>
#include <thread>
#include <functional>
+#include <vector>
+#include "albit.h"
#include "alc/alconfig.h"
#include "alnumeric.h"
+#include "alsem.h"
+#include "althrd_setname.h"
#include "core/device.h"
#include "core/helpers.h"
#include "core/logging.h"
#include "dynload.h"
#include "ringbuffer.h"
-#include "threads.h"
#include <jack/jack.h>
#include <jack/ringbuffer.h>
@@ -126,7 +129,7 @@ bool jack_load()
error = false;
#define LOAD_FUNC(f) do { \
- p##f = reinterpret_cast<decltype(p##f)>(GetSymbol(jack_handle, #f)); \
+ p##f = al::bit_cast<decltype(p##f)>(GetSymbol(jack_handle, #f)); \
if(p##f == nullptr) { \
error = true; \
missing_funcs += "\n" #f; \
@@ -135,7 +138,7 @@ bool jack_load()
JACK_FUNCS(LOAD_FUNC);
#undef LOAD_FUNC
/* Optional symbols. These don't exist in all versions of JACK. */
-#define LOAD_SYM(f) p##f = reinterpret_cast<decltype(p##f)>(GetSymbol(jack_handle, #f))
+#define LOAD_SYM(f) p##f = al::bit_cast<decltype(p##f)>(GetSymbol(jack_handle, #f))
LOAD_SYM(jack_error_callback);
#undef LOAD_SYM
@@ -167,10 +170,10 @@ struct DeviceEntry {
{ }
};
-al::vector<DeviceEntry> PlaybackList;
+std::vector<DeviceEntry> PlaybackList;
-void EnumerateDevices(jack_client_t *client, al::vector<DeviceEntry> &list)
+void EnumerateDevices(jack_client_t *client, std::vector<DeviceEntry> &list)
{
std::remove_reference_t<decltype(list)>{}.swap(list);
@@ -295,7 +298,7 @@ struct JackPlayback final : public BackendBase {
int mixerProc();
- void open(const char *name) override;
+ void open(std::string_view name) override;
bool reset() override;
void start() override;
void stop() override;
@@ -457,7 +460,7 @@ int JackPlayback::mixerProc()
}
-void JackPlayback::open(const char *name)
+void JackPlayback::open(std::string_view name)
{
if(!mClient)
{
@@ -481,9 +484,9 @@ void JackPlayback::open(const char *name)
if(PlaybackList.empty())
EnumerateDevices(mClient, PlaybackList);
- if(!name && !PlaybackList.empty())
+ if(name.empty() && !PlaybackList.empty())
{
- name = PlaybackList[0].mName.c_str();
+ name = PlaybackList[0].mName;
mPortPattern = PlaybackList[0].mPattern;
}
else
@@ -493,14 +496,10 @@ void JackPlayback::open(const char *name)
auto iter = std::find_if(PlaybackList.cbegin(), PlaybackList.cend(), check_name);
if(iter == PlaybackList.cend())
throw al::backend_exception{al::backend_error::NoDevice,
- "Device name \"%s\" not found", name?name:""};
+ "Device name \"%.*s\" not found", static_cast<int>(name.length()), name.data()};
mPortPattern = iter->mPattern;
}
- mRTMixing = GetConfigValueBool(name, "jack", "rt-mix", true);
- jack_set_process_callback(mClient,
- mRTMixing ? &JackPlayback::processRtC : &JackPlayback::processC, this);
-
mDevice->DeviceName = name;
}
@@ -511,6 +510,10 @@ bool JackPlayback::reset()
std::for_each(mPort.begin(), mPort.end(), unregister_port);
mPort.fill(nullptr);
+ mRTMixing = GetConfigValueBool(mDevice->DeviceName.c_str(), "jack", "rt-mix", true);
+ jack_set_process_callback(mClient,
+ mRTMixing ? &JackPlayback::processRtC : &JackPlayback::processC, this);
+
/* Ignore the requested buffer metrics and just keep one JACK-sized buffer
* ready for when requested.
*/
@@ -586,7 +589,7 @@ void JackPlayback::start()
throw al::backend_exception{al::backend_error::DeviceError, "No playback ports found"};
}
- for(size_t i{0};i < al::size(mPort) && mPort[i];++i)
+ for(size_t i{0};i < std::size(mPort) && mPort[i];++i)
{
if(!pnames[i])
{