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