Make it possible to specify a different device name
This commit is contained in:
@@ -69,7 +69,6 @@ SGSoundMgr::SGSoundMgr() :
|
||||
_geod_pos(SGGeod::fromCart(SGVec3d::zeros())),
|
||||
_velocity(SGVec3d::zeros()),
|
||||
_orientation(SGQuatd::zeros()),
|
||||
_devname(NULL),
|
||||
_bad_doppler(false)
|
||||
{
|
||||
#if defined(ALUT_API_MAJOR_VERSION) && ALUT_API_MAJOR_VERSION >= 1
|
||||
@@ -97,13 +96,16 @@ SGSoundMgr::~SGSoundMgr() {
|
||||
}
|
||||
|
||||
// initialize the sound manager
|
||||
void SGSoundMgr::init() {
|
||||
void SGSoundMgr::init(const char *devname) {
|
||||
|
||||
SG_LOG( SG_GENERAL, SG_INFO, "Initializing OpenAL sound manager" );
|
||||
|
||||
ALCdevice *device = alcOpenDevice(_devname);
|
||||
if ( testForError(device, "No default audio device available.") ) {
|
||||
return;
|
||||
ALCdevice *device = alcOpenDevice(devname);
|
||||
if ( testForError(device, "Audio device not available, trying default") ) {
|
||||
ALCdevice *device = alcOpenDevice(NULL);
|
||||
if (testForError(device, "Default Audio device not available.") ) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
ALCcontext *context = alcCreateContext(device, NULL);
|
||||
|
||||
@@ -95,7 +95,7 @@ public:
|
||||
SGSoundMgr();
|
||||
~SGSoundMgr();
|
||||
|
||||
void init();
|
||||
void init(const char *devname = NULL);
|
||||
void bind();
|
||||
void unbind();
|
||||
void update(double dt);
|
||||
@@ -311,7 +311,6 @@ private:
|
||||
vector<ALuint> _free_sources;
|
||||
vector<ALuint> _sources_in_use;
|
||||
|
||||
char *_devname;
|
||||
bool _bad_doppler;
|
||||
|
||||
bool testForALError(string s);
|
||||
|
||||
Reference in New Issue
Block a user