Commit Graph

19 Commits

Author SHA1 Message Date
Max Kellermann
9e55a08d79 songvec: sort songs by disc and track number
Sorting songs by file name does not make much sense.  Most of the
time, users want to add songs in track order to the playlist.
2009-01-15 00:22:30 +01:00
Max Kellermann
4847bbaad3 dirvec, songvec: sort using g_utf8_collate()
Path names in the directory and song structs are always encoded in
UTF-8.  Don't use strcmp(), it cannot handle UTF-8 characters
properly.  Use GLib's UTF-8 aware g_utf8_collate() function for that.
2009-01-15 00:09:18 +01:00
Max Kellermann
2064e8ac4c songvec, dirvec: use GLib instead of utils.h 2009-01-03 14:53:02 +01:00
Thomas Jansen
bfb5657d6d songvec: migrate from pthread to glib threads 2008-12-28 21:02:42 +01:00
Thomas Jansen
f31b4f46e1 Remove xpthread_* wrappers 2008-12-28 21:01:03 +01:00
Eric Wong
d52437d43f update: fix multiple deletes from *vec iterators
{song,dir}vec_for_each each failed to gracefully handle deleted
files when iterating through.  While we were thread-safe, we
were not safe within the calling thread.  If a callback we
passed caused sv->nr to shring, our index would still increment;
causing files to stay in the database.

A way to test this is to remove 10 or so contiguous songs from a
>10 song directory.
2008-10-21 01:35:11 +02:00
Eric Wong
686a6df3a5 {dir,song}vec: these structs are const
We definitely don't modify them here.
2008-10-21 01:31:36 +02:00
Eric Wong
06c8a9ed0b {dir,song}vec: fix off-by-one errors in {dir,song}vec_delete
Found by Valgrind while looking for another bug...

Hmm.. I should really just make this code generic since
they're duplicated...
2008-10-14 11:10:00 +02:00
Eric Wong
313405edb6 songvec: avoid holding nr_lock during free(3)
We only need to lock sv->nr changes to prevent traversals ( why
it's called "nr_lock").  free(3) is a "slow" function on my
system; so we can avoid unnecessarily holding a lock long for
longer than needed.
2008-10-13 09:55:07 +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
d562ba5fbb song: converted typedef Song to struct song
Again, a data type which can be forward-declared.
2008-10-08 10:49:11 +02:00
Max Kellermann
f0366cc8ca songvec: pass const pointers
Pass const songvec pointers to songvec_find() and songvec_for_each().
2008-10-07 22:09:55 +02:00
Eric Wong
45334a23e1 songvec: lock traversals for thread-safe updates/reads
Only one lock is used for all songvec traversals since
they're rarely changed.  Also, minimize lock time and
release it before calling iterator functions since they
may block (updateSongInfo => stat/open/seek/read).

This lock only protects songvecs (and all of them) during
traversals; not the individual song structures themselves.
2008-10-07 22:07:34 +02:00
Eric Wong
bb04c6342e songvec: add songvec_for_each iterator
This is so we can more consistently deal with locking
needed for thread-safety in iterator functions.
2008-10-07 22:07:29 +02:00
Eric Wong
554f4a9fb9 songvec: songvec_delete takes a const Song pointer
We don't modify the Song when we delete it
2008-09-29 13:17:30 +02:00
Eric Wong
6075119f0a songvec_free => songvec_destroy
"free" implies the songvec structure itself is freed,
which is not the case.
2008-09-29 12:17:13 +02:00
Eric Wong
ef35926083 songvec: avoid free(NULL)
Potentially broken free() implementations don't like it
2008-09-23 22:38:43 +02:00
Eric Wong
28d39948d7 songvec: remove songvec_prune
Any pruned files will be noticed during update and pruned
from the live database, so this inefficient function can
go away and never come back.
2008-09-23 22:37:33 +02:00
Eric Wong
0bec1d3807 Replace SongList with struct songvec
Our linked-list implementation is wasteful and the
SongList isn't modified enough to benefit from being a linked
list.  So use a more compact array of song pointers which
saves ~200K on a library with ~9K songs (on x86-32).
2008-09-23 20:48:39 +02:00