1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 16:18:12 +00:00

Kernel/Audio: Propagate errors when creating AudioChannels

While doing this, we can also just return a normal RefPtr instead of a
LockRefPtr, because we create these channels when initializing an audio
controller, and never change the pointer in AudioController instances
after their initialization, hence no locking is necessary.
This commit is contained in:
Liav A 2023-04-11 13:11:02 +03:00 committed by Linus Groh
parent 4921561687
commit dd7633c5f4
8 changed files with 16 additions and 18 deletions

View file

@ -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)