Short answer: yes your code appears to be correct.
Long answer below:
First ensure you are using OpenAL-Soft, so you’ll know for sure that the OpenAL implementation you use is not full of bugs:
http://kcat.strangesoft.net/openal.html
Then ensure your application is actually using the OpenAL-Soft software renderer by selecting the proper device.
I mention this because there are few hardware OpenAL drivers from Creative/Realtek that actually gets the listener orientation right (believe it or not). I have wasted weeks only to find out that nothing was wrong with my code. Always use software audio, hardware is long dead and highly unreliable.
OpenAL listener orientation requires two parameters stored in a single array; a forward facing vector and ‘up-vector’, both in world space orientation.
Pseudo code from our engine:
float m[16]; // world space camera transform
vec3 position = vec3( m[12], m[13], m[14] ); // world space position
vec3 up = vec3( m[4], m[5], m[6] ); // world space up vector
vec3 front = vec3( -m[8], -m[9], -m[10] ); // vector facing forward from camera/listener position
float ori[6];
ori[0] = fr.x;
ori[1] = fr.y;
ori[2] = fr.z;
ori[3] = up.x;
ori[4] = up.y;
ori[5] = up.z;
alListenerfv(AL_POSITION, pos);
alListenerfv(AL_ORIENTATION, ori);
Keep in mind that ‘m’ here, is a regular transformation matrix (e.g. the same you use to transform an entity to it’s world space position).
So you have to take the inverse of GL_MODELVIEW_MATRIX (or the transpose if you are only interested in the rotation part, which is much much easier to compute).
For reference, this is how the view transform is set up in the same engine:
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(camera->fov, asp, camera->nearplane, camera->farplane);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glMultMatrixf( camera->transform->GetInverse() );
Hope that helps.