playback open error:
Hi,
I m trying to run the simple playback program that I have attached with this email -- and I get the following error:
ALSA lib pcm_dmix.c:862:(snd_pcm_dmix_open) unable to open slave
Quoted 1 line
Playback open error: Device or resource busy
I am running this program as a function called wavplay (attached) -- however, if i run the same program, as part of the main function, then there is no problem --
What i mean is that if i basically just paste the code for the wavplay function in main and provide the input values (the pcm data to be played) -- then it can very well open the default device and play the pcm data that is being passed to it!
Any pointers?
Thanks,
Ashlesha.
#include "common.h"
void wavplay(short int in[], int lastind) //lastind - no. of samples from buffin to be played
{
static char *device = "default"; /* playback device */
snd_output_t *output = NULL;
int count;
short int buffin[lastind];
int err,bytesread=1;
unsigned int i;
char d;
snd_pcm_t *handle;
snd_pcm_sframes_t frames;
count=0;
while(count<lastind) // copy the input buffer into a local buffer to be played
buffin[count]=in[count++];// printf("no. of samples @16000Hz are %d\n",count);
if ((err = snd_pcm_open(&handle, device, SND_PCM_STREAM_PLAYBACK, 0)) < 0) {
printf("Playback open error: %s\n", snd_strerror(err));
exit(EXIT_FAILURE);
}
if ((err = snd_pcm_set_params(handle,
SND_PCM_FORMAT_S16_LE,
SND_PCM_ACCESS_RW_INTERLEAVED,
1,
16000,
1,
10000)) < 0) { /* 2 sec */
printf("Playback open error: %s\n", snd_strerror(err));
exit(EXIT_FAILURE);
}
for (i = 0; i < 16; i++) {
//frames = snd_pcm_writei(handle, buffin, sizeof(buffin));
frames = snd_pcm_writei(handle, buffin, 128000);
if (frames < 0)
frames = snd_pcm_recover(handle, frames, 0);
if (frames < 0) {
printf("snd_pcm_writei failed: %s\n", snd_strerror(err));
break;
}
if (frames > 0 && frames < (long)sizeof(buffin))
printf("Short write (expected %li, wrote %li)\n", (long)sizeof(buffin), frames);
}
snd_pcm_close(handle);
//return 0;
}// problem is the fact that the alsa gives an error on the device open! says device is busy.. // /dev/dsp and fuser -v /dev/dsp gives no output!
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
Sorry forgot to add that
Quoted 2 lines
fuser -v
/dev/dsp
gives no output --
Thanks,
Ashlesha.
Quoted 24 lines · Ashlesha Shintre
Hi,
I m trying to run the simple playback program that I have attached with this email -- and I get the following error:
ALSA lib pcm_dmix.c:862:(snd_pcm_dmix_open) unable to open slave
Quoted 1 line
Playback open error: Device or resource busy
I am running this program as a function called wavplay (attached) -- however, if i run the same program, as part of the main function, then there is no problem --
What i mean is that if i basically just paste the code for the wavplay function in main and provide the input values (the pcm data to be played) -- then it can very well open the default device and play the pcm data that is being passed to it!Any pointers?
Thanks,
Ashlesha.
Quoted 8 lines · Ashlesha Shintre
Hi,
I m trying to run the simple playback program that I have attached with this email -- and I get the following error:
ALSA lib pcm_dmix.c:862:(snd_pcm_dmix_open) unable to open slave
Quoted 1 line
Playback open error: Device or resource busy
Are you calling wavplay in a loop or something? Maybe a delay is required between closing the device and opening it again.
Lee