Commit Graph

1906 Commits

Author SHA1 Message Date
Max Kellermann
6aec61637b pcm_utils: 24 bit support
Add support for 24 bit PCM samples to all functions.  Note that
pcm_convertAudioFormat() converts 24 bit samples to 16 bit; to
preserve full quality, support for "real" 24 bit conversion should be
added.
2008-09-29 17:26:07 +02:00
Max Kellermann
ac6bc76cdb pcm_utils: moved code to special 8/16 bit functions
Moved code into separate bit specific functions:
- pcm_volumeChange() -> pcm_volume_change_X()
- pcm_add() -> pcm_add_X()
- pcm_convertTo16bit() -> pcm_convert_8_to_16()
2008-09-29 17:25:45 +02:00
Max Kellermann
c85b570ad7 pcm_utils: pass only one buffer size to pcm_mix()
pcm_mix() might overflow the destination buffer if it is smaller than
the second buffer.  This is ok because the physical buffer size passed
by cross_fade_apply() is always big enough, but clutters pcm_mix()
with complicated length checks and contains a dangerous buffer
overflow pitfall.  Simplify pcm_mix()/pcm_add() and pass only the
smaller buffer size; let cross_fade_apply() do the memcpy().
2008-09-29 17:25:08 +02:00
Max Kellermann
6e21e24cae audio_output: added method pause()
pause() puts the audio output into pause mode: if supported, it may
perform a special action, which keeps the device open, but does not
play anything.  Output plugins like "shout" might want to play silence
during pause, so their clients won't be disconnected.  Plugins which
do not support pausing will simply be closed, and have to be reopened
when unpaused.

This pach includes an implementation for the shout plugin, which
sends silence chunks.
2008-09-29 16:43:55 +02:00
Max Kellermann
c13e8b5146 audio_output: added function audio_output_is_pending()
The function audio_output_is_pending() returns whether there is a
pending command.  This is useful for output plugins as a break
condition for longer loops.
2008-09-29 16:40:07 +02:00
Max Kellermann
de7cda1d6e use C99 struct initializers
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.
2008-09-29 15:55:17 +02:00
Max Kellermann
21d3d300fd decoder: renamed plugin methods
Why have a "_func" prefix on all method names?  Also don't typedef the
methods, there is no advantage in that.
2008-09-29 15:54:27 +02:00
Max Kellermann
a7651b9d30 assume stdint.h and stddef.h are available
Since we use a C99 compiler now, we can assert that the C99 standard
headers are available, no need for complicated compile time checks.
Kill mpd_types.h.
2008-09-29 15:53:53 +02:00
Max Kellermann
35d519625d song: converted "type" to enum
Having an enum type is much nicer than an anonymous integer plus CPP
macros.  Note that the old code didn't save any space by declaring the
variable 8 bit, due to padding.
2008-09-29 15:52:30 +02:00
Max Kellermann
e8e9438255 removed union const_hack
The union const_hack is only used at one place in the shout plugin.
Remove its global type declaration.
2008-09-29 15:51:31 +02:00
Max Kellermann
226d52b36f switch to C99 types, part II
Do full C99 integer type conversion in all modules which were not
touched by Eric's merged patch.
2008-09-29 15:49:29 +02:00
Eric Wong
0352766dca Switch to C99 types (retaining compat with old compilers)
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.
2008-09-29 13:29:33 +02:00
Eric Wong
a4019f7d21 allow searching for albums with an empty tag
tfing wrote:
> I have quite some files with an empty album tag as they do not come
> from a particular album.
>
> If I want to look for those files and browse them, this happens:
> :: nc localhost 6600
> OK MPD 0.12.0
> find album ""
> ACK [2@0] {find} too few arguments for "find"
>
> I'd like to be able to browse those files in a client like gmpc.
> So these 2 items would have to be developed:
> - list album should report that some files have an empty tag
> - it should be possible to search for an empty tag with the find command

