Audacity  3.0.3
Public Member Functions | Private Attributes | List of all members
MeterUpdateQueue Class Reference

Queue of MeterUpdateMsg used to feed the MeterPanel. More...

#include <MeterPanel.h>

Collaboration diagram for MeterUpdateQueue:
[legend]

Public Member Functions

 MeterUpdateQueue (size_t maxLen)
 
 ~MeterUpdateQueue ()
 
bool Put (MeterUpdateMsg &msg)
 
bool Get (MeterUpdateMsg &msg)
 
void Clear ()
 

Private Attributes

int mStart
 
int mEnd
 
size_t mBufferSize
 
ArrayOf< MeterUpdateMsgmBuffer {mBufferSize}
 

Detailed Description

Queue of MeterUpdateMsg used to feed the MeterPanel.

Definition at line 71 of file MeterPanel.h.

Constructor & Destructor Documentation

◆ MeterUpdateQueue()

MeterUpdateQueue::MeterUpdateQueue ( size_t  maxLen)
explicit

Definition at line 194 of file MeterPanel.cpp.

194  :
195  mBufferSize(maxLen)
196 {
197  Clear();
198 }

References Clear().

Here is the call graph for this function:

◆ ~MeterUpdateQueue()

MeterUpdateQueue::~MeterUpdateQueue ( )

Definition at line 201 of file MeterPanel.cpp.

202 {
203 }

Member Function Documentation

◆ Clear()

void MeterUpdateQueue::Clear ( )

Definition at line 205 of file MeterPanel.cpp.

206 {
207  mStart = 0;
208  mEnd = 0;
209 }

References mEnd, and mStart.

Referenced by MeterPanel::Clear(), MeterUpdateQueue(), MeterPanel::OnMeterUpdate(), and MeterPanel::Reset().

Here is the caller graph for this function:

◆ Get()

bool MeterUpdateQueue::Get ( MeterUpdateMsg msg)

Definition at line 234 of file MeterPanel.cpp.

235 {
236  int len = (mEnd + mBufferSize - mStart) % mBufferSize;
237 
238  if (len == 0)
239  return false;
240 
241  msg = mBuffer[mStart];
242  mStart = (mStart+1)%mBufferSize;
243 
244  return true;
245 }

References mBuffer, mBufferSize, mEnd, and mStart.

Referenced by MeterPanel::OnMeterUpdate().

Here is the caller graph for this function:

◆ Put()

bool MeterUpdateQueue::Put ( MeterUpdateMsg msg)

Definition at line 213 of file MeterPanel.cpp.

214 {
215  // mStart can be greater than mEnd because it is all mod mBufferSize
216  wxASSERT( (mEnd + mBufferSize - mStart) >= 0 );
217  int len = (mEnd + mBufferSize - mStart) % mBufferSize;
218 
219  // Never completely fill the queue, because then the
220  // state is ambiguous (mStart==mEnd)
221  if (len + 1 >= (int)(mBufferSize))
222  return false;
223 
224  //wxLogDebug(wxT("Put: %s"), msg.toString());
225 
226  mBuffer[mEnd] = msg;
227  mEnd = (mEnd+1)%mBufferSize;
228 
229  return true;
230 }

References mBuffer, mBufferSize, mEnd, and mStart.

Referenced by MeterPanel::UpdateDisplay().

Here is the caller graph for this function:

Member Data Documentation

◆ mBuffer

ArrayOf<MeterUpdateMsg> MeterUpdateQueue::mBuffer {mBufferSize}
private

Definition at line 86 of file MeterPanel.h.

Referenced by Get(), and Put().

◆ mBufferSize

size_t MeterUpdateQueue::mBufferSize
private

Definition at line 85 of file MeterPanel.h.

Referenced by Get(), and Put().

◆ mEnd

int MeterUpdateQueue::mEnd
private

Definition at line 84 of file MeterPanel.h.

Referenced by Clear(), Get(), and Put().

◆ mStart

int MeterUpdateQueue::mStart
private

Definition at line 83 of file MeterPanel.h.

Referenced by Clear(), Get(), and Put().


The documentation for this class was generated from the following files:
MeterUpdateQueue::mStart
int mStart
Definition: MeterPanel.h:83
MeterUpdateQueue::mEnd
int mEnd
Definition: MeterPanel.h:84
MeterUpdateQueue::mBuffer
ArrayOf< MeterUpdateMsg > mBuffer
Definition: MeterPanel.h:86
MeterUpdateQueue::mBufferSize
size_t mBufferSize
Definition: MeterPanel.h:85
MeterUpdateQueue::Clear
void Clear()
Definition: MeterPanel.cpp:205