mirror of
https://github.com/zarzet/SpotiFLAC-Mobile.git
synced 2026-09-29 21:02:09 +02:00
feat(metadata): display saved ReplayGain values and refresh after analysis
This commit is contained in:
@@ -269,8 +269,49 @@ fn truthy(value: &str) -> bool {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use std::collections::BTreeMap;
|
||||
use std::io::Cursor;
|
||||
|
||||
#[test]
|
||||
fn library_scan_preserves_replaygain_values_written_to_flac() {
|
||||
let mut source = b"fLaC\x80\0\0\x22".to_vec();
|
||||
source.resize(42, 0);
|
||||
source.extend_from_slice(&[0xff, 0xf8, 0, 0]);
|
||||
let fields = BTreeMap::from([
|
||||
("replaygain_track_gain".into(), "-6.20 dB".into()),
|
||||
("replaygain_track_peak".into(), "0.000000".into()),
|
||||
("replaygain_album_gain".into(), "0.00 dB".into()),
|
||||
("replaygain_album_peak".into(), "1.234567".into()),
|
||||
]);
|
||||
let mut output = Vec::new();
|
||||
rewrite_audio_tags(
|
||||
&mut Cursor::new(&source),
|
||||
&mut output,
|
||||
"flac",
|
||||
&fields,
|
||||
None,
|
||||
&|| Ok(()),
|
||||
)
|
||||
.unwrap();
|
||||
let mut reader = Cursor::new(&output);
|
||||
let scan = read_library_metadata(&mut reader, "track.flac", "", "", 0, &|| Ok(())).unwrap();
|
||||
let full = read_file_metadata(&mut reader, "track.flac", "", &|| Ok(())).unwrap();
|
||||
let empty = read_library_metadata(
|
||||
&mut Cursor::new(source),
|
||||
"track.flac",
|
||||
"",
|
||||
"",
|
||||
0,
|
||||
&|| Ok(()),
|
||||
)
|
||||
.unwrap();
|
||||
for (key, value) in fields {
|
||||
assert_eq!(scan[&key], value);
|
||||
assert_eq!(scan[&key], full[&key]);
|
||||
assert!(empty.get(&key).is_none());
|
||||
}
|
||||
}
|
||||
|
||||
fn atom(kind: &[u8; 4], body: &[u8]) -> Vec<u8> {
|
||||
[
|
||||
((body.len() + 8) as u32).to_be_bytes().as_slice(),
|
||||
|
||||
@@ -261,6 +261,10 @@ fn apply_tags(
|
||||
("album_type", "albumType"),
|
||||
("explicit", "explicit"),
|
||||
("upc", "upc"),
|
||||
("replay_gain_track_gain", "replaygain_track_gain"),
|
||||
("replay_gain_track_peak", "replaygain_track_peak"),
|
||||
("replay_gain_album_gain", "replaygain_album_gain"),
|
||||
("replay_gain_album_peak", "replaygain_album_peak"),
|
||||
] {
|
||||
let value = &tags[source];
|
||||
if !matches!(value, Value::Null)
|
||||
|
||||
Reference in New Issue
Block a user