Patch-by: Marc Pavot
ref: http://musicpd.org/mantis/view.php?id=464
2008-09-29 13:18:49 +02:00
Eric Wong
5f0ed72c48 command: don't clobber next list value when preparsing
This only breaks "update" under list command mode and
no other commands.  This can be done more optimally
without the extra heap allocation via xstrdup(); but is
uncommon enough to not matter.
2008-09-29 13:18:35 +02:00
Eric Wong
11245dc119 directory: isRootDirectory() is a one-liner
Improving the signal to noise ratio...
2008-09-29 13:18:27 +02:00
Eric Wong
da79498afd directory: writeDirectoryInfo propagates errors
If a write failed, it's a good sign subsequent writes will fail,
too, so propgate errors all the way up the stack.
2008-09-29 13:17:52 +02:00
Eric Wong
4e15e292e0 directory: make it clear that DIRECTORY_MTIME is deprecated
A long time ago in an mpd far away...
2008-09-29 13:17:48 +02:00
Eric Wong
a0364d38d3 directory: remove "Mp3" references
MPD has supported more audio formats than just MP3
for over five years...
2008-09-29 13:17:42 +02:00
Eric Wong
9819890f1d playlist: deleteASongFromPlaylist takes a const Song *
We don't change the song pointer there, either.
2008-09-29 13:17:37 +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
71b332601a directory: remove shortname arguments everywhere
It was a huge confusing mess of parameter passing around
and around.  Add a few extra assertions to ensure we're
handling parent/child relationships properly.
2008-09-29 13:17:23 +02:00
Eric Wong
8bb96d46e8 path: add mpd_basename() function
This is like basename(3) but with predictable semantics independent
of C library or build options used.  This is also much more strict
and does not account for trailing slashes (mpd should never deal with
trailing slashes on internal functions).
2008-09-29 13:16:48 +02:00
Eric Wong
5c516b8421 directory.h: remove directory_sigChldHandler decl
We no longer fork for directory updates, so we
no longer have children to reap.
2008-09-29 13:16:43 +02:00
Eric Wong
3b8bc33a04 directory: replace DirectoryList with dirvec
Small memory reduction compared to songvec since most users have
much fewer dirs than songs, but still nice to have.
2008-09-29 13:11:40 +02:00
Eric Wong
029f607e15 directory: remove unused CPP defines
We no longer for for updates
2008-09-29 12:17:20 +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
5ec578119f directory.c: kill unnecessary includes 2008-09-29 12:16:57 +02:00
Eric Wong
52a0ea2dc5 directory: update playlist version if updated
If we updated the mpd metadata database; then there's a chance
some of those songs in the playlist will have updated metadata.
So be on the safe side and increment the playlist version number
if _any_ song changed (this is how all released versions of mpd
did it, too).

This bug was introduced recently when making "update" threaded.

