diff options
-rw-r--r-- | Kernel/Devices/Audio/AC97.cpp | 4 | ||||
-rw-r--r-- | Kernel/Devices/Audio/AC97.h | 5 | ||||
-rw-r--r-- | Kernel/Devices/Audio/Channel.cpp | 7 | ||||
-rw-r--r-- | Kernel/Devices/Audio/Channel.h | 2 | ||||
-rw-r--r-- | Kernel/Devices/Audio/Controller.h | 4 | ||||
-rw-r--r-- | Kernel/Devices/Audio/IntelHDA/Controller.cpp | 4 | ||||
-rw-r--r-- | Kernel/Devices/Audio/IntelHDA/Controller.h | 6 | ||||
-rw-r--r-- | Kernel/Devices/Audio/Management.h | 2 |
8 files changed, 16 insertions, 18 deletions
diff --git a/Kernel/Devices/Audio/AC97.cpp b/Kernel/Devices/Audio/AC97.cpp index bef42a6f22..3b85103c77 100644 --- a/Kernel/Devices/Audio/AC97.cpp +++ b/Kernel/Devices/Audio/AC97.cpp @@ -88,7 +88,7 @@ UNMAP_AFTER_INIT ErrorOr<void> AC97::initialize(Badge<AudioManagement>) dbgln_if(AC97_DEBUG, "AC97 @ {}: mixer base: {:#04x}", device_identifier().address(), m_mixer_io_window); dbgln_if(AC97_DEBUG, "AC97 @ {}: bus base: {:#04x}", device_identifier().address(), m_bus_io_window); - m_audio_channel = AudioChannel::must_create(*this, 0); + m_audio_channel = TRY(AudioChannel::create(*this, 0)); // Read out AC'97 codec revision and vendor auto extended_audio_id = m_mixer_io_window->read16(NativeAudioMixerRegister::ExtendedAudioID); @@ -177,7 +177,7 @@ void AC97::set_pcm_output_volume(u8 left_channel, u8 right_channel, Muted mute) m_mixer_io_window->write16(NativeAudioMixerRegister::SetPCMOutputVolume, volume_value); } -LockRefPtr<AudioChannel> AC97::audio_channel(u32 index) const +RefPtr<AudioChannel> AC97::audio_channel(u32 index) const { if (index == 0) return m_audio_channel; diff --git a/Kernel/Devices/Audio/AC97.h b/Kernel/Devices/Audio/AC97.h index 5964220451..5477cf6a8d 100644 --- a/Kernel/Devices/Audio/AC97.h +++ b/Kernel/Devices/Audio/AC97.h @@ -7,6 +7,7 @@ #pragma once #include <AK/Error.h> +#include <AK/RefPtr.h> #include <Kernel/Bus/PCI/API.h> #include <Kernel/Bus/PCI/Device.h> #include <Kernel/Devices/Audio/Controller.h> @@ -167,7 +168,7 @@ private: // ^AudioController virtual ErrorOr<void> initialize(Badge<AudioManagement>) override; - virtual LockRefPtr<AudioChannel> audio_channel(u32 index) const override; + virtual RefPtr<AudioChannel> audio_channel(u32 index) const override; virtual ErrorOr<size_t> write(size_t channel_index, UserOrKernelBuffer const& data, size_t length) override; virtual ErrorOr<void> set_pcm_output_sample_rate(size_t channel_index, u32 samples_per_second_rate) override; virtual ErrorOr<u32> get_pcm_output_sample_rate(size_t channel_index) override; @@ -185,7 +186,7 @@ private: NonnullOwnPtr<AC97Channel> m_pcm_out_channel; u32 m_sample_rate { 0 }; bool m_variable_rate_pcm_supported { false }; - LockRefPtr<AudioChannel> m_audio_channel; + RefPtr<AudioChannel> m_audio_channel; }; } diff --git a/Kernel/Devices/Audio/Channel.cpp b/Kernel/Devices/Audio/Channel.cpp index 104d9dc233..96c412f4f0 100644 --- a/Kernel/Devices/Audio/Channel.cpp +++ b/Kernel/Devices/Audio/Channel.cpp @@ -13,12 +13,9 @@ namespace Kernel { -UNMAP_AFTER_INIT NonnullLockRefPtr<AudioChannel> AudioChannel::must_create(AudioController const& controller, size_t channel_index) +UNMAP_AFTER_INIT ErrorOr<NonnullRefPtr<AudioChannel>> AudioChannel::create(AudioController const& controller, size_t channel_index) { - auto audio_device_or_error = DeviceManagement::try_create_device<AudioChannel>(controller, channel_index); - // FIXME: Find a way to propagate errors - VERIFY(!audio_device_or_error.is_error()); - return audio_device_or_error.release_value(); + return *TRY(DeviceManagement::try_create_device<AudioChannel>(controller, channel_index)); } AudioChannel::AudioChannel(AudioController const& controller, size_t channel_index) diff --git a/Kernel/Devices/Audio/Channel.h b/Kernel/Devices/Audio/Channel.h index 7106bd9ae2..188264a8de 100644 --- a/Kernel/Devices/Audio/Channel.h +++ b/Kernel/Devices/Audio/Channel.h @@ -20,7 +20,7 @@ class AudioChannel final friend class DeviceManagement; public: - static NonnullLockRefPtr<AudioChannel> must_create(AudioController const&, size_t channel_index); + static ErrorOr<NonnullRefPtr<AudioChannel>> create(AudioController const&, size_t channel_index); virtual ~AudioChannel() override = default; // ^CharacterDevice diff --git a/Kernel/Devices/Audio/Controller.h b/Kernel/Devices/Audio/Controller.h index b7ba475d11..dfe39e9d84 100644 --- a/Kernel/Devices/Audio/Controller.h +++ b/Kernel/Devices/Audio/Controller.h @@ -8,11 +8,11 @@ #include <AK/IntrusiveList.h> #include <AK/OwnPtr.h> +#include <AK/RefPtr.h> #include <Kernel/Bus/PCI/Access.h> #include <Kernel/Bus/PCI/Device.h> #include <Kernel/Devices/Audio/Channel.h> #include <Kernel/Devices/Device.h> -#include <Kernel/Library/LockRefPtr.h> #include <Kernel/Library/LockWeakable.h> #include <Kernel/Locking/Mutex.h> #include <Kernel/Memory/PhysicalPage.h> @@ -30,7 +30,7 @@ class AudioController public: virtual ~AudioController() = default; - virtual LockRefPtr<AudioChannel> audio_channel(u32 index) const = 0; + virtual RefPtr<AudioChannel> audio_channel(u32 index) const = 0; virtual ErrorOr<size_t> write(size_t channel_index, UserOrKernelBuffer const& data, size_t length) = 0; virtual ErrorOr<void> initialize(Badge<AudioManagement>) = 0; diff --git a/Kernel/Devices/Audio/IntelHDA/Controller.cpp b/Kernel/Devices/Audio/IntelHDA/Controller.cpp index 767e87210f..0588e47e46 100644 --- a/Kernel/Devices/Audio/IntelHDA/Controller.cpp +++ b/Kernel/Devices/Audio/IntelHDA/Controller.cpp @@ -92,7 +92,7 @@ UNMAP_AFTER_INIT ErrorOr<void> Controller::initialize(Badge<AudioManagement>) return result.release_error(); } - m_audio_channel = AudioChannel::must_create(*this, fixed_audio_channel_index); + m_audio_channel = TRY(AudioChannel::create(*this, fixed_audio_channel_index)); return {}; } @@ -290,7 +290,7 @@ ErrorOr<void> Controller::reset() return {}; } -LockRefPtr<AudioChannel> Controller::audio_channel(u32 index) const +RefPtr<AudioChannel> Controller::audio_channel(u32 index) const { if (index != fixed_audio_channel_index) return {}; diff --git a/Kernel/Devices/Audio/IntelHDA/Controller.h b/Kernel/Devices/Audio/IntelHDA/Controller.h index 5a04fd279a..e747453679 100644 --- a/Kernel/Devices/Audio/IntelHDA/Controller.h +++ b/Kernel/Devices/Audio/IntelHDA/Controller.h @@ -9,6 +9,7 @@ #include <AK/Error.h> #include <AK/NonnullOwnPtr.h> #include <AK/NonnullRefPtr.h> +#include <AK/RefPtr.h> #include <AK/Vector.h> #include <Kernel/Bus/PCI/Device.h> #include <Kernel/Devices/Audio/Channel.h> @@ -16,7 +17,6 @@ #include <Kernel/Devices/Audio/IntelHDA/OutputPath.h> #include <Kernel/Devices/Audio/IntelHDA/RingBuffer.h> #include <Kernel/IOWindow.h> -#include <Kernel/Library/LockRefPtr.h> namespace Kernel::Audio::IntelHDA { @@ -65,7 +65,7 @@ private: ErrorOr<void> reset(); // ^AudioController - virtual LockRefPtr<AudioChannel> audio_channel(u32 index) const override; + virtual RefPtr<AudioChannel> audio_channel(u32 index) const override; virtual ErrorOr<size_t> write(size_t channel_index, UserOrKernelBuffer const& data, size_t length) override; virtual ErrorOr<void> initialize(Badge<AudioManagement>) override; virtual ErrorOr<void> set_pcm_output_sample_rate(size_t channel_index, u32 samples_per_second_rate) override; @@ -79,7 +79,7 @@ private: OwnPtr<ResponseInboundRingBuffer> m_response_buffer; Vector<NonnullRefPtr<Codec>> m_codecs {}; OwnPtr<OutputPath> m_output_path; - LockRefPtr<AudioChannel> m_audio_channel; + RefPtr<AudioChannel> m_audio_channel; }; } diff --git a/Kernel/Devices/Audio/Management.h b/Kernel/Devices/Audio/Management.h index d5b772d8dc..703bdb8c39 100644 --- a/Kernel/Devices/Audio/Management.h +++ b/Kernel/Devices/Audio/Management.h @@ -9,10 +9,10 @@ #include <AK/Badge.h> #include <AK/Error.h> #include <AK/IntrusiveList.h> +#include <AK/NonnullRefPtr.h> #include <AK/OwnPtr.h> #include <AK/Types.h> #include <Kernel/Devices/Audio/Controller.h> -#include <Kernel/Library/LockRefPtr.h> namespace Kernel { |