db/simple: add an AudioFormat to each Song
This commit is contained in:
@@ -21,6 +21,7 @@
|
||||
#define MPD_LIGHT_SONG_HXX
|
||||
|
||||
#include "Chrono.hxx"
|
||||
#include "AudioFormat.hxx"
|
||||
#include "Compiler.h"
|
||||
|
||||
#include <string>
|
||||
@@ -78,6 +79,12 @@ struct LightSong {
|
||||
*/
|
||||
SongTime end_time = SongTime::zero();
|
||||
|
||||
/**
|
||||
* The audio format of the song, if given by the decoder
|
||||
* plugin. May be undefined if unknown.
|
||||
*/
|
||||
AudioFormat audio_format = AudioFormat::Undefined();
|
||||
|
||||
LightSong(const char *_uri, const Tag &_tag) noexcept
|
||||
:uri(_uri), tag(_tag) {}
|
||||
|
||||
|
@@ -161,10 +161,15 @@ directory_load(TextFile &file, Directory &directory)
|
||||
if (directory.FindSong(name) != nullptr)
|
||||
throw FormatRuntimeError("Duplicate song '%s'", name);
|
||||
|
||||
auto song = song_load(file, name);
|
||||
auto audio_format = AudioFormat::Undefined();
|
||||
auto detached_song = song_load(file, name,
|
||||
&audio_format);
|
||||
|
||||
directory.AddSong(Song::NewFrom(std::move(*song),
|
||||
directory));
|
||||
auto song = Song::NewFrom(std::move(*detached_song),
|
||||
directory);
|
||||
song->audio_format = audio_format;
|
||||
|
||||
directory.AddSong(song);
|
||||
} else if ((p = StringAfterPrefix(line, PLAYLIST_META_BEGIN))) {
|
||||
const char *name = p;
|
||||
playlist_metadata_load(file, directory.playlists, name);
|
||||
|
@@ -104,5 +104,6 @@ Song::Export() const noexcept
|
||||
dest.mtime = mtime;
|
||||
dest.start_time = start_time;
|
||||
dest.end_time = end_time;
|
||||
dest.audio_format = audio_format;
|
||||
return dest;
|
||||
}
|
||||
|
@@ -23,6 +23,7 @@
|
||||
#include "check.h"
|
||||
#include "Chrono.hxx"
|
||||
#include "tag/Tag.hxx"
|
||||
#include "AudioFormat.hxx"
|
||||
#include "Compiler.h"
|
||||
|
||||
#include <boost/intrusive/list.hpp>
|
||||
@@ -88,6 +89,12 @@ struct Song {
|
||||
*/
|
||||
SongTime end_time = SongTime::zero();
|
||||
|
||||
/**
|
||||
* The audio format of the song, if given by the decoder
|
||||
* plugin. May be undefined if unknown.
|
||||
*/
|
||||
AudioFormat audio_format = AudioFormat::Undefined();
|
||||
|
||||
/**
|
||||
* The file name.
|
||||
*/
|
||||
|
Reference in New Issue
Block a user