Thanks to stonecrest for the bug report.
2008-09-29 12:15:16 +02:00
Max Kellermann
88aaa6b759 pcm_utils: added pcm_range()
Make the code more readable by moving the range checks to pcm_range().
gcc does quite a good job at optimizing it: the resulting binary is
exactly the same, although it contains a parametrized shift instead of
hard-coded boundaries.
2008-09-28 18:37:43 +02:00
Max Kellermann
5b5e46f5ef pcm_utils: added inline function pcm_dither()
Merge some code into an inline function, so we can optimize it later
only once.
2008-09-28 18:35:42 +02:00
Max Kellermann
75cba9343e output: fix the "outputenabled" value
Patch 9a5b5998 broke the "outputenabled" value of the "outputs"
response.  Make it print "1" if the output is enabled, "0" otherwise.
2008-09-28 18:34:10 +02:00
Max Kellermann
58554e14f9 notify: protect notify->pending with the mutex
There was a known deadlocking bug in the notify library: when the
other thread set notify->pending after the according check in
notify_wait(), the latter thread was deadlocked.  Resolve this by
synchronizing all accesses to notify->pending with the notify object's
mutex.  Since notify_signal_sync() was never used, we can remove it.
As a consequence, we don't need notify_enter() and notify_leave()
anymore; eliminate them, too.
2008-09-26 09:57:11 +02:00
Max Kellermann
323e86489f song: removed type SongList
SongList has been superseded by struct songvec.
2008-09-26 09:54:25 +02:00
Max Kellermann
e2a12deead audio_output: workaround for deadlock
During debugging, I found a deadlock between flushAudioBuffer() and
the audio_output_task(): audio_output_task() didn't notice that there
is a command, and flushAudioBuffer() waited forever in notify_wait().
I am not sure yet what is the real cause; work around this for now by
waking up non-finished audio outputs in every iteration.
2008-09-26 07:12:29 +02:00
Max Kellermann
05f66e04a4 update: send proper response to the client
Due to a merge error, I broke the function handleUpdate().  It did not
do anything for the global update, and it did not send a proper
response to the client.  This patch fixes both bugs.
2008-09-25 22:46:03 +02:00
Max Kellermann
9a5b599883 output: removed DEVICE_ON, DEVICE_OFF
To check whether a device is really on or off, we should rather check
audio_output.open, instead of managing another variable.  Wrap
audio_output.open in the inline function audio_output_is_open() and
use it instead of DEVICE_ON and DEVICE_OFF.
2008-09-24 07:25:07 +02:00
Max Kellermann
2b782b82ea output: semi-asynchronous playback
Send an output buffer to all output plugins at the same time, instead
of waiting for each of them separately.  Make several functions
non-blocking, and introduce the new function audio_output_wait_all()
to synchronize with all audio output threads.
2008-09-24 07:23:19 +02:00
Max Kellermann
6bbea44e91 output: call send_tag() only if device is on
Why send tags to a device which isn't enabled?
2008-09-24 07:21:58 +02:00
Max Kellermann
5cf6213344 output: document the audio_output_plugin methods 2008-09-24 07:21:51 +02:00
Max Kellermann
08352184ac output: document the audio_output elements 2008-09-24 07:21:46 +02:00
Max Kellermann
acc4a0ba2d output: make "struct audio_output" opaque for output plugins
We have eliminated direct accesses to the audio_output struct from
the all output plugins.  Make it opaque for them, and move its real
declaration to output_internal.h, similar to decoder_internal.h.

