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
This commit is contained in:
Stephan Aßmus 2010-09-15 17:37:41 +00:00
parent 2baccbd9fb
commit a0e92900de
2 changed files with 8 additions and 0 deletions

View File

@ -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;
}

View File

@ -85,6 +85,7 @@ private:
ChannelInfo* fChannelInfos;
uint32 fChannelCount;
bool fGotData;
BBitmap* fBackBitmap;
font_height fFontHeight;