All of lore.kernel.org
 help / color / mirror / Atom feed
* Dummy module and sample rates
@ 2015-09-23 11:43 Uli Franke
  2015-09-24  7:02 ` Clemens Ladisch
  0 siblings, 1 reply; 5+ messages in thread
From: Uli Franke @ 2015-09-23 11:43 UTC (permalink / raw)
  To: alsa-devel@alsa-project.org

Hi Clemens,

I fiddled around with the Dummy module and it seems to be the thing
we're looking for. I observed a rather strange behavior though:

I set the hw params sample rate to 44k1 without error, but a subsequent
call of snd_pcm_start returns EPIPE. When setting hw params sample rate
to 4k this does not happen. Did I miss anything?

Regards
Uli

____
uli@ankerklause:~/.../dlna/wdmr$ modinfo snd-dummy
filename:
/lib/modules/3.16.0-46-generic/kernel/sound/drivers/snd-dummy.ko
license:        GPL
description:    Dummy soundcard (/dev/null)
author:         Jaroslav Kysela <perex@perex.cz>
srcversion:     BB2C5716F580F3D7D0F53D1
depends:        snd-pcm,snd
intree:         Y
vermagic:       3.16.0-46-generic SMP mod_unload modversions 686
signer:         Magrathea: Glacier signing key
sig_key:        6C:3B:5C:5E:34:A0:6D:7D:5F:7D:A3:D0:50:98:75:D9:6C:6D:E6:C4
sig_hashalgo:   sha512
parm:           index:Index value for dummy soundcard. (array of int)
parm:           id:ID string for dummy soundcard. (array of charp)
parm:           enable:Enable this dummy soundcard. (array of bool)
parm:           model:Soundcard model. (array of charp)
parm:           pcm_devs:PCM devices # (0-4) for dummy driver. (array of
int)
parm:           pcm_substreams:PCM substreams # (1-128) for dummy
driver. (array of int)
parm:           fake_buffer:Fake buffer allocations. (bool)
parm:           hrtimer:Use hrtimer as the timer source. (bool)

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

* Re: Dummy module and sample rates
  2015-09-23 11:43 Dummy module and sample rates Uli Franke
@ 2015-09-24  7:02 ` Clemens Ladisch
  2015-09-24 10:49   ` Uli Franke
  0 siblings, 1 reply; 5+ messages in thread
From: Clemens Ladisch @ 2015-09-24  7:02 UTC (permalink / raw)
  To: Uli Franke, alsa-devel@alsa-project.org

Uli Franke wrote:
> I fiddled around with the Dummy module and it seems to be the thing
> we're looking for. I observed a rather strange behavior though:
>
> I set the hw params sample rate to 44k1 without error, but a subsequent
> call of snd_pcm_start returns EPIPE. When setting hw params sample rate
> to 4k this does not happen.

In theory, this error code is returned if you didn't write any samples
into the buffer before starting.

An underrun is possible too, but should be reported later AFAIK.
Could you check if a larger buffer size helps?


Regards,
Clemens

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

* Re: Dummy module and sample rates
  2015-09-24  7:02 ` Clemens Ladisch
@ 2015-09-24 10:49   ` Uli Franke
  2015-09-24 18:40     ` Clemens Ladisch
  2015-10-10  7:59     ` Raymond Yau
  0 siblings, 2 replies; 5+ messages in thread
From: Uli Franke @ 2015-09-24 10:49 UTC (permalink / raw)
  To: alsa-devel@alsa-project.org

>> I fiddled around with the Dummy module and it seems to be the thing
>> we're looking for. I observed a rather strange behavior though:
>>
>> I set the hw params sample rate to 44k1 without error, but a subsequent
>> call of snd_pcm_start returns EPIPE. When setting hw params sample rate
>> to 4k this does not happen.
> 
> In theory, this error code is returned if you didn't write any samples
> into the buffer before starting.
> 
> An underrun is possible too, but should be reported later AFAIK.
> Could you check if a larger buffer size helps?

I checked if this is actually an XRun, as this is the official error
code. But even recover didn't have any effect.

When I write samples before starting the stream, snd_pcm_start returns

   File descriptor in bad state (-77)

which is obvious as the state of the stream changes from PREPARED to
RUNNING.

I tried to increase the buffer but with no effect.

No error occurs when I just write samples and omit the snd_pcm_start. I
just read some examples and got the impression that this seems to be
common practice anyhow. But up to now all my ALSA interfacing programs
actively started the stream and I never had any similar effect.

You can find a small test program here:

http://460c9235de50fe3b.paste.se/

Regards,
Uli

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

* Re: Dummy module and sample rates
  2015-09-24 10:49   ` Uli Franke