Pass the opaque structure to plugin.init() only, which will return the
plugin's data pointer on success, and NULL on failure.  This data
pointer will be passed to all other methods instead of the
audio_output struct.
2008-09-24 07:20:55 +02:00
Max Kellermann
63fb1efb5c output: added audio_output_closed()
The JACK output plugin needs to reset its "opened" flag when the JACK
server fails.  To prevent it from accessing the audio_output struct
directly introduce the API function audio_output_closed().
2008-09-24 07:20:37 +02:00
Max Kellermann
3be5db0430 output: added audio_output_get_name()
Reduce direct accesses to the audio_output struct from the plugins:
this time, eliminate all accesses to audio_output.name.  The name is
required by some plugins for log messages.
2008-09-24 07:20:37 +02:00
Max Kellermann
2403d32a50 output: set audio_output->open=1 in audio_output_task()
Since the output plugin returns a value indicating success or error,
we can have the output core code assign the "open" flag.
2008-09-24 07:20:36 +02:00
Max Kellermann
3cae6856b8 output: pass audio_format to plugin.init() and plugin.open()
Pass the globally configured audio_format as a const pointer to
plugin.init().  plugin.open() gets a writable pointer which contains
the audio_format requested by the plugin.  Its initial value is either
the configured audio_format or the input file's audio_format.
2008-09-24 07:20:36 +02:00
Max Kellermann
d32f49a90b output: one thread per audio output
To keep I/O nastiness and latencies away from the core, move the audio
output code to a separate thread, one per output.  The thread is
created on demand, and currently runs until mpd exits.
2008-09-24 07:20:26 +02:00
Max Kellermann
8f4ebf0caf notify: added macro NOTIFY_INITIALIZER
With the macro NOTIFY_INITIALIZER, you can statically initialize a
notify object.
2008-09-24 07:16:59 +02:00
Max Kellermann
a0272c2d61 notify: added notify_deinit()
Destroy the mutex when it is not used anymore.
2008-09-24 07:14:11 +02:00
Max Kellermann
ee1d723ad7 notify: make notify_init() failures fatal
When a mutex cannot be created, there must be something very wrong.
Induce panic and abort MPD in this case.
2008-09-24 07:14:03 +02:00
Max Kellermann
770b140534 notify: declare "struct notify"
"struct notify" is the same as the "Notify" typedef.  It can be
forward-declared and has a lower case name.
2008-09-24 07:05:43 +02:00
Max Kellermann
ad92d9a894 command: fix command "addid"
With patch 8d2830b3, I broke "addid": it did not return the id of the
new song, because of a typo in the return condition (== instead of
!=).
2008-09-23 23:59:55 +02:00
Max Kellermann
d42959c5ce flac: removed FlacData.chunk_length
chunk_length can be converted to a local variable, because it is
always reset to 0 after it was used.
2008-09-23 23:59:55 +02:00
Max Kellermann
0c934f9d36 flac: merged flacSendChunk() into flac_common_write()
Since flacSendChunk() is a trivial function and is only used in one
location, move the code there.  The advantage is that calling
decoder_data() directly returns the decoder_command value, so we can
eliminate one decoder_get_command() call.
2008-09-23 23:59:55 +02:00
Max Kellermann
eeb3011070 flac: removed generic sample size support
Support for bit rates except 16 bits (and 8 bits on little endian) has
always been broken.  Since we added optimized functions for 8, 16,
24/32 bits, we can remove the generic flac_convert() function.
Instead of removing it, convert it to a wrapper function for
flac_convert_*().
2008-09-23 23:59:55 +02:00
Max Kellermann
19971be307 flac: added special functions for 8 and 32 bit
Same optimization for 8 and 32 bit files, like the previous patch for
16 bit.  Along the way, this patch adds 24 bit FLAC support!
2008-09-23 23:59:55 +02:00
Max Kellermann
8c2bde70b0 flac: added optimized converter for 16 bit
flac_convert_16() runs a lot faster than the generic (and quite buggy)
function flac_convert().  flac_convert_16() is only used for
non-stereo files, since there is already flac_convert_stereo16().
2008-09-23 23:59:55 +02:00
Max Kellermann
7486c15088 flac: use signed integers in flac_convert_stereo16()
By mistake, I casted the sample value to uint16_t, which is wrong.
This patch simplifies the code by using a int16_t pointer instead of
casting to int16_t* every time.
2008-09-23 23:59:54 +02:00
Max Kellermann
8bcbe90b25 flac: moved code from flacWrite() to _flac_common.c
There is still a lot of duplicated code in flac_plugin.c and
oggflac_plugin.c.  Move code from flac_plugin.c to _flac_common.c, and
use the new function flac_common_write() also in oggflac_plugin.c,
porting lots of optimizations over to it.
2008-09-23 23:59:54 +02:00
Max Kellermann
aac5f42698 flac: assume the buffer is empty in flacWrite() II
The previous patch on this topic was incomplete: it still added
data->chunk_length when calling flac_convert().  Remove this, too.
2008-09-23 23:59:54 +02:00
Max Kellermann
128d8c7c15 audio_format: added audio_format_sample_size()
The inline function audio_format_sample_size() calculates how many
bytes each sample consumes.  This function already takes into account
that 24 bit samples are 4 bytes long, not 3.
2008-09-23 23:59:54 +02:00
Eric Wong
e4f5d6bdf4 alsa: re-enable-nonblocking, but sleep if busy
Instead of letting ALSA block for us (and potentially allowing
something stupid on certain hardware or drivers), we do the
sleeping ourselves.  We calculate the sleep to be a fraction of
period_time to avoid oversleeping (and thus audible skipping).
2008-09-23 23:59:54 +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
74b34f7b61 directory: fix leak introduced with threaded update
Use freeList() instead of free() to free all elements in
the list.
2008-09-23 22:38:39 +02:00
Eric Wong
260e1a9037 Remove EINTR checking for open(2)
open(2) should only interrupt on "slow" devices, afaik...

