Skip to content

Commit fdf6a8b

Browse files
committed
play,check: Update app dependencies.
Update to latest versions with a MSRV <= 1.85.
1 parent c3025d9 commit fdf6a8b

File tree

7 files changed

+94
-59
lines changed

7 files changed

+94
-59
lines changed

symphonia-check/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ rust-version.workspace = true
1212
version.workspace = true
1313

1414
[dependencies]
15-
clap = "3.1.0"
15+
clap = "4.6.0"
1616
log = { workspace = true, features = ["release_max_level_info"] }
17-
pretty_env_logger = "0.4"
17+
pretty_env_logger = "0.5"
1818
symphonia = { version = "0.6.0-alpha.1", path = "../symphonia", features = ["all"] }

symphonia-check/src/main.rs

Lines changed: 46 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#![allow(clippy::needless_update)]
1414

1515
use std::fs::File;
16-
use std::path::Path;
16+
use std::path::{Path, PathBuf};
1717
use std::process::{Command, Stdio};
1818

1919
use symphonia::core::audio::GenericAudioBufferRef;
@@ -25,7 +25,7 @@ use symphonia::core::formats::{FormatOptions, FormatReader, TrackType};
2525
use symphonia::core::io::{MediaSourceStream, ReadOnlySource};
2626
use symphonia::core::meta::MetadataOptions;
2727

28-
use clap::Arg;
28+
use clap::{Arg, ArgAction};
2929
use log::warn;
3030

3131
/// The absolute maximum allowable sample delta. Around 2^-17 (-102.4dB).
@@ -66,7 +66,7 @@ struct TestResult {
6666
ref_unchecked_samples: u64,
6767
}
6868

