DetachedSong, db/LightSong, SongFilter: move to src/song/

This commit is contained in:
Max Kellermann
2018-08-02 13:45:43 +02:00
parent a31da51fd9
commit 90201e9970
67 changed files with 89 additions and 90 deletions

View File

@@ -23,7 +23,7 @@
#include "Interface.hxx"
#include "Partition.hxx"
#include "client/Response.hxx"
#include "LightSong.hxx"
#include "song/LightSong.hxx"
#include "tag/Tag.hxx"
#include "TagPrint.hxx"

View File

@@ -23,7 +23,7 @@
#include "Selection.hxx"
#include "PlaylistFile.hxx"
#include "Interface.hxx"
#include "DetachedSong.hxx"
#include "song/DetachedSong.hxx"
#include <functional>

View File

@@ -20,16 +20,16 @@
#include "config.h"
#include "DatabasePrint.hxx"
#include "Selection.hxx"
#include "SongFilter.hxx"
#include "SongPrint.hxx"
#include "DetachedSong.hxx"
#include "TimePrint.hxx"
#include "TagPrint.hxx"
#include "client/Response.hxx"
#include "Partition.hxx"
#include "song/DetachedSong.hxx"
#include "song/Filter.hxx"
#include "song/LightSong.hxx"
#include "tag/Tag.hxx"
#include "tag/Mask.hxx"
#include "LightSong.hxx"
#include "LightDirectory.hxx"
#include "PlaylistInfo.hxx"
#include "Interface.hxx"

View File

@@ -23,7 +23,7 @@
#include "Interface.hxx"
#include "Partition.hxx"
#include "Instance.hxx"
#include "DetachedSong.hxx"
#include "song/DetachedSong.hxx"
#include <functional>

View File

@@ -19,9 +19,9 @@
#include "config.h"
#include "DatabaseSong.hxx"
#include "LightSong.hxx"
#include "Interface.hxx"
#include "DetachedSong.hxx"
#include "song/DetachedSong.hxx"
#include "song/LightSong.hxx"
#include "storage/StorageInterface.hxx"
#include "util/ScopeExit.hxx"

View File

@@ -20,7 +20,7 @@
#include "Helpers.hxx"
#include "Stats.hxx"
#include "Interface.hxx"
#include "LightSong.hxx"
#include "song/LightSong.hxx"
#include "tag/Tag.hxx"
#include <set>

View File

@@ -1,35 +0,0 @@
/*
* Copyright 2003-2017 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "LightSong.hxx"
#include "tag/Tag.hxx"
SignedSongTime
LightSong::GetDuration() const noexcept
{
SongTime a = start_time, b = end_time;
if (!b.IsPositive()) {
if (tag.duration.IsNegative())
return tag.duration;
b = SongTime(tag.duration);
}
return SignedSongTime(b - a);
}

View File

@@ -1,106 +0,0 @@
/*
* Copyright 2003-2017 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef MPD_LIGHT_SONG_HXX
#define MPD_LIGHT_SONG_HXX
#include "Chrono.hxx"
#include "AudioFormat.hxx"
#include "Compiler.h"
#include <string>
#include <chrono>
struct Tag;
/**
* A reference to a song file. Unlike the other "Song" classes in the
* MPD code base, this one consists only of pointers. It is supposed
* to be as light as possible while still providing all the
* information MPD has about a song file. This class does not manage
* any memory, and the pointers become invalid quickly. Only to be
* used to pass around during well-defined situations.
*/
struct LightSong {
/**
* If this is not nullptr, then it denotes a prefix for the
* #uri. To build the full URI, join directory and uri with a
* slash.
*/
const char *directory = nullptr;
const char *uri;
/**
* The "real" URI, the one to be used for opening the
* resource. If this attribute is nullptr, then #uri (and
* #directory) shall be used.
*
* This attribute is used for songs from the database which
* have a relative URI.
*/
const char *real_uri = nullptr;
/**
* Metadata.
*/
const Tag &tag;
/**
* The time stamp of the last file modification. A negative
* value means that this is unknown/unavailable.
*/
std::chrono::system_clock::time_point mtime = std::chrono::system_clock::time_point::min();
/**
* Start of this sub-song within the file.
*/
SongTime start_time = SongTime::zero();
/**
* End of this sub-song within the file.
* Unused if zero.
*/
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) {}
gcc_pure
std::string GetURI() const noexcept {
if (directory == nullptr)
return std::string(uri);
std::string result(directory);
result.push_back('/');
result.append(uri);
return result;
}
gcc_pure
SignedSongTime GetDuration() const noexcept;
};
#endif

