From 93727d4b07a18f439f839fe6830fdc4ef3efec13 Mon Sep 17 00:00:00 2001 From: sagu <16504129+sagudev@users.noreply.github.com> Date: Sat, 29 Jan 2022 01:13:21 +0100 Subject: [PATCH] core: Make FormatReader, Decoder, and MetadataReader Sync (#98) --- symphonia-codec-vorbis/src/floor.rs | 2 +- symphonia-core/src/codecs.rs | 2 +- symphonia-core/src/formats.rs | 2 +- symphonia-core/src/io/mod.rs | 6 +++--- symphonia-core/src/meta.rs | 2 +- symphonia-format-isomp4/src/stream.rs | 2 +- symphonia-format-ogg/src/mappings/mod.rs | 4 ++-- 7 files changed, 10 insertions(+), 10 deletions(-) diff --git a/symphonia-codec-vorbis/src/floor.rs b/symphonia-codec-vorbis/src/floor.rs index 958756b1..810e0492 100644 --- a/symphonia-codec-vorbis/src/floor.rs +++ b/symphonia-codec-vorbis/src/floor.rs @@ -111,7 +111,7 @@ macro_rules! try_or_ret { }; } -pub trait Floor: Send { +pub trait Floor: Send + Sync { fn read_channel( &mut self, bs: &mut BitReaderRtl<'_>, diff --git a/symphonia-core/src/codecs.rs b/symphonia-core/src/codecs.rs index 7751ce0f..bd9d5e9b 100644 --- a/symphonia-core/src/codecs.rs +++ b/symphonia-core/src/codecs.rs @@ -440,7 +440,7 @@ pub struct DecoderOptions { /// A `Decoder` implements a codec's decode algorithm. It consumes `Packet`s and produces /// `AudioBuffer`s. -pub trait Decoder: Send { +pub trait Decoder: Send + Sync { /// Attempts to instantiates a `Decoder` using the provided `CodecParameters`. fn try_new(params: &CodecParameters, options: &DecoderOptions) -> Result where diff --git a/symphonia-core/src/formats.rs b/symphonia-core/src/formats.rs index be90a8ae..87997842 100644 --- a/symphonia-core/src/formats.rs +++ b/symphonia-core/src/formats.rs @@ -165,7 +165,7 @@ impl Track { /// `FormatReader` provides an Iterator-like interface over packets for easy consumption and /// filtering. Seeking will invalidate the state of any `Decoder` processing packets from the /// `FormatReader` and should be reset after a successful seek operation. -pub trait FormatReader: Send { +pub trait FormatReader: Send + Sync { /// Attempt to instantiate a `FormatReader` using the provided `FormatOptions` and /// `MediaSourceStream`. The reader will probe the container to verify format support, determine /// the number of tracks, and read any initial metadata. diff --git a/symphonia-core/src/io/mod.rs b/symphonia-core/src/io/mod.rs index f013bea4..90b7186a 100644 --- a/symphonia-core/src/io/mod.rs +++ b/symphonia-core/src/io/mod.rs @@ -39,7 +39,7 @@ pub use scoped_stream::ScopedStream; /// /// Despite requiring the [`std::io::Seek`] trait, seeking is an optional capability that can be /// queried at runtime. -pub trait MediaSource: io::Read + io::Seek + Send { +pub trait MediaSource: io::Read + io::Seek + Send + Sync { /// Returns if the source is seekable. This may be an expensive operation. fn is_seekable(&self) -> bool; @@ -74,7 +74,7 @@ impl MediaSource for std::fs::File { } } -impl + Send> MediaSource for io::Cursor { +impl + Send + Sync> MediaSource for io::Cursor { /// Always returns true since a `io::Cursor` is always seekable. fn is_seekable(&self) -> bool { true @@ -118,7 +118,7 @@ impl ReadOnlySource { } } -impl MediaSource for ReadOnlySource { +impl MediaSource for ReadOnlySource { fn is_seekable(&self) -> bool { false } diff --git a/symphonia-core/src/meta.rs b/symphonia-core/src/meta.rs index d7197312..6abf6a65 100644 --- a/symphonia-core/src/meta.rs +++ b/symphonia-core/src/meta.rs @@ -498,7 +498,7 @@ impl MetadataLog { } } -pub trait MetadataReader: Send { +pub trait MetadataReader: Send + Sync { /// Instantiates the `MetadataReader` with the provided `MetadataOptions`. fn new(options: &MetadataOptions) -> Self where diff --git a/symphonia-format-isomp4/src/stream.rs b/symphonia-format-isomp4/src/stream.rs index eee9a856..c51aa42e 100644 --- a/symphonia-format-isomp4/src/stream.rs +++ b/symphonia-format-isomp4/src/stream.rs @@ -21,7 +21,7 @@ pub struct SampleTiming { pub dur: u32, } -pub trait StreamSegment: Send { +pub trait StreamSegment: Send + Sync { /// Gets the sequence number of this segment. fn sequence_num(&self) -> u32; diff --git a/symphonia-format-ogg/src/mappings/mod.rs b/symphonia-format-ogg/src/mappings/mod.rs index 0b4e5d4c..bc47a574 100644 --- a/symphonia-format-ogg/src/mappings/mod.rs +++ b/symphonia-format-ogg/src/mappings/mod.rs @@ -38,12 +38,12 @@ pub enum MapResult { /// A `PacketParser` implements a packet parser that decodes the timestamp and duration for a /// packet. -pub trait PacketParser: Send { +pub trait PacketParser: Send + Sync { fn parse_next_packet_dur(&mut self, packet: &[u8]) -> u64; } /// A `Mapper` implements packet-handling for a specific `Codec`. -pub trait Mapper: Send { +pub trait Mapper: Send + Sync { /// Gets the name of the mapper. fn name(&self) -> &'static str;