1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 09:17:35 +00:00

AudioServer: Added ability to get count of samples in the buffer queue

Now the AClientConnection can get the count of samples still in the
buffer queue.
This commit is contained in:
Till Mayer 2019-10-19 19:10:53 +02:00 committed by Andreas Kling
parent 8bb919d1cc
commit 406aabff23
7 changed files with 28 additions and 0 deletions

View file

@ -24,9 +24,13 @@ public:
{
while (!m_current && !m_queue.is_empty())
m_current = m_queue.dequeue();
if (!m_current)
return false;
sample = m_current->samples()[m_position++];
m_remaining_samples--;
if (m_position >= m_current->sample_count()) {
m_current = nullptr;
m_position = 0;
@ -35,16 +39,20 @@ public:
}
ASClientConnection* client() { return m_client.ptr(); }
void clear()
{
m_queue.clear();
m_position = 0;
}
int get_remaining_samples() const { return m_remaining_samples; }
private:
RefPtr<ABuffer> m_current;
Queue<NonnullRefPtr<ABuffer>> m_queue;
int m_position { 0 };
int m_remaining_samples { 0 };
WeakPtr<ASClientConnection> m_client;
};