diff options
author | Lenny Maiorani <lenny@serenityos.org> | 2022-03-17 14:38:24 -0600 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-03-18 19:59:43 +0100 |
commit | d3893a73fbb80697bbf322398bc93c6cd21ea679 (patch) | |
tree | 159c3b76c3d5722ae2fe88ffa2e1f47d820eff2f /Userland/Libraries | |
parent | be360db2232ffd401b86627d3e682cf5be71492c (diff) | |
download | serenity-d3893a73fbb80697bbf322398bc93c6cd21ea679.zip |
Libraries: Change enums to enum classes in LibAudio
Diffstat (limited to 'Userland/Libraries')
-rw-r--r-- | Userland/Libraries/LibAudio/FlacLoader.cpp | 16 | ||||
-rw-r--r-- | Userland/Libraries/LibAudio/FlacTypes.h | 8 | ||||
-rw-r--r-- | Userland/Libraries/LibAudio/LoaderError.h | 4 | ||||
-rw-r--r-- | Userland/Libraries/LibAudio/SampleFormats.cpp | 14 | ||||
-rw-r--r-- | Userland/Libraries/LibAudio/SampleFormats.h | 2 |
5 files changed, 22 insertions, 22 deletions
diff --git a/Userland/Libraries/LibAudio/FlacLoader.cpp b/Userland/Libraries/LibAudio/FlacLoader.cpp index 68692b5520..ab74865e27 100644 --- a/Userland/Libraries/LibAudio/FlacLoader.cpp +++ b/Userland/Libraries/LibAudio/FlacLoader.cpp @@ -169,7 +169,7 @@ MaybeLoaderError FlacLoaderPlugin::reset() MaybeLoaderError FlacLoaderPlugin::seek(const int position) { if (m_stream->seek(position, Core::Stream::SeekMode::SetPosition).is_error()) - return LoaderError { LoaderError::IO, m_loaded_samples, String::formatted("Invalid seek position {}", position) }; + return LoaderError { LoaderError::Category::IO, m_loaded_samples, String::formatted("Invalid seek position {}", position) }; return {}; } @@ -232,7 +232,7 @@ MaybeLoaderError FlacLoaderPlugin::next_frame(Span<Sample> target_vector) u32 frame_sample_rate = TRY(convert_sample_rate_code(LOADER_TRY(bit_stream->read_bits<u8>(4)))); u8 channel_type_num = LOADER_TRY(bit_stream->read_bits<u8>(4)); - FLAC_VERIFY(channel_type_num < 0b1011, LoaderError::Format, "Channel assignment"); + FLAC_VERIFY(channel_type_num < 0b1011, LoaderError::Category::Format, "Channel assignment"); FlacFrameChannelType channel_type = (FlacFrameChannelType)channel_type_num; PcmSampleFormat bit_depth = TRY(convert_bit_depth_code(LOADER_TRY(bit_stream->read_bits<u8>(3)))); @@ -440,8 +440,8 @@ ErrorOr<PcmSampleFormat, LoaderError> FlacLoaderPlugin::convert_bit_depth_code(u u8 frame_channel_type_to_channel_count(FlacFrameChannelType channel_type) { - if (channel_type <= 7) - return channel_type + 1; + if (channel_type <= FlacFrameChannelType::Surround7p1) + return to_underlying(channel_type) + 1; return 2; } @@ -451,13 +451,13 @@ ErrorOr<FlacSubframeHeader, LoaderError> FlacLoaderPlugin::next_subframe_header( // For inter-channel correlation, the side channel needs an extra bit for its samples switch (m_current_frame->channels) { - case LeftSideStereo: - case MidSideStereo: + case FlacFrameChannelType::LeftSideStereo: + case FlacFrameChannelType::MidSideStereo: if (channel_index == 1) { ++bits_per_sample; } break; - case RightSideStereo: + case FlacFrameChannelType::RightSideStereo: if (channel_index == 0) { ++bits_per_sample; } @@ -675,7 +675,7 @@ ErrorOr<Vector<i32>, LoaderError> FlacLoaderPlugin::decode_fixed_lpc(FlacSubfram // Decode the residual, the "error" between the function approximation and the actual audio data MaybeLoaderError FlacLoaderPlugin::decode_residual(Vector<i32>& decoded, FlacSubframeHeader& subframe, BigEndianInputBitStream& bit_input) { - u8 residual_mode = LOADER_TRY(bit_input.read_bits<u8>(2)); + auto residual_mode = static_cast<FlacResidualMode>(LOADER_TRY(bit_input.read_bits<u8>(2))); u8 partition_order = LOADER_TRY(bit_input.read_bits<u8>(4)); size_t partitions = 1 << partition_order; diff --git a/Userland/Libraries/LibAudio/FlacTypes.h b/Userland/Libraries/LibAudio/FlacTypes.h index e422f595a2..c5fb663b4e 100644 --- a/Userland/Libraries/LibAudio/FlacTypes.h +++ b/Userland/Libraries/LibAudio/FlacTypes.h @@ -21,7 +21,7 @@ namespace Audio { #define FLAC_SAMPLERATE_AT_END_OF_HEADER_16X10 0xfffffffd // Metadata block type, 7 bits. -enum FlacMetadataBlockType : u8 { +enum class FlacMetadataBlockType : u8 { STREAMINFO = 0, // Important data about the audio format PADDING = 1, // Non-data block to be ignored APPLICATION = 2, // Ignored @@ -33,7 +33,7 @@ enum FlacMetadataBlockType : u8 { }; // follows FLAC codes -enum FlacFrameChannelType : u8 { +enum class FlacFrameChannelType : u8 { Mono = 0, Stereo = 1, StereoCenter = 2, // left, right, center @@ -49,7 +49,7 @@ enum FlacFrameChannelType : u8 { }; // follows FLAC codes -enum FlacSubframeType : u8 { +enum class FlacSubframeType : u8 { Constant = 0, Verbatim = 1, Fixed = 0b001000, @@ -58,7 +58,7 @@ enum FlacSubframeType : u8 { }; // follows FLAC codes -enum FlacResidualMode : u8 { +enum class FlacResidualMode : u8 { Rice4Bit = 0, Rice5Bit = 1, }; diff --git a/Userland/Libraries/LibAudio/LoaderError.h b/Userland/Libraries/LibAudio/LoaderError.h index 583476c032..58455c355f 100644 --- a/Userland/Libraries/LibAudio/LoaderError.h +++ b/Userland/Libraries/LibAudio/LoaderError.h @@ -14,7 +14,7 @@ namespace Audio { struct LoaderError { - enum Category : u32 { + enum class Category : u32 { // The error category is unknown. Unknown = 0, IO, @@ -25,7 +25,7 @@ struct LoaderError { // The loader encountered something in the format that is not yet implemented. Unimplemented, }; - Category category { Unknown }; + Category category { Category::Unknown }; // Binary index: where in the file the error occurred. size_t index { 0 }; FlyString description { String::empty() }; diff --git a/Userland/Libraries/LibAudio/SampleFormats.cpp b/Userland/Libraries/LibAudio/SampleFormats.cpp index 740c24e58d..882628bc78 100644 --- a/Userland/Libraries/LibAudio/SampleFormats.cpp +++ b/Userland/Libraries/LibAudio/SampleFormats.cpp @@ -11,16 +11,16 @@ namespace Audio { u16 pcm_bits_per_sample(PcmSampleFormat format) { switch (format) { - case Uint8: + case PcmSampleFormat::Uint8: return 8; - case Int16: + case PcmSampleFormat::Int16: return 16; - case Int24: + case PcmSampleFormat::Int24: return 24; - case Int32: - case Float32: + case PcmSampleFormat::Int32: + case PcmSampleFormat::Float32: return 32; - case Float64: + case PcmSampleFormat::Float64: return 64; default: VERIFY_NOT_REACHED(); @@ -29,7 +29,7 @@ u16 pcm_bits_per_sample(PcmSampleFormat format) String sample_format_name(PcmSampleFormat format) { - bool is_float = format == Float32 || format == Float64; + bool is_float = format == PcmSampleFormat::Float32 || format == PcmSampleFormat::Float64; return String::formatted("PCM {}bit {}", pcm_bits_per_sample(format), is_float ? "Float" : "LE"); } diff --git a/Userland/Libraries/LibAudio/SampleFormats.h b/Userland/Libraries/LibAudio/SampleFormats.h index 2990ee80b8..567489303a 100644 --- a/Userland/Libraries/LibAudio/SampleFormats.h +++ b/Userland/Libraries/LibAudio/SampleFormats.h @@ -12,7 +12,7 @@ namespace Audio { // Supported PCM sample formats. -enum PcmSampleFormat : u8 { +enum class PcmSampleFormat : u8 { Uint8, Int16, Int24, |