Add a function to retreive all available playback devices.
This commit is contained in:
@@ -562,6 +562,32 @@ bool SGSoundMgr::load(string &samplepath, void **dbuf, int *fmt,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vector<const char*> SGSoundMgr::get_available_devices()
|
||||||
|
{
|
||||||
|
vector<const char*> devices;
|
||||||
|
const ALCchar *s;
|
||||||
|
|
||||||
|
if (alcIsExtensionPresent(NULL, "ALC_enumerate_all_EXT") == AL_TRUE) {
|
||||||
|
s = alcGetString(NULL, ALC_ALL_DEVICES_SPECIFIER);
|
||||||
|
} else {
|
||||||
|
s = alcGetString(NULL, ALC_DEVICE_SPECIFIER);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (s) {
|
||||||
|
ALCchar *nptr, *ptr = (ALCchar *)s;
|
||||||
|
|
||||||
|
nptr = ptr;
|
||||||
|
while (*(nptr += strlen(ptr)+1) != 0)
|
||||||
|
{
|
||||||
|
devices.push_back(ptr);
|
||||||
|
ptr = nptr;
|
||||||
|
}
|
||||||
|
devices.push_back(ptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
return devices;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool SGSoundMgr::testForError(void *p, string s)
|
bool SGSoundMgr::testForError(void *p, string s)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -59,6 +59,10 @@
|
|||||||
# include <AL/alut.h>
|
# include <AL/alut.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef ALC_ALL_DEVICES_SPECIFIER
|
||||||
|
# define ALC_ALL_DEVICES_SPECIFIER 0x1013
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <simgear/compiler.h>
|
#include <simgear/compiler.h>
|
||||||
#include <simgear/structure/subsystem_mgr.hxx>
|
#include <simgear/structure/subsystem_mgr.hxx>
|
||||||
#include <simgear/math/SGMathFwd.hxx>
|
#include <simgear/math/SGMathFwd.hxx>
|
||||||
@@ -280,6 +284,11 @@ public:
|
|||||||
bool load(string &samplepath, void **data, int *format,
|
bool load(string &samplepath, void **data, int *format,
|
||||||
size_t *size, int *freq );
|
size_t *size, int *freq );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a list of available playback devices.
|
||||||
|
*/
|
||||||
|
vector<const char*> get_available_devices();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static int _alut_init;
|
static int _alut_init;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user