[mk: still using fopen()]
2008-09-23 22:38:36 +02:00
Eric Wong
5cc5c37856 directory: don't leak file handles if we get a corrupt db 2008-09-23 22:37:40 +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
3f0ae13c4b directory: update do its work inside a thread
A lot of the preparation was needed (and done in previous
months) in making update thread-safe, but here it is.

This was the first thing I made work inside a thread when I
started mpd-uclinux many years ago, and also the last thing I've
done in mainline mpd to work inside a thread, go figure.
2008-09-23 22:37:18 +02:00
Max Kellermann
0f0ac43b8f directory: use enum update_return for return values II
Converted some more functions and their callers to enum update_return.
2008-09-23 22:36:00 +02:00
Eric Wong
986c2f134d directory: use enum update_return for return values
This way we avoid having to document -1, 0, 1
2008-09-23 20:49:05 +02:00
Eric Wong
cfc2dd3e94 Don't try to prune unless we're updating
Pruning is very expensive and we won't need it in the future
anyways.  This brings startup back to previous speeds (before
songvec changes).
2008-09-23 20:48:51 +02:00
Eric Wong
cce2f93de7 workaround race condition on updates with broken signal blocking
pthreads with our existing signal blocking/handling is broken,
for now just sleep a bit in the child to prevent the CHLD handler
from being called too early.  Also, improve error reporting when
handling SIGCHLD by storing the status to be called in the main
task (which can be logged, since we can't do logging inside the
sig handler).
2008-09-23 20:48:44 +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
Eric Wong
afe6ce7210 directory: remove unused updateMp3Directory() function
It hasn't been used in many years

  commit 3a89afdd80
  Author: Warren Dukes <warren.dukes@gmail.com>
  Date:   Sat Nov 20 20:28:32 2004 +0000

      remove --update-db option

      (SVN r2719)
