Commit Graph

107 Commits

Author SHA1 Message Date
Max Kellermann
a3afd5178c tag/TagPool: optimize _dup_item()
When a reference counter is at its limit, don't allocate a new
TagPoolSlot - that would result in many TagPoolSlot instances with
ref==1.  This in turn would make the linked list very very large,
which means quadratic runtime for many operations.
2016-03-14 13:08:04 +01:00
Max Kellermann
f1285a6dfd tag/TagPool: add constexpr MAX_REF 2016-03-14 08:07:22 +01:00
Max Kellermann
cf7c1afb93 tag/TagPool: use prime number for NUM_SLOTS 2016-03-14 08:04:51 +01:00
Max Kellermann
f3cefaf043 tag/Tag: move code to MoveItemsFrom() 2016-02-23 20:57:56 +01:00
Max Kellermann
4abcb08cc9 tag/{aiff,riff}: fix ID3 chunk padding
Apply padding only to the fseek(), not to the chunk size.  This fixes
bogus "failed to read riff chunk" messages when the last chunk has an
odd size.

See http://bugs.musicpd.org/view.php?id=4486
2016-02-19 17:31:20 +01:00
Benno Fünfstück
cae2811762 fix mpd crash on invalid utf8 stream title 2015-12-15 21:49:53 +01:00
Max Kellermann
205fba74cf tag/ApeLoader: fix buffer overflow after unterminated key 2015-10-16 14:55:40 +02:00
Max Kellermann
b3fe3e8b3d TagBuilder: allow adding duplicate tag types in Complement()
Build a table of pre-existing tag types before adding new items.  The
old way would check HasType() each time, which would return true after
the first instance of that tag type had been added, preventing
duplicate tag types to be merged.

This broke duplicate tag types loaded from the state file, because
this code path uses TagBuilder::Complement().
2015-02-06 12:25:34 +01:00
Max Kellermann
940cab8620 Merge branch 'v0.18.x' into v0.19.x 2014-12-26 14:28:52 +01:00
Max Kellermann
53f4044890 util/{ASCII,UriUtil}, ...: work around -Wtautological-pointer-compare
New in clang 3.6.
2014-12-26 13:43:32 +01:00
Max Kellermann
b5ba94f1de tag/Set: do AlbumArtist/Artist fallback only if AlbumArtist is not disabled
On "list albumartist", songs that have no AlbumArtist tag will use the
Artist tag.  However, if AlbumArtist is disabled via
"metadata_to_use", the TagBuilder::AddItem() call is ignored, and
PrintUniqueTag() attempts to print a nullptr string.

This commit fixes the problem by attempting the fallback only if
AlbumArtist is not disabled.
2014-11-08 19:25:01 +01:00
Max Kellermann
c37f7abb79 TagString: use g_strndup() for unterminated string
Fixes buffer overflow bug.
2014-11-02 11:48:13 +01:00
Max Kellermann
666f700a93 TagString: implement fix_utf8() without GLib 2014-10-10 22:11:38 +02:00
Max Kellermann
b7a1954c33 TagString: return WritableBuffer<char> 2014-10-10 22:07:19 +02:00
Max Kellermann
6520589a37 TagString: use strndup() for unterminated string
Fixes buffer overflow bug.
2014-10-10 22:06:48 +02:00
Max Kellermann
f445b0178a TagString: remove ISO-Latin-1 fallback
MPD handles all strings in UTF-8 internally.  Those decoders which
read Latin-1 tags are supposed to implement the conversion, instead of
passing Latin-1 to TagBuilder::AddItem().  FixTagString() is simply
the wrong place to do that, and hard-coding Latin-1 is kind of
arbitrary.
2014-10-10 20:53:08 +02:00
Max Kellermann
3560dc4be6 Tag: support "AlbumSort"
The new tag is supported by all decoders that use the tag name table,
and the ID3v2 tag "TSOA" maps to it.
2014-09-29 18:55:59 +02:00
Wieland Hoffmann
5525ea45a4 Add MusicBrainz' Release Track Id tag
The Release Track Id uniquely identifies a recording on a release - that
is, even if a recording appears twice on a release (meaning that the
combination of recording and release id are not enough to figure out
which one it is), the release track id will allow differentiating the two.

