mirror of
https://github.com/librespot-org/librespot.git
synced 2024-12-18 17:11:53 +00:00
- add missing audio formats to message AudioFile - ensure that unknown formats gets mapped to DEFAULT_FORMAT
This commit is contained in:
parent
fb5c0efdd6
commit
67d31959f5
3 changed files with 21 additions and 4 deletions
|
@ -901,7 +901,7 @@ impl PlayerTrackLoader {
|
|||
}
|
||||
}
|
||||
|
||||
fn stream_data_rate(&self, format: AudioFileFormat) -> usize {
|
||||
fn stream_data_rate(&self, format: AudioFileFormat) -> Option<usize> {
|
||||
let kbps = match format {
|
||||
AudioFileFormat::OGG_VORBIS_96 => 12,
|
||||
AudioFileFormat::OGG_VORBIS_160 => 20,
|
||||
|
@ -913,9 +913,17 @@ impl PlayerTrackLoader {
|
|||
AudioFileFormat::MP3_160_ENC => 20,
|
||||
AudioFileFormat::AAC_24 => 3,
|
||||
AudioFileFormat::AAC_48 => 6,
|
||||
AudioFileFormat::AAC_160 => 20,
|
||||
AudioFileFormat::AAC_320 => 40,
|
||||
AudioFileFormat::MP4_128 => 16,
|
||||
AudioFileFormat::OTHER5 => 40,
|
||||
AudioFileFormat::FLAC_FLAC => 112, // assume 900 kbit/s on average
|
||||
AudioFileFormat::UNKNOWN_FORMAT => {
|
||||
error!("Unknown stream data rate");
|
||||
return None;
|
||||
}
|
||||
};
|
||||
kbps * 1024
|
||||
Some(kbps * 1024)
|
||||
}
|
||||
|
||||
async fn load_track(
|
||||
|
@ -993,7 +1001,7 @@ impl PlayerTrackLoader {
|
|||
}
|
||||
};
|
||||
|
||||
let bytes_per_second = self.stream_data_rate(format);
|
||||
let bytes_per_second = self.stream_data_rate(format)?;
|
||||
|
||||
// This is only a loop to be able to reload the file if an error occurred
|
||||
// while opening a cached file.
|
||||
|
|
|
@ -18,6 +18,10 @@ message AudioFile {
|
|||
MP3_160_ENC = 7;
|
||||
AAC_24 = 8;
|
||||
AAC_48 = 9;
|
||||
AAC_160 = 10;
|
||||
AAC_320 = 11;
|
||||
MP4_128 = 12;
|
||||
OTHER5 = 13;
|
||||
FLAC_FLAC = 16;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -288,7 +288,7 @@ message ExternalId {
|
|||
message AudioFile {
|
||||
optional bytes file_id = 1;
|
||||
|
||||
optional Format format = 2;
|
||||
optional Format format = 2 [default = UNKNOWN_FORMAT];
|
||||
enum Format {
|
||||
OGG_VORBIS_96 = 0;
|
||||
OGG_VORBIS_160 = 1;
|
||||
|
@ -300,7 +300,12 @@ message AudioFile {
|
|||
MP3_160_ENC = 7;
|
||||
AAC_24 = 8;
|
||||
AAC_48 = 9;
|
||||
AAC_160 = 10;
|
||||
AAC_320 = 11;
|
||||
MP4_128 = 12;
|
||||
OTHER5 = 13;
|
||||
FLAC_FLAC = 16;
|
||||
UNKNOWN_FORMAT = 255;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue