Commit Graph

2331 Commits

Author SHA1 Message Date
Max Kellermann
a5480108f8 dirvec: constant pointers in dirvec_find()
dirvec_find() does not modify the object, thus it should get a const
pointer.
2008-10-09 15:24:34 +02:00
Max Kellermann
68f716a28b directory: moved dirvec struct declaration to dirvec.h
No idea why it was created in directory.h, but it should be in
dirvec.h.
2008-10-09 15:24:05 +02:00
Max Kellermann
a0c044df11 diretory: moved code to directory_save.c, directory_print.c
Remove clutter from directory.c.  Everything which saves or loads
to/from the hard disk goes to directory_save.c, and code which sends
directory information to the client is moved into directory_print.c.
2008-10-09 15:23:37 +02:00
Max Kellermann
cb12eb8e23 database: removed local variable bufferSize
Use sizeof(buffer) instead.
2008-10-09 15:21:23 +02:00
Max Kellermann
5dc4c325aa database: simplify db_load()
Removed a superfluous closure.
2008-10-09 15:21:18 +02:00
Max Kellermann
5583b6c5e1 shout: removed DISABLED_SHOUT_ENCODER_PLUGIN
Having an array with disabled entries sucks.  Removed that
DISABLED_SHOUT_ENCODER_PLUGIN macro, and fill the plugin list only
with plugins which are actually enabled.  This should be done for all
plugin types.
2008-10-09 15:18:21 +02:00
Max Kellermann
671b455133 pcm: fix const flac in pcm_convertSampleRate()
In the libsamplerate fallback code, a "const" attribute was missing.
2008-10-09 15:18:18 +02:00
Max Kellermann
40f59cacda pcm: fixed software volume, broken by unsigned integer
"volume" was passed as an unsigned integer, which is correct.  It's
just that when it was multiplied with the sample value, the whole
operation was changed to unsigned, breaking the algorithm (and Qball's
ears).  Internally change "volume" to signed.
2008-10-09 15:18:09 +02:00
Qball Cow
ecc3c39e2f Fix error code for "Playlist already exists"
With commit 6dcd7fea (if I am not mistaken) the error returned when
you try to save to an existing playlist is wrong.  Instead of
MPD_ACK_ERROR_EXIST, MPD_ACK_ERROR_NO_EXIST is returned.  This is
obviously wrong and breaks gmpc.
2008-10-09 11:51:22 +02:00
Max Kellermann
22645abc10 directory: fix update in root directory
Commit 0bfe7802 broke update for new files in the root directory,
because music_root->path was an empty string and not NULL.  There were
some NULL tests missing.  Change them to !isRootDirectory(path)
instead of path!=NULL.
2008-10-08 11:55:52 +02:00
Max Kellermann
e8413541f4 update: fix deadlock in delete_song()
Due to a merge error, reap_update_task() called cond_signal_async()
with a locked mutex.  That always fails.  Use cond_signal_sync()
instead.
2008-10-08 11:36:38 +02:00
Max Kellermann
81220ca206 directory: include sys/types.h
ino_t and dev_t are declared in sys/types.h, not sys/stat.h.
2008-10-08 11:25:33 +02:00
Max Kellermann
0bfe7802d2 directory: path must not be NULL
For the root directory, let's set path to an empty string.  This saves
a few checks.
2008-10-08 11:08:16 +02:00
Max Kellermann
3b6efa99da directory: directory_get_path(NULL) is not allowed
Also convert directory_get_path() to an inline function, which returns
a constant string.
2008-10-08 11:08:04 +02:00
Max Kellermann
68977af6e0 directory: eliminate CamelCase
CamelCase is ugly, rename the functions.
2008-10-08 11:07:58 +02:00
Max Kellermann
bb8a9533b1 database: renamed functions, "db_" prefix and no CamelCase
Yet another CamelCase removal patch.
2008-10-08 11:07:55 +02:00
Max Kellermann
7a023eb0b2 database: removed printDirectoryInfo()
The same can be achieved with directory_print(db_get_directory()).
2008-10-08 11:07:39 +02:00
Max Kellermann
8a50e8a266 directory: moved code to database.c
Taming the directory.c monster, part II: move the database management
stuff to database.  directory.c should only contain code which works
on directory objects.
2008-10-08 11:07:35 +02:00
Max Kellermann
ba5c9b0375 directory: converted isRootDirectory() to an inline function
The function isRootDirectory() is tiny and can be converted to an
inline function.  Don't allow name==NULL.
2008-10-08 11:06:44 +02:00
Max Kellermann
e1a4474ad4 song: don't allow calling song_get_url(NULL)
The runtime check suggests that the author has somehow thought
song_get_url(NULL) might be valid.  It should not be.  Replace it with
an assertion.
2008-10-08 11:06:37 +02:00
Max Kellermann
4ab6b59aaf song: use song_file_update() in song_file_load()
Eliminate duplicated code.
2008-10-08 11:06:27 +02:00
Max Kellermann
02e8c000d1 song: song_file_update() returns bool
Instead of returning 0 or -1, return true on success and false on
failure.  This seems more natural, and when the C library was
designed, there was no "bool" data type.
2008-10-08 11:06:26 +02:00
Max Kellermann
1f9b614850 song: don't check song_is_file() in song_file_update()
This function was never used on remote songs.  Replace the runtime
check with an assertion.
2008-10-08 11:05:38 +02:00
Max Kellermann
5e7b18f874 song: removed CamelCase
CamelCase is ugly...  rename all functions.
2008-10-08 11:05:34 +02:00
Max Kellermann
5e4be9e495 song: replaced all song constructors
Provide separate constructors for creating a remote song, a local
song, and one for loading data from a song file.  This way, we can add
more assertions.
2008-10-08 11:05:25 +02:00
Max Kellermann
4a510a2674 playlist: simplified setPlaylistRandomStatus()
Check the old status before assigning.  This saves a temporary
variable.
2008-10-08 11:05:02 +02:00
Max Kellermann
b084bc28ed use the "bool" data type instead of "int"
"bool" should be used in C99 programs for boolean values.
2008-10-08 11:03:39 +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
ca68b1c80a CPP include cleanup
Include only headers which are really used.
2008-10-08 10:49:26 +02:00
Max Kellermann
b159832418 notify: removed the "Notify" typedef
Typedefs shouldn't be used, use the bare struct names instead.
2008-10-08 10:49:16 +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
25f67da58c directory: converted typedef Directory to struct directory
The struct can be forward-declared by other headers, which relaxes the
header dependencies.
2008-10-08 10:49:05 +02:00
Max Kellermann
3c1142cbcb update: merged exploreDirectory() into updateDirectory()
exploreDirectory() duplicates some code in updateDirectory().  Merge
both functions, and use directory_is_empty() to determine whether
update or explore mode should be used.
2008-10-08 10:48:55 +02:00
Max Kellermann
e79aacf1db directory: added directory_is_empty()
directory_is_empty() is a tiny inline function which determine if a
directory has any child objects (sub directories or songs).
2008-10-08 10:48:49 +02:00
Max Kellermann
7b9bed8398 directory: moved code to update.c
The source directory.c mixes several libraries: directory object
management, database management and database update, resulting in a
1000+ line monster.  Move the whole database update code to update.c.
2008-10-08 10:48:48 +02:00
Max Kellermann
4cfd356e12 dirvec: moved code to dirvec.c
Having all functions as static (non-inline) functions generates GCC
warnings, and duplicates binary code across several object files.
Most of dirvec's methods are too complex for becoming inline
functions.  Move them all to dirvec.c and publish the prototypes in
dirvec.h.
2008-10-08 06:55:10 +02:00
Max Kellermann
b42974eee1 notify: loop while no signal is pending
pthread_cond_wait() may wake up spuriously.  To prevent superfluous
state checks, loop until the "pending" flag becomes true.  Removed the
dangerous assertion.
2008-10-08 06:55:08 +02:00
Max Kellermann
46eda29d1c song: really make the song struct non-packed
Somehow I must have missed this in commit 22e40b61.
2008-10-07 22:15:06 +02:00
Eric Wong
81ce068085 directory: fix return value in removeDeletedFromDirectory
oops :x
2008-10-07 22:11:21 +02:00
Eric Wong
7d8c9cc7e3 directory: serialize song deletes from playlist during update
This makes the update code thread-safe and doesn't penalize
the playlist code by complicating it with complicated and
error-prone locks (and the associated overhead, not everybody
has a thread-implementation as good as NPTL).

