diff options
author | Till Mayer <till.mayer@web.de> | 2019-10-19 19:10:53 +0200 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-10-19 20:05:13 +0200 |
commit | 406aabff233d2f6d312a5dc9131e616d7f8e4261 (patch) | |
tree | 30e18ef99b77b3ca22cb8b7329c02a351609f9e9 /Servers/AudioServer/ASMixer.h | |
parent | 8bb919d1cc9bab052eb1764d78069cfdf41c97c9 (diff) | |
download | serenity-406aabff233d2f6d312a5dc9131e616d7f8e4261.zip |
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.
Diffstat (limited to 'Servers/AudioServer/ASMixer.h')
-rw-r--r-- | Servers/AudioServer/ASMixer.h | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/Servers/AudioServer/ASMixer.h b/Servers/AudioServer/ASMixer.h index 7a6b032715..cd086d0da7 100644 --- a/Servers/AudioServer/ASMixer.h +++ b/Servers/AudioServer/ASMixer.h @@ -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; }; |