Commit Graph

48 Commits

Author SHA1 Message Date
Eric Wong
8867bd554c tag_item: avoid wasting space when struct is unpackable
Not all compilers support struct packing, and those that don't
shouldn't be punished for it.
2008-10-13 09:40:14 +02:00
Max Kellermann
71351160b1 don't include os_compat.h
When there are standardized headers, use these instead of the bloated
os_compat.h.
2008-10-08 10:49:29 +02:00
Max Kellermann
a7651b9d30 assume stdint.h and stddef.h are available
Since we use a C99 compiler now, we can assert that the C99 standard
headers are available, no need for complicated compile time checks.
Kill mpd_types.h.
2008-09-29 15:53:53 +02:00
Eric Wong
0352766dca Switch to C99 types (retaining compat with old compilers)
Seeing the "mpd_" prefix _everywhere_ is mind-numbing as the
mind needs to retrain itself to skip over the first 4 tokens of
a type to get to its meaning.  So avoid having extra characters
on my terminal to make it easier to follow code at 2:30 am in
the morning.

Please report any new issues you may come across on Free
toolchains.  I realize how difficult it can be to build/maintain
cross-compiling toolchains and I have no intention of forcing
people to upgrade their toolchains to build mpd.

Tested with gcc 2.95.4 and and gcc 4.3.1 on x86-32.
2008-09-29 13:29:33 +02:00
Max Kellermann
386c303121 tag: moved code to tag_print.c
Move everything which dumps a tag to a file descriptor to tag_print.c.
This relaxes dependencies and splits the code into smaller parts.
2008-09-07 13:28:01 +02:00
Max Kellermann
37d77caa3c const pointers
Yet another patch which converts pointer arguments to "const".
2008-08-29 14:48:39 +02:00
Max Kellermann
1aa3457346 tag: try not to reallocate tag.items in every add() call
If many tag_items are added at once while the tag cache is being
loaded, manage these items in a static fixed list, instead of
reallocating the list with every newly created item.  This reduces
heap fragmentation.

Massif results again:

 mk before:  total 12,837,632; useful 10,626,383; extra 2,211,249
 mk now:     total 12,736,720; useful 10,626,383; extra 2,110,337

The "useful" value is the same since this patch only changes the way
we allocate the same amount of memory, but heap fragmentation was
reduced by 5%.
2008-08-29 09:39:08 +02:00
Max Kellermann
c855415c73 tag: added a pool for tag items
The new source tag_pool.c manages a pool of reference counted tag_item
objects.  This is used to merge tag items of the same type and value,
saving lots of memory.  Formerly, only the value itself was pooled,
wasting memory for all the pointers and tag_item structs.

The following results were measured with massif.  Started MPD on
amd64, typed "mpc", no song being played.  My music database contains
35k tagged songs.  The results are what massif reports as "peak".

 0.13.2:     total 14,131,392; useful 11,408,972; extra 2,722,420
 eric:       total 18,370,696; useful 15,648,182; extra 2,722,514
 mk f34f694: total 15,833,952; useful 13,111,470; extra 2,722,482
 mk now:     total 12,837,632; useful 10,626,383; extra 2,211,249

This patch set saves 20% memory, and does a good job in reducing heap
fragmentation.
2008-08-29 09:38:37 +02:00
Max Kellermann
e5a7879892 tag: converted tag_item.value to a char array
The value is stored in the same memory allocation as the tag_item
struct; this saves memory because we do not store the value pointer
anymore.  Also remove the getTagItemString()/removeTagItemString()
dummies.
2008-08-29 09:38:33 +02:00
Max Kellermann
ad0e09b2db tag: converted MpdTag.items to a pointer list
This prepares the following patches, which aim to reduce MPD's memory
usage: we plan to share tag_item instances, instead of just their
values.
2008-08-29 09:38:29 +02:00
Max Kellermann
6f72fe3ecf tag: moved code to tag_id3.c
The ID3 code uses only the public tag API, but is otherwise
unrelated.  Move it to a separate source file.
2008-08-29 09:38:27 +02:00
Max Kellermann
5e1feb8fa3 tag: converted tag_add_item() to an inline function 2008-08-29 09:38:24 +02:00
Max Kellermann
91502cd71e tag: renamed functions, no CamelCase 2008-08-29 09:38:21 +02:00
Max Kellermann
d0556dc983 tag: renamed MpdTag and MpdTagItem to struct tag, struct mpd_tag_item
Getting rid of CamelCase; not having typedefs also allows us to
forward-declare the structures.
2008-08-29 09:38:11 +02:00
Max Kellermann
bc1c8835c6 const pointers
The usual bunch of pointer arguments which should be const.
2008-08-28 20:02:17 +02:00
Max Kellermann
801c71ed1c unsigned integers and size_t
Use "unsigned int" whenever negative values are not meaningful.  Use
size_t whenever we are going to describe buffer sizes.
2008-08-28 20:02:16 +02:00
Max Kellermann
0fc2422cd0 converted MpdTagItem.type to an enum
Don't use CPP macros when you can use C enum... this also allows
better type checking.
2008-08-26 08:27:09 +02:00
Max Kellermann
6fbdc721d9 fix -Wconst warnings
[ew: cleaned up the dirty union hack a bit]
Signed-off-by: Eric Wong <normalperson@yhbt.net>

