aboutsummaryrefslogtreecommitdiffstats
path: root/src/pipe.c (unfollow)
Commit message (Collapse)AuthorFilesLines
2008-11-02music_pipe: add tag pointer to the music_chunk structMax Kellermann1-1/+27
Each music chunk can now carry a tag object. Decoder plugins which support it (e.g. oggvorbis) may use this to inject decoded tags into their output.
2008-11-02music_pipe: added functions chunk_init() and chunk_free()Max Kellermann1-10/+38
These two functions will care about memory allocation and deallocation in the future.
2008-11-02music_pipe: renamed "size" to "num_chunks"Max Kellermann1-10/+10
The name "num_chunks" expresses the meaning of the variable better.
2008-11-02music_pipe: no CamelCaseMax Kellermann1-14/+14
Rename all variables and struct members.
2008-11-02music_pipe: set bit_rate and time in music_pipe_append()Max Kellermann1-10/+10
Don't bother to pass these values as parameters to tail_chunk().
2008-11-02music_pipe: moved code to music_chunk_append()Max Kellermann1-13/+28
2008-11-02music_pipe: renamed "ob" to "music_pipe"Max Kellermann1-43/+43
Last music_pipe rename patch: renamed the global variable (singleton).
2008-11-02music_pipe: use GLib instead of utils.hMax Kellermann1-3/+3
Eliminate the deprecated utils.h memory allocation functions.
2008-11-02decoder: replaced music_pipe.audioFormat with dc.out_audio_formatMax Kellermann1-1/+3
.. and rename dc.audioFormat to dc.in_audio_format. The music pipe does not need to know the audio format, and its former "audioFormat" property indicated the format of the most recently added chunk, which might be confusing when you are reading the oldest chunks.
2008-11-02music_pipe: pass frame size to tail_chunk()Max Kellermann1-3/+2
Don't make tail_chunk() calculate the frame size again.
2008-11-02music_pipe: renamed ob_* functions to music_pipe_*Max Kellermann1-20/+20
Rename all functions to the new prefix.
2008-11-02music_pipe: renamed struct output_buffer to struct music_pipeMax Kellermann1-6/+8
.. and rename ob_chunk to struct music_chunk.
2008-11-02renamed outputBuffer.[ch] to pipe.[ch]Max Kellermann1-1/+1
No CamelCase in the file name. The output_buffer struct is going to be renamed to music_pipe. There are so many buffer levels in MPD, and calling this one "output buffer" is wrong, because it's not the last buffer before the music reaches the output devices.
2008-10-23output_buffer: don't split framesMax Kellermann1-1/+10
Splitting a frame between two buffer chunks causes distortion in the output. MPD used to assume that the chunk size 1020 would never cause splitted frames, but that isn't the case for 24 bit stereo (127.5 frames), and even less for files with even more channels.
2008-10-12output_buffer: converted ob_is_empty() to inlineMax Kellermann1-5/+0
The function ob_is_empty() is called very often. It's worth it to convert it to an inline function.
2008-10-08use the "bool" data type instead of "int"Max Kellermann1-2/+2
"bool" should be used in C99 programs for boolean values.
2008-10-08don't include os_compat.hMax Kellermann1-0/+3
When there are standardized headers, use these instead of the bloated os_compat.h.
2008-10-08notify: removed the "Notify" typedefMax Kellermann1-2/+3
Typedefs shouldn't be used, use the bare struct names instead.
2008-09-29switch to C99 types, part IIMax Kellermann1-2/+2
Do full C99 integer type conversion in all modules which were not touched by Eric's merged patch.
2008-08-26moved global variable "ob" to outputBuffer.hMax Kellermann1-1/+2
This releases several include file dependencies. As a side effect, "CHUNK_SIZE" isn't defined by decoder_api.h anymore, so we have to define it directly in the plugins which need it. It just isn't worth it to add it to the decoder plugin API.
2008-08-26moved convState to struct decoderMax Kellermann1-1/+0
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.
2008-08-26tail_chunk() returns ob_chunk pointerMax Kellermann1-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.
2008-08-26added OutputBuffer.notifyMax Kellermann1-3/+4
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.
2008-08-26added decoder_data()Max Kellermann1-66/+16
Moved all of the player-waiting code to decoder_data(), to make OutputBuffer more generic.
2008-08-26invoke the notify API directlyMax Kellermann1-2/+3
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.
2008-08-26added dc_command_finished()Max Kellermann1-2/+1
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.
2008-08-26merged start, stop, seek into DecoderControl.commandMax Kellermann1-3/+3
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.
2008-04-15added ob_set_lazy()Max Kellermann1-1/+7
In lazy mode (previously the default), outputBuffer.c only wakes up the player when it was previously empty. That caused a deadlock when the player was waiting for buffered_before_play, since the decoder wouldn't wake up the player when buffered_before_play was reached. In non-lazy mode, always wake up the player when a new chunk was decoded. git-svn-id: https://svn.musicpd.org/mpd/trunk@7364 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-04-13Make the OutputBuffer API more consistentEric Wong1-65/+65
We had functions names varied between outputBufferFoo, fooOutputBuffer, and output_buffer_foo That was too confusing for my little brain to handle. And the global variable was somehow named 'cb' instead of the more obvious 'ob'... git-svn-id: https://svn.musicpd.org/mpd/trunk@7355 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-04-13Stop passing our single OutputBuffer object everywhereEric Wong1-69/+69
All of our main singleton data structures are implicitly shared, so there's no reason to keep passing them around and around in the stack and making our internal API harder to deal with. git-svn-id: https://svn.musicpd.org/mpd/trunk@7354 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-04-13Stop passing our single DecoderControl object everywhereEric Wong1-15/+13
This at least makes the argument list to a lot of our plugin functions shorter and removes a good amount of line nois^W^Wcode, hopefully making things easier to read and follow. git-svn-id: https://svn.musicpd.org/mpd/trunk@7353 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-04-12flush after loop in sendDataToOutputBuffer()Max Kellermann1-5/+4
Since tailChunk() automatically flushes full buffers, we do not have to check this in every iteration of sendDataToOutputBuffer(). git-svn-id: https://svn.musicpd.org/mpd/trunk@7343 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-04-12yet another migration to size_tMax Kellermann1-4/+4
We can also get rid of one the two variables. git-svn-id: https://svn.musicpd.org/mpd/trunk@7341 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-04-12check cb->stop in the while loopMax Kellermann1-4/+4
Checking dc->stop in the while condition and again after the while loop costs some CPU cycles we should save. git-svn-id: https://svn.musicpd.org/mpd/trunk@7340 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-04-12eliminate OutputBuffer.currentChunkMax Kellermann1-29/+51
OutputBuffer.currentChunk contains redundant data: it is either -1 when there is no chunk which is currently being written, or it equals "end". If we always keep chunk[end] in a valid state, we can remove OutputBuffer.currentChunk. This patch may look a bit clumsy, especially flushOutputBuffer(), but that will be fixed later with an major OutputBuffer API overhaul. git-svn-id: https://svn.musicpd.org/mpd/trunk@7339 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-04-12added output_buffer_expand()Max Kellermann1-13/+22
output_buffer_expand() moves the cb->end to the new position (only its current successor is allowed) and wakes up the player if is waiting for the decoder. This simplifies flushOutputBuffer(). git-svn-id: https://svn.musicpd.org/mpd/trunk@7338 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-04-12initialize all elements in initOutputBuffer()Max Kellermann1-0/+2
The current OutputBuffer object is allocated statically, i.e. it is zeroed. To be safe for other cases in the future, also initialize the other elements. git-svn-id: https://svn.musicpd.org/mpd/trunk@7337 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-04-12wake up player on demandMax Kellermann1-1/+9
The decoder should not wake up the player when it did not produce a flushed chunk. Move the decoder_wakeup_player() call to flushOutputBuffer() and invoke it only if the buffer was previously empty. git-svn-id: https://svn.musicpd.org/mpd/trunk@7336 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-04-12clean up CPP includesMax Kellermann1-5/+0
Try to only include headers which are really needed. We should particularly check all "headers including other headers". The long-term goal is to have a manageable, small API for plugins (decoders, output) without so many mpd internals cluttering the namespace. git-svn-id: https://svn.musicpd.org/mpd/trunk@7319 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-04-12pass DecoderControl object to decoder_sleep()Max Kellermann1-1/+1
Less global variables: at any invocation of decoder_sleep(), we have a reference to the DecoderControl anyway, so we should pass it. This costs less than having to call getPlayerData() in every tiny function. Maybe some day we will be able to have multiple decoders at the same time... git-svn-id: https://svn.musicpd.org/mpd/trunk@7316 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-04-12added output_buffer_free()Max Kellermann1-0/+6
To do proper cleanup before exiting, we have to provide a destructor for OutputBuffer. One day, valgrind will not complain about memory leaks! git-svn-id: https://svn.musicpd.org/mpd/trunk@7315 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-04-12don't use short chunk numbersMax Kellermann1-2/+2
Don't be mean with integer sizes. Although we will probably never have more than 32k buffered chunks, we should use 32 bit integers for addressing them. We do not save very much (some of the saved space is eaten by alignment anyway), but we save at least one assembler instruction for converting short to int. This change requires some more explicit casts, because gcc was less picky when comparing short with a full int. git-svn-id: https://svn.musicpd.org/mpd/trunk@7313 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-04-12added output_buffer_skip()Max Kellermann1-0/+6
First patch without camelCase ;) output_buffer_skip() lets us eliminate advanceOutputBufferTo(), and removes yet another external OutputBuffer struct access. git-svn-id: https://svn.musicpd.org/mpd/trunk@7312 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-04-12pass buffered_chunks to initOutputBuffer()Max Kellermann1-14/+17
Try to make OutputBuffer self-contained, without depending on a global variable. git-svn-id: https://svn.musicpd.org/mpd/trunk@7310 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-04-12fix typo in commentMax Kellermann1-3/+3
git-svn-id: https://svn.musicpd.org/mpd/trunk@7305 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-04-12let initOutputBuffer() allocate memoryMax Kellermann1-2/+2
This is the first patch in a series which removes the shared memory, and moves all the playerData objects into the normal libc heap. git-svn-id: https://svn.musicpd.org/mpd/trunk@7304 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-04-12added inline function successor()Max Kellermann1-11/+12
The new function successor() can be used to simplify a lot of code lines and saves a lot of "i+>=buffered_chunks" checks. git-svn-id: https://svn.musicpd.org/mpd/trunk@7285 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-04-12moved currentChunk into OutputBufferMax Kellermann1-10/+9
currentChunk is a global variable, which renders the whole output buffer code non-reentrant. Although this is not a real problem since there is only one global output buffer currently, we should move it to the OutputBuffer struct. git-svn-id: https://svn.musicpd.org/mpd/trunk@7284 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-04-12added outputBufferShift()Max Kellermann1-0/+10
Hiding OutputBuffer internals, yet again. Two more assertions. git-svn-id: https://svn.musicpd.org/mpd/trunk@7274 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-04-12use sizeof(chunk.data) instead of CHUNK_SIZEMax Kellermann1-2/+2
sizeof() is the more "natural" or "direct" access to the buffer size, instead of a macro happening to be used to the buffer declaration. git-svn-id: https://svn.musicpd.org/mpd/trunk@7270 09075e82-0dd4-0310-85a5-a0d7c8717e4f