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:
Your program did not setup sw_params but start pcm stream by snd_pcm_start() without snd_pcm_write() any data