git-svn-id: https://svn.musicpd.org/mpd/trunk@7180 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-02-05 10:17:33 +00:00
Eric Wong
cb8f1af3bd Cleanup #includes of standard system headers and put them in one place
This will make refactoring features easier, especially now that
pthreads support and larger refactorings are on the horizon.

Hopefully, this will make porting to other platforms (even
non-UNIX-like ones for masochists) easier, too.

os_compat.h will house all the #includes for system headers
considered to be the "core" of MPD.  Headers for optional
features will be left to individual source files.

git-svn-id: https://svn.musicpd.org/mpd/trunk@7130 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-01-03 07:29:49 +00:00
Avuton Olrich
a061da8fb5 The massive copyright update
git-svn-id: https://svn.musicpd.org/mpd/trunk@5834 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2007-04-05 03:22:33 +00:00
J. Alexander Treuman
e3e4964f59 Adding tagtypes command to list available tag types (takes metadata_to_use
into account).

git-svn-id: https://svn.musicpd.org/mpd/trunk@5792 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2007-03-31 18:43:16 +00:00
J. Alexander Treuman
7a4e0162ae Closing some parenthesis around shank's email address in copyright headers.
git-svn-id: https://svn.musicpd.org/mpd/trunk@5376 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2007-02-18 01:20:21 +00:00
Avuton Olrich
f79a70d1b9 Fix warnings for -Wmissing-prototypes
Add -Wmissing-prototypes if compiling with gcc
Static where possible

git-svn-id: https://svn.musicpd.org/mpd/trunk@4657 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2006-08-20 00:50:44 +00:00
Eric Wong
4cf5d04ca1 interface/connection malloc reductions from mpd-ke
This patch massively reduces the amount of heap allocations at
the interface/command layer.  Most commands with minimal output
should not allocate memory from the heap at all.  Things like
repeatedly polling status, currentsong, and volume changes
should be faster as a result, and more importantly, not a source
of memory fragmentation.

These changes should be safe in that there's no way for a
remote-client to corrupt memory or otherwise do bad stuff to
MPD, but an extra set of eyes to review would be good.  Of
course there's never any warranty :)

No longer do we use FILE * structures in the interface, which means
we don't have to allocate any new memory for most connections.

Now, before you go on about losing the buffering that FILE *
+implies+, remember that myfprintf() never took advantage of
any of the stdio buffering features.

