[alsa-devel] [PATCH - JACK 1/1] jack: Use internal snd_pcm_state to reduce amount of additional variables

Wischer, Timo (ADITG/ESB) twischer at de.adit-jv.com
Thu Mar 15 15:05:39 CET 2018


Hello Takashi,

> Well, the fact that the state change is done for PREPARE before the
> plugin callback can be seen as a generic bug of ioplug.  The best
> would be to fix in ioplug side.

This change could possibly brake other existing IO plugins.
Do you think we should really change it?


> For RUNNING, instead of keeping an internal shadow state, a saner way
> would be to have a jack->running bool flag indicating whether it's
> really running.

With the following pending commits [1] and [2] we would than have 3 additional variables to indicate
- running
- xruns
- draining

My idea was to avoid this variables and use the already existing snd_pcm_state enum.

With further commits which I have not yet sent I want to make the JACK plugin thread save.
But instead of using locking I am using atomic lock-less access (to avoid blocking of the JACK daemon).
Therefore I cannot call snd_pcm_state() to get the internal state.
I have to forward the status by my own to the JACK thread.
Due to that I need an internal variable which will be atomically accessed and represents the state.
(I think it is not intended by ALSA to extend the ALSA library to update the internal ALSA state atomically
so that it can be read atomically from any thread. Therefore I have not yet another idea how to transfer the state to the JACK thread with atomic lock-less access.)

I could replace the assignments to the internal state in all IO plug callback functions in the JACK plugin with
jack->state = io->state
But I am not sure if this is really helpful for the understanding.

[1] http://mailman.alsa-project.org/pipermail/alsa-devel/2018-March/132725.html
[2] http://mailman.alsa-project.org/pipermail/alsa-devel/2018-March/132726.html

Best regards

Timo Wischer

Advanced Driver Information Technology GmbH
Engineering Software Base (ADITG/ESB)
Robert-Bosch-Str. 200
31139 Hildesheim
Germany

Tel. +49 5121 49 6938
Fax +49 5121 49 6999
twischer at de.adit-jv.com

ADIT is a joint venture company of Robert Bosch GmbH/Robert Bosch Car Multimedia GmbH and DENSO Corporation
Sitz: Hildesheim, Registergericht: Amtsgericht Hildesheim HRB 3438
Geschäftsführung: Wilhelm Grabow, Ken Yaguchi

________________________________________
From: Takashi Iwai [tiwai at suse.de]
Sent: Thursday, March 15, 2018 2:14 PM
To: Wischer, Timo (ADITG/ESB)
Cc: alsa-devel at alsa-project.org
Subject: Re: [PATCH - JACK 1/1] jack: Use internal snd_pcm_state to reduce amount of additional variables

On Thu, 15 Mar 2018 13:56:27 +0100,
<twischer at de.adit-jv.com> wrote:
>
> From: Timo Wischer <twischer at de.adit-jv.com>
>
> This variable will be used to exchange the status of the stream between
> the ALSA and JACK thread. In future commits it will also be used to signal
> DRAINING state from the ALSA to JACK thread and to signal XRUN state form
> the JACK to ALSA thread.
>
> Therefore this internal state variable is not always in sync with
> io->state. In addition the internal state variable will be updated after
> the corresponding callback function was processed and not before the
> callback function was called (e.g. PREPARE and RUNNING).

Well, the fact that the state change is done for PREPARE before the
plugin callback can be seen as a generic bug of ioplug.  The best
would be to fix in ioplug side.

And, the rest is RUNNING state.  Is there anything else?
For RUNNING, instead of keeping an internal shadow state, a saner way
would be to have a jack->running bool flag indicating whether it's
really running.


thanks,

Takashi


More information about the Alsa-devel mailing list