Skip to contentSkip to conversation

Dummy module and sample rates

DISCUSSION Uli Franke 3 participants 5 messages Sep 23, 2015 – Oct 10, 2015

lore
Share & tools
lore

Uli Franke

author
#0 lore raw

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 <[email protected]>
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)
#1 lore raw
Quoted 6 lines · Uli Franke

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

author
#2 lore raw
Quoted 7 lines
Quoted 6 lines

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.

Quoted 5 lines

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

#3 lore raw
Quoted 11 lines · Uli Franke
Quoted 5 lines
Quoted 2 lines

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.

Quoted 1 line
Quoted 1 line
Quoted 1 line

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

This appears to be an artifact of the resampler.

Quoted 6 lines

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

#4 lore raw
In reply to Uli Franke
Quoted 26 lines
Quoted 8 lines
Quoted 7 lines

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.

Quoted 5 lines

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.

Quoted 8 lines

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