@ 2015-09-24 18:40     ` Clemens Ladisch
  2015-10-10  7:59     ` Raymond Yau
  1 sibling, 0 replies; 5+ messages in thread
From: Clemens Ladisch @ 2015-09-24 18:40 UTC (permalink / raw)
  To: Uli Franke, alsa-devel@alsa-project.org

Uli Franke wrote:
>>> I set the hw params sample rate to 44k1 without error, but a subsequent
>>> call of snd_pcm_start returns EPIPE.
>>
>> In theory, this error code is returned if you didn't write any samples
>> into the buffer before starting.

> T(snd_pcm_start(pcm));
>
> n = snd_pcm_writei(pcm,
> 	             buffer,
> 	             ARRAY_SIZE(buffer) / channels);

And indeed this code tries to start the device without any samples in
the buffer.

>>> When setting hw params sample rate to 4k this does not happen.

This appears to be an artifact of the resampler.

> When I write samples before starting the stream, snd_pcm_start returns
>
>    File descriptor in bad state (-77)
>
> which is obvious as the state of the stream changes from PREPARED to
> RUNNING.

To prevent the device from starting automatically, change the
start_threshold.


Regards,
Clemens

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

* Re: Dummy module and sample rates
  2015-09-24 10:49   ` Uli Franke
  2015-09-24 18:40     ` Clemens Ladisch
@ 2015-10-10  7:59     ` Raymond Yau
  1 sibling, 0 replies; 5+ messages in thread
From: Raymond Yau @ 2015-10-10  7:59 UTC (permalink / raw)
  To: Uli Franke; +Cc: ALSA Development Mailing List

>
> >> I fiddled around with the Dummy module and it seems to be the thing
> >> we're looking for. I observed a rather strange behavior though:
> >>
> >> I set the hw params sample rate to 44k1 without error, but a subsequent
> >> call of snd_pcm_start returns EPIPE. When setting hw params sample rate
> >> to 4k this does not happen.
> >
> > In theory, this error code is returned if you didn't write any samples
> > into the buffer before starting.
> >
> > An underrun is possible too, but should be reported later AFAIK.
> > Could you check if a larger buffer size helps?
>
> I checked if this is actually an XRun, as this is the official error
> code. But even recover didn't have any effect.
>
> When I write samples before starting the stream, snd_pcm_start returns
>
>    File descriptor in bad state (-77)
>
> which is obvious as the state of the stream changes from PREPARED to
> RUNNING.
>
> I tried to increase the buffer but with no effect.
>
> No error occurs when I just write samples and omit the snd_pcm_start. I
> just read some examples and got the impression that this seems to be
> common practice anyhow. But up to now all my ALSA interfacing programs
> actively started the stream and I never had any similar effect.
>
> You can find a small test program here:
>
> http://460c9235de50fe3b.paste.se/

Your program did not setup sw_params but start pcm stream by
snd_pcm_start() without snd_pcm_write() any data

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

end of thread, other threads:[~2015-10-10  7:59 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-09-23 11:43 Dummy module and sample rates Uli Franke
2015-09-24  7:02 ` Clemens Ladisch
2015-09-24 10:49   ` Uli Franke
2015-09-24 18:40     ` Clemens Ladisch
2015-10-10  7:59     ` Raymond Yau

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.