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:
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; // world space camera transform
vec3 position = vec3( m, m, m ); // world space position
vec3 up = vec3( m, m, m ); // world space up vector
vec3 front = vec3( -m, -m, -m ); // vector facing forward from camera/listener position
ori = fr.x;
ori = fr.y;
ori = fr.z;
ori = up.x;
ori = up.y;
ori = up.z;
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:
gluPerspective(camera->fov, asp, camera->nearplane, camera->farplane);
glMultMatrixf( camera->transform->GetInverse() );
Hope that helps.