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:
@@ -44,6 +44,7 @@ PeakView::PeakView(const char* name, bool useGlobalPulse, bool displayLabels)
|
|||||||
|
|
||||||
fChannelInfos(NULL),
|
fChannelInfos(NULL),
|
||||||
fChannelCount(0),
|
fChannelCount(0),
|
||||||
|
fGotData(true),
|
||||||
|
|
||||||
fBackBitmap(NULL),
|
fBackBitmap(NULL),
|
||||||
fPeakNotificationWhat(0)
|
fPeakNotificationWhat(0)
|
||||||
@@ -72,6 +73,7 @@ PeakView::MessageReceived(BMessage* message)
|
|||||||
float max;
|
float max;
|
||||||
for (int32 i = 0; message->FindFloat("max", i, &max) == B_OK; i++)
|
for (int32 i = 0; message->FindFloat("max", i, &max) == B_OK; i++)
|
||||||
SetMax(max, i);
|
SetMax(max, i);
|
||||||
|
fGotData = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -193,6 +195,9 @@ PeakView::FrameResized(float width, float height)
|
|||||||
void
|
void
|
||||||
PeakView::Pulse()
|
PeakView::Pulse()
|
||||||
{
|
{
|
||||||
|
if (!fGotData)
|
||||||
|
return;
|
||||||
|
|
||||||
if (fBackBitmap == NULL)
|
if (fBackBitmap == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -207,6 +212,7 @@ PeakView::Pulse()
|
|||||||
|
|
||||||
for (uint32 i = 0; i < fChannelCount; i++)
|
for (uint32 i = 0; i < fChannelCount; i++)
|
||||||
fChannelInfos[i].current_max = 0.0f;
|
fChannelInfos[i].current_max = 0.0f;
|
||||||
|
fGotData = false;
|
||||||
|
|
||||||
_DrawBitmap();
|
_DrawBitmap();
|
||||||
Flush();
|
Flush();
|
||||||
@@ -327,6 +333,7 @@ PeakView::_ResizeBackBitmap(int32 width, int32 channels)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
memset(fBackBitmap->Bits(), 0, fBackBitmap->BitsLength());
|
memset(fBackBitmap->Bits(), 0, fBackBitmap->BitsLength());
|
||||||
|
fGotData = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -85,6 +85,7 @@ private:
|
|||||||
|
|
||||||
ChannelInfo* fChannelInfos;
|
ChannelInfo* fChannelInfos;
|
||||||
uint32 fChannelCount;
|
uint32 fChannelCount;
|
||||||
|
bool fGotData;
|
||||||
|
|
||||||
BBitmap* fBackBitmap;
|
BBitmap* fBackBitmap;
|
||||||
font_height fFontHeight;
|
font_height fFontHeight;
|
||||||
|
|||||||
Reference in New Issue
Block a user