mirror of
https://github.com/gnif/LookingGlass.git
synced 2024-11-25 06:47:19 +00:00
[client] audio/pw: request real-time priority
This is as per the PipeWire ALSA plugin [1]. The existing
`PW_STREAM_FLAG_RT_PROCESS` flag is misleading and doesn't really have
anything to do with real-time priority; it just tells PipeWire to pull data
from the application synchronously from its main processing thread. More
detail at [2].
[1] f5d47c079e/pipewire-alsa/alsa-plugins/pcm_pipewire.c
[2] https://gitlab.freedesktop.org/pipewire/pipewire/-/issues/2024
This commit is contained in:
parent
70158a64e7
commit
d9dc399522
@ -40,6 +40,7 @@ StreamState;
|
|||||||
struct PipeWire
|
struct PipeWire
|
||||||
{
|
{
|
||||||
struct pw_loop * loop;
|
struct pw_loop * loop;
|
||||||
|
struct pw_context * context;
|
||||||
struct pw_thread_loop * thread;
|
struct pw_thread_loop * thread;
|
||||||
|
|
||||||
struct
|
struct
|
||||||
@ -132,33 +133,38 @@ static bool pipewire_init(void)
|
|||||||
pw_init(NULL, NULL);
|
pw_init(NULL, NULL);
|
||||||
|
|
||||||
pw.loop = pw_loop_new(NULL);
|
pw.loop = pw_loop_new(NULL);
|
||||||
struct pw_context * context = pw_context_new(pw.loop, NULL, 0);
|
pw.context = pw_context_new(
|
||||||
if (!context)
|
pw.loop,
|
||||||
|
pw_properties_new(
|
||||||
|
// Request real-time priority on the PipeWire threads
|
||||||
|
PW_KEY_CONFIG_NAME, "client-rt.conf",
|
||||||
|
NULL
|
||||||
|
),
|
||||||
|
0);
|
||||||
|
if (!pw.context)
|
||||||
{
|
{
|
||||||
DEBUG_ERROR("Failed to create a context");
|
DEBUG_ERROR("Failed to create a context");
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* this is just to test for PipeWire availabillity */
|
/* this is just to test for PipeWire availabillity */
|
||||||
struct pw_core * core = pw_context_connect(context, NULL, 0);
|
struct pw_core * core = pw_context_connect(pw.context, NULL, 0);
|
||||||
if (!core)
|
if (!core)
|
||||||
goto err_context;
|
goto err_context;
|
||||||
|
|
||||||
pw_context_destroy(context);
|
|
||||||
|
|
||||||
/* PipeWire is available so create the loop thread and start it */
|
/* PipeWire is available so create the loop thread and start it */
|
||||||
pw.thread = pw_thread_loop_new_full(pw.loop, "PipeWire", NULL);
|
pw.thread = pw_thread_loop_new_full(pw.loop, "PipeWire", NULL);
|
||||||
if (!pw.thread)
|
if (!pw.thread)
|
||||||
{
|
{
|
||||||
DEBUG_ERROR("Failed to create the thread loop");
|
DEBUG_ERROR("Failed to create the thread loop");
|
||||||
goto err;
|
goto err_context;
|
||||||
}
|
}
|
||||||
|
|
||||||
pw_thread_loop_start(pw.thread);
|
pw_thread_loop_start(pw.thread);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
err_context:
|
err_context:
|
||||||
pw_context_destroy(context);
|
pw_context_destroy(pw.context);
|
||||||
|
|
||||||
err:
|
err:
|
||||||
pw_loop_destroy(pw.loop);
|
pw_loop_destroy(pw.loop);
|
||||||
@ -502,10 +508,12 @@ static void pipewire_free(void)
|
|||||||
pipewire_recordStopStream();
|
pipewire_recordStopStream();
|
||||||
pw_thread_loop_stop(pw.thread);
|
pw_thread_loop_stop(pw.thread);
|
||||||
pw_thread_loop_destroy(pw.thread);
|
pw_thread_loop_destroy(pw.thread);
|
||||||
|
pw_context_destroy(pw.context);
|
||||||
pw_loop_destroy(pw.loop);
|
pw_loop_destroy(pw.loop);
|
||||||
|
|
||||||
pw.loop = NULL;
|
pw.loop = NULL;
|
||||||
pw.thread = NULL;
|
pw.context = NULL;
|
||||||
|
pw.thread = NULL;
|
||||||
|
|
||||||
pw_deinit();
|
pw_deinit();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user