Initialize Pipewire with pw_init() (#1032)

Before you using any PipeWire functions, one must call pw_init() (e.g. https://docs.pipewire.org/page_tutorial1.html)
This commit is contained in:
Tom M 2022-01-29 13:13:25 +01:00 committed by GitHub
parent b89898ef7f
commit 0b4fa214b6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 20 additions and 2 deletions

View file

@ -31,6 +31,7 @@ and a description.
- file: Driver to output audio to a file - file: Driver to output audio to a file
- sdl2*: Simple DirectMedia Layer (Linux, Windows, Mac OS X, iOS, Android, - sdl2*: Simple DirectMedia Layer (Linux, Windows, Mac OS X, iOS, Android,
FreeBSD, Haiku, etc.) FreeBSD, Haiku, etc.)
- pipewire**: PipeWire (Linux)
The default audio driver depends on the settings with which FluidSynth was The default audio driver depends on the settings with which FluidSynth was
compiled. You can get the default driver with compiled. You can get the default driver with
@ -79,4 +80,10 @@ is responsible for initializing SDL (e.g. with SDL_Init()). This must be done
Also make sure to call SDL_Quit() after all fluidsynth instances have been Also make sure to call SDL_Quit() after all fluidsynth instances have been
destroyed. destroyed.
<strong>**Note:</strong> In order to use pipeiwre as audio driver, the application
is responsible for initializing PipeWire (e.g. with pw_init()). This must be done
<strong>before</strong> the first call to <code>new_fluid_settings()</code>!
Also make sure to call pw_deinit() after all fluidsynth instances have been
destroyed.
*/ */

View file

@ -490,6 +490,10 @@ if ( TARGET PkgConfig::SDL2 AND SDL2_SUPPORT ) # because SDL_Init() etc.
target_link_libraries ( fluidsynth PRIVATE PkgConfig::SDL2 ) target_link_libraries ( fluidsynth PRIVATE PkgConfig::SDL2 )
endif() endif()
if ( TARGET PkgConfig::PIPEWIRE AND PIPEWIRE_SUPPORT ) # because pw_init() etc.
target_link_libraries ( fluidsynth PRIVATE PkgConfig::PIPEWIRE )
endif()
if ( TARGET PkgConfig::LIBINSTPATCH AND LIBINSTPATCH_SUPPORT ) if ( TARGET PkgConfig::LIBINSTPATCH AND LIBINSTPATCH_SUPPORT )
target_link_libraries ( fluidsynth PRIVATE PkgConfig::LIBINSTPATCH ) target_link_libraries ( fluidsynth PRIVATE PkgConfig::LIBINSTPATCH )
endif() endif()

View file

@ -192,7 +192,7 @@ new_fluid_pipewire_audio_driver2(fluid_settings_t *settings, fluid_audio_func_t
if(!drv->pw_loop) if(!drv->pw_loop)
{ {
FLUID_LOG(FLUID_ERR, "Failed to allocate PipeWire loop"); FLUID_LOG(FLUID_ERR, "Failed to allocate PipeWire loop. Have you called pw_init() ?");
goto driver_cleanup; goto driver_cleanup;
} }

View file

@ -42,6 +42,10 @@
#include <SDL.h> #include <SDL.h>
#endif #endif
#if PIPEWIRE_SUPPORT
#include <pipewire/pipewire.h>
#endif
void print_usage(void); void print_usage(void);
void print_help(fluid_settings_t *settings); void print_help(fluid_settings_t *settings);
void print_welcome(void); void print_welcome(void);
@ -400,7 +404,6 @@ int main(int argc, char **argv)
#endif #endif
#if SDL2_SUPPORT #if SDL2_SUPPORT
if(SDL_Init(SDL_INIT_AUDIO) != 0) if(SDL_Init(SDL_INIT_AUDIO) != 0)
{ {
fprintf(stderr, "Warning: Unable to initialize SDL2 Audio: %s", SDL_GetError()); fprintf(stderr, "Warning: Unable to initialize SDL2 Audio: %s", SDL_GetError());
@ -409,7 +412,11 @@ int main(int argc, char **argv)
{ {
atexit(SDL_Quit); atexit(SDL_Quit);
} }
#endif
#if PIPEWIRE_SUPPORT
pw_init(&argc, &argv);
atexit(pw_deinit);
#endif #endif
/* create the settings */ /* create the settings */