mirror of
https://github.com/cookiengineer/audacity
synced 2025-12-26 22:51:21 +01:00
Bug1714, partial fix for silent, freezing Midi play on ALSA...
Don't assume Pa_GetStreamTimePaStreamCallbackTimeInfo origin is time-of-day. portaudio.h says you should not, and in fact it was not. The report is that this gets us some play, but there are still freezes.
This commit is contained in:
@@ -4014,13 +4014,14 @@ double AudioIO::PauseTime()
|
|||||||
|
|
||||||
PmTimestamp AudioIO::MidiTime()
|
PmTimestamp AudioIO::MidiTime()
|
||||||
{
|
{
|
||||||
//printf("AudioIO:MidiTime: PaUtil_GetTime() %g mAudioCallbackOutputTime %g time - outputTime %g\n",
|
//printf("AudioIO:MidiTime: PaUtil_GetTime() %g mAudioCallbackOutputDacTime %g time - outputTime %g\n",
|
||||||
// PaUtil_GetTime(), mAudioCallbackOutputTime, PaUtil_GetTime() - mAudioCallbackOutputTime);
|
// PaUtil_GetTime(), mAudioCallbackOutputDacTime, PaUtil_GetTime() - mAudioCallbackOutputDacTime);
|
||||||
// note: the extra 0.0005 is for rounding. Round down by casting to
|
// note: the extra 0.0005 is for rounding. Round down by casting to
|
||||||
// unsigned long, then convert to PmTimeStamp (currently signed)
|
// unsigned long, then convert to PmTimeStamp (currently signed)
|
||||||
|
auto offset = mAudioCallbackOutputDacTime - mAudioCallbackOutputCurrentTime;
|
||||||
return (PmTimestamp) ((unsigned long) (1000 * (AudioTime() + 1.0005 -
|
return (PmTimestamp) ((unsigned long) (1000 * (AudioTime() + 1.0005 -
|
||||||
mAudioFramesPerBuffer / mRate +
|
mAudioFramesPerBuffer / mRate +
|
||||||
PaUtil_GetTime() - mAudioCallbackOutputTime)));
|
-offset)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void AudioIO::AllNotesOff()
|
void AudioIO::AllNotesOff()
|
||||||
@@ -4253,8 +4254,9 @@ int audacityAudioCallback(const void *inputBuffer, void *outputBuffer,
|
|||||||
|
|
||||||
#ifdef EXPERIMENTAL_MIDI_OUT
|
#ifdef EXPERIMENTAL_MIDI_OUT
|
||||||
/* GSW: Save timeInfo in case MidiPlayback needs it */
|
/* GSW: Save timeInfo in case MidiPlayback needs it */
|
||||||
gAudioIO->mAudioCallbackOutputTime = timeInfo->outputBufferDacTime;
|
gAudioIO->mAudioCallbackOutputDacTime = timeInfo->outputBufferDacTime;
|
||||||
// printf("in callback, mAudioCallbackOutputTime %g\n", gAudioIO->mAudioCallbackOutputTime); //DBG
|
gAudioIO->mAudioCallbackOutputCurrentTime = timeInfo->currentTime;
|
||||||
|
// printf("in callback, mAudioCallbackOutputDacTime %g\n", gAudioIO->mAudioCallbackOutputDacTime); //DBG
|
||||||
gAudioIO->mAudioFramesPerBuffer = framesPerBuffer;
|
gAudioIO->mAudioFramesPerBuffer = framesPerBuffer;
|
||||||
if(gAudioIO->IsPaused())
|
if(gAudioIO->IsPaused())
|
||||||
gAudioIO->mNumPauseFrames += framesPerBuffer;
|
gAudioIO->mNumPauseFrames += framesPerBuffer;
|
||||||
|
|||||||
@@ -530,8 +530,10 @@ private:
|
|||||||
|
|
||||||
// These fields are used to synchronize MIDI with audio:
|
// These fields are used to synchronize MIDI with audio:
|
||||||
|
|
||||||
|
/// PortAudio's currentTime
|
||||||
|
volatile double mAudioCallbackOutputCurrentTime;
|
||||||
/// PortAudio's outTime
|
/// PortAudio's outTime
|
||||||
volatile double mAudioCallbackOutputTime;
|
volatile double mAudioCallbackOutputDacTime;
|
||||||
/// Number of frames output, including pauses
|
/// Number of frames output, including pauses
|
||||||
volatile long mNumFrames;
|
volatile long mNumFrames;
|
||||||
/// How many frames of zeros were output due to pauses?
|
/// How many frames of zeros were output due to pauses?
|
||||||
|
|||||||
Reference in New Issue
Block a user