mirror of
https://github.com/cookiengineer/audacity
synced 2025-06-19 01:20:04 +02:00
Make effects of 582e574 conditionally compiled...
... It was only "mostly harmless" on Windows and Mac. Now where is my towel?
This commit is contained in:
parent
6f8b37a921
commit
c11e3d1511
@ -1554,7 +1554,9 @@ bool AudioIO::StartPortAudioStream(double sampleRate,
|
||||
int userData = 24;
|
||||
int* lpUserData = (captureFormat_saved == int24Sample) ? &userData : NULL;
|
||||
|
||||
#ifndef USE_TIME_INFO
|
||||
mMidiTimeCorrection = 0;
|
||||
#endif
|
||||
mLastPaError = Pa_OpenStream( &mPortStreamV19,
|
||||
useCapture ? &captureParameters : NULL,
|
||||
usePlayback ? &playbackParameters : NULL,
|
||||
@ -1568,10 +1570,14 @@ bool AudioIO::StartPortAudioStream(double sampleRate,
|
||||
Px_SetInputVolume(mPortMixer, oldRecordVolume);
|
||||
#endif
|
||||
if (mPortStreamV19 != NULL && mLastPaError == paNoError) {
|
||||
|
||||
#ifndef USE_TIME_INFO
|
||||
auto info = Pa_GetStreamInfo(mPortStreamV19);
|
||||
if (info)
|
||||
mMidiTimeCorrection =
|
||||
info->outputLatency - (MIDI_MINIMAL_LATENCY_MS / 1000.0);
|
||||
#endif
|
||||
|
||||
#ifdef __WXMAC__
|
||||
if (mPortMixer) {
|
||||
if (Px_SupportsPlaythrough(mPortMixer)) {
|
||||
@ -4101,15 +4107,20 @@ PmTimestamp AudioIO::MidiTime()
|
||||
// sample count generated by the audio callback (in AudioTime()) might also
|
||||
// have the virtue of keeping the Midi output synched with audio, even though
|
||||
// pmlinuxalsa.c does not implement any synchronization of its own.
|
||||
|
||||
#ifdef USE_TIME_INFO
|
||||
auto offset = mAudioCallbackOutputDacTime - mAudioCallbackOutputCurrentTime;
|
||||
#else
|
||||
// We are now using mMidiTimeCorrection, computed once after opening the
|
||||
// portaudio stream, rather than the difference of dac and current
|
||||
// times reported to the audio callback; because the answer is very nearly
|
||||
// the same on Windows and macOs, doing no harm, whereas on Linux with ALSA,
|
||||
// times reported to the audio callback; because on Linux with ALSA,
|
||||
// the dac and current times were not reliable, and that caused irregular
|
||||
// timing of Midi playback because latency was effectively zero.
|
||||
auto offset = mMidiTimeCorrection;
|
||||
#endif
|
||||
|
||||
auto clockChange = PaUtil_GetTime() - mAudioCallbackClockTime;
|
||||
// auto offset = mAudioCallbackOutputDacTime - mAudioCallbackOutputCurrentTime;
|
||||
auto offset = mMidiTimeCorrection;
|
||||
return (PmTimestamp) ((unsigned long) (1000 * (
|
||||
AudioTime() + 1.0005 -
|
||||
mAudioFramesPerBuffer / mRate +
|
||||
@ -4349,11 +4360,10 @@ int audacityAudioCallback(const void *inputBuffer, void *outputBuffer,
|
||||
/* GSW: Save timeInfo in case MidiPlayback needs it */
|
||||
gAudioIO->mAudioCallbackClockTime = PaUtil_GetTime();
|
||||
|
||||
// PRL: We no longer trust these numbers on Linux / ALSA:
|
||||
/*
|
||||
#ifdef USE_TIME_INFO
|
||||
gAudioIO->mAudioCallbackOutputDacTime = timeInfo->outputBufferDacTime;
|
||||
gAudioIO->mAudioCallbackOutputCurrentTime = timeInfo->currentTime;
|
||||
*/
|
||||
#endif
|
||||
|
||||
// printf("in callback, mAudioCallbackOutputDacTime %g\n", gAudioIO->mAudioCallbackOutputDacTime); //DBG
|
||||
gAudioIO->mAudioFramesPerBuffer = framesPerBuffer;
|
||||
|
@ -99,6 +99,13 @@ DECLARE_EXPORTED_EVENT_TYPE(AUDACITY_DLL_API, EVT_AUDIOIO_MONITOR, -1);
|
||||
// play. PRL.
|
||||
#undef USE_MIDI_THREAD
|
||||
|
||||
// Whether we trust all of the time info passed to audacityAudioCallback
|
||||
#ifdef __WXGTK__
|
||||
#undef USE_TIME_INFO
|
||||
#else
|
||||
#define USE_TIME_INFO
|
||||
#endif
|
||||
|
||||
struct ScrubbingOptions;
|
||||
|
||||
// To avoid growing the argument list of StartStream, add fields here
|
||||
@ -534,7 +541,11 @@ private:
|
||||
// MIDI_PLAYBACK:
|
||||
PmStream *mMidiStream;
|
||||
PmError mLastPmError;
|
||||
|
||||
#ifndef USE_TIME_INFO
|
||||
PaTime mMidiTimeCorrection; // seconds
|
||||
#endif
|
||||
|
||||
/// Latency of MIDI synthesizer
|
||||
long mSynthLatency; // ms
|
||||
|
||||
@ -543,17 +554,12 @@ private:
|
||||
/// PortAudio's clock time
|
||||
volatile double mAudioCallbackClockTime;
|
||||
|
||||
/// PRL: no longer using the next two because they are not reliably
|
||||
/// reported to the audio callback on Linux.
|
||||
/// Compute the approximate difference of them by other means now:
|
||||
/// use PaStreamInfo::outputLatency.
|
||||
|
||||
/*
|
||||
#ifdef USE_TIME_INFO
|
||||
/// PortAudio's currentTime -- its origin is unspecified!
|
||||
volatile double mAudioCallbackOutputCurrentTime;
|
||||
/// PortAudio's outTime
|
||||
volatile double mAudioCallbackOutputDacTime;
|
||||
*/
|
||||
#endif
|
||||
|
||||
/// Number of frames output, including pauses
|
||||
volatile long mNumFrames;
|
||||
|
Loading…
x
Reference in New Issue
Block a user