ladybird/Servers/AudioServer/ASMixer.h
Andreas Kling 5e01dde7b1 Audio: Make ABuffer sit on top of a SharedBuffer.
This allows us to carry the same buffer all the way from the WAV loader
to the AudioServer mixer.

This alleviates some of the stutter, but there's still a noticeable
skip when switching buffers. We're gonna need to do better. :^)
2019-07-27 18:17:17 +02:00

34 lines
721 B
C++

#pragma once
#include <AK/ByteBuffer.h>
#include <AK/NonnullRefPtrVector.h>
#include <AK/RefCounted.h>
#include <AK/WeakPtr.h>
#include <LibAudio/ABuffer.h>
#include <LibCore/CFile.h>
#include <LibCore/CLock.h>
class ASClientConnection;
class ASMixer : public RefCounted<ASMixer> {
public:
ASMixer();
void queue(ASClientConnection&, const ABuffer&);
private:
struct ASMixerBuffer {
ASMixerBuffer(const NonnullRefPtr<ABuffer>&, ASClientConnection&);
NonnullRefPtr<ABuffer> buffer;
int pos { 0 };
bool done { false };
WeakPtr<ASClientConnection> m_client;
};
Vector<ASMixerBuffer> m_pending_mixing;
CFile m_device;
CLock m_lock;
void mix();
};