Search code examples
c++copenalpulseaudio

What does, 'AL lib: pulseaudio.c:612: Context did not connect: Access denied' mean?


I'm getting the following error when running a simple OpenAL program:

AL lib: pulseaudio.c:612: Context did not connect: Access denied

Interestingly, if I try playing audio then it plays correctly, although it sounds slightly distorted.

Below is the code that produces the error. It also happens if I initialize with ALUT.

#include <AL/al.h>
#include <AL/alc.h>
#include <string.h>

int main() {
  ALCdevice* dev;
  ALCcontext* ctx;
  dev = alcOpenDevice(NULL);
  ctx = alcCreateContext(dev, NULL);
  alcMakeContextCurrent(ctx);
  // cleanup
  alcMakeContextCurrent(NULL);
  alcDestroyContext(ctx);
  alcCloseDevice(dev);
  return 0;
}

What does the error mean? Can I fix it?


Solution

  • I fixed it by changing /etc/openal/alsoft.conf (I'm using Arch Linux) to this:

    drivers=alsa,pulse
    

    The default checks Pulse first, which I didn't have installed.

    Installing Pulse should fix it too.