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

Re-enabling the separate MIDI thread, and comments about that

This commit is contained in:
Paul Licameli 2017-09-23 20:37:41 -04:00
parent d6657df045
commit ce649cf851
2 changed files with 20 additions and 6 deletions

View File

@ -441,8 +441,14 @@ writing audio.
#ifdef EXPERIMENTAL_MIDI_OUT
#define MIDI_SLEEP 10 /* milliseconds */
// how long do we think the thread might be delayed due to other threads?
#define THREAD_LATENCY 10 /* milliseconds */
// how long do we think the thread that fills MIDI buffers,
// if it is separate from the portaudio thread,
// might be delayed due to other threads?
#ifdef USE_MIDI_THREAD
#define THREAD_LATENCY 10 /* milliseconds */
#else
#define THREAD_LATENCY 0 /* milliseconds */
#endif
#define ROUND(x) (int) ((x)+0.5)
//#include <string.h>
#include "../lib-src/portmidi/pm_common/portmidi.h"
@ -4987,6 +4993,8 @@ int audacityAudioCallback(const void *inputBuffer, void *outputBuffer,
if ((gAudioIO->ReversedTime()
? gAudioIO->mTime <= gAudioIO->mT1
: gAudioIO->mTime >= gAudioIO->mT1))
// PRL: singalling MIDI output complete is necessary if
// not USE_MIDI_THREAD, otherwise it's harmlessly redundant
gAudioIO->mMidiOutputComplete = true,
callbackReturn = paComplete;
}
@ -5048,6 +5056,8 @@ int audacityAudioCallback(const void *inputBuffer, void *outputBuffer,
? gAudioIO->mTime <= gAudioIO->mT1
: gAudioIO->mTime >= gAudioIO->mT1)) {
// PRL: singalling MIDI output complete is necessary if
// not USE_MIDI_THREAD, otherwise it's harmlessly redundant
gAudioIO->mMidiOutputComplete = true,
callbackReturn = paComplete;
}

View File

@ -93,11 +93,15 @@ DECLARE_EXPORTED_EVENT_TYPE(AUDACITY_DLL_API, EVT_AUDIOIO_PLAYBACK, -1);
DECLARE_EXPORTED_EVENT_TYPE(AUDACITY_DLL_API, EVT_AUDIOIO_CAPTURE, -1);
DECLARE_EXPORTED_EVENT_TYPE(AUDACITY_DLL_API, EVT_AUDIOIO_MONITOR, -1);
// PRL:
// If we always run a portaudio output stream (even just to produce silence)
// whenever we play Midi, then we can use just one thread for both, which
// simplifies synchronization problems and avoids the rush of notes at start of
// play. PRL.
#undef USE_MIDI_THREAD
// whenever we play Midi, then we might use just one thread for both.
// I thought this would improve MIDI synch problems on Linux/ALSA, but RBD
// convinced me it was neither a necessary nor sufficient fix. Perhaps too the
// MIDI thread might block in some error situations but we should then not
// also block the audio thread.
// So leave the separate thread ENABLED.
#define USE_MIDI_THREAD
struct ScrubbingOptions;