alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
From: Clemens Ladisch <clemens@ladisch.de>
To: Smilen Dimitrov <sd@imi.aau.dk>
Cc: alsa-devel@alsa-project.org
Subject: Re: Questions about virtual ALSA driver (dummy), PortAudio and full-duplex drops
Date: Tue, 06 Aug 2013 12:59:30 +0200	[thread overview]
Message-ID: <5200D712.2040800@ladisch.de> (raw)
In-Reply-To: <51FD9AB6.4050408@imi.aau.dk>

Smilen Dimitrov wrote:
> On 2013-07-25 10:37, Clemens Ladisch wrote:
>> Your driver's .pointer callback must report the *actual* position at
>> which the hardware has finished reading from the buffer

... for a playback stream, or finished reading, for a capture stream.

> I'm interested in the operation of a virtual (platform) driver,
> which talks to _no_ soundcard hardware

And what does this driver do?  What is your goal?

> I'm assuming that the card has it's own intern capture buffer memory
> on board;

No modern card has this.  All data is immediately read from/written to
main memory.

> and ALSA manages the equivalent of `substream->runtime->dma_area`
> as capture buffer memory in RAM. The main purpose of the ALSA driver,
> then, is to manage the copying the data from the intern card capture
> buffer, to the `dma_area` capture buffer in RAM of the PC;

This is handled by the hardware's DMA.

> once the data is in the `dma_area`, the rest of the ALSA engine will
> make sure that data ends up in `audiobuf` in user-space, upon a call
> to `snd_pcm_readi` as given above.

Yes.  (When using snd_pcm_mmap_*, the dma_area is mapped to userspace,
and ALSA itself will never access the contents of the buffer.)

> [...] where the `azx_interrupt` handler has been called (since it's
> also possible to capture interrupt entries for power, for instance);

The stream's SD_STS register tells whether this is an interrupt because
a period boundary has been crossed.

> On the PC side, the driver's .pointer callback can be triggered both
> by userspace call to `snd_pcm_readi`, and (apparently) independently
> of it - but (surprising for me) it is not necessarily periodic!

The .pointer callback is triggered by snd_pcm_period_elapsed() (because
some more data, or even another period, might have been transferred in
the meantime), whenever userspace writes or reads samples, or whenever
userspace feels like asking for the current position.

> when I see "wall clock" referred to in code, does that refer to
> this, which I've called "Real Time"?

It's called "wall clock" because Intel named the register this way;
actually, it's the device's sample clock.

> And herein lies the crux of my inquiery: given there is no hardware
> targetted with a virtual driver, I can in principle return whatever I
> want as a .pointer position.

If you are actually transferring sample from/to somewhere, you must
return the status of these transfers.

> I should be able to simulate a proper operation to userspace, just by
> increasing this .pointer value properly. However, even if I do that,
> I still manage to somehow trigger a full-duplex drop in the PortAudio
> userspace layer

A buffer length of about 1 ms is very likely to result in over/underruns,
regardless of what your .pointer callback does.

Better try with a 32000-frame buffer first.

> The card then, uses it's own clock, which is not burdened with
> anything else but filling buffers, meaning we can expect tight timing
> here; and when it generates an IRQ, it is handled by kernel with
> highest priority - ergo, not so much jitter. Timer functions, on the
> other hand, run in softIRQ context - meaning they (and their
> scheduling) could be preempted by the hardware IRQ of any other device
> on the system; ergo, more jitter. Is this reasonable to assume?

Yes, but other hardware interrupts interfere only if other devices are
used at the same time.


Regards,
Clemens

  reply	other threads:[~2013-08-06 10:59 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-24  2:54 Questions about virtual ALSA driver (dummy), PortAudio and full-duplex drops Smilen Dimitrov
2013-07-24 13:03 ` Alan Horstmann
2013-07-25  0:29   ` Smilen Dimitrov
2013-07-25  8:37     ` Clemens Ladisch
2013-08-04  0:05       ` Smilen Dimitrov
2013-08-06 10:59         ` Clemens Ladisch [this message]
2013-08-06 11:41           ` David Henningsson
2013-08-06 13:04             ` Clemens Ladisch
2013-08-08  2:50           ` Smilen Dimitrov
2013-08-14 14:30       ` Questions about virtual ALSA driver (dummy), PortAudio and full-duplex drops (playback) Smilen Dimitrov
2013-08-15  4:17         ` Raymond Yau
2013-08-16  5:20           ` Smilen Dimitrov
2013-09-13  6:23       ` Questions about virtual ALSA driver (dummy), PortAudio and full-duplex drops (full-duplex: latency.c) Smilen Dimitrov
2013-09-17 16:07         ` Smilen Dimitrov
2013-10-21 14:48       ` [Solved] Questions about virtual ALSA driver (dummy), PortAudio and full-duplex Smilen Dimitrov
2013-07-24 18:30 ` [Audacity-devel] Questions about virtual ALSA driver (dummy), PortAudio and full-duplex drops Richard Ash

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5200D712.2040800@ladisch.de \
    --to=clemens@ladisch.de \
    --cc=alsa-devel@alsa-project.org \
    --cc=sd@imi.aau.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).