69-
fn build_ffmpeg_command(path: &str, gapless: bool) -> Command {
69+
fn build_ffmpeg_command(path: &Path, gapless: bool) -> Command {
7070
let mut cmd = Command::new("ffmpeg");
7171

7272
// Gapless argument must come before everything else.
@@ -91,15 +91,15 @@ fn build_ffmpeg_command(path: &str, gapless: bool) -> Command {
9191
cmd
9292
}
9393

94-
fn build_flac_command(path: &str) -> Command {
94+
fn build_flac_command(path: &Path) -> Command {
9595
let mut cmd = Command::new("flac");
9696

9797
cmd.arg("--stdout").arg("-d").arg(path).stdout(Stdio::piped()).stderr(Stdio::null());
9898

9999
cmd
100100
}
101101

102-
fn build_mpg123_command(path: &str, gapless: bool) -> Command {
102+
fn build_mpg123_command(path: &Path, gapless: bool) -> Command {
103103
let mut cmd = Command::new("mpg123");
104104

105105
if !gapless {
@@ -111,7 +111,7 @@ fn build_mpg123_command(path: &str, gapless: bool) -> Command {
111111
cmd
112112
}
113113

114-
fn build_oggdec_command(path: &str) -> Command {
114+
fn build_oggdec_command(path: &Path) -> Command {
115115
let mut cmd = Command::new("oggdec");
116116
cmd.arg(path).arg("-o").arg("-").stdout(Stdio::piped()).stderr(Stdio::null());
117117
cmd
@@ -122,7 +122,7 @@ struct RefProcess {
122122
}
123123

124124
impl RefProcess {
125-
fn try_spawn(decoder: RefDecoder, gapless: bool, path: &str) -> Result<RefProcess> {
125+
fn try_spawn(decoder: RefDecoder, gapless: bool, path: &Path) -> Result<RefProcess> {
126126
let mut cmd = match decoder {
127127
RefDecoder::Ffmpeg => build_ffmpeg_command(path, gapless),
128128
RefDecoder::Flac => build_flac_command(path),
@@ -343,7 +343,7 @@ fn run_check(
343343
Ok(())
344344
}
345345

346-
fn run_test(path: &str, opts: &TestOptions, result: &mut TestResult) -> Result<()> {
346+
fn run_test(path: &Path, opts: &TestOptions, result: &mut TestResult) -> Result<()> {
347347
// 1. Start the reference decoder process.
348348
let mut ref_process = RefProcess::try_spawn(opts.ref_decoder, opts.gapless, path)?;
349349

@@ -354,7 +354,7 @@ fn run_test(path: &str, opts: &TestOptions, result: &mut TestResult) -> Result<(
354354
let mut ref_inst = DecoderInstance::try_open(ref_mss, Default::default(), Default::default())?;
355355

356356
// 3. Instantiate a Symphonia decoder for the test target.
357-
let tgt_ms = Box::new(File::open(Path::new(path))?);
357+
let tgt_ms = Box::new(File::open(path)?);
358358
let tgt_mss = MediaSourceStream::new(tgt_ms, Default::default());
359359

360360
let tgt_fmt_opts = Default::default();
@@ -373,34 +373,57 @@ fn main() {
373373
.version("1.0")
374374
.author("Philip Deljanov <philip.deljanov@gmail.com>")
375375
.about("Check Symphonia output with a reference decoding")
376-
.arg(Arg::new("samples").long("samples").help("Print failures per sample"))
376+
.arg(
377+
Arg::new("samples")
378+
.long("samples")
379+
.action(ArgAction::SetTrue)
380+
.help("Print failures per sample"),
381+
)
377382
.arg(
378383
Arg::new("stop-after-fail")
379384
.long("first-fail")
380385
.short('f')
386+
.action(ArgAction::SetTrue)
381387
.help("Stop testing after the first failed packet"),
382388
)
383-
.arg(Arg::new("quiet").long("quiet").short('q').help("Only print test results"))
389+
.arg(
390+
Arg::new("quiet")
391+
.long("quiet")
392+
.short('q')
393+
.action(ArgAction::SetTrue)
394+
.help("Only print test results"),
395+
)
384396
.arg(
385397
Arg::new("keep-going")
386398
.long("keep-going")
399+
.action(ArgAction::SetTrue)
387400
.help("Continue after a decode error (may cause many failures)"),
388401
)
389402
.arg(
390403
Arg::new("decoder")
391404
.long("ref")
392-
.takes_value(true)
393-
.possible_values(["ffmpeg", "flac", "mpg123", "oggdec"])
405+
.value_parser(["ffmpeg", "flac", "mpg123", "oggdec"])
394406
.default_value("ffmpeg")
395407
.help("Specify a particular decoder to be used as the reference"),
396408
)
397-
.arg(Arg::new("no-gapless").long("no-gapless").help("Disable gapless decoding"))
398-
.arg(Arg::new("INPUT").help("The input file path").required(true).index(1))
409+
.arg(
410+
Arg::new("no-gapless")
411+
.long("no-gapless")
412+
.action(ArgAction::SetTrue)
413+
.help("Disable gapless decoding"),
414+
)
415+
.arg(
416+
Arg::new("INPUT")
417+
.help("The input file path")
418+
.value_parser(clap::value_parser!(PathBuf))
419+
.required(true)
420+
.index(1),
421+
)
399422
.get_matches();
400423

401-
let path = matches.value_of("INPUT").unwrap();
424+
let path = matches.get_one::<PathBuf>("INPUT").expect("path is a required argument");
402425

403-
let ref_decoder = match matches.value_of("decoder").unwrap() {
426+
let ref_decoder = match matches.get_one("decoder").copied().unwrap() {
404427
"ffmpeg" => RefDecoder::Ffmpeg,
405428
"flac" => RefDecoder::Flac,
406429
"mpg123" => RefDecoder::Mpg123,
@@ -414,17 +437,17 @@ fn main() {
414437

415438
let opts = TestOptions {
416439
ref_decoder,
417-
is_per_sample: matches.is_present("samples"),
418-
is_quiet: matches.is_present("quiet"),
419-
stop_after_fail: matches.is_present("stop-after-fail"),
420-
keep_going: matches.is_present("keep-going"),
421-
gapless: !matches.is_present("no-gapless"),
440+
is_per_sample: matches.get_flag("samples"),
441+
is_quiet: matches.get_flag("quiet"),
442+
stop_after_fail: matches.get_flag("stop-after-fail"),
443+
keep_going: matches.get_flag("keep-going"),
444+
gapless: !matches.get_flag("no-gapless"),
422445
..Default::default()
423446
};
424447

425448
let mut res: TestResult = Default::default();
426449

427-
println!("Input Path: {path}");
450+
println!("Input Path: {}", path.to_string_lossy());
428451
println!();
429452

430453
if let Err(err) = run_test(path, &opts, &mut res) {

symphonia-core/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,6 @@ optional = true
4646
default-features = false
4747

4848
[dev-dependencies.rand]
49-
version = "0.9.2"
50-
features = ["small_rng"]
49+
version = "0.10.0"
50+
5151
default-features = false

symphonia-core/src/io/bit.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1382,7 +1382,7 @@ impl FiniteBitStream for BitReaderRtl<'_> {
13821382

13831383
#[cfg(test)]
13841384
mod tests {
1385-
use rand::{RngCore, SeedableRng};
1385+
use rand::{Rng, SeedableRng};
13861386

13871387
use super::vlc::{BitOrder, Codebook, CodebookBuilder, Entry8x8};
13881388
use super::{BitReaderLtr, ReadBitsLtr};

symphonia-play/Cargo.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,18 @@ exp-subtitle-codecs = ["symphonia/exp-subtitle-codecs"]
2020
default = ["exp-subtitle-codecs", "exp-video-codecs"]
2121

2222
[dependencies]
23-
clap = "3.1.0"
23+
clap = "4.6.0"
2424
lazy_static = { workspace = true }
2525
log = { workspace = true, features = ["release_max_level_info"] }
26-
pretty_env_logger = "0.4"
26+
pretty_env_logger = "0.5"
2727
symphonia = { version = "0.6.0-alpha.1", path = "../symphonia", features = ["all"] }
2828

2929
[target.'cfg(target_os = "linux")'.dependencies]
3030
libpulse-binding = "2.5.0"
3131
libpulse-simple-binding = "2.5.0"
3232

3333
[target.'cfg(not(target_os = "linux"))'.dependencies]
34-
cpal = "0.13.3"
35-
rb = "0.3.2"
34+
cpal = "0.17.3"
35+
rb = "0.4.1"
3636
rubato = "0.14.1"
3737
smallvec = { workspace = true }

symphonia-play/src/main.rs

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ use symphonia::core::io::{MediaSource, MediaSourceStream, ReadOnlySource};
2626
use symphonia::core::meta::{MetadataOptions, Visual};
2727
use symphonia::core::units::{Duration, Time, Timestamp};
2828

29-
use clap::{Arg, ArgMatches};
29+
use clap::{Arg, ArgAction, ArgMatches};
3030
use log::{error, info, warn};
3131

3232
mod output;
@@ -55,7 +55,7 @@ fn main() {
5555
.value_name("TIME")
5656
.value_parser(clap::value_parser!(f64))
5757
.help("Seek to the time in seconds")
58-
.conflicts_with_all(&[
58+
.conflicts_with_all([
5959
"seek-ts",
6060
"decode-only",
6161
"probe-only",
@@ -71,13 +71,7 @@ fn main() {
7171
.value_parser(clap::value_parser!(i64))
7272
.allow_hyphen_values(true)
7373
.help("Seek to the timestamp in timebase units")
74-
.conflicts_with_all(&[
75-
"seek",
76-
"decode-only",
77-
"probe-only",
78-
"verify",
79-
"verify-only",
80-
]),
74+
.conflicts_with_all(["seek", "decode-only", "probe-only", "verify", "verify-only"]),
8175
)
8276
.arg(
8377
Arg::new("track")
@@ -90,34 +84,47 @@ fn main() {
9084
.arg(
9185
Arg::new("decode-only")
9286
.long("decode-only")
87+
.action(ArgAction::SetTrue)
9388
.help("Decode, but do not play the audio")
94-
.conflicts_with_all(&["probe-only", "verify-only", "verify"]),
89+
.conflicts_with_all(["probe-only", "verify-only", "verify"]),
9590
)
9691
.arg(
9792
Arg::new("probe-only")
9893
.long("probe-only")
94+
.action(ArgAction::SetTrue)
9995
.help("Only probe the input for metadata")
100-
.conflicts_with_all(&["decode-only", "verify-only"]),
96+
.conflicts_with_all(["decode-only", "verify-only"]),
10197
)
10298
.arg(
10399
Arg::new("verify-only")
104100
.long("verify-only")
101+
.action(ArgAction::SetTrue)
105102
.help("Verify the decoded audio is valid, but do not play the audio")
106-
.conflicts_with_all(&["verify"]),
103+
.conflicts_with_all(["verify"]),
107104
)
108105
.arg(
109106
Arg::new("verify")
110107
.long("verify")
111108
.short('v')
109+
.action(ArgAction::SetTrue)
112110
.help("Verify the decoded audio is valid during playback"),
113111
)
114-
.arg(Arg::new("no-progress").long("no-progress").help("Do not display playback progress"))
115112
.arg(
116-
Arg::new("no-gapless").long("no-gapless").help("Disable gapless decoding and playback"),
113+
Arg::new("no-progress")
114+
.long("no-progress")
115+
.action(ArgAction::SetTrue)
116+
.help("Do not display playback progress"),
117+
)
118+
.arg(
119+
Arg::new("no-gapless")
120+
.long("no-gapless")
121+
.action(ArgAction::SetTrue)
122+
.help("Disable gapless decoding and playback"),
117123
)
118124
.arg(
119125
Arg::new("dump-visuals")
120126
.long("dump-visuals")
127+
.action(ArgAction::SetTrue)
121128
.help("Dump all visuals to the current working directory"),
122129
)
123130
.arg(
@@ -177,7 +184,7 @@ fn run(args: &ArgMatches) -> Result<i32> {
177184
match symphonia::default::get_probe().probe(&hint, mss, fmt_opts, meta_opts) {
178185
Ok(mut format) => {
179186
// Dump visuals if requested.
180-
if args.is_present("dump-visuals") {
187+
if args.get_flag("dump-visuals") {
181188
let name = match path.file_name() {
182189
Some(name) if name != "-" => name,
183190
_ => OsStr::new("NoName"),
@@ -189,20 +196,20 @@ fn run(args: &ArgMatches) -> Result<i32> {
189196
// Get the value of the track number option, if provided.
190197
let track_num = args.get_one::<usize>("track").copied();
191198

192-
let dec_opts = AudioDecoderOptions::default().gapless(!args.is_present("no-gapless"));
199+
let dec_opts = AudioDecoderOptions::default().gapless(!args.get_flag("no-gapless"));
193200

194201
// Select the operating mode.
195-
if args.is_present("probe-only") {
202+
if args.get_flag("probe-only") {
196203
// Probe-only mode only prints information about the format, tracks, metadata, etc.
197204
ui::print_format(path, &mut format);
198205
Ok(0)
199206
}
200-
else if args.is_present("verify-only") {
207+
else if args.get_flag("verify-only") {
201208
// Verify-only mode decodes and verifies the audio, but does not play it.
202209
let opts = DecodeOptions { dec_opts: dec_opts.verify(true), track_num };
203210
decode_only(format, opts)
204211
}
205-
else if args.is_present("decode-only") {
212+
else if args.get_flag("decode-only") {
206213
// Decode-only mode decodes the audio, but does not play or verify it.
207214
let opts = DecodeOptions { dec_opts: dec_opts.verify(false), track_num };
208215

@@ -224,10 +231,10 @@ fn run(args: &ArgMatches) -> Result<i32> {
224231

225232
// Setup playback options.
226233
let opts = PlayOptions {
227-
decoder_opts: dec_opts.verify(args.is_present("verify")),
234+
decoder_opts: dec_opts.verify(args.get_flag("verify")),
228235
track_num,
229236
seek_pos,
230-
no_progress: args.is_present("no-progress"),
237+
no_progress: args.get_flag("no-progress"),
231238
};
232239

233240
// Play it!

0 commit comments

Comments
 (0)