To reduce the diff and make bugs easier to spot in the diff,
I've kept myfprintf in places where we write to files (and not
network interfaces).  Expect myfprintf to go away entirely soon
(we'll use fprintf for writing regular files).

git-svn-id: https://svn.musicpd.org/mpd/trunk@4483 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2006-07-30 03:43:38 +00:00
Avuton Olrich
29a25b9933 Add mpd-indent.sh
Indent the entire tree, hopefully we can keep
it indented.

git-svn-id: https://svn.musicpd.org/mpd/trunk@4410 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2006-07-20 16:02:40 +00:00
Avuton Olrich
2001db8c18 Remove hosted libid3tag & libmad
git-svn-id: https://svn.musicpd.org/mpd/trunk@4369 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2006-07-16 17:49:15 +00:00
Avuton Olrich
be006b86ed [CLEANUP] Remove unused code
Fix whitespace->tabs
Use static where possible

git-svn-id: https://svn.musicpd.org/mpd/trunk@4346 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2006-07-15 04:51:31 +00:00
J. Alexander Treuman
2fa7125cce Change shank's email address
git-svn-id: https://svn.musicpd.org/mpd/trunk@4333 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2006-07-14 19:37:45 +00:00
Avuton Olrich
a37348a74f Huge header update, update the copyright and add
the GPL header where necessary

git-svn-id: https://svn.musicpd.org/mpd/trunk@4317 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2006-07-13 19:20:34 +00:00
Qball Cow
4324150b42 Added Disc # metadata item based on bug 571 (added id3v2 support)
git-svn-id: https://svn.musicpd.org/mpd/trunk@4131 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2006-04-30 19:55:56 +00:00
Warren Dukes
01b708bc13 add support for parsing ape tags in musepack files
git-svn-id: https://svn.musicpd.org/mpd/trunk@3030 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2005-03-07 00:51:21 +00:00
Warren Dukes
3bdee55217 added composer, performer, and comment metadata items
git-svn-id: https://svn.musicpd.org/mpd/trunk@3022 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2005-03-05 22:24:10 +00:00
Warren Dukes
c5d27d8eaa merge changes from metadata-rewrite branch
git-svn-id: https://svn.musicpd.org/mpd/trunk@2589 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2004-11-10 21:58:27 +00:00
Warren Dukes
b29f73c819 mechanism for updating metadata while decoding
vorbis comments are updated on the fly for streams
need to decode icy metadata
buffering of metadata needs to be hardened, to ensure that player has already read a particular metachunk or passed over it

git-svn-id: https://svn.musicpd.org/mpd/trunk@1358 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2004-06-06 19:41:03 +00:00
Warren Dukes
4e53282469 todo update
git-svn-id: https://svn.musicpd.org/mpd/trunk@1352 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2004-06-06 16:42:14 +00:00
Warren Dukes
16da97e4c8 parsing mp3 id3v2 tags on the fly for streams
git-svn-id: https://svn.musicpd.org/mpd/trunk@1281 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2004-06-01 12:50:15 +00:00
Warren Dukes
199ad37e22 more efficient of updating of metadata
git-svn-id: https://svn.musicpd.org/mpd/trunk@1277 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2004-06-01 10:28:06 +00:00
Warren Dukes
000e053ce7 icynames are now copied to title of streams
git-svn-id: https://svn.musicpd.org/mpd/trunk@1258 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2004-05-31 11:42:46 +00:00
Warren Dukes
97fe75a0bf little cleanup of plugin stuff
git-svn-id: https://svn.musicpd.org/mpd/trunk@1247 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2004-05-31 02:21:06 +00:00
Warren Dukes
fd6aa25359 mp3 and ogg plugin stuff
git-svn-id: https://svn.musicpd.org/mpd/trunk@1245 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2004-05-31 01:21:17 +00:00
Warren Dukes
549344d38a add vim shiznit to end of all source files
git-svn-id: https://svn.musicpd.org/mpd/trunk@750 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2004-04-14 14:53:41 +00:00
Warren Dukes
b72f591641 parse length from Aac files and ID3 tags
git-svn-id: https://svn.musicpd.org/mpd/trunk@346 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2004-03-21 18:12:37 +00:00
Warren Dukes
91450723b2 bunch of autotool cleanups
git-svn-id: https://svn.musicpd.org/mpd/trunk@271 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2004-03-18 03:29:25 +00:00
Warren Dukes
9a7636f5bc have AAC and MP4 types
git-svn-id: https://svn.musicpd.org/mpd/trunk@267 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2004-03-17 17:30:50 +00:00
Warren Dukes
f114fbd437 fix a few snafoo's in configure.ac
Add initial stuff for AAC support, now we just need to write the decoder

git-svn-id: https://svn.musicpd.org/mpd/trunk@264 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2004-03-17 03:10:17 +00:00
Warren Dukes
1157b5d332 move time back into MpdTag
git-svn-id: https://svn.musicpd.org/mpd/trunk@250 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2004-03-11 00:16:49 +00:00
Warren Dukes
ec234e9855 move time from tag info to song info.
also, if we can't get the time, then don't add the song to the db!

git-svn-id: https://svn.musicpd.org/mpd/trunk@236 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2004-03-10 02:38:31 +00:00
Warren Dukes
d35747a40c import from SF CVS
git-svn-id: https://svn.musicpd.org/mpd/trunk@1 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2004-02-23 23:41:20 +00:00