From 86cd5252007c294616392c5a9d89a102953dcf64 Mon Sep 17 00:00:00 2001 From: ehofman Date: Mon, 30 Nov 2009 14:24:16 +0000 Subject: [PATCH] update to allow selection of a new sound device --- src/Main/main.cxx | 11 +++++++++++ src/Main/options.cxx | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/Main/main.cxx b/src/Main/main.cxx index 07d232a80..ca63accb2 100644 --- a/src/Main/main.cxx +++ b/src/Main/main.cxx @@ -104,6 +104,8 @@ long global_multi_loop; SGTimeStamp last_time_stamp; SGTimeStamp current_time_stamp; +void fgSetNewSoundDevice(const char *); + // The atexit() function handler should know when the graphical subsystem // is initialized. extern int _bootstrap_OSInit; @@ -509,6 +511,7 @@ static void fgMainLoop( void ) { } else { smgr->stop(); } + globals->get_props()->tie("/sim/sound/device", SGRawValueFunctions(0, fgSetNewSoundDevice), false); } fgRequestRedraw(); @@ -516,6 +519,14 @@ static void fgMainLoop( void ) { SG_LOG( SG_ALL, SG_DEBUG, "" ); } +void fgSetNewSoundDevice(const char *device) +{ + globals->get_soundmgr()->suspend(); + globals->get_soundmgr()->stop(); + globals->get_soundmgr()->init(device); + globals->get_soundmgr()->resume(); +} + // Operation for querying OpenGL parameters. This must be done in a // valid OpenGL context, potentially in another thread. namespace diff --git a/src/Main/options.cxx b/src/Main/options.cxx index ceca89101..e03f1b1f0 100644 --- a/src/Main/options.cxx +++ b/src/Main/options.cxx @@ -204,7 +204,7 @@ fgSetDefaults () fgSetBool("/sim/rendering/shading", true); fgSetBool("/sim/rendering/skyblend", true); fgSetBool("/sim/rendering/textures", true); - fgTie( "/sim/rendering/filtering", SGGetTextureFilter, SGSetTextureFilter, false); + fgTie( "/sim/rendering/filtering", SGGetTextureFilter, SGSetTextureFilter, false); fgSetInt("/sim/rendering/filtering", 1); fgSetBool("/sim/rendering/wireframe", false); fgSetBool("/sim/rendering/horizon-effect", false);