All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: Memory allocation and the "prealloc" procfile
       [not found] <20050405192033.6B8A88993B@sc8-sf-spam1.sourceforge.net>
@ 2005-04-06 12:03 ` Andy Robinson
  2005-04-08 10:55   ` Clemens Ladisch
  0 siblings, 1 reply; 3+ messages in thread
From: Andy Robinson @ 2005-04-06 12:03 UTC (permalink / raw)
  To: ALSA devel

> Message: 3
> Date: Tue, 05 Apr 2005 19:16:39 +0200
> From: Takashi Iwai <tiwai@suse.de>
> To: Andy Robinson <andy@seventhstring.com>
> Cc: ALSA devel <alsa-devel@lists.sourceforge.net>
> Subject: Re: [Alsa-devel] Memory allocation and the "prealloc" procfile
> 
> At Mon, 04 Apr 2005 10:03:37 +0100,
> Andy Robinson wrote:
> > 
> > I'm using Mandrake 10.1 on a DELL Precision M60.
> > Soundcard is Intel 82801DB-ICH4
> > ALSA version 1.0.6
> > 
> > By default, /proc/asound/card0/pcm0p/sub0/prealloc contains the number
> > 64 and SNDCTL_DSP_GETOSPACE reports a total of 16k bytes output space
> > available. If I
> > echo 128 >/proc/asound/card0/pcm0p/sub0/prealloc
> > then SNDCTL_DSP_GETOSPACE reports a total of 32k bytes.
> > 
> > My question is, what is the rest of the "prealloc" memory being used
> > for? And how can I change the amounts used for whatever other purposes,
> > so as to get a bigger SNDCTL_DSP_GETOSPACE buffer? It's not such a
> > problem for me but one of my users reports that with a 128k "prealloc",
> > he still gets only 4k from SNDCTL_DSP_GETOSPACE. Is it perhaps an ALSA
> > version issue?
> 
> It might be.  It's worth to try the latest ALSA version, anyway.
> 
> If you want a bigger buffer, you can call SNDCTL_DSP_SETFRAGMENT ioctl
> to specify the fragments and its size explicitly.
> Takashi

I will try a later ALSA version and see what happens.

But I'm still curious to know, what is all
that /proc/asound/card0/pcm0p/sub0/prealloc
memory used for? I specify 128k but only get a 32k buffer reported by
SNDCTL_DSP_GETOSPACE (and one of my users gets only 4k of buffer) ...
where is the rest going? AFAIK this prealloc file relates only to
playback and only to one specific stream.

SNDCTL_DSP_SETFRAGMENT doesn't help - it can change the way the buffer
is divided into fragments but will not increase the total
SNDCTL_DSP_GETOSPACE buffer size (e.g. it can give you twice as many
fragments, of half the size).

This problem doesn't just affect me, it affects users of my software.
Therefore I would be happier if I could find some tweak to ALSA's
configuration to fix this. I consider it more user-friendly for me to
say to them "tweak this configuration file" rather than "you must
install a later ALSA version".

Regards,
Andy Robinson, Seventh String Software, www.seventhstring.com



-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click

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

* Re: Re: Memory allocation and the "prealloc" procfile
  2005-04-06 12:03 ` Memory allocation and the "prealloc" procfile Andy Robinson
@ 2005-04-08 10:55   ` Clemens Ladisch
  2005-04-08 11:06     ` Takashi Iwai
  0 siblings, 1 reply; 3+ messages in thread
From: Clemens Ladisch @ 2005-04-08 10:55 UTC (permalink / raw)
  To: Andy Robinson; +Cc: ALSA devel

Andy Robinson wrote:
> But I'm still curious to know, what is all that
> /proc/asound/card0/pcm0p/sub0/prealloc memory used for?

For the buffer. :)

> I specify 128k but only get a 32k buffer reported by
> SNDCTL_DSP_GETOSPACE (and one of my users gets only 4k of buffer)

Doesn't happen on my machine.  What parameters are you using?


$ cat ospace.c
#include <stdio.h>
#include <fcntl.h>
#include <sys/soundcard.h>

int main()
{
	int fd;
	audio_buf_info i;
	int x;

	fd = open("/dev/dsp", O_WRONLY);
	x = 1;
	ioctl(fd, SNDCTL_DSP_STEREO, &x);
	x = AFMT_S16_LE;
	ioctl(fd, SNDCTL_DSP_SETFMT, &x);
	x = 48000;
	ioctl(fd, SNDCTL_DSP_SPEED, &x);
	ioctl(fd, SNDCTL_DSP_GETOSPACE, &i);
	close(fd);
	printf("buffer bytes: %d * %d = %d\n", i.fragstotal, i.fragsize, i.fragstotal * i.fragsize);
	return 0;
}
$ cat /proc/asound/cards
0 [ICH5           ]: ICH4 - Intel ICH5
                     Intel ICH5 with AD1985 at 0xfebff400, irq 209
$ cat /proc/asound/card0/pcm0p/sub0/prealloc
64
$ ospace
buffer bytes: 16 * 4096 = 65536
$ echo 128 > /proc/asound/card0/pcm0p/sub0/prealloc
$ ospace
buffer bytes: 16 * 8192 = 131072


Regards,
Clemens



-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click

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

* Re: Re: Memory allocation and the "prealloc" procfile
  2005-04-08 10:55   ` Clemens Ladisch
@ 2005-04-08 11:06     ` Takashi Iwai
  0 siblings, 0 replies; 3+ messages in thread
From: Takashi Iwai @ 2005-04-08 11:06 UTC (permalink / raw)
  To: Clemens Ladisch; +Cc: Andy Robinson, ALSA devel

At Fri, 8 Apr 2005 12:55:29 +0200 (METDST),
Clemens Ladisch wrote:
> 
> Andy Robinson wrote:
> > But I'm still curious to know, what is all that
> > /proc/asound/card0/pcm0p/sub0/prealloc memory used for?
> 
> For the buffer. :)
> 
> > I specify 128k but only get a 32k buffer reported by
> > SNDCTL_DSP_GETOSPACE (and one of my users gets only 4k of buffer)
> 
> Doesn't happen on my machine.  What parameters are you using?

I guess this depends on the order of ioctls.

Each ioctl limits the available configuration.  At each time either
fragment size,  fragment, format, channels, etc. is changed via ioctl,
the max. buffer size is recalculated, but it won't grow once if the
size is limited via the constraint.


Takashi


-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click

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

end of thread, other threads:[~2005-04-08 11:06 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20050405192033.6B8A88993B@sc8-sf-spam1.sourceforge.net>
2005-04-06 12:03 ` Memory allocation and the "prealloc" procfile Andy Robinson
2005-04-08 10:55   ` Clemens Ladisch
2005-04-08 11:06     ` 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.