Hi,

I am working on a more complete pipewire audio sink
(audio/pipewire-spa-oss-ng) and ran into an interesting case where a
user has an interface with 10 channels on one dsp device.

In sys/dev/sound/pcm/channel.h we currently have:
#define CHN_2NDBUFMAXSIZE 131072

This is workable but results in a tighter bound than my sink requests.

I am wondering if we should dynamically scale, something like this:

 #define CHN_2NDBUFMAXSIZE_DEFAULT 131072
 #define CHN_2NDBUFMAXSIZE_LIMIT   1048576

 static uint32_t
 chn_2ndbuf_maxsize(struct pcm_channel *c)
 {
         struct snd_dbuf *bs = c->bufsoft;
         uint64_t bytes;

         /* e.g. allow up to about 100 ms of the actual stream. */
         bytes = (uint64_t)bs->align * bs->spd / 10;

         if (bytes < CHN_2NDBUFMAXSIZE_DEFAULT)
                 bytes = CHN_2NDBUFMAXSIZE_DEFAULT;
         if (bytes > chn_2ndbuf_maxsize_limit)
                 bytes = chn_2ndbuf_maxsize_limit;

         return (uint32_t)bytes;
 }

I can send a complete patch for review if it seems like a reasonable direction.

Regards,
Kevin Bowling

Reply via email to