2008-09-23 20:48:33 +02:00
Eric Wong
27fad52c6b start using prefixcmp()
LOC reduction and less noise makes things easier for
tired old folks to follow.
2008-09-23 20:48:12 +02:00
Eric Wong
f5df13f853 Add prefixcmp() (stol^H^H^H^Hborrowed from git)
This allows us to avoid the nasty repetition in strncmp(foo,
bar, strlen(foo)).  We'll miss out on the compiler optimizing
strlen() into sizeof() - 1 for string literals for this; but we
don't use this it for performance-critical functions anyways...
2008-09-23 20:48:08 +02:00
Eric Wong
15b25ad174 volume: oops, only #include <alloca.h> if OSS is enabled 2008-09-23 20:48:04 +02:00
Eric Wong
9f441f2538 oss: avoid heap allocations when configuring mixer
Noticed-by: Courtney Cavin
2008-09-23 20:47:53 +02:00
Eric Wong
d095d52ed4 Directory: don't allocate stat information dynamically
This should save a few thousand ops.  Not worth it to malloc
for such a small (3-words on 32-bit ARM and x86) structures.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2008-09-23 20:47:45 +02:00
Eric Wong
3263dbe517 mp3: fix long line, I can't read past 80 cols 2008-09-23 20:47:40 +02:00
Max Kellermann
7613688575 main_notify: removed assertion in wakeup_main_task()
It is legal to call wakeup_main_task() from within the main thread,
e.g. from within a signal handler.  Remove the assertion.
2008-09-23 20:47:32 +02:00
Max Kellermann
1db88364bb main_notify: use init_async_pipe()
Remove duplicated code.
2008-09-23 20:47:31 +02:00
Max Kellermann
913028a780 mp3: fix buffer overflow when max_frames is too large
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.
2008-09-17 22:30:34 +02:00
Max Kellermann
ef0e2fdc1b client: check expired after client_process_line()
The assertion on "!client_is_expired(client)" was wrong, because
writing the command response may cause the client to become expired.
Replace that assertion with a check.
2008-09-17 22:02:13 +02:00
Terry
79a14c9a10 mp4: fix potential integer overflow bug in the mp4_decode() function
A crafted mp4 file could cause an integer overflow in mp4_decode
function in src/inputPlugins/mp4_plugin.c.  mp4ff_num_samples()
function returns some tainted value. sizeof(float) * numSamples is an
integer overflow operation if numSamples is too huge, so xmalloc will
allocate a small memory region.  I constructe a mp4 file, and use
faad2 to open the file. mp4ff_num_samples() returns -1. So I think mpd
bears from the same problem.
2008-09-12 17:06:04 +02:00
Max Kellermann
89c8b19a8c shout: don't write empty buffers
Add a check to write_page() which checks if there is actually data.
Don't bother to call shout_send() if there is not.
2008-09-12 16:42:14 +02:00
Max Kellermann
42f6177199 shout: removed clear_shout_buffer()
The function is trivial, without a benefit.  Also don't initialize
buf.data[0], this is not a null terminated string.
2008-09-12 16:41:22 +02:00
Max Kellermann
265b8fffb2 shout: make the shout_buffer static
Since the buffer size is known at compile time, we can save an
indirection by declaring it as a char array instead of a pointer.
That saves an extra allocation, and we can calculate with the
compile-time constant sizeof(data) instead of the attribute "max_len".
2008-09-12 16:41:20 +02:00
Max Kellermann
ebd194998a shout: constant plugin declarations
Declare both shout plugins "const", since they will never change, once
initialized at compile time.
2008-09-12 16:39:53 +02:00
Max Kellermann
d9f170b5db shout: static encoder plugin list
Shout encoder plugins are known at compile time.  There is no reason
to use a complex data structure as "List" to manage them at runtime -
just put the pointers into a static array.
2008-09-12 16:39:51 +02:00
Max Kellermann
a84de9b010 shout: removed typedefs on structs and plugin methods
Don't typedef the structs at all.  It is easier to forward-declare
this way.

Don't typedef methods.  They are used exactly once, a few lines below.
2008-09-12 16:38:54 +02:00
Eric Wollesen
5f8eebd122 shout: added mp3 encoder
[mk: moved this patch after "Refactor and cleanup of shout Ogg and MP3
audio outputs".  The original commit message follows, although it is
outdated:]

Creation of shout_mp3 audio output plugin. Basically I just copied the
existing shout plugin and replaced ogg with lame. Uses lame for mp3
encoding. Next step is to pull common functionality out of each shout
plugin and share it between them.

Configuration options for "shout_mp3" are the same as for "shout".
2008-09-12 16:05:23 +02:00
Eric Wollesen
4970c42c86 shout: introduce pluggable encoder API
I've perhaps gone a bit overboard, but here's the current rundown:

Both Ogg and MP3 use the "shout" audio output plugin.  The shout audio
output plugin itself has two new plugins, one for the Ogg encoder,
and another for the MP3 (LAME) encoder.

Configuration for an Ogg stream doesn't change.  For an MP3 stream,
configuration is the same as Ogg, with two exceptions.  First, you must
specify the optional "encoding" parameter, which should be set to "mp3".
See mpd.conf(5) for more details.  Second, the "quality" parameter is
reversed for LAME, such that 1 is high quality for LAME, whereas 10 is
high quality for Ogg.

I've decomposed the code so that all libshout related operations
are done in audioOutput_shout.c, all Ogg specific functions are in
audioOutput_shout_ogg.c, and of course then all LAME specific functions
are handled in audioOutput_shout_mp3.c.

