From a88feab98695aa923b760eddefae694655d1def1 Mon Sep 17 00:00:00 2001 From: Niels Martin Hansen Date: Sun, 7 Jan 2007 04:52:33 +0000 Subject: [PATCH] More fixes for dsound playing code and a bit for spectrum rendering Originally committed to SVN as r732. --- aegisub/audio_display.cpp | 20 ++++++++------------ aegisub/audio_player_dsound.cpp | 4 +++- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/aegisub/audio_display.cpp b/aegisub/audio_display.cpp index 8cdc8a8d0..05940284d 100644 --- a/aegisub/audio_display.cpp +++ b/aegisub/audio_display.cpp @@ -534,18 +534,14 @@ void AudioDisplay::DrawSpectrum(wxDC &finaldc,bool weak) { spectrumDisplay = new wxBitmap(imgobj); } - if (hasSel && selStartCap < selEndCap && - ((selStartCap > Position && selStartCap < Position+w) || - (selEndCap > Position && selEndCap < Position+w) || - (selStartCap < Position && selEndCap > Position+w)) && - !spectrumDisplaySelected) { - // There is a visible selection and we don't have a rendered one - // This should be done regardless whether we're "weak" or not - // Assume a few things were already set up when things were first rendered though - unsigned char *img = (unsigned char *)malloc(h*w*3); - spectrumRenderer->RenderRange(Position*samples, (Position+w)*samples, true, img, 0, w, w, h); - wxImage imgobj(w, h, img, false); - spectrumDisplaySelected = new wxBitmap(imgobj); + if (hasSel && selStartCap < selEndCap && !spectrumDisplaySelected) { + // There is a visible selection and we don't have a rendered one + // This should be done regardless whether we're "weak" or not + // Assume a few things were already set up when things were first rendered though + unsigned char *img = (unsigned char *)malloc(h*w*3); + spectrumRenderer->RenderRange(Position*samples, (Position+w)*samples, true, img, 0, w, w, h); + wxImage imgobj(w, h, img, false); + spectrumDisplaySelected = new wxBitmap(imgobj); } // Draw diff --git a/aegisub/audio_player_dsound.cpp b/aegisub/audio_player_dsound.cpp index 119e4ec30..2b56dc0cd 100644 --- a/aegisub/audio_player_dsound.cpp +++ b/aegisub/audio_player_dsound.cpp @@ -295,8 +295,10 @@ void DirectSoundPlayer::Stop(bool timerToo) { offset = 0; // Close event handle - if (notificationEvent) + if (notificationEvent) { CloseHandle(notificationEvent); + notificationEvent = 0; + } // Stop timer if (timerToo && displayTimer) {