Merge pull request #45 from Polochon-street/fix-decoding

fix decoding when a file is broken
This commit is contained in:
Polochon-street 2022-09-07 23:40:58 +02:00 committed by GitHub
commit 701feb414d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 18 additions and 2 deletions

View File

@ -1,5 +1,9 @@
#Changelog #Changelog
## bliss 5.2.3
* Fix a bug with some broken MP3 files
* Bump ffmpeg to 5.1.0
## bliss 0.5.0 ## bliss 0.5.0
* Add support for CUE files. * Add support for CUE files.
* Add `album_artist` and `duration` to `Song`. * Add `album_artist` and `duration` to `Song`.

2
Cargo.lock generated
View File

@ -85,7 +85,7 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
[[package]] [[package]]
name = "bliss-audio" name = "bliss-audio"
version = "0.5.2" version = "0.5.3"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"bliss-audio-aubio-rs", "bliss-audio-aubio-rs",

View File

@ -1,6 +1,6 @@
[package] [package]
name = "bliss-audio" name = "bliss-audio"
version = "0.5.2" version = "0.5.3"
authors = ["Polochon-street <polochonstreet@gmx.fr>"] authors = ["Polochon-street <polochonstreet@gmx.fr>"]
edition = "2018" edition = "2018"
license = "GPL-3.0-only" license = "GPL-3.0-only"

View File

@ -664,7 +664,16 @@ fn resample_frame(
)) ))
})?; })?;
let mut resampled = ffmpeg::frame::Audio::empty(); let mut resampled = ffmpeg::frame::Audio::empty();
let mut something_happened = false;
for decoded in rx.iter() { for decoded in rx.iter() {
if in_codec_format != decoded.format()
|| in_channel_layout != decoded.channel_layout()
|| in_rate != decoded.rate()
{
warn!("received decoded packet with wrong format; file might be corrupted.");
continue;
}
something_happened = true;
resampled = ffmpeg::frame::Audio::empty(); resampled = ffmpeg::frame::Audio::empty();
resample_context resample_context
.run(&decoded, &mut resampled) .run(&decoded, &mut resampled)
@ -673,6 +682,9 @@ fn resample_frame(
})?; })?;
push_to_sample_array(&resampled, &mut sample_array); push_to_sample_array(&resampled, &mut sample_array);
} }
if !something_happened {
return Ok(sample_array);
}
// TODO when ffmpeg-next will be active again: shouldn't we allocate // TODO when ffmpeg-next will be active again: shouldn't we allocate
// `resampled` again? // `resampled` again?
loop { loop {