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;
}
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);
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;