I am working on pulseaudio for recording sound and I faced with the "Access Denied" error.
First of all, I am working in Ubuntu 16.04 machine. I am trying to connect to server with following part of code :
_s = NULL;
int32_t err = -1;
_ss.format = PA_SAMPLE_S16LE;
_ss.rate = 44100;
_ss.channels = 2;
_s = pa_simple_new(NULL, "Recorder", PA_STREAM_RECORD, NULL, "record", &_ss, NULL, NULL, &err);
pa_simple_new not return null, so I assume that, this part is not wrong.
But in another part of code, I am trying to read data from server like following :
int32_t err = -1;
int8_t buff[ ( CIRC_DATA_SIZE ) ] = { 0x00 };
if ( pa_simple_read(_s, &buff, ( CIRC_DATA_SIZE ), &err ) > 0 )
{
_ReadBuff->add_to_buffer(buff, ( CIRC_DATA_SIZE ) );
}else { DEBUG_MSG("Unable to read from audio device, %s\n", pa_strerror(err)); }
In the output of application, I saw following statement : Unable to read from audio device, Access denied
Then I set the PULSE_COOKIE environment variable like this :
export PULSE_COOKIE=/home/sbahadirarslan/.config/pulse/cookie
By the way, cookie file is really exist in /home/sbahadirarslan/.config/pulse directory.
After this arrangement, application give me same error log. Then I set PULSE_SERVER environment variable like this :
export PULSE_SERVER=unix:/run/user/1000/pulse/native
But after this change, application gave me the same error. So Are these changes wrong or Do I have to make other changes ?
Thanks for your helps.