All of lore.kernel.org
 help / color / mirror / Atom feed
* Bug in pcm_plugin.c, function snd_pcm_plug_alloc?
@ 2003-09-16  9:26 Nick Hogle
  2003-09-16 12:48 ` James Courtier-Dutton
  2003-09-16 16:31 ` Takashi Iwai
  0 siblings, 2 replies; 3+ messages in thread
From: Nick Hogle @ 2003-09-16  9:26 UTC (permalink / raw)
  To: alsa-devel

I believe this is a bug: the loop in plug_alloc doesn't iterate completely 
through the plugin linked list.   The problem with this, is that 
snd_pcm_plugin_alloc won't get called for every plugin in the list, and 
vital components of those plugins won't be initialized.

The solution would be to replace the while (plugin->next/prev) lines with 
while (plugin), to move lines: plugin = plugin->next/prev to the spot just 
after if (err < 0) return err;

I found that the aformentioned changes fixed a problem I was having with 
reading from /dev/dsp.   Unless I set the rate to 48000, then read() would 
always return 0.  This was because when read_transfer iterated through the 
plugins, the "rate conversion" plugin, which had not been initialized, had 
the value 0 in dst_channels[0].frames.  This caused the entire read call to 
return 0.

BTW, I'm using the intel8x0 driver, and the latest 0.9.6 release of 
alsa-drivers.

Anyone else agree that this is a bug?  Or am I missing something, that 
requires that plug_alloc to NOT iterate completely through the list?

Thanks,
-Nick

_________________________________________________________________
Get 10MB of e-mail storage! Sign up for Hotmail Extra Storage.  
http://join.msn.com/?PAGE=features/es



-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Bug in pcm_plugin.c, function snd_pcm_plug_alloc?
  2003-09-16  9:26 Bug in pcm_plugin.c, function snd_pcm_plug_alloc? Nick Hogle
@ 2003-09-16 12:48 ` James Courtier-Dutton
  2003-09-16 16:31 ` Takashi Iwai
  1 sibling, 0 replies; 3+ messages in thread
From: James Courtier-Dutton @ 2003-09-16 12:48 UTC (permalink / raw)
  To: Nick Hogle; +Cc: alsa-devel

Nick Hogle wrote:
> I believe this is a bug: the loop in plug_alloc doesn't iterate 
> completely through the plugin linked list.   The problem with this, is 
> that snd_pcm_plugin_alloc won't get called for every plugin in the list, 
> and vital components of those plugins won't be initialized.
> 
> The solution would be to replace the while (plugin->next/prev) lines 
> with while (plugin), to move lines: plugin = plugin->next/prev to the 
> spot just after if (err < 0) return err;
> 
> I found that the aformentioned changes fixed a problem I was having with 
> reading from /dev/dsp.   Unless I set the rate to 48000, then read() 
> would always return 0.  This was because when read_transfer iterated 
> through the plugins, the "rate conversion" plugin, which had not been 
> initialized, had the value 0 in dst_channels[0].frames.  This caused the 
> entire read call to return 0.
> 
> BTW, I'm using the intel8x0 driver, and the latest 0.9.6 release of 
> alsa-drivers.
> 
> Anyone else agree that this is a bug?  Or am I missing something, that 
> requires that plug_alloc to NOT iterate completely through the list?
> 
> Thanks,
> -Nick
> 
I see the "read return 0" problem sometimes with the intel8x0, but for 
me the problem appeared with arecord, and seemed to depend on some mixer 
settings.
Cheers
James




-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Bug in pcm_plugin.c, function snd_pcm_plug_alloc?
  2003-09-16  9:26 Bug in pcm_plugin.c, function snd_pcm_plug_alloc? Nick Hogle
  2003-09-16 12:48 ` James Courtier-Dutton
@ 2003-09-16 16:31 ` Takashi Iwai
  1 sibling, 0 replies; 3+ messages in thread
From: Takashi Iwai @ 2003-09-16 16:31 UTC (permalink / raw)
  To: Nick Hogle; +Cc: alsa-devel

[-- Attachment #1: Type: text/plain, Size: 1412 bytes --]

At Tue, 16 Sep 2003 02:26:43 -0700,
Nick Hogle wrote:
> 
> I believe this is a bug: the loop in plug_alloc doesn't iterate completely 
> through the plugin linked list.   The problem with this, is that 
> snd_pcm_plugin_alloc won't get called for every plugin in the list, and 
> vital components of those plugins won't be initialized.
> 
> The solution would be to replace the while (plugin->next/prev) lines with 
> while (plugin), to move lines: plugin = plugin->next/prev to the spot just 
> after if (err < 0) return err;
> 
> I found that the aformentioned changes fixed a problem I was having with 
> reading from /dev/dsp.   Unless I set the rate to 48000, then read() would 
> always return 0.  This was because when read_transfer iterated through the 
> plugins, the "rate conversion" plugin, which had not been initialized, had 
> the value 0 in dst_channels[0].frames.  This caused the entire read call to 
> return 0.
> 
> BTW, I'm using the intel8x0 driver, and the latest 0.9.6 release of 
> alsa-drivers.
> 
> Anyone else agree that this is a bug?  Or am I missing something, that 
> requires that plug_alloc to NOT iterate completely through the list?

at least i agree that is a bug, but it's in the different place :)

you don't need allocate the buffer for the last plugin because the
last one will write to the recording buffer directly.

the attached patch will fix this problem.


Takashi

[-- Attachment #2: plugin-rec-fix.dif --]
[-- Type: application/octet-stream, Size: 696 bytes --]

Index: alsa-kernel/core/oss/pcm_plugin.c
===================================================================
RCS file: /suse/tiwai/cvs/alsa/alsa-kernel/core/oss/pcm_plugin.c,v
retrieving revision 1.15
diff -u -r1.15 pcm_plugin.c
--- alsa-kernel/core/oss/pcm_plugin.c	6 Aug 2003 17:43:13 -0000	1.15
+++ alsa-kernel/core/oss/pcm_plugin.c	16 Sep 2003 16:22:45 -0000
@@ -646,6 +646,7 @@
 	nchannels = format->channels;
 	snd_assert(plugin->access == SNDRV_PCM_ACCESS_RW_INTERLEAVED || format->channels <= 1, return -ENXIO);
 	for (channel = 0; channel < nchannels; channel++, v++) {
+		v->frames = count;
 		v->enabled = 1;
 		v->wanted = (stream == SNDRV_PCM_STREAM_CAPTURE);
 		v->area.addr = buf;

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2003-09-16 16:31 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-09-16  9:26 Bug in pcm_plugin.c, function snd_pcm_plug_alloc? Nick Hogle
2003-09-16 12:48 ` James Courtier-Dutton
2003-09-16 16:31 ` 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.