View File

@@ -19,7 +19,7 @@
#include "config.h"
#include "Selection.hxx"
#include "SongFilter.hxx"
#include "song/Filter.hxx"
DatabaseSelection::DatabaseSelection(const char *_uri, bool _recursive,
const SongFilter *_filter)

View File

@@ -19,7 +19,7 @@
#include "UniqueTags.hxx"
#include "Interface.hxx"
#include "LightSong.hxx"
#include "song/LightSong.hxx"
#include "tag/Set.hxx"
#include "tag/Mask.hxx"

View File

@@ -26,9 +26,9 @@
#include "db/DatabaseError.hxx"
#include "db/PlaylistInfo.hxx"
#include "db/LightDirectory.hxx"
#include "db/LightSong.hxx"
#include "song/LightSong.hxx"
#include "db/Stats.hxx"
#include "SongFilter.hxx"
#include "song/Filter.hxx"
#include "Compiler.h"
#include "config/Block.hxx"
#include "tag/Builder.hxx"

View File

@@ -23,11 +23,11 @@
#include "Song.hxx"
#include "Mount.hxx"
#include "db/LightDirectory.hxx"
#include "db/LightSong.hxx"
#include "song/LightSong.hxx"
#include "db/Uri.hxx"
#include "db/DatabaseLock.hxx"
#include "db/Interface.hxx"
#include "SongFilter.hxx"
#include "song/Filter.hxx"
#include "lib/icu/Collate.hxx"
#include "fs/Traits.hxx"
#include "util/Alloc.hxx"

View File

@@ -22,7 +22,7 @@
#include "Directory.hxx"
#include "Song.hxx"
#include "SongSave.hxx"
#include "DetachedSong.hxx"
#include "song/DetachedSong.hxx"
#include "PlaylistDatabase.hxx"
#include "fs/io/TextFile.hxx"
#include "fs/io/BufferedOutputStream.hxx"

View File

@@ -20,7 +20,7 @@
#include "config.h"
#include "Mount.hxx"
#include "PrefixedLightSong.hxx"
#include "SongFilter.hxx"
#include "song/Filter.hxx"
#include "db/Selection.hxx"
#include "db/LightDirectory.hxx"
#include "db/Interface.hxx"

View File

@@ -21,7 +21,7 @@
#define MPD_DB_SIMPLE_PREFIXED_LIGHT_SONG_HXX
#include "check.h"
#include "db/LightSong.hxx"
#include "song/LightSong.hxx"
#include "fs/Traits.hxx"
#include <string>

View File

@@ -23,7 +23,7 @@
#include "check.h"
#include "db/Interface.hxx"
#include "fs/AllocatedPath.hxx"
#include "db/LightSong.hxx"
#include "song/LightSong.hxx"
#include "util/Manual.hxx"
#include "Compiler.h"

View File

@@ -22,8 +22,8 @@
#include "Directory.hxx"
#include "tag/Tag.hxx"
#include "util/VarSize.hxx"
#include "DetachedSong.hxx"
#include "db/LightSong.hxx"
#include "song/DetachedSong.hxx"
#include "song/LightSong.hxx"
#include <assert.h>
#include <string.h>

View File

@@ -29,7 +29,7 @@
#include "db/Selection.hxx"
#include "db/DatabaseError.hxx"
#include "db/LightDirectory.hxx"
#include "db/LightSong.hxx"
#include "song/LightSong.hxx"
#include "db/Stats.hxx"
#include "config/Block.hxx"
#include "tag/Builder.hxx"
@@ -37,7 +37,7 @@
#include "tag/Mask.hxx"
#include "fs/Traits.hxx"
#include "Log.hxx"
#include "SongFilter.hxx"
#include "song/Filter.hxx"
#include "util/SplitString.hxx"
#include <string>

View File

@@ -20,7 +20,7 @@
#include "config.h" /* must be first for large file support */
#include "Walk.hxx"
#include "UpdateDomain.hxx"
#include "DetachedSong.hxx"
#include "song/DetachedSong.hxx"
#include "db/DatabaseLock.hxx"
#include "db/plugins/simple/Directory.hxx"
#include "db/plugins/simple/Song.hxx"