The update task blocks during the delete; but the update task is
a slow task anyways so we can block w/o people caring too much.

This was also our only freeSong call site, so remove that
function.

Note that deleting entire directories is not fully thread-safe,
yet; as their traversals are not yet locked.
2008-10-07 22:11:16 +02:00
Eric Wong
2b965a5424 directory: use songvec_for_each for iterators
Get rid of songvec_write so we can enforce proper locking
2008-10-07 22:10:48 +02:00
Max Kellermann
c47f97e1dc song: use songvec_for_each() in songvec_print() / songvec_save()
songvec_for_each() has locking, use it instead of manually iterating
over the songvec items.
2008-10-07 22:10:42 +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
8be6026336 dbUtils/directory: traverseAllIn forEachSong returns -1 on error
Being consistent with most UNIX functions...
2008-10-07 22:07:44 +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
e19f6905d9 song: replace printSong* with song_print_*
This make argument order more consistent for iterators.
Additionally, these now return ssize_t results for error
checking.
2008-10-07 22:06:59 +02:00
Eric Wong
0d34815f6c Assert if we don't have song or song->url set
song objects cannot exist without a path or URL
2008-10-07 21:20:34 +02:00
Eric Wong
016af692d9 autotools: tidy up make dist
* Add missing headers in Makefile.am
* remove mp4ff.dsp (Win32 crap)
* Add scripts, m4, bs, autogen.sh to allow for hotfixes by the
  SCM-challenged.  (downloading the source via git is NOT a
  lightweight operation for everybody).
2008-10-06 18:54:12 +02:00
Eric Wong
a792dc5b93 autotools: add pthreads linker support
This is needed for people that don't use any of the following:
JACK, ALSA, libmikmod, Shout.
2008-10-06 18:52:48 +02:00