* reset of kernel input buffer for /dev/dsp @ 2010-11-27 12:33 Amit Nagal 2010-11-29 8:00 ` Clemens Ladisch 0 siblings, 1 reply; 6+ messages in thread From: Amit Nagal @ 2010-11-27 12:33 UTC (permalink / raw) To: alsa-devel; +Cc: alsa-user, tiwai, Clemens Ladisch 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 ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: reset of kernel input buffer for /dev/dsp 2010-11-27 12:33 reset of kernel input buffer for /dev/dsp Amit Nagal @ 2010-11-29 8:00 ` Clemens Ladisch 2010-11-29 8:40 ` Amit Nagal 0 siblings, 1 reply; 6+ messages in thread From: Clemens Ladisch @ 2010-11-29 8:00 UTC (permalink / raw) To: Amit Nagal; +Cc: alsa-user, tiwai, alsa-devel 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 ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: reset of kernel input buffer for /dev/dsp 2010-11-29 8:00 ` Clemens Ladisch @ 2010-11-29 8:40 ` Amit Nagal 2010-11-29 8:58 ` Takashi Iwai 0 siblings, 1 reply; 6+ messages in thread From: Amit Nagal @ 2010-11-29 8:40 UTC (permalink / raw) To: Clemens Ladisch; +Cc: alsa-user, tiwai, alsa-devel 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 > ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: reset of kernel input buffer for /dev/dsp 2010-11-29 8:40 ` Amit Nagal @ 2010-11-29 8:58 ` Takashi Iwai 2010-11-30 2:51 ` Amit Nagal 0 siblings, 1 reply; 6+ messages in thread From: Takashi Iwai @ 2010-11-29 8:58 UTC (permalink / raw) To: Amit Nagal; +Cc: alsa-user, alsa-devel, Clemens Ladisch 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; } ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: reset of kernel input buffer for /dev/dsp 2010-11-29 8:58 ` Takashi Iwai @ 2010-11-30 2:51 ` Amit Nagal 2010-11-30 7:20 ` Takashi Iwai 0 siblings, 1 reply; 6+ messages in thread From: Amit Nagal @ 2010-11-30 2:51 UTC (permalink / raw) To: Takashi Iwai; +Cc: alsa-user, alsa-devel, Clemens Ladisch 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; > } > ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: reset of kernel input buffer for /dev/dsp 2010-11-30 2:51 ` Amit Nagal @ 2010-11-30 7:20 ` Takashi Iwai 0 siblings, 0 replies; 6+ messages in thread From: Takashi Iwai @ 2010-11-30 7:20 UTC (permalink / raw) To: Amit Nagal; +Cc: alsa-user, alsa-devel, Clemens Ladisch 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; > > } > > > _______________________________________________ Alsa-devel mailing list Alsa-devel@alsa-project.org http://mailman.alsa-project.org/mailman/listinfo/alsa-devel ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2010-11-30 7:20 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2010-11-27 12:33 reset of kernel input buffer for /dev/dsp Amit Nagal 2010-11-29 8:00 ` Clemens Ladisch 2010-11-29 8:40 ` Amit Nagal 2010-11-29 8:58 ` Takashi Iwai 2010-11-30 2:51 ` Amit Nagal 2010-11-30 7:20 ` Takashi Iwai
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.