Skip to content

Commit

Permalink
core: Make FormatReader, Decoder, and MetadataReader Sync (#98)
Browse files Browse the repository at this point in the history
  • Loading branch information
sagudev authored Jan 29, 2022
1 parent 2119c49 commit 93727d4
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion symphonia-codec-vorbis/src/floor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<'_>,
Expand Down
2 changes: 1 addition & 1 deletion symphonia-core/src/codecs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Self>
where
Expand Down
2 changes: 1 addition & 1 deletion symphonia-core/src/formats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 3 additions & 3 deletions symphonia-core/src/io/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -74,7 +74,7 @@ impl MediaSource for std::fs::File {
}
}

impl<T: std::convert::AsRef<[u8]> + Send> MediaSource for io::Cursor<T> {
impl<T: std::convert::AsRef<[u8]> + Send + Sync> MediaSource for io::Cursor<T> {
/// Always returns true since a `io::Cursor<u8>` is always seekable.
fn is_seekable(&self) -> bool {
true
Expand Down Expand Up @@ -118,7 +118,7 @@ impl<R: io::Read + Send> ReadOnlySource<R> {
}
}

impl<R: io::Read + Send> MediaSource for ReadOnlySource<R> {
impl<R: io::Read + Send + Sync> MediaSource for ReadOnlySource<R> {
fn is_seekable(&self) -> bool {
false
}
Expand Down
2 changes: 1 addition & 1 deletion symphonia-core/src/meta.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion symphonia-format-isomp4/src/stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
4 changes: 2 additions & 2 deletions symphonia-format-ogg/src/mappings/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 93727d4

Please sign in to comment.