aboutsummaryrefslogtreecommitdiffstats
path: root/src/cue
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2014-01-07 21:39:47 +0100
committerMax Kellermann <max@duempel.org>2014-01-09 09:05:58 +0100
commit322b0616322760dc162447563d8f4da7e024ca90 (patch)
tree2f87cb3ce061556161797aba9f57ee08de5b9e21 /src/cue
parent43847f2244a34064af24704aac4cfad4a3c76f7d (diff)
downloadmpd-322b0616322760dc162447563d8f4da7e024ca90.tar.gz
mpd-322b0616322760dc162447563d8f4da7e024ca90.tar.xz
mpd-322b0616322760dc162447563d8f4da7e024ca90.zip
DetachedSong: fork of struct Song
From now on, struct Song will be used by the database only, and DetachedSong will be used by everybody else. DetachedSong is easier to use, but Song has lower overhead.
Diffstat (limited to 'src/cue')
-rw-r--r--src/cue/CueParser.cxx35
-rw-r--r--src/cue/CueParser.hxx10
2 files changed, 20 insertions, 25 deletions
diff --git a/src/cue/CueParser.cxx b/src/cue/CueParser.cxx
index 4a4f823ab..f05a69ae3 100644
--- a/src/cue/CueParser.cxx
+++ b/src/cue/CueParser.cxx
@@ -22,7 +22,7 @@
#include "util/Alloc.hxx"
#include "util/StringUtil.hxx"
#include "util/CharUtil.hxx"
-#include "Song.hxx"
+#include "DetachedSong.hxx"
#include "tag/Tag.hxx"
#include <assert.h>
@@ -38,14 +38,9 @@ CueParser::CueParser()
CueParser::~CueParser()
{
- if (current != nullptr)
- current->Free();
-
- if (previous != nullptr)
- previous->Free();
-
- if (finished != nullptr)
- finished->Free();
+ delete current;
+ delete previous;
+ delete finished;
}
static const char *
@@ -169,8 +164,8 @@ CueParser::Commit()
if (current == nullptr)
return;
- assert(current->tag == nullptr);
- current->tag = song_tag.CommitNew();
+ assert(!current->GetTag().IsDefined());
+ current->SetTag(song_tag.Commit());
finished = previous;
previous = current;
@@ -249,8 +244,8 @@ CueParser::Feed2(char *p)
}
state = TRACK;
- current = Song::NewRemote(filename.c_str());
- assert(current->tag == nullptr);
+ current = new DetachedSong(std::move(filename));
+ assert(!current->GetTag().IsDefined());
song_tag = header_tag;
song_tag.AddItem(TAG_TRACK, nr);
@@ -272,14 +267,14 @@ CueParser::Feed2(char *p)
return;
if (!last_updated && previous != nullptr &&
- previous->start_ms < (unsigned)position_ms) {
+ previous->GetStartMS() < (unsigned)position_ms) {
last_updated = true;
- previous->end_ms = position_ms;
- previous->tag->time =
- (previous->end_ms - previous->start_ms + 500) / 1000;
+ previous->SetEndMS(position_ms);
+ previous->WritableTag().time =
+ (previous->GetEndMS() - previous->GetStartMS() + 500) / 1000;
}
- current->start_ms = position_ms;
+ current->SetStartMS(position_ms);
}
}
@@ -305,7 +300,7 @@ CueParser::Finish()
end = true;
}
-Song *
+DetachedSong *
CueParser::Get()
{
if (finished == nullptr && end) {
@@ -317,7 +312,7 @@ CueParser::Get()
previous = nullptr;
}
- Song *song = finished;
+ DetachedSong *song = finished;
finished = nullptr;
return song;
}
diff --git a/src/cue/CueParser.hxx b/src/cue/CueParser.hxx
index bcc759c37..9a32a33c4 100644
--- a/src/cue/CueParser.hxx
+++ b/src/cue/CueParser.hxx
@@ -26,7 +26,7 @@
#include <string>
-struct Song;
+class DetachedSong;
struct Tag;
class CueParser {
@@ -74,19 +74,19 @@ class CueParser {
/**
* The song currently being edited.
*/
- Song *current;
+ DetachedSong *current;
/**
* The previous song. It is remembered because its end_time
* will be set to the current song's start time.
*/
- Song *previous;
+ DetachedSong *previous;
/**
* A song that is completely finished and can be returned to
* the caller via cue_parser_get().
*/
- Song *finished;
+ DetachedSong *finished;
/**
* Set to true after previous.end_time has been updated to the
@@ -125,7 +125,7 @@ public:
* @return a song object that must be freed by the caller, or NULL if
* no song was finished at this time
*/
- Song *Get();
+ DetachedSong *Get();
private:
gcc_pure