Mix_QuerySpec
Name
Mix_QuerySpec -- gets the actual mixer parameters.
Synopsis
#include "SDL_mixer.h" int Mix_QuerySpec(int *frequency, Uint16 *format, int *channels);
Description
Mix_QuerySpec gets the actual audio format in use by the opened audio device. This may or may not match the parameters you passed to Mix_OpenAudio.
Parameters
frequency
- A pointer to an int where the frequency actually used by the opened audio device will be stored.
format
- A pointer to a Uint16 where the output format actually being used by the audio device will be stored.
channels
- A pointer to an int where the number of audio channels will be stored.
- 2 will mean stereo, 1 will mean mono.
Return Value
Returns 0 on error. If the device was open the number of times it was opened will be returned. The values of the arguments variables are not set on an error.
Example
// get and print the audio format in use
int numtimesopened, frequency, channels;
Uint16 format;
numtimesopened=Mix_QuerySpec(&frequency, &format, &channels);
if(!numtimesopened) {
printf("Mix_QuerySpec: %s\n",Mix_GetError());
}
else {
char *format_str="Unknown";
switch(format) {
case AUDIO_U8: format_str="U8"; break;
case AUDIO_S8: format_str="S8"; break;
case AUDIO_U16LSB: format_str="U16LSB"; break;
case AUDIO_S16LSB: format_str="S16LSB"; break;
case AUDIO_U16MSB: format_str="U16MSB"; break;
case AUDIO_S16MSB: format_str="S16MSB"; break;
}
printf("opened=%d times frequency=%dHz format=%s channels=%d",
numtimesopened, frequency, format_str, channels);
}