To develop encoder plugins for the shout audio output plugin, I basically
just mimicked the plugin system used for audio outputs.  This might be
overkill, but hopefully if anyone ever wants to support some other sort
of stream, like maybe AAC, FLAC, or WMA (hey it could happen), they will
hopefully be all set.

The Ogg encoder is slightly less optimal under this configuration.
It used to send shout data directly out of its ogg_page structures.  Now,
in the interest of encapsulation, it copies the data from its ogg_page
structures into a buffer provided by the shout audio output plugin (see
audioOutput_shout_ogg.c, line 77.)  I suspect the performance impact
is negligible.

As for metadata, I'm pretty sure they'll both work.  I wrote up a test
scaffold that would create a fake tag, and tell the plugin to send it
out to the stream every few seconds.  It seemed to work fine.  Of course,
if something does break, I'll be glad to fix it.

Lastly, I've renamed lots of things into snake_case, in keeping with
normalperson's wishes in that regard.

[mk: moved the MP3 patch after this one.  Splitted this patch into
several parts; the others were already applied before this one.  Fixed
a bunch GCC warnings and wrong whitespace modifications.  Made it
compile with mpd-mk by adapting to its prototypes]
2008-09-12 16:04:40 +02:00
Eric Wollesen
43ee3c3b36 shout: send shout metadata
Support sending metadata to a shout server using shout_metadata_new()
and shout_metadata_add().  The Ogg Vorbis encoder does not support
this currently.

[mk: this patch was separated from Eric's patch "Refactor and cleanup
of shout Ogg and MP3 audio outputs", I added a description]
2008-09-12 16:00:01 +02:00
Max Kellermann
1333c39244 shout: added struct _ogg_vorbis_data
Preparing the merge of Eric Wollesen's patch "Refactor and cleanup of
shout Ogg and MP3 audio outputs": we declare one of the struct types
here, to make the merge smoother.
2008-09-12 15:59:55 +02:00
Eric Wollesen
f482f83eb8 shout: added shout_buffer
The Ogg encoder is slightly less optimal under this configuration.  It
used to send shout data directly out of its ogg_page structures.  Now,
in the interest of encapsulation, it copies the data from its ogg_page
structures into a buffer provided by the shout audio output plugin
(see audioOutput_shout_ogg.c, line 77.)  I suspect the performance
impact is negligible.

[mk: this patch and its description was separated from Eric's patch
"Refactor and cleanup of shout Ogg and MP3 audio outputs"]
2008-09-12 15:57:43 +02:00
Max Kellermann
fcac05a207 shout: moved code to audioOutput_shout_ogg.c
Begin dividing audioOutput_shout.c: move everything OGG Vorbis related
to audioOutput_shout_ogg.c.  The header audioOutput_shout.h has to
keep its dependency on vorbis/vorbisenc.h, because it needs the vorbis
encoder types.

For this patch, we have to export several internal functions with
generic names to the ABI; these will be removed later when the encoder
plugin patches are merged.
2008-09-12 15:02:57 +02:00
Max Kellermann
7d3ca9c1ff shout: moved declarations to audioOutput_shout.h
Prepare the split of the shout plugin into multiple sources: move
all important declarations to audioOutput_shout.h.
2008-09-12 14:59:53 +02:00
Max Kellermann
b0884ddd81 shout: removed commented code
Remove unused code which is in comments.  Remove that comment about
"stolen code", since the plugin has changed much, and it isn't obvious
which parts are derived.
2008-09-12 14:58:42 +02:00
Max Kellermann
0eb4038dcb shout: no CamelCase 2008-09-12 14:01:45 +02:00
Max Kellermann
85d952c58b output: copy reqAudioFormat to outAudioFormat only if not yet open
If the output device is already open, it may have modified
outAudioFormat; in this case, outAudioFormat is still valid, and does
not need an overwrite.
2008-09-11 07:50:20 +02:00