The tag names are taken from
https://musicbrainz.org/doc/MusicBrainz_Picard/Tags/Mapping
2014-09-27 19:54:12 +02:00
Max Kellermann
8a7ff6a6fd decoder/flac: move code to tag/MixRamp.cxx 2014-09-24 22:44:58 +02:00
Max Kellermann
6c48aa5fae decoder/mad: move code to tag/MixRamp.cxx 2014-09-24 22:40:34 +02:00
Max Kellermann
441f9cc2ee tag/ReplayGain: add VorbisComment parser
Move code from the Vorbis and FLAC decoder plugins.
2014-09-24 22:21:13 +02:00
Max Kellermann
9f4fc8ad33 tag/ReplayGain: move code to template function 2014-09-24 22:19:55 +02:00
Max Kellermann
d1e31261fe decoder/{vorbis,flac}: move duplicate code to tag/VorbisComment.cxx 2014-09-24 21:50:42 +02:00
Max Kellermann
05dd9acba8 tag/ApeReplayGain, decoder/mad: move duplicate code to tag/ReplayGain.cxx 2014-09-24 21:50:34 +02:00
Max Kellermann
3158955198 TagHandler: pass SongTime to duration() 2014-08-29 22:52:04 +02:00
Max Kellermann
7c25d83f1c Tag: use SignedSongTime for the song duration 2014-08-29 13:20:58 +02:00
Max Kellermann
be36c0769a TagId3: fix printf string parameter 2014-07-30 22:02:46 +02:00
Max Kellermann
7a1f3177c9 util/Cast: reimplement as template without macro 2014-07-14 16:24:07 +02:00
Max Kellermann
41a7203c28 Tag: add class const_iterator and methods begin(), end()
Enables using range-based "for".
2014-07-12 17:22:39 +02:00
Max Kellermann
b2433a664c TagPool: move code to tag_value_slot_p() 2014-06-16 19:26:26 +02:00
Max Kellermann
adad4279f3 TagPool: convert macro to constexpr 2014-06-16 19:18:10 +02:00
Max Kellermann
ecc12c9ba1 db/Helpers: move code to tag/Set.cxx 2014-04-24 18:32:23 +02:00
Max Kellermann
9e50993c13 db/Helpers: move TagSet to dedicated header 2014-04-24 18:18:26 +02:00
Max Kellermann
2220651253 TagBuilder: add method AddEmptyItem() 2014-04-24 11:38:48 +02:00
Max Kellermann
07c1ba1f5e TagId3: disable charset conversion without GLib 2014-03-01 19:18:50 +01:00
Max Kellermann
4ad14f6a2c TagId3: use xstrdup() instead of g_strdup() 2014-02-17 22:42:54 +01:00
Max Kellermann
579e48edbb util/StringUtil: add function Strip()
Replaces g_strstrip().
2014-02-17 22:37:43 +01:00
Max Kellermann
6a08f2281a TagString: disable UTF-8 validation if GLib is disabled 2014-02-17 22:33:10 +01:00
Max Kellermann
197b503f3e Config*: move to config/ 2014-01-24 00:20:01 +01:00
Max Kellermann
bde27ccec3 Tag: pack attributes tighter
This saves another 3% memory.
2014-01-19 03:11:01 +01:00
Max Kellermann
a1b798e555 SongFilter, TagConfig: cast TAG_NUM_OF_ITEM_TYPES to integer
Fixes clang warning.
2014-01-15 11:23:41 +01:00
Max Kellermann
a3f9abcbd1 SongFilter, TagConfig: cast TAG_NUM_OF_ITEM_TYPES to integer
Fixes clang warning.
2014-01-14 22:40:07 +01:00
Max Kellermann
4f83c60296 copyright year 2014 2014-01-13 22:31:55 +01:00
Max Kellermann
970b10d01b tag/TagTable: add lookup TagType -> name 2014-01-09 19:01:03 +01:00
Max Kellermann
bc23a6bb05 tag/TagBuilder: overload Commit() returning a Tag object 2014-01-08 19:49:08 +01:00
Max Kellermann
ac1983eae3 tag/TagBuilder: rename Commit() to CommitNew() 2014-01-08 19:48:55 +01:00
Max Kellermann
27ca0db7a6 util/Alloc: new library replacing GLib's g_malloc() 2014-01-07 23:35:18 +01:00
Max Kellermann
fe6094a822 tag/TagPool: use NewVarSize() to allocate TagPoolSlot 2014-01-07 23:24:59 +01:00
Max Kellermann
8a30c7992d tag/TagPool: rename struct slot to TagPoolSlot 2014-01-07 23:12:24 +01:00
Max Kellermann
70eb9335bd tag/TagPool: use gcc_packed instead of mpd_packed
By accident, this declared a global variable instead of adding the
"packed" attribute.
2014-01-07 23:11:00 +01:00