1
0
Fork 0

Improve OpenAL driver for IAXClient

Abort OpenAL initialization if input device are not found in this way we don't create and merge new OpenAL context with SGSoundMgr
Close OpenAL context and input device when FG is stopped
This commit is contained in:
f-jjth 2013-08-19 14:36:13 +02:00
parent b27eb2571c
commit f24c4df73f

View file

@ -248,6 +248,12 @@ int openal_mic_boost_set(struct iaxc_audio_driver *d, int enable)
int openal_destroy(struct iaxc_audio_driver *d)
{
struct openal_priv_data* priv = (struct openal_priv_data*)(d->priv);
alcCaptureStop(priv->in_dev);
alcCaptureCloseDevice(priv->in_dev);
alDeleteSources(1, &priv->source);
return 0;
}
@ -256,11 +262,19 @@ int openal_initialize(struct iaxc_audio_driver *d, int sample_rate)
struct openal_priv_data* priv = malloc(sizeof(struct openal_priv_data));
int err = alGetError();
d->priv = priv;
// First we are looking for input device
priv->in_dev = alcCaptureOpenDevice(NULL, 8000, AL_FORMAT_MONO16, 800);
if (!priv->in_dev) return openal_error("alcCaptureOpenDevice", alGetError());
alcCaptureStart(priv->in_dev);
if ((err = alGetError())) return openal_error("alcCaptureStart", err);
// Then we look for output device
priv->out_ctx = alcGetCurrentContext();
if( priv->out_ctx == NULL ) { // FGCom standalone only
ALCdevice* out_dev = alcOpenDevice(0);
ALCdevice* out_dev = alcOpenDevice(NULL);
if (out_dev == 0) return openal_error("alcOpenDevice", alGetError());
priv->out_ctx = alcCreateContext(out_dev, 0);
@ -285,12 +299,6 @@ int openal_initialize(struct iaxc_audio_driver *d, int sample_rate)
alGenSources(1, &priv->source);
if ((err = alGetError())) return openal_error("alGenSources", err);
priv->in_dev = alcCaptureOpenDevice(0, 8000, AL_FORMAT_MONO16, 800);
if (!priv->in_dev) return openal_error("alcCaptureOpenDevice", 0);
alcCaptureStart(priv->in_dev);
if ((err = alGetError())) return openal_error("alcCaptureStart", err);
d->initialize = openal_initialize;
d->destroy = openal_destroy;
d->select_devices = openal_select_devices;