From f11e3e39a146187ac9c4df8bd8f6a8d051f491f4 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Wed, 21 Mar 2012 20:15:01 -0700 Subject: [PATCH] Add an enumerate method to the sound output interface --- apps/openmw/mwsound/openal_output.cpp | 14 ++++++++++++++ apps/openmw/mwsound/openal_output.hpp | 1 + apps/openmw/mwsound/sound_output.hpp | 1 + apps/openmw/mwsound/soundmanager.cpp | 6 ++++++ 4 files changed, 22 insertions(+) diff --git a/apps/openmw/mwsound/openal_output.cpp b/apps/openmw/mwsound/openal_output.cpp index ed7be21f63..6ee36b1ab1 100644 --- a/apps/openmw/mwsound/openal_output.cpp +++ b/apps/openmw/mwsound/openal_output.cpp @@ -358,6 +358,20 @@ void OpenAL_Sound::update(const float *pos) // // An OpenAL output device // +std::vector OpenAL_Output::enumerate() +{ + std::vector 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) { if(mDevice || mContext) diff --git a/apps/openmw/mwsound/openal_output.hpp b/apps/openmw/mwsound/openal_output.hpp index aeb64ad0d1..6e41c7deed 100644 --- a/apps/openmw/mwsound/openal_output.hpp +++ b/apps/openmw/mwsound/openal_output.hpp @@ -38,6 +38,7 @@ namespace MWSound ALuint getBuffer(const std::string &fname); void bufferFinished(ALuint buffer); + virtual std::vector enumerate(); virtual void init(const std::string &devname=""); virtual void deinit(); diff --git a/apps/openmw/mwsound/sound_output.hpp b/apps/openmw/mwsound/sound_output.hpp index a2a035e710..14b61e6099 100644 --- a/apps/openmw/mwsound/sound_output.hpp +++ b/apps/openmw/mwsound/sound_output.hpp @@ -16,6 +16,7 @@ namespace MWSound { SoundManager &mManager; + virtual std::vector enumerate() = 0; virtual void init(const std::string &devname="") = 0; virtual void deinit() = 0; diff --git a/apps/openmw/mwsound/soundmanager.cpp b/apps/openmw/mwsound/soundmanager.cpp index 4cc4eec934..e3931afd64 100644 --- a/apps/openmw/mwsound/soundmanager.cpp +++ b/apps/openmw/mwsound/soundmanager.cpp @@ -53,6 +53,12 @@ namespace MWSound try { mOutput.reset(new DEFAULT_OUTPUT(*this)); + + std::vector names = mOutput->enumerate(); + std::cout <<"Enumerated output devices:"<< std::endl; + for(size_t i = 0;i < names.size();i++) + std::cout <<" "<init(); } catch(std::exception &e)