aboutsummaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* moved convState to struct decoderMax Kellermann2008-08-264-7/+10
| | | | | | Since we moved all PCM conversions to decoder_data(), the attribute convState isn't being used anymore by the OutputBuffer code. Move it to struct decoder.
* moved struct AudioFormat to audio_format.hMax Kellermann2008-08-2613-19/+48
| | | | | We want to expose the AudioFormat structure to plugins; remove some clutter by moving its declaration to a separate header file.
* moved InputPlugin to decoder_api.hMax Kellermann2008-08-266-61/+64
| | | | | | InputPlugin is the API which is implemented by a decoder plugin. This belongs to the public API/ABI, so move it to decoder_api.h. It will later be renamed to something like "decoder_plugin".
* remove one indent level from audiofile pluginMax Kellermann2008-08-261-30/+25
| | | | | Anonymous code blocks just to declare variables look ugly. Move the variable declarations up and disband the code block.
* use break instead of local variable "eof"Max Kellermann2008-08-261-16/+12
| | | | | Similar to previous patch: eliminate one variable by using "break". This also simplifies the code since we can remove one level of indent.
* removed local variable "eof" because it is unusedMax Kellermann2008-08-262-19/+9
| | | | | "break" is so much easier than "eof=1; continue;", when "!eof" is the loop condition.
* simplify several dc->command checksMax Kellermann2008-08-261-7/+3
| | | | | | Since we have merged dc->stop, dc->seek into one variable, we don't have to check both conditions at a time; we can replace "!stop && !seek" with "none".
* added parameter total_time to decoder_initialized()Max Kellermann2008-08-2614-29/+31
| | | | | Similar to the previous patch: pass total_time instead of manipulating dc->totalTime directly.
* added audio_format parameter to decoder_initialized()Max Kellermann2008-08-2614-83/+88
| | | | | | dc->audioFormat is set once by the decoder plugins before invoking decoder_initialized(); hide dc->audioFormat and let the decoder pass an AudioFormat pointer to decoder_initialized().
* added decoder_clear() and decoder_flush()Max Kellermann2008-08-2612-22/+35
| | | | | | We are now beginning to remove direct structure accesses from the decoder plugins. decoder_clear() and decoder_flush() mask two very common buffer functions.
* tail_chunk() returns ob_chunk pointerMax Kellermann2008-08-261-8/+6
| | | | | | Code simplification: since we are not using in-band signalling with the chunk index anymore, we can just return a pointer to the tail chunk instead of the index.
* added OutputBuffer.notifyMax Kellermann2008-08-263-5/+9
| | | | | | | | OutputBuffer should be a more generic low-level library, without dependencies to the other headers. This patch adds the field "notify", which is used to signal the player thread. It is passed in the constructor, and removes the need to compile with the decode.h header.
* added decoder_data()Max Kellermann2008-08-2613-136/+177
| | | | | Moved all of the player-waiting code to decoder_data(), to make OutputBuffer more generic.
* use the notify library in main_notify.cMax Kellermann2008-08-261-10/+7
| | | | Avoid some duplicated code in main_notify.c.
* do not sleep after openAudioDevice()Max Kellermann2008-08-261-3/+0
| | | | | | After the decoder has been initialized and the audio device has been opened, don't sleep. The decoder plugin won't do anything special nor will it care to wake us up for some reason.
* added decoder_initialized()Max Kellermann2008-08-2614-31/+66
| | | | | | | decoder_initialized() sets the state to DECODE_STATE_DECODE and wakes up the player thread. It is called by the decoder plugin after its internal initialization is finished. More arguments will be added later to prevent direct accesses to the DecoderControl struct.
* added struct decoderMax Kellermann2008-08-2617-30/+121
| | | | | | The decoder struct should later be made opaque to the decoder plugin, because maintaining a stable struct ABI is quite difficult. The ABI should only consist of a small number of stable functions.
* invoke the notify API directlyMax Kellermann2008-08-265-62/+24
| | | | | | Don't use wrappers like player_wakeup_decoder_nb(). These have been wrappers calling notify.c functions, for compatibility with the existing code when we migrated to notify.c.
* removed "else"Max Kellermann2008-08-261-2/+3
| | | | | The "if" block breaked out of the loop. That means we can move the code out of the "else" block.
* added dc_command_finished()Max Kellermann2008-08-2613-34/+32
| | | | | | | | dc_command_finished() is invoked by the decoder thread when it has finished a command (sent by the player thread). It resets dc.command and wakes up the player thread. This combination was used at a lot of places, and by introducing this function, the code will be more readable.
* don't busy wait for the decoder threadMax Kellermann2008-08-261-3/+7
| | | | | | | Busy wait loops are a bad thing, especially when the response time can be very long - busy waits eat a lot of CPU, and thus slow down the other thread. Since the other thread will notify us when it's ready, we can use notify_wait() instead.
* merged start, stop, seek into DecoderControl.commandMax Kellermann2008-08-2615-108/+139
| | | | | | | Much of the existing code queries all three variables sequentially. Since only one of them can be set at a time, this can be optimized and unified by merging all of them into one enum variable. Later, the "command" checks can be expressed in a "switch" statement.
* don't set pc->errored_song in decodeStart()Max Kellermann2008-08-261-1/+0
| | | | | pc->errored_song is already set by decodeParent() in the player thread when we set dc->error; no need to set it in the decoder thread.
* added dc.next_song, renamed pc.current_songMax Kellermann2008-08-264-15/+18
| | | | | | | | | Since pc->current_song denotes the song which the decoder should use next, we should move it to DecoderControl. This removes one internal PlayerControl struct access from the decoder code. Also add pc.next_song, which is manipulated by the playlist code, and gets copied to dc.next_song as soon as the decoder is started.
* clean up CPP includesMax Kellermann2008-08-2619-79/+1
| | | | | Include only headers which are really required. This speeds up compilation and helps detect cross-layer accesses.
* enable -Wpointer-arith, -Wstrict-prototypesMax Kellermann2008-08-2621-119/+186
| | | | | | Also enable -Wunused-parameter - this forces us to add the gcc "unused" attribute to a lot of parameters (mostly library callback functions), but it's worth it during code refactorizations.
* quote "=" in the CFLAGS checkMax Kellermann2008-08-251-1/+1
| | | | Previously, it was not possible to check for e.g. "-std=c99".
* fix warnings in the HTTP clientMax Kellermann2008-08-251-3/+4
| | | | | Fix a "unused argument" warning, and several warnings regarding void pointer calculation.
* fixed ringbuf.c warningsMax Kellermann2008-08-252-5/+5
| | | | | Fix a "signed/unsigned comparison warning", and several void pointer math warnings.
* bs: better support for mp4/faad/aac and wavpack buildssvn/trunkEric Wong2008-08-164-4/+8
| | | | | | | | | | | | * Correctly define the following CPP directives: HAVE_FAAD_BUFLEN_FUNCS HAVE_MP4AUDIOSPECIFICCONFIG * link against libwavpack correctly in bs * fix include path for the mpd config.h for mp4ff git-svn-id: https://svn.musicpd.org/mpd/trunk@7399 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* http: hopefully allow seeking to work on static filesEric Wong2008-06-301-1/+2
| | | git-svn-id: https://svn.musicpd.org/mpd/trunk@7398 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* don't call seekInputStream(0) if r==0Max Kellermann2008-06-301-1/+2
| | | | | | If nothing has been read from the input stream, we don't have to rewind it. git-svn-id: https://svn.musicpd.org/mpd/trunk@7397 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* eliminated local variable "to_read"Max Kellermann2008-06-301-4/+3
| | | | | | | The variable "to_read" is never modified except in the last iteration of the while loop. This means the while condition will never become false, as the body will break before that may be checked. git-svn-id: https://svn.musicpd.org/mpd/trunk@7396 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* introduce struct condition as a more correct version of NotifyEric Wong2008-06-304-64/+191
| | | | | Start using it in the HTTP code git-svn-id: https://svn.musicpd.org/mpd/trunk@7395 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* utils: pthread_{mutex,cond}_init can fail, so check for itEric Wong2008-06-302-0/+18
| | | git-svn-id: https://svn.musicpd.org/mpd/trunk@7394 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* http: initial rewrite using ringbuffer + pthreadsEric Wong2008-06-302-562/+799
| | | | | | | | | | | | | | | | | This institutes the usage of a separate thread to buffer HTTP input. It is basically practice code for using the ringbuffer code which I plan on reusing for the OutputBuffer as well as further input buffering for disk (networked filesystems over WAN, laptops on battery, etc). Each readFromInputStream() call on an HTTP stream can take several seconds to complete, short reads are avoided. A single-threaded solution for systems supporting large enough SO_RCVBUF values should also be possible and will likely be done in the future; but this lock-free(except when full/empty) ringbuffer is cool :) git-svn-id: https://svn.musicpd.org/mpd/trunk@7393 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* http: fix some small memory leaks when hitting redirectsEric Wong2008-06-301-0/+6
| | | git-svn-id: https://svn.musicpd.org/mpd/trunk@7392 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* utils: add new unforgiving utility functionsEric Wong2008-06-302-0/+30
| | | | | | We'll be using pipes when waiting for I/O, and condition variables at other times. git-svn-id: https://svn.musicpd.org/mpd/trunk@7391 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* ringbuf: add thread-safe, thread-specific reset functionsEric Wong2008-06-302-0/+30
| | | | | | This will allow both the reader and writer threads to reset the ringbuffer in a thread-safe fashion. git-svn-id: https://svn.musicpd.org/mpd/trunk@7390 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* ringbuf: get_{write,read}_vector returns total bytes in both vec eltsEric Wong2008-06-302-5/+9
| | | | | This will eliminate unnecessary calls to ringbuf_{read,write}_space git-svn-id: https://svn.musicpd.org/mpd/trunk@7389 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* http: split out logic around getaddrinfo() and connect()Eric Wong2008-06-301-40/+42
| | | | | Makes code easier to read and modularize git-svn-id: https://svn.musicpd.org/mpd/trunk@7388 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* http: split out auth code since it's mostly uninteresting for nowEric Wong2008-06-303-75/+103
| | | | | | The auth code also has some ugly usages of string generation which I will eventually replace with something nicer... git-svn-id: https://svn.musicpd.org/mpd/trunk@7387 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* Add a generic ring buffer implementationEric Wong2008-06-303-0/+503
| | | | | | | | | | | | | | | | This piece of code is from the JACK Audio Connection Kit (trimmed down a bit for better readability). The vector functions now reuse the common iovec struct used by writev/readv instead of reinventing an identical but differently-named struct. From the comments: > ISO/POSIX C version of Paul Davis's lock free ringbuffer C++ code. > This is safe for the case of one read thread and one write thread. License is LGPL 2.1 or later git-svn-id: https://svn.musicpd.org/mpd/trunk@7386 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* os_compat.h: add sys/uio.h for writev/readvEric Wong2008-06-301-0/+1
| | | | | vectored I/O will be useful with our ring buffer lib git-svn-id: https://svn.musicpd.org/mpd/trunk@7385 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* Die if a specific backend is requested but not found.Jim Ramsay2008-06-161-3/+3
| | | git-svn-id: https://svn.musicpd.org/mpd/trunk@7382 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* jack: initialize audioOutput->dataMax Kellermann2008-06-131-1/+3
| | | | | | | | | | | | | Initialize audioOutput->data with NULL in jack_initDriver(). Previously, this was never initialized, although the other functions relied on it being NULL prior to jack_openDevice(). This patch addresses bug 0001641[1]. In contrast to the patch provided by the bug reporter, it moves the initialization before the "!param" check. [1] - http://musicpd.org/mantis/view.php?id=1641 git-svn-id: https://svn.musicpd.org/mpd/trunk@7375 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* mod: fix crashing on modtracker filesHans de Goede2008-06-131-1/+1
| | | | | | | | | This patch was taken from http://bugzilla.livna.org/show_bug.cgi?id=1987 and addresses bug 0001693[1] [1] - http://musicpd.org/mantis/view.php?id=1693 git-svn-id: https://svn.musicpd.org/mpd/trunk@7374 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* audio.c: avoid magic numbers even if they have comments :)Eric Wong2008-06-021-1/+1
| | | git-svn-id: https://svn.musicpd.org/mpd/trunk@7373 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* remove audioDeviceStates from playerData and getPlayerDataEric Wong2008-06-025-40/+14
| | | git-svn-id: https://svn.musicpd.org/mpd/trunk@7372 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* fix stream URLMax Kellermann2008-06-011-1/+2
| | | | | | | | Streaming was broken, beacuse the stream URL was never copied to path_max_fs. [ew: replaced strcpy with pathcpy_trunc for ease of auditing] git-svn-id: https://svn.musicpd.org/mpd/trunk@7371 09075e82-0dd4-0310-85a5-a0d7c8717e4f