aboutsummaryrefslogtreecommitdiffstats
path: root/taglib/mp4
diff options
context:
space:
mode:
authorTsuda Kageyu <tsuda.kageyu@gmail.com>2015-12-16 11:48:52 +0900
committerTsuda Kageyu <tsuda.kageyu@gmail.com>2015-12-16 11:48:52 +0900
commitfc571e5150d052b47221223d67057d4dbaf97680 (patch)
treec8c1da046be146fe01ba52848ad172b650bd3bf5 /taglib/mp4
parent5480458dfcc0747cb10532fb301e4b40afd20a12 (diff)
parent94b78289900337e57dc1c090cd2485bc80da8100 (diff)
Merge pull request #683 from TsudaKageyu/save-mp4
Fix saving MP4 files.
Diffstat (limited to 'taglib/mp4')
-rw-r--r--taglib/mp4/mp4file.cpp18
-rw-r--r--taglib/mp4/mp4file.h3
-rw-r--r--taglib/mp4/mp4tag.cpp5
3 files changed, 8 insertions, 18 deletions
diff --git a/taglib/mp4/mp4file.cpp b/taglib/mp4/mp4file.cpp
index 566a5e32..d0a6c4c6 100644
--- a/taglib/mp4/mp4file.cpp
+++ b/taglib/mp4/mp4file.cpp
@@ -55,8 +55,7 @@ public:
FilePrivate() :
tag(0),
atoms(0),
- properties(0),
- hasMP4Tag(false) {}
+ properties(0) {}
~FilePrivate()
{
@@ -68,8 +67,6 @@ public:
MP4::Tag *tag;
MP4::Atoms *atoms;
MP4::Properties *properties;
-
- bool hasMP4Tag;
};
MP4::File::File(FileName file, bool readProperties, AudioProperties::ReadStyle) :
@@ -138,10 +135,6 @@ MP4::File::read(bool readProperties)
return;
}
- if(d->atoms->find("moov", "udta", "meta", "ilst")) {
- d->hasMP4Tag = true;
- }
-
d->tag = new Tag(this, d->atoms);
if(readProperties) {
d->properties = new Properties(this, d->atoms);
@@ -161,16 +154,11 @@ MP4::File::save()
return false;
}
- const bool success = d->tag->save();
- if(success) {
- d->hasMP4Tag = true;
- }
-
- return success;
+ return d->tag->save();
}
bool
MP4::File::hasMP4Tag() const
{
- return d->hasMP4Tag;
+ return (d->atoms->find("moov", "udta", "meta", "ilst") != 0);
}
diff --git a/taglib/mp4/mp4file.h b/taglib/mp4/mp4file.h
index 40fcde78..3840bd02 100644
--- a/taglib/mp4/mp4file.h
+++ b/taglib/mp4/mp4file.h
@@ -111,9 +111,6 @@ namespace TagLib {
* Save the file.
*
* This returns true if the save was successful.
- *
- * \warning In the current implementation, it's dangerous to call save()
- * repeatedly. At worst it will corrupt the file.
*/
bool save();
diff --git a/taglib/mp4/mp4tag.cpp b/taglib/mp4/mp4tag.cpp
index 4b8a7039..a8e2e7d3 100644
--- a/taglib/mp4/mp4tag.cpp
+++ b/taglib/mp4/mp4tag.cpp
@@ -629,6 +629,11 @@ MP4::Tag::saveNew(ByteVector data)
updateParents(path, data.size());
updateOffsets(data.size(), offset);
+
+ // Insert the newly created atoms into the tree to keep it up-to-date.
+
+ d->file->seek(offset);
+ path.back()->children.prepend(new Atom(d->file));
}
void