1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 06:07:44 +00:00

Kernel/Audio: Simplify initialization sequence for drivers

Instead of enumerating all available controllers and then ask each to
find its audio channels, we change the initialization sequence to match
what happens in the Networking subsystem and Graphics subsystem - we
essentially probe for a matching driver on a PCI device, create a device
instance, and immediately initialize it.

This in fact allows us to immediately find any hardware initialization
issues and report it, and then dropping the created instance, as usually
being done in other initialization paths in the Kernel.

This also opens the opportunity to propagate errors when failed to
initialize an AudioChannel instance, and it will be addressed in a
future commit.
This commit is contained in:
Liav A 2023-04-11 12:45:31 +03:00 committed by Linus Groh
parent 0050358cd3
commit 4921561687
7 changed files with 77 additions and 72 deletions

View file

@ -33,13 +33,13 @@ public:
virtual LockRefPtr<AudioChannel> audio_channel(u32 index) const = 0;
virtual ErrorOr<size_t> write(size_t channel_index, UserOrKernelBuffer const& data, size_t length) = 0;
virtual void detect_hardware_audio_channels(Badge<AudioManagement>) = 0;
virtual ErrorOr<void> initialize(Badge<AudioManagement>) = 0;
virtual ErrorOr<void> set_pcm_output_sample_rate(size_t channel_index, u32 samples_per_second_rate) = 0;
// Note: The return value is rate of samples per second
virtual ErrorOr<u32> get_pcm_output_sample_rate(size_t channel_index) = 0;
private:
IntrusiveListNode<AudioController, LockRefPtr<AudioController>> m_node;
IntrusiveListNode<AudioController, NonnullRefPtr<AudioController>> m_node;
};
}