Skip to content

Commit 67d3195

Browse files
authored
Fix 96kbps playback issue (issues #1236) (#1342)
- add missing audio formats to message AudioFile - ensure that unknown formats gets mapped to DEFAULT_FORMAT
1 parent fb5c0ef commit 67d3195

3 files changed

Lines changed: 21 additions & 4 deletions

File tree

playback/src/player.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -901,7 +901,7 @@ impl PlayerTrackLoader {
901901
}
902902
}
903903

904-
fn stream_data_rate(&self, format: AudioFileFormat) -> usize {
904+
fn stream_data_rate(&self, format: AudioFileFormat) -> Option<usize> {
905905
let kbps = match format {
906906
AudioFileFormat::OGG_VORBIS_96 => 12,
907907
AudioFileFormat::OGG_VORBIS_160 => 20,
@@ -913,9 +913,17 @@ impl PlayerTrackLoader {
913913
AudioFileFormat::MP3_160_ENC => 20,
914914
AudioFileFormat::AAC_24 => 3,
915915
AudioFileFormat::AAC_48 => 6,
916+
AudioFileFormat::AAC_160 => 20,
917+
AudioFileFormat::AAC_320 => 40,
918+
AudioFileFormat::MP4_128 => 16,
919+
AudioFileFormat::OTHER5 => 40,
916920
AudioFileFormat::FLAC_FLAC => 112, // assume 900 kbit/s on average
921+
AudioFileFormat::UNKNOWN_FORMAT => {
922+
error!("Unknown stream data rate");
923+
return None;
924+
}
917925
};
918-
kbps * 1024
926+
Some(kbps * 1024)
919927
}
920928

921929
async fn load_track(
@@ -993,7 +1001,7 @@ impl PlayerTrackLoader {
9931001
}
9941002
};
9951003

996-
let bytes_per_second = self.stream_data_rate(format);
1004+
let bytes_per_second = self.stream_data_rate(format)?;
9971005

9981006
// This is only a loop to be able to reload the file if an error occurred
9991007
// while opening a cached file.

protocol/proto/media_manifest.proto

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ message AudioFile {
1818
MP3_160_ENC = 7;
1919
AAC_24 = 8;
2020
AAC_48 = 9;
21+
AAC_160 = 10;
22+
AAC_320 = 11;
23+
MP4_128 = 12;
24+
OTHER5 = 13;
2125
FLAC_FLAC = 16;
2226
}
2327
}

protocol/proto/metadata.proto

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ message ExternalId {
288288
message AudioFile {
289289
optional bytes file_id = 1;
290290

291-
optional Format format = 2;
291+
optional Format format = 2 [default = UNKNOWN_FORMAT];
292292
enum Format {
293293
OGG_VORBIS_96 = 0;
294294
OGG_VORBIS_160 = 1;
@@ -300,7 +300,12 @@ message AudioFile {
300300
MP3_160_ENC = 7;
301301
AAC_24 = 8;
302302
AAC_48 = 9;
303+
AAC_160 = 10;
304+
AAC_320 = 11;
305+
MP4_128 = 12;
306+
OTHER5 = 13;
303307
FLAC_FLAC = 16;
308+
UNKNOWN_FORMAT = 255;
304309
}
305310
}
306311

0 commit comments

Comments
 (0)