Skip to content

Conversation

@twischer-adit
Copy link
Owner

for variables which will be accessed by the ALSA and JACK thread

Has to be rebased when #1 was upstreamed

Timo Wischer added 13 commits January 17, 2018 13:33
when no audio data was copied

Signed-off-by: Timo Wischer <twischer@de.adit-jv.com>
instead of using buffer_size as wrap around.

This is required to detect Xruns.

It is also required to allow the JACK thread
to processes the whole buffer
without a snd_pcm_avail_update() call in between.

Signed-off-by: Timo Wischer <twischer@de.adit-jv.com>
when the JACK thread is requesting to many frames

In playback use case fill the JACK buffer with silence.

Signed-off-by: Timo Wischer <twischer@de.adit-jv.com>
to avoid issues with architeture which are using a different size for
unsigned int

Signed-off-by: Timo Wischer <twischer@de.adit-jv.com>
because the JACK process callback will be called before
io->state == SND_PCM_STATE_RUNNING

Signed-off-by: Timo Wischer <twischer@de.adit-jv.com>
Signed-off-by: Timo Wischer <twischer@de.adit-jv.com>
Signed-off-by: Timo Wischer <twischer@de.adit-jv.com>
…locking

Signed-off-by: Timo Wischer <twischer@de.adit-jv.com>
volatile is not sufficient for guaranteeing the order of buffer access
and hardware pointer update.
In playback it could happen that the hardware pointer is updated but the
audio data is not yet forwarded to the JACK daemon.
Therefore the audio data could be overwritten by the ALSA application
before it was copied to the JACK daemon.

Signed-off-by: Timo Wischer <twischer@de.adit-jv.com>
This replaces the additional draining and activated variables.
The state has to be accessed with memory barriers to guarantee the order
of execution.
e.g. to guarantee that snd_pcm_state not changes from DRAINING to
RUNNING

Signed-off-by: Timo Wischer <twischer@de.adit-jv.com>
To guarantee that the execution order.
e.g. In playback case do not updating the application pointer before the
audio data was copied to the buffer

Additionally guarantee that the read of the application pointer is
atomic and an invalid value will not be read.

Signed-off-by: Timo Wischer <twischer@de.adit-jv.com>
because it accesses io->state and a read to this variable can result in
an invalid value because there is no synchronisation used.

Signed-off-by: Timo Wischer <twischer@de.adit-jv.com>
jack_areas contains the pointer to the JACK buffers

Signed-off-by: Timo Wischer <twischer@de.adit-jv.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants