[alsa-devel] reset of kernel input buffer for /dev/dsp
Hi ,
i am doing usb audio streaming using usb audio class interface .
our application is OSS based , uses OSS calls to interact with linux audio driver .
Our device is capture only device .
we want to flush kernel input pcm buffer without using close() system call .
does OSS supports in userspace any ioctl call which can flush kernel pcm buffer at any time .
right now we have to close audio-fd and open audio-fd again .
how we can flush kernel input pcm buffer without using close system call in based OSS application
regards Amit Nagal
Hi ,
Thanx for the reply .
we tried SNDCTL_DSP_RESET , but it is not flushing the kernel pcm buffer for us .
any other method which we can use ?
also please lets us the function available with alsa - lib which serves the purpose of flushing the kernel pcm buffer .
thanx & regards amit nagal
On Mon, Nov 29, 2010 at 5:00 PM, Clemens Ladisch clemens@ladisch.de wrote:
Amit Nagal wrote:
we want to flush kernel input pcm buffer without using close() system call .
does OSS supports in userspace any ioctl call which can flush kernel pcm buffer at any time .
SNDCTL_DSP_RESET
Regards, Clemens
At Mon, 29 Nov 2010 17:40:03 +0900, Amit Nagal wrote:
Hi ,
Thanx for the reply .
we tried SNDCTL_DSP_RESET , but it is not flushing the kernel pcm buffer for us .
It should. It abandons the pending data and resets to the initial state before starting the stream.
But, it might be a bug in OSS emulation later. It doesn't seem to reset the internal buffer. Try the patch below.
any other method which we can use ?
also please lets us the function available with alsa - lib which serves the purpose of flushing the kernel pcm buffer .
snd_pcm_drop() corresponds to it.
Takashi
--- diff --git a/sound/core/oss/pcm_oss.c b/sound/core/oss/pcm_oss.c index 5c8c7df..a4411a3 100644 --- a/sound/core/oss/pcm_oss.c +++ b/sound/core/oss/pcm_oss.c @@ -1510,16 +1510,19 @@ static ssize_t snd_pcm_oss_read1(struct snd_pcm_substream *substream, char __use static int snd_pcm_oss_reset(struct snd_pcm_oss_file *pcm_oss_file) { struct snd_pcm_substream *substream; + struct snd_pcm_runtime *runtime; + int i;
- substream = pcm_oss_file->streams[SNDRV_PCM_STREAM_PLAYBACK]; - if (substream != NULL) { - snd_pcm_kernel_ioctl(substream, SNDRV_PCM_IOCTL_DROP, NULL); - substream->runtime->oss.prepare = 1; - } - substream = pcm_oss_file->streams[SNDRV_PCM_STREAM_CAPTURE]; - if (substream != NULL) { + for (i = 0; i < 2; i++) { + substream = pcm_oss_file->streams[i]; + if (!substream) + continue; + runtime = substream->runtine; snd_pcm_kernel_ioctl(substream, SNDRV_PCM_IOCTL_DROP, NULL); - substream->runtime->oss.prepare = 1; + runtime->oss.prepare = 1; + runtime->oss.buffer_used = 0; + runtime->oss.prev_hw_ptr_period = 0; + runtime->oss.period_ptr = 0; } return 0; }
Hi ,
Thanx for the patch . Application of this patch resolves kernel pcm ring buffer flush problem . Now SNDCTL_DSP_RESET works properly .
On a suggestive note , as this bug is present in main stream kernel also , this patch should also be applied as well .
Thanx & Regards Amit Nagal
On Mon, Nov 29, 2010 at 5:58 PM, Takashi Iwai tiwai@suse.de wrote:
At Mon, 29 Nov 2010 17:40:03 +0900, Amit Nagal wrote:
Hi ,
Thanx for the reply .
we tried SNDCTL_DSP_RESET , but it is not flushing the kernel pcm buffer for us .
It should. It abandons the pending data and resets to the initial state before starting the stream.
But, it might be a bug in OSS emulation later. It doesn't seem to reset the internal buffer. Try the patch below.
any other method which we can use ?
also please lets us the function available with alsa - lib which serves the purpose of flushing the kernel pcm buffer .
snd_pcm_drop() corresponds to it.
Takashi
diff --git a/sound/core/oss/pcm_oss.c b/sound/core/oss/pcm_oss.c index 5c8c7df..a4411a3 100644 --- a/sound/core/oss/pcm_oss.c +++ b/sound/core/oss/pcm_oss.c @@ -1510,16 +1510,19 @@ static ssize_t snd_pcm_oss_read1(struct snd_pcm_substream *substream, char __use static int snd_pcm_oss_reset(struct snd_pcm_oss_file *pcm_oss_file) { struct snd_pcm_substream *substream;
- struct snd_pcm_runtime *runtime;
- int i;
- substream = pcm_oss_file->streams[SNDRV_PCM_STREAM_PLAYBACK];
- if (substream != NULL) {
- snd_pcm_kernel_ioctl(substream, SNDRV_PCM_IOCTL_DROP, NULL);
- substream->runtime->oss.prepare = 1;
- }
- substream = pcm_oss_file->streams[SNDRV_PCM_STREAM_CAPTURE];
- if (substream != NULL) {
- for (i = 0; i < 2; i++) {
- substream = pcm_oss_file->streams[i];
- if (!substream)
- continue;
- runtime = substream->runtine;
snd_pcm_kernel_ioctl(substream, SNDRV_PCM_IOCTL_DROP, NULL);
- substream->runtime->oss.prepare = 1;
- runtime->oss.prepare = 1;
- runtime->oss.buffer_used = 0;
- runtime->oss.prev_hw_ptr_period = 0;
- runtime->oss.period_ptr = 0;
} return 0; }
At Tue, 30 Nov 2010 11:51:33 +0900, Amit Nagal wrote:
Hi ,
Thanx for the patch . Application of this patch resolves kernel pcm ring buffer flush problem . Now SNDCTL_DSP_RESET works properly .
On a suggestive note , as this bug is present in main stream kernel also , this patch should also be applied as well .
Thanks for testing. Yes, I applied the patch now, and it'll be included in the stable kernel as well.
Takashi
Thanx & Regards Amit Nagal
On Mon, Nov 29, 2010 at 5:58 PM, Takashi Iwai tiwai@suse.de wrote:
At Mon, 29 Nov 2010 17:40:03 +0900, Amit Nagal wrote:
Hi ,
Thanx for the reply .
we tried SNDCTL_DSP_RESET , but it is not flushing the kernel pcm buffer for us .
It should. It abandons the pending data and resets to the initial state before starting the stream.
But, it might be a bug in OSS emulation later. It doesn't seem to reset the internal buffer. Try the patch below.
any other method which we can use ?
also please lets us the function available with alsa - lib which serves the purpose of flushing the kernel pcm buffer .
snd_pcm_drop() corresponds to it.
Takashi
diff --git a/sound/core/oss/pcm_oss.c b/sound/core/oss/pcm_oss.c index 5c8c7df..a4411a3 100644 --- a/sound/core/oss/pcm_oss.c +++ b/sound/core/oss/pcm_oss.c @@ -1510,16 +1510,19 @@ static ssize_t snd_pcm_oss_read1(struct snd_pcm_substream *substream, char __use static int snd_pcm_oss_reset(struct snd_pcm_oss_file *pcm_oss_file) { struct snd_pcm_substream *substream;
- struct snd_pcm_runtime *runtime;
- int i;
- substream = pcm_oss_file->streams[SNDRV_PCM_STREAM_PLAYBACK];
- if (substream != NULL) {
- snd_pcm_kernel_ioctl(substream, SNDRV_PCM_IOCTL_DROP, NULL);
- substream->runtime->oss.prepare = 1;
- }
- substream = pcm_oss_file->streams[SNDRV_PCM_STREAM_CAPTURE];
- if (substream != NULL) {
- for (i = 0; i < 2; i++) {
- substream = pcm_oss_file->streams[i];
- if (!substream)
- continue;
- runtime = substream->runtine;
snd_pcm_kernel_ioctl(substream, SNDRV_PCM_IOCTL_DROP, NULL);
- substream->runtime->oss.prepare = 1;
- runtime->oss.prepare = 1;
- runtime->oss.buffer_used = 0;
- runtime->oss.prev_hw_ptr_period = 0;
- runtime->oss.period_ptr = 0;
} return 0; }
participants (3)
-
Amit Nagal
-
Clemens Ladisch
-
Takashi Iwai