| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
| |
Don't compile the sources of disabled decoder plugins at all, and
don't attempt to register these.
|
|
|
|
|
|
|
|
| |
The mp3 plugin did not use the MAD_NCHANNELS() value correctly: when a
stream was not stereo, it was assumed to be mono, although the correct
number was passed to MPD. libmad doesn't support more than 2
channels, but this change allows gcc to optimize its inlining
strategy.
|
|
|
|
|
|
| |
The dithering function audio_linear_dither() worked for signed 16 bits
only anyway, having a variable "bits" just disables important gcc
optimizations.
|
|
|
|
|
| |
The last bit of CamelCase in audio_format.h. Additionally, rename a
bunch of local variables.
|
|
|
|
|
|
| |
The old struct initializers are error prone and don't allow moving
elements around. Since we are going to overhaul some of the APIs
soon, it's easier to have all implementations use C99 initializers.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
| |
LOC reduction and less noise makes things easier for
tired old folks to follow.
|
| |
|
|
|
|
|
|
|
| |
The function decodeFirstFrame() allocates memory based on data from
the mp3 header. This can make the buffer size allocation overflow, or
lead to a DoS attack with a very large buffer. Cap this buffer at 8
million frames, which should really be enough for reasonable files.
|
|
|
|
|
| |
Get rid of CamelCase, and don't use a typedef, so we can
forward-declare it, and unclutter the include dependencies.
|
| |
|
|
|
|
|
| |
Getting rid of CamelCase; not having typedefs also allows us to
forward-declare the structures.
|
|
|
|
|
|
|
| |
When we introduced decoder_read(), we added code which aborts the read
operation when a decoder command arrives. Several plugins however did
not expect that when they were converted to decoder_read(). Add
proper checks to the mp3 and flac decoder plugins.
|
|
|
|
|
|
| |
The code said "decoder_command==STOP" because that was a conversion
from the old "dc->stop" test. As we can now check for all commands in
one test, we can simply rewrite that to decoder_command!=NONE.
|
|
|
|
| |
Also introduce MUTEFRAME_NONE; previously, the code used "0".
|
| |
|
|
|
|
|
|
|
|
|
| |
On our way to stabilize the decoder API, we will one day remove the
input stream functions. The most basic function, read() will be
provided by decoder_api.h with this patch. It already contains a loop
(still with manual polling), error/eof handling and decoder command
checks. This kind of code used to be duplicated in all decoder
plugins.
|
|
|
|
|
|
| |
We need the decoder object at several places in the mp3 plugin. Add
it to mp3DecodeData, so we don't have to pass it around in every
function.
|
|
|
|
|
|
| |
The return value of audio_linear_dither() is always casted to
mpd_sint16. Returning long does not make sense, and consumed 8 bytes
on a 64 bit platform.
|
|
|
|
|
| |
The output buffer always contains mpd_sint16; declaring it with that
type saves several casts.
|
|
|
|
|
| |
The previous patch removed all loop specific dependencies from the
num_samples formula; we can now calculate it before entering the loop.
|
|
|
|
|
|
| |
The output buffer is always flushed after being appended to, which
allows us to assume it is always empty. Always start writing at
outputBuffer, don't remember outputPtr.
|
|
|
|
|
|
| |
The previous patch made mp3Read() flush the output buffer in every
iteration, which means we can eliminate the flush check after invoking
mp3Read().
|
|
|
|
|
| |
Since we try to fill the buffer in every iteration, we assume that we
should flush the output buffer at the end of each iteration.
|
|
|
|
|
|
| |
Fill the whole output buffer at a time by using dither_buffer()'s
ability to decode blocks. Calculate how many samples fit into the
output buffer before each invocation.
|
|
|
|
|
|
|
| |
Simplifying loops for performance: why check dropSamplesAtEnd in every
iteration, when we could modify the loop boundary? The (writable)
variable samplesLeft can be eliminated; add a write-once variable
pcm_length instead, which is used for the loop condition.
|
|
|
|
|
|
| |
The variable samplesPerFrame is used only in one single closure. Make
it local to this closure. The compiler will probably convert it to a
register anyway.
|
| |
|
|
|
|
|
| |
cmd has already been checked before, it cannot have changed meanwhile
because it is a local variable.
|
|
|
|
|
|
|
|
| |
Preparing for simplifying and thus speeding up the dithering code:
moved dithering to a separate function which contains a trivial loop.
With this patch, only one sample is dithered at a time, but the
following patches will allow us to dither a whole block at a time,
without complicated buffer length checks.
|
|
|
|
|
| |
Performance improvement by moving stuff out of a loop: skip part of
the first frame before entering the loop.
|
|
|
|
|
|
| |
"decoder plugin" is a better name than "input plugin", since the
plugin does not actually do the input - InputStream does. Also don't
use typedef, so we can forward-declare it if required.
|
|
|
|
|
| |
(Ab)use the decoder_command enumeration, which has nearly the same
values and the same meaning.
|
|
|
|
|
| |
Provide access to seeking for the decoder plugins; they have to know
where to seek, and they need a way to tell us that seeking has failed.
|
|
|
|
|
|
|
| |
Some decoder commands are implemented in the decoder plugins, thus
they need to have an API call to signal that their current command has
been finished. Let them use the new decoder_command_finished()
instead of the internal dc_command_finished().
|
|
|
|
|
|
| |
Another big patch which hides internal mpd APIs from decoder plugins:
decoder plugins regularly poll dc->command; expose it with a
decoder_api.h function.
|
|
|
|
|
|
| |
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".
|
|
|
|
|
| |
Similar to the previous patch: pass total_time instead of manipulating
dc->totalTime directly.
|
|
|
|
|
|
| |
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().
|
|
|
|
|
|
| |
We are now beginning to remove direct structure accesses from the
decoder plugins. decoder_clear() and decoder_flush() mask two very
common buffer functions.
|
|
|
|
|
| |
Moved all of the player-waiting code to decoder_data(), to make
OutputBuffer more generic.
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
| |
Include only headers which are really required. This speeds up
compilation and helps detect cross-layer accesses.
|
|
|
|
|
|
|
|
|
|
| |
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
|
|
|
|
|
|
|
| |
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
|
|
|
|
|
|
|
| |
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
|
|
|
| |
git-svn-id: https://svn.musicpd.org/mpd/trunk@7287 09075e82-0dd4-0310-85a5-a0d7c8717e4f
|