From a0e92900de4e2a1a6e587d0ad2f2bc35b9f5ff7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20A=C3=9Fmus?= Date: Wed, 15 Sep 2010 17:37:41 +0000 Subject: [PATCH] Pulse() may run twice before receiving the next data, so we should prevent showing a current peak of 0. Fixes the periodic 0 peaks. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38660 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/apps/mediaplayer/interface/PeakView.cpp | 7 +++++++ src/apps/mediaplayer/interface/PeakView.h | 1 + 2 files changed, 8 insertions(+) diff --git a/src/apps/mediaplayer/interface/PeakView.cpp b/src/apps/mediaplayer/interface/PeakView.cpp index ebf369ef4d..37c5031de9 100644 --- a/src/apps/mediaplayer/interface/PeakView.cpp +++ b/src/apps/mediaplayer/interface/PeakView.cpp @@ -44,6 +44,7 @@ PeakView::PeakView(const char* name, bool useGlobalPulse, bool displayLabels) fChannelInfos(NULL), fChannelCount(0), + fGotData(true), fBackBitmap(NULL), fPeakNotificationWhat(0) @@ -72,6 +73,7 @@ PeakView::MessageReceived(BMessage* message) float max; for (int32 i = 0; message->FindFloat("max", i, &max) == B_OK; i++) SetMax(max, i); + fGotData = true; return; } @@ -193,6 +195,9 @@ PeakView::FrameResized(float width, float height) void PeakView::Pulse() { + if (!fGotData) + return; + if (fBackBitmap == NULL) return; @@ -207,6 +212,7 @@ PeakView::Pulse() for (uint32 i = 0; i < fChannelCount; i++) fChannelInfos[i].current_max = 0.0f; + fGotData = false; _DrawBitmap(); Flush(); @@ -327,6 +333,7 @@ PeakView::_ResizeBackBitmap(int32 width, int32 channels) return; } memset(fBackBitmap->Bits(), 0, fBackBitmap->BitsLength()); + fGotData = true; } diff --git a/src/apps/mediaplayer/interface/PeakView.h b/src/apps/mediaplayer/interface/PeakView.h index a9a051bdd7..f78fdeaa4c 100644 --- a/src/apps/mediaplayer/interface/PeakView.h +++ b/src/apps/mediaplayer/interface/PeakView.h @@ -85,6 +85,7 @@ private: ChannelInfo* fChannelInfos; uint32 fChannelCount; + bool fGotData; BBitmap* fBackBitmap; font_height fFontHeight;