Skip to content

Commit 7e05c8b

Browse files
committed
Rework error wrapping
1 parent 7122e93 commit 7e05c8b

File tree

25 files changed

+119
-286
lines changed

25 files changed

+119
-286
lines changed

symphonia-bundle-mp3/src/layer3/mod.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
use std::fmt;
99

1010
use symphonia_core::audio::{AudioBuffer, Signal};
11-
use symphonia_core::errors::{decode_error, Error, IoErrorKind, Result};
11+
use symphonia_core::errors::{decode_error, Result};
12+
use symphonia_core::errors::SymphoniaError as Error;
1213
use symphonia_core::io::{BitReaderLtr, BufReader, ReadBitsLtr, ReadBytes};
1314

1415
mod bitstream;
@@ -356,7 +357,7 @@ impl Layer3 {
356357
// IO error to a decode error.
357358
frame_data.granules[gr].channels[ch].rzero = match huffman_result {
358359
Ok(rzero) => rzero,
359-
Err(Error::IoError(IoErrorKind::Other, _)) => {
360+
Err(Error::IoError(_)) => {
360361
return decode_error("mpa: huffman decode overrun");
361362
}
362363
Err(err) => return Err(err),

symphonia-bundle-mp3/src/lib.rs

+2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
#![allow(clippy::identity_op)]
1515
#![allow(clippy::manual_range_contains)]
1616

17+
extern crate alloc;
18+
1719
// Shared modules.
1820
mod common;
1921
mod header;

symphonia-check/src/main.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ use std::process::{Command, Stdio};
1818

1919
use symphonia::core::audio::{AudioBufferRef, SampleBuffer};
2020
use symphonia::core::codecs::{Decoder, DecoderOptions};
21-
use symphonia::core::errors::{Error, IoErrorKind, Result};
21+
use symphonia::core::errors::Result;
22+
use symphonia::core::errors::SymphoniaError as Error;
2223
use symphonia::core::formats::{FormatOptions, FormatReader};
2324
use symphonia::core::io::{MediaSourceStream, ReadOnlySource};
2425
use symphonia::core::meta::MetadataOptions;
@@ -396,7 +397,7 @@ fn main() {
396397
println!();
397398

398399
match run_test(path, &opts, &mut res) {
399-
Err(Error::IoError(IoErrorKind::UnexpectedEof, _)) => (),
400+
Err(Error::EndOfFile) => (),
400401
Err(err) => {
401402
eprintln!("Test interrupted by error: {}", err);
402403
std::process::exit(2);

symphonia-codec-aac/src/lib.rs

+2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
// TODO: Remove this when refactoring AAC.
1717
#![allow(clippy::needless_range_loop)]
1818

19+
extern crate alloc;
20+
1921
mod aac;
2022
mod adts;
2123
mod common;

symphonia-codec-adpcm/src/lib.rs

+2
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ use symphonia_core::errors::{unsupported_error, Result};
2424
use symphonia_core::formats::Packet;
2525
use symphonia_core::io::ReadBytes;
2626

27+
extern crate alloc;
28+
2729
mod codec_ima;
2830
mod codec_ms;
2931
mod common;

symphonia-codec-alac/src/lib.rs

+2
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ use symphonia_core::formats::Packet;
2929
use symphonia_core::io::{BitReaderLtr, BufReader, FiniteStream, ReadBitsLtr, ReadBytes};
3030
use symphonia_core::support_codec;
3131

32+
extern crate alloc;
33+
3234
/// Supported ALAC version.
3335
const ALAC_VERSION: u8 = 0;
3436

symphonia-codec-vorbis/src/floor.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
use std::cmp::min;
99
use std::collections::HashSet;
1010

11-
use symphonia_core::errors::{decode_error, Error, IoErrorKind, Result};
11+
use symphonia_core::errors::SymphoniaError as Error;
12+
use symphonia_core::errors::{decode_error, Result};
1213
use symphonia_core::io::{BitReaderRtl, ReadBitsRtl};
1314

1415
use super::codebook::VorbisCodebook;
@@ -92,7 +93,7 @@ macro_rules! io_try_or_ret {
9293
// An end-of-bitstream error is classified under ErrorKind::Other. This condition
9394
// should not be treated as an error, rather, it should return from the function
9495
// immediately without error.
95-
Err(Error::IoError(IoErrorKind::Other, _)) => return Ok(()),
96+
Err(Error::EndOfFile) => return Ok(()),
9697
Err(e) => return Err(e.into()),
9798
}
9899
};
@@ -105,7 +106,7 @@ macro_rules! try_or_ret {
105106
// An end-of-bitstream error is classified under ErrorKind::Other. This condition
106107
// should not be treated as an error, rather, it should return from the function
107108
// immediately without error.
108-
Err(Error::IoError(IoErrorKind::Other, _)) => return Ok(()),
109+
Err(Error::EndOfFile) => return Ok(()),
109110
Err(e) => return Err(e),
110111
}
111112
};

symphonia-codec-vorbis/src/lib.rs

+2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
// Disable to better express the specification.
1717
#![allow(clippy::collapsible_else_if)]
1818

19+
extern crate alloc;
20+
1921
use symphonia_core::audio::{AsAudioBufferRef, AudioBuffer, AudioBufferRef};
2022
use symphonia_core::audio::{Signal, SignalSpec};
2123
use symphonia_core::codecs::{CodecDescriptor, CodecParameters, CODEC_TYPE_VORBIS};

symphonia-codec-vorbis/src/residue.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
use std::cmp::min;
99
use std::convert::TryInto;
1010

11-
use symphonia_core::errors::{decode_error, Error, IoErrorKind, Result};
11+
use symphonia_core::errors::SymphoniaError as Error;
12+
use symphonia_core::errors::{decode_error, Result};
1213
use symphonia_core::io::{BitReaderRtl, ReadBitsRtl};
1314

1415
use super::codebook::VorbisCodebook;
@@ -154,7 +155,7 @@ impl Residue {
154155
Ok(_) => (),
155156
// An end-of-bitstream error is classified under ErrorKind::Other. This condition
156157
// should not be treated as an error.
157-
Err(Error::IoError(IoErrorKind::Other, _)) => (),
158+
Err(Error::EndOfFile) => (),
158159
Err(e) => return Err(e),
159160
};
160161

0 commit comments

Comments
 (0)