aboutsummaryrefslogtreecommitdiffstats
path: root/src/Directory.cxx
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2014-01-19 10:51:34 +0100
committerMax Kellermann <max@duempel.org>2014-01-19 17:04:51 +0100
commitf5ae1ce00b85699291a7cdf9782574e70a8c28f5 (patch)
tree9cb95dd1d98b1b0cd522ee27d7e8a374a3c8eb4a /src/Directory.cxx
parent738d6f10409037fbf8aa30cec5aceb121e21e230 (diff)
downloadmpd-f5ae1ce00b85699291a7cdf9782574e70a8c28f5.tar.gz
mpd-f5ae1ce00b85699291a7cdf9782574e70a8c28f5.tar.xz
mpd-f5ae1ce00b85699291a7cdf9782574e70a8c28f5.zip
LightSong: new class to be used by DatabasePlugin callbacks
Detach the Song class completely from the public API, only to be used by SimpleDatabase and the update thread.
Diffstat (limited to 'src/Directory.cxx')
-rw-r--r--src/Directory.cxx23
1 files changed, 20 insertions, 3 deletions
diff --git a/src/Directory.cxx b/src/Directory.cxx
index ff2c00b05..210d7cb67 100644
--- a/src/Directory.cxx
+++ b/src/Directory.cxx
@@ -24,6 +24,7 @@
#include "DatabaseLock.hxx"
#include "SongSort.hxx"
#include "Song.hxx"
+#include "LightSong.hxx"
#include "fs/Traits.hxx"
#include "util/Alloc.hxx"
#include "util/Error.hxx"
@@ -251,6 +252,20 @@ Directory::Sort()
child->Sort();
}
+static LightSong
+ExportSong(const Song &src)
+{
+ LightSong dest;
+ dest.directory = src.parent->IsRoot()
+ ? nullptr : src.parent->GetPath();
+ dest.uri = src.uri;
+ dest.tag = &src.tag;
+ dest.mtime = src.mtime;
+ dest.start_ms = src.start_ms;
+ dest.end_ms = src.end_ms;
+ return dest;
+}
+
bool
Directory::Walk(bool recursive, const SongFilter *filter,
VisitDirectory visit_directory, VisitSong visit_song,
@@ -261,10 +276,12 @@ Directory::Walk(bool recursive, const SongFilter *filter,
if (visit_song) {
Song *song;
- directory_for_each_song(song, *this)
- if ((filter == nullptr || filter->Match(*song)) &&
- !visit_song(*song, error))
+ directory_for_each_song(song, *this) {
+ const LightSong song2 = ExportSong(*song);
+ if ((filter == nullptr || filter->Match(song2)) &&
+ !visit_song(song2, error))
return false;
+ }
}
if (visit_playlist) {