mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 00:08:11 +00:00
Kernel: Teach DeviceManagement to handle multiple audio devices
This commit is contained in:
parent
61d77274db
commit
1aafb6cd23
4 changed files with 9 additions and 9 deletions
|
@ -84,7 +84,9 @@ UNMAP_AFTER_INIT RefPtr<SB16> SB16::try_detect_and_create()
|
||||||
auto device_or_error = DeviceManagement::try_create_device<SB16>();
|
auto device_or_error = DeviceManagement::try_create_device<SB16>();
|
||||||
if (device_or_error.is_error())
|
if (device_or_error.is_error())
|
||||||
return {};
|
return {};
|
||||||
return device_or_error.release_value();
|
auto device = device_or_error.release_value();
|
||||||
|
DeviceManagement::the().attach_audio_device(device);
|
||||||
|
return device;
|
||||||
}
|
}
|
||||||
|
|
||||||
UNMAP_AFTER_INIT void SB16::initialize()
|
UNMAP_AFTER_INIT void SB16::initialize()
|
||||||
|
|
|
@ -22,9 +22,9 @@ UNMAP_AFTER_INIT void DeviceManagement::initialize()
|
||||||
s_the.ensure_instance();
|
s_the.ensure_instance();
|
||||||
}
|
}
|
||||||
|
|
||||||
UNMAP_AFTER_INIT void DeviceManagement::attach_sb16_device(SB16 const& device)
|
UNMAP_AFTER_INIT void DeviceManagement::attach_audio_device(CharacterDevice const& device)
|
||||||
{
|
{
|
||||||
m_sb16_device = device;
|
m_audio_devices.append(device);
|
||||||
}
|
}
|
||||||
|
|
||||||
UNMAP_AFTER_INIT void DeviceManagement::attach_console_device(ConsoleDevice const& device)
|
UNMAP_AFTER_INIT void DeviceManagement::attach_console_device(ConsoleDevice const& device)
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
#include <AK/Types.h>
|
#include <AK/Types.h>
|
||||||
#include <Kernel/API/TimePage.h>
|
#include <Kernel/API/TimePage.h>
|
||||||
#include <Kernel/Arch/RegisterState.h>
|
#include <Kernel/Arch/RegisterState.h>
|
||||||
#include <Kernel/Devices/Audio/SB16.h>
|
#include <Kernel/Devices/CharacterDevice.h>
|
||||||
#include <Kernel/Devices/ConsoleDevice.h>
|
#include <Kernel/Devices/ConsoleDevice.h>
|
||||||
#include <Kernel/Devices/Device.h>
|
#include <Kernel/Devices/Device.h>
|
||||||
#include <Kernel/Devices/NullDevice.h>
|
#include <Kernel/Devices/NullDevice.h>
|
||||||
|
@ -36,7 +36,7 @@ public:
|
||||||
void attach_console_device(ConsoleDevice const&);
|
void attach_console_device(ConsoleDevice const&);
|
||||||
|
|
||||||
// FIXME: Once we have a singleton for managing many sound cards, remove this from here
|
// FIXME: Once we have a singleton for managing many sound cards, remove this from here
|
||||||
void attach_sb16_device(SB16 const&);
|
void attach_audio_device(CharacterDevice const&);
|
||||||
|
|
||||||
void after_inserting_device(Badge<Device>, Device&);
|
void after_inserting_device(Badge<Device>, Device&);
|
||||||
void before_device_removal(Badge<Device>, Device&);
|
void before_device_removal(Badge<Device>, Device&);
|
||||||
|
@ -62,7 +62,7 @@ private:
|
||||||
RefPtr<NullDevice> m_null_device;
|
RefPtr<NullDevice> m_null_device;
|
||||||
RefPtr<ConsoleDevice> m_console_device;
|
RefPtr<ConsoleDevice> m_console_device;
|
||||||
// FIXME: Once we have a singleton for managing many sound cards, remove this from here
|
// FIXME: Once we have a singleton for managing many sound cards, remove this from here
|
||||||
RefPtr<SB16> m_sb16_device;
|
NonnullRefPtrVector<CharacterDevice, 1> m_audio_devices;
|
||||||
MutexProtected<HashMap<u32, Device*>> m_devices;
|
MutexProtected<HashMap<u32, Device*>> m_devices;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -318,9 +318,7 @@ void init_stage2(void*)
|
||||||
(void)RandomDevice::must_create().leak_ref();
|
(void)RandomDevice::must_create().leak_ref();
|
||||||
PTYMultiplexer::initialize();
|
PTYMultiplexer::initialize();
|
||||||
|
|
||||||
// FIXME: Once we have a singleton for managing many sound cards, remove this from here
|
SB16::try_detect_and_create();
|
||||||
if (auto device = SB16::try_detect_and_create(); !!device)
|
|
||||||
DeviceManagement::the().attach_sb16_device(*device);
|
|
||||||
|
|
||||||
StorageManagement::the().initialize(kernel_command_line().root_device(), kernel_command_line().is_force_pio());
|
StorageManagement::the().initialize(kernel_command_line().root_device(), kernel_command_line().is_force_pio());
|
||||||
if (VirtualFileSystem::the().mount_root(StorageManagement::the().root_filesystem()).is_error()) {
|
if (VirtualFileSystem::the().mount_root(StorageManagement::the().root_filesystem()).is_error()) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue