Skip to content

Commit

Permalink
Upgrade bitflags to 2.4.1
Browse files Browse the repository at this point in the history
  • Loading branch information
GnomedDev committed Nov 7, 2023
1 parent b157bb5 commit bf1a334
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 29 deletions.
1 change: 0 additions & 1 deletion symphonia-bundle-mp3/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ mp3 = []

[dependencies]
log = "0.4"
bitflags = "1.2.1"
lazy_static = "1.4.0"
symphonia-core = { version = "0.5.2", path = "../symphonia-core" }
symphonia-metadata = { version = "0.5.2", path = "../symphonia-metadata" }
2 changes: 1 addition & 1 deletion symphonia-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ rust-version = "1.53"

[dependencies]
arrayvec = "0.7.1"
bitflags = "1.2.1"
bitflags = "2.4.1"
bytemuck = "1.7"
lazy_static = "1.4.0"
log = "0.4"
Expand Down
30 changes: 3 additions & 27 deletions symphonia-core/src/audio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ bitflags! {
/// The first 18 defined channels are guaranteed to be identical to those specified by
/// Microsoft's WAVEFORMATEXTENSIBLE structure. Channels after 18 are defined by Symphonia and
/// no order is guaranteed.
#[derive(Default)]
#[derive(Default, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Clone, Copy)]
pub struct Channels: u32 {
/// Front-left (left) or the Mono channel.
const FRONT_LEFT = 0x0000_0001;
Expand Down Expand Up @@ -89,41 +89,17 @@ bitflags! {
}
}

/// An iterator over individual channels within a `Channels` bitmask.
pub struct ChannelsIter {
channels: Channels,
}

impl Iterator for ChannelsIter {
type Item = Channels;

fn next(&mut self) -> Option<Self::Item> {
if !self.channels.is_empty() {
let channel = Channels::from_bits_truncate(1 << self.channels.bits.trailing_zeros());
self.channels ^= channel;
Some(channel)
}
else {
None
}
}
}

impl Channels {
/// Gets the number of channels.
pub fn count(self) -> usize {
self.bits.count_ones() as usize
self.bits().count_ones() as usize
}

/// Gets an iterator over individual channels.
pub fn iter(&self) -> ChannelsIter {
ChannelsIter { channels: *self }
}
}

impl fmt::Display for Channels {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{:#032b}", self.bits)
write!(f, "{:#032b}", self.bits())
}
}

Expand Down

0 comments on commit bf1a334

Please sign in to comment.