Disable the PipeWire backend when compiling as C89.

The SPA headers are not compatible with C89 which means the PipeWire
backend is not usable.
This commit is contained in:
David Reid
2025-08-21 07:33:08 +10:00
parent f6453a1418
commit e826957a12
2 changed files with 9 additions and 3 deletions
@@ -76,8 +76,10 @@ which can then be stored in the backend state?
#if defined(MA_LINUX) #if defined(MA_LINUX)
#if defined(__STDC_VERSION__) /* <-- PipeWire cannot be used with C89 mode (__STDC_VERSION__ is only defined starting with C90). */
#define MA_SUPPORT_PIPEWIRE #define MA_SUPPORT_PIPEWIRE
#endif #endif
#endif
#if defined(MA_SUPPORT_PIPEWIRE) && !defined(MA_NO_PIPEWIRE) && (!defined(MA_ENABLE_ONLY_SPECIFIC_BACKENDS) || defined(MA_ENABLE_PIPEWIRE)) #if defined(MA_SUPPORT_PIPEWIRE) && !defined(MA_NO_PIPEWIRE) && (!defined(MA_ENABLE_ONLY_SPECIFIC_BACKENDS) || defined(MA_ENABLE_PIPEWIRE))
#define MA_HAS_PIPEWIRE #define MA_HAS_PIPEWIRE
@@ -438,6 +440,7 @@ static void ma_stream_event_param_changed__pipewire(void* pUserData, ma_uint32 i
const struct spa_pod* pBufferParameters[1]; const struct spa_pod* pBufferParameters[1];
ma_uint32 bufferSizeInFrames; ma_uint32 bufferSizeInFrames;
ma_uint32 bytesPerFrame; ma_uint32 bytesPerFrame;
ma_uint32 iChannel;
if (pDeviceStatePipeWire->isInternalFormatFinalised) { if (pDeviceStatePipeWire->isInternalFormatFinalised) {
ma_log_postf(pContextStatePipeWire->pLog, MA_LOG_LEVEL_WARNING, "PipeWire format parameter changed after device has been initialized."); ma_log_postf(pContextStatePipeWire->pLog, MA_LOG_LEVEL_WARNING, "PipeWire format parameter changed after device has been initialized.");
@@ -456,7 +459,7 @@ static void ma_stream_event_param_changed__pipewire(void* pUserData, ma_uint32 i
printf("Channels: %d\n", audioInfo.channels); printf("Channels: %d\n", audioInfo.channels);
printf("Rate: %d\n", audioInfo.rate); printf("Rate: %d\n", audioInfo.rate);
printf("Channel Map: {"); printf("Channel Map: {");
for (ma_uint32 iChannel = 0; iChannel < audioInfo.channels; iChannel += 1) { for (iChannel = 0; iChannel < audioInfo.channels; iChannel += 1) {
printf("%d", audioInfo.position[iChannel]); printf("%d", audioInfo.position[iChannel]);
if (iChannel < audioInfo.channels - 1) { if (iChannel < audioInfo.channels - 1) {
printf(", "); printf(", ");
@@ -529,7 +532,7 @@ static void ma_stream_event_process__pipewire(void* pUserData)
return; return;
} }
//frameCount = (ma_uint32)ma_min(pBuffer->requested, pBuffer->buffer->datas[0].maxsize / bytesPerFrame); /*frameCount = (ma_uint32)ma_min(pBuffer->requested, pBuffer->buffer->datas[0].maxsize / bytesPerFrame);*/
frameCount = (ma_uint32)(pBuffer->buffer->datas[0].maxsize / bytesPerFrame); frameCount = (ma_uint32)(pBuffer->buffer->datas[0].maxsize / bytesPerFrame);
if (frameCount > 0) { if (frameCount > 0) {
if (pStream == pDeviceStatePipeWire->pStreamPlayback) { if (pStream == pDeviceStatePipeWire->pStreamPlayback) {
@@ -13,6 +13,9 @@ Unfortunately PipeWire has a hard dependency on the above package, and because i
entirely of non-trivial inlined code, it's not possible to avoid this dependency. It's for entirely of non-trivial inlined code, it's not possible to avoid this dependency. It's for
this reason the PipeWire backend cannot be included in miniaudio.h since it has a requirement this reason the PipeWire backend cannot be included in miniaudio.h since it has a requirement
that it does not depend on external development packages. that it does not depend on external development packages.
The PipeWire backend cannot be used with `-std=c89`. This is because the SPA headers do not
support it.
*/ */
#ifndef miniaudio_backend_pipewire_h #ifndef miniaudio_backend_pipewire_h
#define miniaudio_backend_pipewire_h #define miniaudio_backend_pipewire_h