Skip to content

Commit

Permalink
FluidSynth|Unix: Use the pulseaudio driver by default
Browse files Browse the repository at this point in the history
When using the system libfluidsynth, by default use pulseaudio as the
output driver.
  • Loading branch information
skyjake committed Nov 6, 2012
1 parent 748bf32 commit efb7637
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 14 deletions.
26 changes: 12 additions & 14 deletions doomsday/plugins/fluidsynth/fluidsynth.pro
Expand Up @@ -35,10 +35,22 @@ unix:!macx {
target.path = $$DENG_PLUGIN_LIB_DIR
}

INCLUDEPATH += include

HEADERS += \
include/driver_fluidsynth.h \
include/fluidsynth_music.h \
include/version.h

SOURCES += \
src/driver_fluidsynth.cpp \
src/fluidsynth_music.cpp

# libfluidsynth config ------------------------------------------------------

!deng_embedfluidsynth {
include(../../dep_fluidsynth.pri)
DEFINES += FLUIDSYNTH_DEFAULT_DRIVER_NAME=\"\\\"pulseaudio\\\"\"
}

deng_embedfluidsynth {
Expand Down Expand Up @@ -66,20 +78,6 @@ unix {
HAVE_NETINET_TCP_H HAVE_FCNTL_H HAVE_ERRNO_H
}

# Sources -------------------------------------------------------------------

INCLUDEPATH += include

HEADERS += \
include/driver_fluidsynth.h \
include/fluidsynth_music.h \
include/version.h

SOURCES += \
src/driver_fluidsynth.cpp \
src/fluidsynth_music.cpp

# libfluidsynth
FS_DIR = ../../external/fluidsynth

INCLUDEPATH += \
Expand Down
1 change: 1 addition & 0 deletions doomsday/plugins/fluidsynth/include/driver_fluidsynth.h
Expand Up @@ -43,6 +43,7 @@ int DS_Set(int prop, const void* ptr);
}

fluid_synth_t* DMFluid_Synth();
fluid_audio_driver_t* DMFluid_Driver();
audiointerface_sfx_generic_t* DMFluid_Sfx();

#ifdef DENG_DSFLUIDSYNTH_DEBUG
Expand Down
22 changes: 22 additions & 0 deletions doomsday/plugins/fluidsynth/src/driver_fluidsynth.cpp
Expand Up @@ -29,13 +29,19 @@
static fluid_settings_t* fsConfig;
static fluid_synth_t* fsSynth;
static audiointerface_sfx_t* fsSfx;
static fluid_audio_driver_t* fsDriver;

fluid_synth_t* DMFluid_Synth()
{
DENG_ASSERT(fsSynth != 0);
return fsSynth;
}

fluid_audio_driver_t* DMFluid_Driver()
{
return fsDriver;
}

audiointerface_sfx_generic_t* DMFluid_Sfx()
{
DENG_ASSERT(fsSfx != 0);
Expand Down Expand Up @@ -64,6 +70,18 @@ int DS_Init(void)
return false;
}

#ifndef FLUIDSYNTH_NOT_A_DLL
// Create the output driver that will play the music.
const char* driverName = FLUIDSYNTH_DEFAULT_DRIVER_NAME;
fluid_settings_setstr(fsConfig, "audio.driver", driverName);
fsDriver = new_fluid_audio_driver(fsConfig, fsSynth);
if(!fsDriver)
{
Con_Message("Failed to create FluidSynth audio driver '%s'.\n", driverName);
return false;
}
#endif

DSFLUIDSYNTH_TRACE("DS_Init: FluidSynth initialized.");
return true;
}
Expand All @@ -79,6 +97,10 @@ void DS_Shutdown(void)

DSFLUIDSYNTH_TRACE("DS_Shutdown.");

if(fsDriver)
{
delete_fluid_audio_driver(fsDriver);
}
delete_fluid_synth(fsSynth);
delete_fluid_settings(fsConfig);

Expand Down
7 changes: 7 additions & 0 deletions doomsday/plugins/fluidsynth/src/fluidsynth_music.cpp
Expand Up @@ -238,6 +238,7 @@ static int streamOutSamples(sfxbuffer_t* buf, void* data, unsigned int size)

static void startWorker()
{
DENG_ASSERT(DMFluid_Driver() == NULL);
DENG_ASSERT(worker == NULL);

workerShouldStop = false;
Expand All @@ -249,6 +250,8 @@ static void startWorker()
*/
static void startPlayer()
{
if(DMFluid_Driver()) return;

DENG_ASSERT(!worker);
DENG_ASSERT(sfxBuf == NULL);

Expand Down Expand Up @@ -278,6 +281,8 @@ static void startPlayer()

static void stopWorker()
{
DENG_ASSERT(DMFluid_Driver() == NULL);

if(worker)
{
DSFLUIDSYNTH_TRACE("stopWorker: Stopping thread " << worker);
Expand All @@ -292,6 +297,8 @@ static void stopWorker()

static void stopPlayer()
{
if(DMFluid_Driver()) return;

DSFLUIDSYNTH_TRACE("stopPlayer: fsPlayer " << fsPlayer);

if(!fsPlayer) return;
Expand Down

0 comments on commit efb7637

Please sign in to comment.