1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-05-03 00:59:43 +02:00

An experiment, not enabled, to reduce jitter in ALSA MIDI playback...

... Change to #define REALTIME_ALSA_THREAD near the top to enable it.
This commit is contained in:
Paul Licameli 2017-08-29 16:25:55 -04:00
parent 37bc61f4ac
commit 6f8b37a921

View File

@ -326,6 +326,19 @@ enum {
#include "tracks/ui/Scrubbing.h"
#ifdef __WXGTK__
// Might #define this for a useful thing on Linux
#undef REALTIME_ALSA_THREAD
#else
// never on the other operating systems
#undef REALTIME_ALSA_THREAD
#endif
#ifdef REALTIME_ALSA_THREAD
#include "pa_linux_alsa.h"
#endif
/*
This work queue class, with the aid of the playback ring
buffers, coordinates three threads during scrub play:
@ -2003,6 +2016,23 @@ int AudioIO::StartStream(const ConstWaveTrackArray &playbackTracks,
if(mNumPlaybackChannels > 0 || mNumCaptureChannels > 0) {
#ifdef REALTIME_ALSA_THREAD
// PRL: Do this in hope of less thread scheduling jitter in calls to
// audacityAudioCallback.
// Not needed to make audio playback work smoothly.
// But needed in case we also play MIDI, so that the variable "offset"
// in AudioIO::MidiTime() is a better approximation of the duration
// between the call of audacityAudioCallback and the actual output of
// the first audio sample.
// (Which we should be able to determine from fields of
// PaStreamCallbackTimeInfo, but that seems not to work as documented with
// ALSA.)
wxString hostName = gPrefs->Read(wxT("/AudioIO/Host"), wxT(""));
if (hostName == "ALSA")
// Perhaps we should do this only if also playing MIDI ?
PaAlsa_EnableRealtimeScheduling( mPortStreamV19, 1 );
#endif
// Now start the PortAudio stream!
PaError err;
err = Pa_StartStream( mPortStreamV19 );