1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-22 10:53:54 +00:00

Add an enumerate method to the sound output interface

This commit is contained in:
Chris Robinson 2012-03-21 20:15:01 -07:00
parent 366c97c492
commit f11e3e39a1
4 changed files with 22 additions and 0 deletions

View file

@ -358,6 +358,20 @@ void OpenAL_Sound::update(const float *pos)
// //
// An OpenAL output device // An OpenAL output device
// //
std::vector<std::string> OpenAL_Output::enumerate()
{
std::vector<std::string> devlist;
const ALCchar *devnames;
devnames = alcGetString(NULL, ALC_DEVICE_SPECIFIER);
while(devnames && *devnames)
{
devlist.push_back(devnames);
devnames += strlen(devnames)+1;
}
return devlist;
}
void OpenAL_Output::init(const std::string &devname) void OpenAL_Output::init(const std::string &devname)
{ {
if(mDevice || mContext) if(mDevice || mContext)

View file

@ -38,6 +38,7 @@ namespace MWSound
ALuint getBuffer(const std::string &fname); ALuint getBuffer(const std::string &fname);
void bufferFinished(ALuint buffer); void bufferFinished(ALuint buffer);
virtual std::vector<std::string> enumerate();
virtual void init(const std::string &devname=""); virtual void init(const std::string &devname="");
virtual void deinit(); virtual void deinit();

View file

@ -16,6 +16,7 @@ namespace MWSound
{ {
SoundManager &mManager; SoundManager &mManager;
virtual std::vector<std::string> enumerate() = 0;
virtual void init(const std::string &devname="") = 0; virtual void init(const std::string &devname="") = 0;
virtual void deinit() = 0; virtual void deinit() = 0;

View file

@ -53,6 +53,12 @@ namespace MWSound
try try
{ {
mOutput.reset(new DEFAULT_OUTPUT(*this)); mOutput.reset(new DEFAULT_OUTPUT(*this));
std::vector<std::string> names = mOutput->enumerate();
std::cout <<"Enumerated output devices:"<< std::endl;
for(size_t i = 0;i < names.size();i++)
std::cout <<" "<<names[i]<< std::endl;
mOutput->init(); mOutput->init();
} }
catch(std::exception &e) catch(std::exception &e)