Build the PipeWire drivers in the C89 lane

The PipeWire audio, microphone and camera drivers use positional
initializers for their event tables, plain loops in place of compound
literals and SPA_FOR_EACH_ELEMENT_VAR, and declarations at block start,
so they compile as C89. Under C89_BUILD the SPA and PipeWire include
directories are read as system headers and given __inline__, since
those headers are C99 and outside our control.

The linux-c89 job installs libpipewire-0.3-dev, so configure enables
the PipeWire drivers there and every one of their sources is held to
-std=c89 in CI.
This commit is contained in:
libretroadmin committed 2026-10-16 04:51:53 +02:00
1 parent a36004c08b
commit cb95aac128
5 files changed
+50 -25

No files matched your search

+2 -1
View File
@@ -32,7 +32,8 @@ jobs:
# (shader_vulkan.c, slang_process.c, glslang_util.c, slang_cache.c)
# and the Vulkan contexts into this lane; without it configure
# drops them and none of those C files ever meet -std=c89.
pkgs="build-essential libxkbcommon-dev libx11-xcb-dev libvulkan-dev zlib1g-dev libfreetype6-dev libegl1-mesa-dev libgles2-mesa-dev libgbm-dev nvidia-cg-toolkit nvidia-cg-dev libavcodec-dev libsdl2-dev libsdl-image1.2-dev libxml2-dev yasm"
# libpipewire-0.3-dev does the same for the PipeWire drivers.
pkgs="build-essential libxkbcommon-dev libx11-xcb-dev libvulkan-dev libpipewire-0.3-dev zlib1g-dev libfreetype6-dev libegl1-mesa-dev libgles2-mesa-dev libgbm-dev nvidia-cg-toolkit nvidia-cg-dev libavcodec-dev libsdl2-dev libsdl-image1.2-dev libxml2-dev yasm"
if dpkg -s $pkgs >/dev/null 2>&1; then
echo "All packages already present on runner image; skipping apt."
exit 0
+8
View File
@@ -131,6 +131,14 @@ ifneq ($(CXX_BUILD), 1)
# string literal, which no declaration of ours can help: this lane
# is here for declarations, comments and C99 syntax.
CFLAGS += -std=c89 -ansi -pedantic -Werror=pedantic -Wno-long-long -Werror=declaration-after-statement -Wno-variadic-macros -Wno-overlength-strings
ifeq ($(HAVE_PIPEWIRE), 1)
# The SPA headers are C99: read them as system headers, which
# takes them out of -pedantic, and give them __inline__.
PIPEWIRE_C89_OBJ := $(addprefix $(OBJDIR)/,audio/drivers/pipewire.o \
audio/common/pipewire.o camera/drivers/pipewire.o)
$(PIPEWIRE_C89_OBJ): DEFINES += -Dinline=__inline__ \
$(patsubst -I%,-isystem %,$(filter -I%,$(PIPEWIRE_CFLAGS)))
endif
else ifeq ($(HAVE_C99), 1)
CFLAGS += $(C99_CFLAGS)
endif
+4 -2
View File
@@ -53,8 +53,10 @@ static void core_done_cb(void *data, uint32_t id, int seq)
static const struct pw_core_events core_events = {
PW_VERSION_CORE_EVENTS,
.done = core_done_cb,
.error = core_error_cb,
NULL, /* info */
core_done_cb,
NULL, /* ping */
core_error_cb
};
bool pipewire_loop_wait_ms(struct pw_thread_loop *loop, unsigned ms)
+23 -12
View File
@@ -142,8 +142,8 @@ static void pwire_set_position_layout(uint32_t layout,
{ AUDIO_SPEAKER_SIDE_RIGHT, SPA_AUDIO_CHANNEL_SR },
};
size_t i, n = 0;
memcpy(position, (uint32_t[SPA_AUDIO_MAX_CHANNELS]) { SPA_AUDIO_CHANNEL_UNKNOWN, },
sizeof(uint32_t) * SPA_AUDIO_MAX_CHANNELS);
for (i = 0; i < SPA_AUDIO_MAX_CHANNELS; i++)
position[i] = SPA_AUDIO_CHANNEL_UNKNOWN;
for (i = 0; i < ARRAY_SIZE(map); i++)
if (layout & map[i].bit)
position[n++] = map[i].spa;
@@ -153,8 +153,9 @@ static void pwire_set_position(uint32_t channels, uint32_t position[SPA_AUDIO_MA
{
if (channels == 1)
{
memcpy(position, (uint32_t[SPA_AUDIO_MAX_CHANNELS]) { SPA_AUDIO_CHANNEL_UNKNOWN, },
sizeof(uint32_t) * SPA_AUDIO_MAX_CHANNELS);
size_t i;
for (i = 1; i < SPA_AUDIO_MAX_CHANNELS; i++)
position[i] = SPA_AUDIO_CHANNEL_UNKNOWN;
position[0] = SPA_AUDIO_CHANNEL_MONO;
return;
}
@@ -224,9 +225,14 @@ static void pwire_capture_process_cb(void *data)
static const struct pw_stream_events capture_stream_events = {
PW_VERSION_STREAM_EVENTS,
.destroy = pwire_stream_destroy_cb,
.state_changed = pwire_mic_stream_state_changed_cb,
.process = pwire_capture_process_cb
pwire_stream_destroy_cb,
pwire_mic_stream_state_changed_cb,
NULL, /* control_info */
NULL, /* io_changed */
NULL, /* param_changed */
NULL, /* add_buffer */
NULL, /* remove_buffer */
pwire_capture_process_cb
};
static void pwire_mic_registry_event_global(void *data, uint32_t id,
@@ -260,7 +266,7 @@ static void pwire_mic_registry_event_global(void *data, uint32_t id,
static const struct pw_registry_events pwire_mic_registry_events = {
PW_VERSION_REGISTRY_EVENTS,
.global = pwire_mic_registry_event_global,
pwire_mic_registry_event_global
};
static void pwire_microphone_free(void *driver_context)
@@ -735,9 +741,14 @@ static void pwire_stream_state_changed_cb(void *data,
static const struct pw_stream_events pwire_playback_stream_events = {
PW_VERSION_STREAM_EVENTS,
.destroy = pwire_stream_destroy_cb,
.process = pwire_playback_process_cb,
.state_changed = pwire_stream_state_changed_cb,
pwire_stream_destroy_cb,
pwire_stream_state_changed_cb,
NULL, /* control_info */
NULL, /* io_changed */
NULL, /* param_changed */
NULL, /* add_buffer */
NULL, /* remove_buffer */
pwire_playback_process_cb
};
static void pwire_registry_event_global(void *data, uint32_t id,
@@ -768,7 +779,7 @@ static void pwire_registry_event_global(void *data, uint32_t id,
static const struct pw_registry_events pwire_registry_events = {
PW_VERSION_REGISTRY_EVENTS,
.global = pwire_registry_event_global,
pwire_registry_event_global
};
/* Context-free enumeration: bring up a throwaway core with the same
+13 -10
View File
@@ -87,10 +87,11 @@ static struct
static uint32_t id_to_scaler_format(uint32_t id)
{
SPA_FOR_EACH_ELEMENT_VAR(scaler_video_formats, f)
size_t i;
for (i = 0; i < SPA_N_ELEMENTS(scaler_video_formats); i++)
{
if (f->id == id)
return f->format;
if (scaler_video_formats[i].id == id)
return scaler_video_formats[i].format;
}
return SCALER_FMT_ARGB8888;
}
@@ -101,6 +102,7 @@ static int build_format(struct spa_pod_builder *b, const struct spa_pod **params
uint32_t width = VIDEO_SCALE_W(dims);
uint32_t height = VIDEO_SCALE_H(dims);
struct spa_pod_frame frame[2];
size_t i;
/* make an object of type SPA_TYPE_OBJECT_Format and id SPA_PARAM_EnumFormat.
* The object type is important because it defines the properties that are
@@ -117,9 +119,9 @@ static int build_format(struct spa_pod_builder *b, const struct spa_pod **params
spa_pod_builder_prop(b, SPA_FORMAT_VIDEO_format, 0);
spa_pod_builder_push_choice(b, &frame[1], SPA_CHOICE_Enum, 0);
spa_pod_builder_id(b, SPA_VIDEO_FORMAT_YUY2); /* default */
SPA_FOR_EACH_ELEMENT_VAR(scaler_video_formats, f)
for (i = 0; i < SPA_N_ELEMENTS(scaler_video_formats); i++)
{
uint32_t id = f->id;
uint32_t id = scaler_video_formats[i].id;
if (id != SPA_VIDEO_FORMAT_UNKNOWN)
spa_pod_builder_id(b, id); /* alternative */
}
@@ -255,6 +257,7 @@ static void stream_param_changed_cb(void *data, uint32_t id, const struct spa_po
{
uint8_t params_buffer[1024];
const struct spa_pod *params[5];
struct spa_pod_frame frame;
unsigned input_stride;
pipewire_camera_t *camera = (pipewire_camera_t*)data;
struct spa_pod_builder b = SPA_POD_BUILDER_INIT(params_buffer, sizeof(params_buffer));
@@ -329,7 +332,6 @@ static void stream_param_changed_cb(void *data, uint32_t id, const struct spa_po
break;
}
struct spa_pod_frame frame;
spa_pod_builder_push_object(&b, &frame, SPA_TYPE_OBJECT_ParamBuffers, SPA_PARAM_Buffers);
spa_pod_builder_add(&b,
SPA_PARAM_BUFFERS_stride, SPA_POD_Int(input_stride),
@@ -378,10 +380,11 @@ static void stream_param_changed_cb(void *data, uint32_t id, const struct spa_po
static const struct pw_stream_events stream_events = {
PW_VERSION_STREAM_EVENTS,
.state_changed = stream_state_changed_cb,
.io_changed = stream_io_changed_cb,
.param_changed = stream_param_changed_cb,
.process = NULL,
NULL, /* destroy */
stream_state_changed_cb,
NULL, /* control_info */
stream_io_changed_cb,
stream_param_changed_cb
};
static void pwire_camera_stop(void *data)