- Refactor AL_SoundInfo() into the platform dependent

QAL_SoundInfo().
- Use QAL_SoundInfo() to print the OpenAL infos 
  at startup and by the "soundinfo" command.
- Implement printing of all available OpenAL
  devices at startup and by the "soundinfo"
  command.
This commit is contained in:
Yamagi Burmeister 2012-04-24 14:07:33 +00:00
parent 79c137254a
commit bf6d491af3
4 changed files with 77 additions and 15 deletions

View file

@ -26,6 +26,9 @@
* =======================================================================
*/
#ifndef _QAL_API_H_
#define _QAL_API_H_
#include <AL/al.h>
/* Function pointers used to tie
@ -104,15 +107,23 @@ extern LPALDOPPLERVELOCITY qalDopplerVelocity;
extern LPALSPEEDOFSOUND qalSpeedOfSound;
extern LPALDISTANCEMODEL qalDistanceModel;
/*
* Gives information over the OpenAL
* implementation and it's state
*/
void QAL_SoundInfo(void);
/*
* Loads the OpenAL shared lib, creates
* a context and device handle.
*/
qboolean QAL_Init( void );
qboolean QAL_Init(void);
/*
* Shuts OpenAL down, frees all context and
* device handles and unloads the shared lib.
*/
void QAL_Shutdown( void );
void QAL_Shutdown(void);
#endif /* _QAL_API_H_ */

View file

@ -30,7 +30,9 @@
*/
#include <dlfcn.h>
#include <AL/al.h>
#include <AL/alc.h>
#include <AL/alext.h>
#include "../../common/header/common.h"
#include "header/qal_api.h"
@ -138,7 +140,58 @@ LPALDOPPLERFACTOR qalDopplerFactor;
LPALDOPPLERVELOCITY qalDopplerVelocity;
LPALSPEEDOFSOUND qalSpeedOfSound;
LPALDISTANCEMODEL qalDistanceModel;
/*
* Gives information over the OpenAL
* implementation and it's state
*/
void QAL_SoundInfo()
{
Com_Printf("OpenAL settings:\n");
Com_Printf("AL_VENDOR: %s\n", qalGetString(AL_VENDOR));
Com_Printf("AL_RENDERER: %s\n", qalGetString(AL_RENDERER));
Com_Printf("AL_VERSION: %s\n", qalGetString(AL_VERSION));
Com_Printf("AL_EXTENSIONS: %s\n", qalGetString(AL_EXTENSIONS));
if (alcIsExtensionPresent(NULL, "ALC_ENUMERATE_ALL_EXT"))
{
const char *devs = alcGetString(NULL, ALC_ALL_DEVICES_SPECIFIER);
Com_Printf("\nAvailable OpenAL devices:\n");
if (devs == NULL)
{
Com_Printf("- No devices found. Depending on your\n");
Com_Printf(" platform this may be expected and\n");
Com_Printf(" doesn't indicate a problem!\n");
}
else
{
while (devs && *devs)
{
Com_Printf("- %s\n", devs);
devs += strlen(devs) + 1;
}
}
}
if (alcIsExtensionPresent(NULL, "ALC_ENUMERATE_ALL_EXT"))
{
const char *devs = alcGetString(NULL, ALC_DEVICE_SPECIFIER);
Com_Printf("\nCurrent OpenAL device:\n");
if (devs == NULL)
{
Com_Printf("- No OpenAL device in use\n");
}
else
{
Com_Printf("- %s\n", devs);
}
}
}
/*
* Shuts OpenAL down, frees all context and
* device handles and unloads the shared lib.
@ -422,6 +475,11 @@ QAL_Init()
Com_Printf("ok\n");
/* Print OpenAL informations */
Com_Printf("\n");
QAL_SoundInfo();
Com_Printf("\n");
return true;
}

View file

@ -49,14 +49,6 @@ static void S_AL_StreamUpdate( void );
static void S_AL_StreamDie( void );
// /Forward Declarations
void AL_SoundInfo( void ) {
Com_Printf( "AL_VENDOR: %s\n", qalGetString( AL_VENDOR ) );
Com_Printf( "AL_RENDERER: %s\n", qalGetString( AL_RENDERER ) );
Com_Printf( "AL_VERSION: %s\n", qalGetString( AL_VERSION ) );
Com_Printf( "AL_EXTENSIONS: %s\n", qalGetString( AL_EXTENSIONS ) );
Com_Printf( "Number of sources: %d\n", s_numchannels );
}
static void AL_InitStreamSource() {
qalSourcei (streamSource, AL_BUFFER, 0 );
qalSourcei (streamSource, AL_LOOPING, AL_FALSE );
@ -108,10 +100,9 @@ qboolean AL_Init( void ) {
s_numchannels = i;
AL_InitStreamSource();
Com_Printf("Number of OpenAL sources: %d\n\n", s_numchannels);
Com_Printf("\nOpenAL setting:\n");
AL_SoundInfo();
Com_Printf("\n");
return true;
fail:

View file

@ -29,6 +29,7 @@
#include "../header/client.h"
#include "header/local.h"
#include "header/vorbis.h"
#include "header/qal_api.h"
void S_Play ( void );
void S_SoundList ( void );
@ -108,7 +109,8 @@ S_SoundInfo_f ( void )
}
#if USE_OPENAL
if(sound_started == SS_OAL) {
AL_SoundInfo();
QAL_SoundInfo();
Com_Printf("\nNumber of sources: %d\n", s_numchannels);
} else
#endif
DMA_SoundInfo();