- Removed virtual functions for all of the stat stuff. This did however introduce some issues, mainly with /proc becoming out of sync if you changed your ID. I propose we do the linux thing and just have a stat update function which is optional, but allows dynamic updates of stat fields for cases such as those in uid/gid in /proc. - Simplified the API, although still kind of annoying it is a bit simpler. - Moved some of the FS structure from having the FS inode inside the in memory inode to a Serialise <-> Deserialise model where Inodes are deserialised from disk into in memory ones and then back into on disk ones when it comes time for syncing. This makes it semantically better in my opinion, as it explicitly separates disk and non-disk functionality.
57 lines
1.4 KiB
C++
57 lines
1.4 KiB
C++
#pragma once
|
|
|
|
#include <kernel/Device/Device.h>
|
|
#include <kernel/Memory/ByteRingBuffer.h>
|
|
#include <kernel/PCI.h>
|
|
|
|
#include <sys/ioctl.h>
|
|
|
|
namespace Kernel
|
|
{
|
|
|
|
class AudioController : public CharacterDevice
|
|
{
|
|
public:
|
|
static BAN::ErrorOr<void> create(PCI::Device& pci_device);
|
|
|
|
BAN::StringView name() const override { return m_name; }
|
|
|
|
protected:
|
|
AudioController();
|
|
BAN::ErrorOr<void> initialize();
|
|
|
|
virtual void handle_new_data() = 0;
|
|
|
|
virtual uint32_t get_channels() const = 0;
|
|
virtual uint32_t get_sample_rate() const = 0;
|
|
|
|
virtual uint32_t get_total_pins() const = 0;
|
|
virtual uint32_t get_current_pin() const = 0;
|
|
virtual BAN::ErrorOr<void> set_current_pin(uint32_t) = 0;
|
|
|
|
virtual BAN::ErrorOr<void> set_volume_mdB(int32_t) = 0;
|
|
|
|
bool can_read_impl() const override { return false; }
|
|
bool can_write_impl() const override { SpinLockGuard _(m_spinlock); return !m_sample_data->full(); }
|
|
bool has_error_impl() const override { return false; }
|
|
bool has_hungup_impl() const override { return false; }
|
|
|
|
BAN::ErrorOr<size_t> write_impl(off_t, BAN::ConstByteSpan) override;
|
|
|
|
BAN::ErrorOr<long> ioctl_impl(int cmd, void* arg) override;
|
|
|
|
protected:
|
|
ThreadBlocker m_sample_data_blocker;
|
|
mutable SpinLock m_spinlock;
|
|
|
|
static constexpr size_t m_sample_data_capacity = 1 << 20;
|
|
BAN::UniqPtr<ByteRingBuffer> m_sample_data;
|
|
|
|
snd_volume_info m_volume_info {};
|
|
|
|
private:
|
|
char m_name[10] {};
|
|
};
|
|
|
|
}
|