mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-22 07:23:52 +00:00
Add an enumerate method to the sound output interface
This commit is contained in:
parent
366c97c492
commit
f11e3e39a1
4 changed files with 22 additions and 0 deletions
|
@ -358,6 +358,20 @@ void OpenAL_Sound::update(const float *pos)
|
|||
//
|
||||
// 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)
|
||||
{
|
||||
if(mDevice || mContext)
|
||||
|
|
|
@ -38,6 +38,7 @@ namespace MWSound
|
|||
ALuint getBuffer(const std::string &fname);
|
||||
void bufferFinished(ALuint buffer);
|
||||
|
||||
virtual std::vector<std::string> enumerate();
|
||||
virtual void init(const std::string &devname="");
|
||||
virtual void deinit();
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@ namespace MWSound
|
|||
{
|
||||
SoundManager &mManager;
|
||||
|
||||
virtual std::vector<std::string> enumerate() = 0;
|
||||
virtual void init(const std::string &devname="") = 0;
|
||||
virtual void deinit() = 0;
|
||||
|
||||
|
|
|
@ -53,6 +53,12 @@ namespace MWSound
|
|||
try
|
||||
{
|
||||
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();
|
||||
}
|
||||
catch(std::exception &e)
|
||||
|
|
Loading…
Reference in a new issue