1 gstreamer: implement pipewire integration using pwaudiosrc/pwaudiosink
3 The code path is wrapped in #ifdef USE_PIPEWIRE so that it can be toggled
4 easily at compile time.
6 The device string is abused to hold the role name, just like it was
7 with 4A. In the future this may need to be reconsidered. In theory,
8 we could detect the backend or make it configurable from the upper layer
9 if we knew exactly what kind of data is in that device string
10 (is it an ALSA device name? a pipewire role? a pipewire node id?
11 a pulseaudio device name? ...)
13 Upstream-Status: Pending
15 Signed-off-by: George Kiagiadakis <george.kiagiadakis@collabora.com>
16 [reworked for SDK 2.0]
17 Signed-off-by: Scott Murray <scott.murray@konsulko.com>
19 diff --git a/lib/aal/CMakeLists.txt b/lib/aal/CMakeLists.txt
20 index a892465..c92b2cf 100644
21 --- a/lib/aal/CMakeLists.txt
22 +++ b/lib/aal/CMakeLists.txt
23 @@ -7,6 +7,7 @@ set(CMAKE_POSITION_INDEPENDENT_CODE ON)
25 add_definitions(-DUSE_GLOOP)
26 add_definitions(-DUSE_FAKEMUTE)
27 +add_definitions(-DUSE_PIPEWIRE)
30 find_package(PkgConfig)
31 diff --git a/lib/aal/src/player.c b/lib/aal/src/player.c
32 index 02a2881..8747854 100644
33 --- a/lib/aal/src/player.c
34 +++ b/lib/aal/src/player.c
35 @@ -120,6 +120,19 @@ aal_handle_t aal_player_create(const aal_attributes_t *attr)
36 g_object_get(volume, "volume", &ctx->saved_volume, NULL);
40 + sink = create_and_add_element(bin, "pwaudiosink", "sink");
41 + if (sink && attr->device && !IS_EMPTY_STRING(attr->device)) {
42 + g_info("Using role: %s\n", attr->device);
43 + GstStructure *s = gst_structure_new("properties",
48 + g_object_set(G_OBJECT(sink), "stream-properties", s, NULL);
49 + gst_structure_free(s);
52 if (!attr->device || IS_EMPTY_STRING(attr->device)) {
53 sink = create_and_add_element(bin, "autoaudiosink", "sink");
55 @@ -128,6 +141,7 @@ aal_handle_t aal_player_create(const aal_attributes_t *attr)
57 g_object_set(G_OBJECT(sink), "device", attr->device, NULL);
63 diff --git a/lib/aal/src/recorder.c b/lib/aal/src/recorder.c
64 index 96c9b2a..66b36e1 100644
65 --- a/lib/aal/src/recorder.c
66 +++ b/lib/aal/src/recorder.c
67 @@ -86,6 +86,19 @@ aal_handle_t aal_recorder_create(const aal_attributes_t *attr)
72 + source = create_and_add_element(ctx->pipeline, "pwaudiosrc", "source");
73 + if (source && attr->device && !IS_EMPTY_STRING(attr->device)) {
74 + g_info("Using role: %s\n", attr->device);
75 + GstStructure *s = gst_structure_new("properties",
80 + g_object_set(G_OBJECT(source), "stream-properties", s, NULL);
81 + gst_structure_free(s);
84 if (!attr->device || IS_EMPTY_STRING(attr->device)) {
85 source = create_and_add_element(ctx->pipeline, "autoaudiosrc", "source");
87 @@ -94,6 +107,7 @@ aal_handle_t aal_recorder_create(const aal_attributes_t *attr)
89 g_object_set(G_OBJECT(source), "device", attr->device, NULL);