Commit Graph

383 Commits

Author SHA1 Message Date
Max Kellermann
375fd5ed4c output/jack: added option "server_name" 2009-11-07 17:26:21 +01:00
Max Kellermann
c9f726048c output/httpd: moved code to httpd_output_bind() 2009-11-07 16:52:44 +01:00
Max Kellermann
41f3f12709 output/jack: free source port names on exit
Make valgrind happy.
2009-11-07 15:17:48 +01:00
Max Kellermann
ba34d48cf0 output/jack: dynamic source port list
Same as the previous patch: create up to 16 configured source ports.
The plugin tries to do its best at guessing the right combination for
the given input file, the number of source and destination ports.
2009-11-06 18:58:35 +01:00
Max Kellermann
2598dd5109 output/jack: dynamic destination port list
Support up to 16 configured destination ports, that should really be
enough for everybody.
2009-11-06 18:55:26 +01:00
Max Kellermann
fac6e9ecdb output/jack: renamed option "ports" to "destination_ports"
Be more clear which kind of port should be configured here.
2009-11-06 01:54:58 +01:00
Max Kellermann
dbbead6e72 output/jack: renamed "output ports" to "destination ports"
Use the same name as in the libjack API documentation.
2009-11-06 01:35:19 +01:00
Max Kellermann
945287358b output/httpd: bind port when output is enabled
Implement the methods enable() and disable().  Bind the HTTP port in
the enable() method, but reject all incoming connections until the
output is opened.
2009-11-05 23:47:29 +01:00
Max Kellermann
979cd5a768 output/jack: support mono input
When MPD plays a mono song (audio_format.channel==1), connect only one
source port to both destination ports.
2009-11-05 20:02:04 +01:00
Max Kellermann
a68da8a475 output/jack: clear ring buffers before activating
After playback has stopped, the ring buffers may still contain
samples.  These will be played when playback is started the next
time.  We should clear the buffers each time.
2009-11-05 20:01:50 +01:00
Max Kellermann
2a9685cb3a output/jack: use jack_client_open() instead of jack_client_new()
jack_client_new() is deprecated.  This requires libjack 0.100
(released nearly 5 years ago).  We havn't been testing older libjack
versions anyway.

As a side effect, there is the new option "autostart".
2009-11-05 20:01:18 +01:00
Max Kellermann
88abfc0d0f output/jack: added option "client_name"
Instead of using MPD's audio output name (setting "name"), use a
separate configuration option.  Change the default to "Music Player
Daemon".
2009-11-05 19:55:00 +01:00
Jeffrey Middleton
4dc25d3908 alsa_plugin.c: workaround snd_pcm_drain bug
Reintroduce a fix from commit 52a0653 (Warren Dukes): "don't call
snd_pcm_drain unless we're already in the RUNNING state". This prevents
ALSA with dmix from sometimes hanging when snd_pcm_drain is called, e.g.
when moving from one song to the next (as in mantis issue 2634).
2009-11-02 23:58:15 -06:00
Viliam Mateicka
bb5acc939f httpd: add config option to limit number of clients 2009-10-29 22:38:18 +01:00
Max Kellermann
1403172ef3 output_plugin: added method "drain"
drain() is the opposite of cancel(): it waits until all data in the
buffer has finished playing.  Instead of implicitly draining in the
close() method like the ALSA plugin has been doing it forever, let the
output thread decide whether to drain or to cancel.
2009-10-29 15:59:40 +01:00
Max Kellermann
f74ee1a352 output/alsa: don't recover on CANCEL
The recovery is for nothing if we get CLOSE afterwards.  Let's not
recover in the cancel() method, and let the next play() call sort it
out.
2009-10-29 15:59:35 +01:00
Max Kellermann
82af161210 output/pulse: initialize pulse_output.mixer
This variable was uninitialized and led to crashes.
2009-10-29 15:58:18 +01:00
Alam Arias
83a9cf74fb include pulse/version.h for PA_CHECK_VERSION 2009-10-27 07:46:53 +01:00
Max Kellermann
ac830468bf output/jack: implement methods enable()/disable()
Don't connect to JACK before MPD has daemonized.
2009-10-23 10:56:25 +02:00
Max Kellermann
7547b1170b output/pulse: implement methods enable()/disable()
Don't connect to PulseAudio before MPD has daemonized.
2009-10-23 10:56:16 +02:00
Max Kellermann
e53ca368a5 output_plugin: added methods enable() and disable()
With these methods, an output plugin can allocate some global
resources only if it is actually enabled.  The method enable() is
called after daemonization, which allows for more sophisticated
resource allocation during that method.
2009-10-23 10:55:52 +02:00
Max Kellermann
c426a0bc5c output/pulse: call mixer on state changes
Don't let the mixer plugin "override" the libpulse callbacks.
Instead, add a "mixer" attribute to the pulse_output struct, and call
the mixer on all interesting events.
2009-10-23 10:33:26 +02:00
Max Kellermann
80ac82c8fb output/fifo: renamed source to fifo_output_plugin.c 2009-10-22 19:23:30 +02:00
Max Kellermann
9526fdbe73 audio_format: wildcards allowed in audio_format configuration
An asterisk means that this attribute should not be enforced, and
stays whatever it used to be.  This way, some configuration values
work like masks.
2009-10-21 23:01:04 +02:00
Max Kellermann
83844ec239 output/jack: make ringbuffer_size a size_t 2009-10-21 21:39:26 +02:00
Max Kellermann
1bfd25be35 output/jack: connect to server on MPD startup
.. and keep up the JACK connection while MPD runs.  Allocate the ring
buffers on the first open, and free them at MPD exit.
2009-10-21 21:37:11 +02:00
Max Kellermann
cee216f2dc output/jack: removed the empty "cancel" method
JACK doesn't need cancel() because it won't do much anyway.  Buffers
are small.
2009-10-21 21:01:00 +02:00
Max Kellermann
27c246e8d9 output/jack: renamed parameter "error" to "error_r"
It's a double pointer.
2009-10-21 20:13:39 +02:00
Max Kellermann
1ff39476eb output/jack: implement the "pause" method
Don't disconnect from JACK during pause.
2009-10-21 18:33:05 +02:00
Max Kellermann
acfd9a73bc output/jack: renamed source to jack_output_plugin.c 2009-10-21 18:33:01 +02:00
Max Kellermann
b479a264b6 pulse: code rewrite using the asynchronous libpulse API
This is a complete rewrite of the PulseAudio output plugin.  It uses
the asynchronous API, which gives us more control over everything.
Additionally, it connects to the PulseAudio server on startup, and
keeps this connection up while MPD runs.  During pause, instead of
closing the stream, it enables "cork".
2009-10-21 10:30:42 +02:00
Max Kellermann
097e200a97 mixer/{oss,alsa}: renamed the mixer source files 2009-10-20 21:23:05 +02:00
Max Kellermann
bd28caed3c output/pulse: renamed context to "Music Player Daemon"
This looks nicer in the PulseAudio manager than just "mpd".
2009-10-20 21:07:38 +02:00
Max Kellermann
bc4266bef8 pulse: renamed source files 2009-10-20 21:05:11 +02:00
Max Kellermann
bc629c8a3e pulse: announce "media.role=music"
This allows PulseAudio to do some advanced tweaks.
2009-10-20 21:02:10 +02:00
Max Kellermann
ea616b3ed4 tag: removed the "_ITEM_" suffix from the enum names 2009-10-13 16:12:45 +02:00
Max Kellermann
4390d72b14 configure.ac: require GLib 2.16
Accidently, MPD has been using several GLib 2.16 functions for a
while, and nobody noticed yet.  To simplify the code base, let's bump
the minimum GLib version for MPD to 2.16.  That version is old enough,
and it's reasonable to expect users to have it.
2009-10-13 16:12:43 +02:00
Patrik Weiskircher
32f212cb86 output/osx: fix the OS X 10.6 build
Include CoreServices/CoreServices.h.
2009-09-20 23:30:37 +02:00
Patrik Weiskircher
803a698f98 output/osx: fix the OS X 10.6 build
Include CoreServices/CoreServices.h.
2009-09-20 23:28:07 +02:00
Serge Ziryukin
761771ad24 output/openal: support OpenAL plugin on Mac OS X 2009-09-07 15:52:32 +02:00
Serge Ziryukin
eefef369ea output/openal: fix default device name 2009-09-06 22:22:17 +02:00
Serge Ziryukin
8b6a5d19d0 openal output plugin 2009-09-06 17:34:56 +02:00
Max Kellermann
4a0d4a02a6 output/recorder: new output plugin for recording radio streams
The recorder plugin writes audio played by MPD to a file.  This may be
useful for recording radio streams.

This implementation is incomplete, because support for tags is
missing, and MPD should be able to record each track to a different
file.
2009-08-24 18:57:06 +02:00
Max Kellermann
f401c1059c Merged release 0.15.2 from branch 'v0.15.x'
Conflicts:

	NEWS
	configure.ac
2009-08-15 21:18:38 +02:00
Max Kellermann
f38ce5408b output/shout: minimize the unpause latency
During the pause loop, manually sleep for 500ms if shout_delay()
returns a value greater than that.  Don't exhaust libshout's buffer.
2009-08-14 11:52:36 +02:00
David Woodhouse
49ede85827 Support wrong-endian ALSA output 2009-07-19 17:15:35 +01:00
Max Kellermann
58dd6eee5d output/httpd: removed duplicate sys/types.h include
The first patch by Patrick didn't work, because his "#ifdef HAVE_OSX"
line would have required config.h.
2009-07-14 14:23:44 +02:00
Max Kellermann
64ca94c910 output/httpd: include sys/types.h
On Mac OS X, the httpd plugin cannot be compiled, because OS X's
system headers do nto include sys/types.h, although they use
u_int32_t.
2009-07-06 14:40:06 +02:00
Max Kellermann
ddc2694419 conf: eliminated CamelCase
Renamed all remaining CamelCase functions.
2009-06-03 06:55:04 +02:00
Patrik Weiskircher
7e678d2ba9 latest git, httpd_output_plugin compile fix, mac os x
Hello,

While compiling latest git I've received a compile error in the
httpd_output_plugin.
Small patch attached.

Patrik
2009-05-10 21:15:53 +02:00
Max Kellermann
4818d38677 httpd_output: save the page generated by encoder_tag()
Flush the encoder before calling encoder_tag().  The first page
generated by the encoder after sending the tag will be the new
"header" page, which is sent to all HTTP clients when they connect.
This is a little bit specific to the vorbis encoder, but there are no
other encoders which support tags (yet).
2009-05-05 22:51:17 +02:00
Max Kellermann
e55e560d4e httpd_output: moved code to httpd_output_encoder_to_clients()
Moved some code from httpd_output_encode_and_play() into separate
functions httpd_output_broadcast_page() and
httpd_output_encoder_to_clients().
2009-05-05 22:43:28 +02:00
Max Kellermann
9080797025 httpd_output: disable Icy-Metadata when encoder supports tags
There's no reason to send both encoder tags and Icy-Metadata to the
client.  Let's disable Icy-Metadata when the encoder supports embedded
tags.
2009-05-05 22:41:36 +02:00
Max Kellermann
795569208a httpd_output: assert that tag!=NULL
In the tag() method, MPD guarantees that it does not pass tag==NULL.
Converted the runtime check to an assertion.
2009-05-05 22:36:44 +02:00
Max Kellermann
85658965c9 alsa_output: don't use atexit() to clean up the ALSA library
Call snd_config_update_free_global() manually in our finish() method,
don't use atexit().
2009-04-21 22:47:12 +02:00
Max Kellermann
9919704be3 httpd: use C99 "bool" instead of GLib's gboolean
Plain "bool" consumes only one byte instead of four.
2009-04-13 19:39:19 +02:00
Max Kellermann
3f81f5b476 httpd: use g_ascii_strncasecmp() to compare headers
In HTTP, header names are case insensitive.
2009-04-13 19:39:16 +02:00
Hagen Schink
92ba754fc6 Implemented basic icy support for the httpd output
[mk: folded with patch "Put icy related functions in extra source
files"; moved icy_server.c from HAVE_CURL to ENABLE_HTTPD_OUTPUT;
removed an unused variable]
2009-04-13 19:35:02 +02:00
Max Kellermann
cd6182862a httpd: don't pass uninitialized page to httpd_client_check_queue()
The httpd_client_check_queue() callback function does not use its
"user_data" argument.  Don't pass any, and fix the gcc warning.
2009-04-01 22:45:21 +02:00
Max Kellermann
52575d1b9d pulse: make configuration strings const
Nobody needs to modify these strings.  We can make them const, and
convert config_dup_block_string() to config_get_block_string().  This
also fixes memory leaks in the pulse mixer.
2009-03-26 19:50:10 +01:00
Max Kellermann
cd4964cdee pulse: don't check config_param!=NULL
The conf.h functions deal well with config_param==NULL and will return
the specified default value then.
2009-03-26 19:50:02 +01:00
Max Kellermann
66a2c5669e output_plugin: replaced output_plugin.get_mixer() with mixer_plugin
The mixer core library is now responsible for creating and managing
the mixer object.  This removes duplicated code from the output
plugins.
2009-03-26 18:23:23 +01:00
Jeffrey Middleton
91f3370913 httpd: fixed encoder plugin check
Check if encoder_plugin!=NULL, not encoder_plugin_get (which is a
function).
2009-03-17 06:52:23 +01:00
Max Kellermann
bba127a392 solaris: new audio output plugin for Solaris /dev/audio 2009-03-16 09:55:10 +01:00
Max Kellermann
870706519a httpd_output: check client->write_source_id in handler
Due to a race condition, httpd_client_out_event() could be called even
when its GLib event source was already removed.  Check that case.
2009-03-15 19:06:14 +01:00
Max Kellermann
58844aabac httpd_output: clear the client's page queue on cancel
When the httpd output is cancelled, it freed all pages, but didn't
remove them from the queue.  Call g_queue_clear() and remove the
write source id.
2009-03-15 19:06:10 +01:00
Max Kellermann
e62580db0b httpd: new output plugin to replace "shout"
Let's get rid of the "shout" plugin, and the awfully complicated
icecast daemon setup!  MPD can do better if it's doing the HTTP server
stuff on its own.  This new plugin has several advantages:

- easier to set up - only one daemon, no password settings, no mount
  settings
- MPD controls the encoder and thus already knows the packet
  boundaries - icecast has to parse them
- MPD doesn't bother to encode data while nobody is listening

This implementation is very experimental (no header parsing, ignores
request URI, no icy-metadata, ...).  It should be able to suport
several encoders in parallel in the future (with different bit rates,
different codec, ...), to make MPD the perfect streaming server.  Once
MPD gets multi-player support, we can even mount several different
radio stations on one server.
2009-03-15 03:32:34 +01:00
Max Kellermann
b488355df8 mixer_api: moved mixer_plugin imports to mixer_list.h
This patch allows the output plugins to import only mixer_list.h,
instead of the full mixer_api.h (which would expose internal
structures).
2009-03-14 11:36:59 +01:00
Max Kellermann
a5017a2d7c mixer_api: moved functions to mixer_control.c
mixer_control.h should provide the functions needed to manipulate a
mixer, without exposing the internal mixer API (which is provided by
mixer_api.h).
2009-03-14 11:36:50 +01:00
Avuton Olrich
0aee49bdf8 all: Update copyright header.
This updates the copyright header to all be the same, which is
pretty much an update of where to mail request for a copy of the GPL
and the years of the MPD project. This also puts all committers under
'The Music Player Project' umbrella. These entries should go
individually in the AUTHORS file, for consistancy.
2009-03-13 11:51:55 -07:00
Max Kellermann
cff29f5e86 alsa: use snd_pcm_sframes_t instead of int
snd_pcm_writei() returns the type snd_pcm_sframes_t, not int.  Use the
correct variable type.
2009-03-10 21:31:13 +01:00
Max Kellermann
855054fee1 alsa: don't close PCM handle in alsa_recover()
If the PCM handle gets disconnected, don't close and clear it in
alsa_recover().  The MPD core will call alsa_close() anyway.  This
way, we can always assume that alsa_data.pcm is always valid.
2009-03-10 21:25:45 +01:00
Max Kellermann
ab656a52da alsa: determine buffer_time if not already known
This patch fixes a theoretical (but practically impossible) flaw: the
variable "buffer_time" may be uninitialized when it is used.
Initialize the variable with snd_pcm_hw_params_get_buffer_time().
2009-03-08 04:11:30 +01:00
Max Kellermann
554a34fb95 alsa: better period_time default value for high sample rates
The default values for buffer_time and period_time were both capped by
the hardware limits on practically all chips.  The result was a
period_time which was half as big as the buffer_time.  On some chips,
this led to lots of underruns when using a high sample rate (192 kHz),
because MPD had very little time to send new samples to ALSA.

A period time which is one fourth of the buffer time turned out to be
much better.  If no period_time is configured, see how much
buffer_time the hardware accepts, and try to configure one fourth of
it as period_time, instead of hard-coding the default period_time
value.

This is yet another attempt to provide a solution which is valid for
all sound chips.  Using the SND_PCM_NONBLOCK flag also seemed to solve
the underruns, but put a lot more CPU load to MPD.
2009-03-08 03:55:01 +01:00
David Guibert
21bb10f4bf pulse mixer
This patch introduces the mixer for the pulse output.

Technically speaking, the pulse index is needed to get or set
the volume. You must define callback fonctions to get this index since
the pulse output in mpd is done using the simpe api. The pulse simple api
does not provide the index of the newly defined output.

So callback fonctions are associated to the pulse context.
The list of all the sink input is then retreived.
Then we select the name of the mpd pulse output and control
its volume by its associated index number.

Signed-off-by: Patrice Linel <patnathanael@gmail.com>
Signed-off-by: David Guibert <david.guibert@gmail.com>

[mk: fixed whitespace errors and broke long lines; removed
daemonization changes from main.c]
2009-03-07 15:59:20 +01:00
Max Kellermann
1063c1f2e3 alsa: log period and buffer size
Log the real period and buffer size.  This might be useful when
debugging xruns.  Note that the same information is available in
/proc/asound/card*/pcm*p/sub*/hw_params
2009-03-03 22:19:37 +01:00
Max Kellermann
0f64e658fd alsa: fall back to 32 bit samples if 16 is not supported
There are a few high-end devices (e.g. ICE1724) which cannot even play
16 bit audio.  Try the 32 bit fallback, which we already implemented
for 24 bit.
2009-03-03 09:38:20 +01:00
Max Kellermann
72176db429 alsa: fall back to 32 bit samples if 24 is not supported
Some sound chips/drivers (e.g. Intel HDA) don't support 24 bit
samples, they want to get 32 bit instead.  Now that MPD's PCM library
supports 32 bit, add a 32 bit fallback when 24 bit is not supported.
2009-03-02 16:41:38 +01:00
Max Kellermann
614fe8b341 output: removed duplicate debug messages from plugins
The MPD core logs the audio format of all audio outputs.  Remove the
duplicate message from the plugins.
2009-03-01 10:39:42 +01:00
Michal Nazarewicz
cabbf7ab4a pipe: new audio output plugin which runs a command
[mk: adapted to new output plugin API]
2009-02-28 16:11:59 +01:00
Max Kellermann
75c2029b1c tag: no CamelCase
Renamed numOfItems to num_items.
2009-02-27 09:01:55 +01:00
Max Kellermann
dfea6b7cdd mvp: fixed default device detection
The check "open()!=0" is wrong, you have to write "open()>=0", because
-1 means error, and 0 is a valid file handle.
2009-02-26 22:10:58 +01:00
Max Kellermann
ec926539a3 output_plugin: report errors with GError
Use GLib's GError library for reporting output device failures.

Note that some init() methods don't clean up properly after a failure,
but that's ok for now, because the MPD core will abort anyway.
2009-02-26 22:04:59 +01:00
Max Kellermann
353ae5e558 osx: use OSStatus and GetMacOSStatusCommentString()
The return type of most OS X functions is OSStatus, not int.  We can
get a nice error message from GetMacOSStatusCommentString(), log it.
2009-02-26 22:01:42 +01:00
Max Kellermann
9dc966041d osx: start the audio device in the open() method
Don't call AudioOutputUnitStart() in the play() method, do it after
the device has been opened.  We can eliminate the "started" property
now, because the device is always started when it's open.
2009-02-26 21:40:22 +01:00
Max Kellermann
fb5ca6aa29 osx: removed commented code
We don't need to keep commented code forever.  If we want that
test_default_device() implementation back one day, we'll pick it from
the git history.
2009-02-26 21:33:13 +01:00
Max Kellermann
985ca094f2 osx: no CamelCase
Renamed types, functions, variables.
2009-02-26 21:03:06 +01:00
Max Kellermann
bcc3a9debf shout: use config_get_block_unsigned()
Eliminated manual integer parsing.
2009-02-26 19:34:00 +01:00
Max Kellermann
710a61a3dc pulse: removed pa_simple!=NULL checks
The MPD core guarantees that the audio_output object is always
consistent, and our pa_simple!=NULL checks are superfluous.  Also
don't manually close the device on error in pulse_play(), since the
MPD core does this automatically when the play() method returns 0.
2009-02-26 19:29:06 +01:00
Max Kellermann
4f2ac7ec2c oss: moved code from oss_open() to oss_setup()
Eliminate one label and a bunch of gotos.
2009-02-26 19:18:16 +01:00
Max Kellermann
749d6c7766 oss: convert OSS_STAT_* to an enum
Use C instead of CPP.
2009-02-26 19:18:13 +01:00
Max Kellermann
a0b3f35537 oss: return bool instead of int
Return type of oss_find_supported_param(), oss_can_convert() and
oss_find_unsupported_param() should be bool instead of int.
2009-02-26 19:17:56 +01:00
Max Kellermann
e1f58fdcf5 oss: use unsigned integers
Convert the num_supported and num_unsupported variables from signed to
unsigned.
2009-02-26 19:17:09 +01:00
Max Kellermann
4958a6f56f oss: no CamelCase
Renamed types, functions and variables.
2009-02-26 19:16:33 +01:00
Max Kellermann
a4cf7b7dfd alsa: fall back to 16 bit audio
When the sample format is unknown, fall back to 16 bit samples.
2009-02-25 22:01:32 +01:00
Max Kellermann
4c1fb8278b alsa: moved code from alsa_open() to alsa_setup()
Simplify error handling a bit by moving some code into a separate
function.  This eliminates a good bunch of gotos, but that's not
finished yet.
2009-02-25 22:01:30 +01:00
Max Kellermann
d3409a65b5 mvp: check for reopen errors
When the MVP device has been closed in the cancel() method, and the
play() method attempts to reopen it, check for errors.
2009-02-25 21:57:02 +01:00
Max Kellermann
883e31d55b mvp: moved code to mvp_find_sample_rate()
Moved the table lookup code to a separate function.
2009-02-25 21:56:48 +01:00
Max Kellermann
b4c65cac8c mvp: make the mvp_sample_rates array const
The array must never be modified, it's a constant lookup table.
2009-02-25 21:54:02 +01:00
Max Kellermann
99f535ad77 mvp: fall back to 16 bit audio samples
Looks like the MVP audio output only supports 16 and 24 bit audio
samples.  If MPD generates any other sample formats, force it to use
16 bit.
2009-02-25 21:52:11 +01:00
Max Kellermann
8491f61d6c mvp: fall back to stereo
When the channel count is greater than 2, fall back to stereo sound.
2009-02-25 21:51:39 +01:00
Max Kellermann
6722c508a1 mvp: mvp_set_pcm_params() returns bool
Return true/false instead of 0/-1.  Also check its return value in
mvp_output_open().
2009-02-25 21:51:36 +01:00
Max Kellermann
84ed6d4701 mvp: pass audio_format struct to mvp_set_pcm_params()
Pass a pointer to the audio_format struct instead of 3 separate
integers.
2009-02-25 21:51:32 +01:00
Max Kellermann
57a9e5605b mvp: removed big_endian parameter from mvp_set_pcm_params()
Don't pass the big_endian flag to mvp_set_pcm_params(), do a simple
"G_BYTE_ORDER==G_LITTLE_ENDIAN" instead.
2009-02-25 21:51:13 +01:00
Max Kellermann
d902465375 mvp: use G_N_ELEMENTS(mvp_sample_rates)
Instead of manually calculating the number of elements in the
mvp_sample_rates array, use GLib's convenience macro G_N_ELEMENTS().
2009-02-25 21:50:50 +01:00
Max Kellermann
fff52ac5b9 mvp: no CamelCase
Renamed types, functions and variables.
2009-02-25 21:49:59 +01:00
Max Kellermann
d56ae1e9c2 fifo: return bool values
Return true/false for success/failure instead of returning 0/-1.
2009-02-25 19:53:27 +01:00
Max Kellermann
74af4e4c3d fifo: no CamelCase
Renamed types, functions and variables.
2009-02-25 19:53:24 +01:00
Max Kellermann
ee7cf9c9b8 fifo: removed timer!=NULL checks
The MPD core guarantees that the audio_output object is always
consistent, and our timer!=NULL checks are superfluous.
2009-02-25 19:09:38 +01:00
Max Kellermann
ba4dd651ef ao: no CamelCase
Renamed functions and variables.
2009-02-25 19:08:49 +01:00
Max Kellermann
074d5ae13e ao: removed AoData.device!=NULL checks
The MPD core guarantees that the audio_output object is always in a
consistent state: either open or closed.  When open, it will not call
the open() method again, and when closed, it will not call play().
Removed several checks and the NULL initialization.
2009-02-25 18:48:27 +01:00
Max Kellermann
8a882209c3 ao: removed implementation of method cancel()
The method is empty, and we can simply set the method pointer to NULL
instead.
2009-02-25 18:45:09 +01:00
Max Kellermann
dcd84c19cd output_plugin: don't pass audio_output object to method init()
audio_output_get_name() has been removed, which was the only function
left in output_api.h.  The output plugin doesn't need the audio_output
object at all, remove the parameter from the init() method.
2009-02-25 18:34:02 +01:00
Max Kellermann
0cf4f09e4f output_api: removed audio_output_get_name()
Use config_get_block_string("name") instead of audio_output_get_name().
2009-02-25 17:32:58 +01:00
Max Kellermann
e065c4db33 jack: initialize local variable "space"
Fix a gcc warning, initialize the "space" variable at the beginning of
mpd_jack_play().
2009-02-24 19:06:34 +01:00
Max Kellermann
a4dfab2aee output: pass the music chunk pointer as void*, not char*
The meaning of the chunk depends on the audio format; don't suggest a
specific format by declaring the pointer as "char*", pass "void*"
instead.
2009-02-23 09:34:26 +01:00
Max Kellermann
5a898c15e7 output_api: play() returns a length
The old API required an output plugin to not return until all data
passed to the play() method is consumed.  Some output plugins have to
loop to fulfill that requirement, and may block during that.  Simplify
these, by letting them consume only part of the buffer: make play()
return the length of the consumed data.
2009-02-23 09:29:56 +01:00
Max Kellermann
d50a3d513e shout: removed shout_plugin.h
There are no plugins left which require shout_plugin.h.  Moved the
struct declaration to shout_plugin.c.
2009-02-22 17:52:37 +01:00
Max Kellermann
1c56edd1c8 shout: removed shout_encoder_plugins
This array is empty, and is not used anymore.
2009-02-22 17:51:12 +01:00
Max Kellermann
f6e5c00726 shout: use the new encoder API
Removed shout's encoder plugin API in favor of the new generic encoder
plugin API.
2009-02-22 17:18:28 +01:00
Max Kellermann
e79a82ba3a shout: merged open_shout_conn() into my_shout_open_device()
The method implementation my_shout_open_device() consists of only one
line, the call to open_shout_conn().  Merge both functions into one.
2009-02-22 15:24:41 +01:00
Max Kellermann
cece6c00f4 shout: bool return values instead of int
Return true/false instead of 0/-1.
2009-02-22 15:18:58 +01:00
Max Kellermann
e7131b5da2 utils: use g_usleep() instead of my_usleep()
Now that I've found this nice function in the GLib docs, we can
finally remove our custom sleep function.  Still all those callers of
g_usleep() have to be migrated one day to use events, instead of
regular polling.
2009-02-19 13:33:03 +01:00
Max Kellermann
585f81ece1 output_api: don't include config.h
If an output plugin requires config.h, it should include it directly.
2009-02-16 18:41:30 +01:00
Max Kellermann
37bc31d161 output_plugin: replaced method "control()" with "mixer()"
The output plugin shouldn't know any specifics of the mixer API.  Make
it return the mixer object, and let the caller deal with it.
2009-02-16 01:39:00 +01:00
Max Kellermann
744702f266 shout_mp3: use audio_format_frame_size()
Use audio_format_frame_size() instead of
channels*audio_format_sample_size().
2009-02-10 21:30:28 +01:00
Max Kellermann
b27d9e055b shout: pass void pointer to the encoder
Pass the music chunk as a "const void *" to the encoder, instead of a
"const char *".  Actually, both encoders currently expect 16 bit
samples, passing a 8-bit character is rather pointless.
2009-02-10 21:28:25 +01:00
Max Kellermann
12756c1b55 shout_ogg: moved PCM conversion to a separate function
For simplification, moved the PCM conversion code to
pcm16_to_ogg_buffer().  Work with a int16_t pointer instead of a char
pointer.
2009-02-10 21:25:45 +01:00
Max Kellermann
54982f755f ao: declare AoData.writeSize as size_t
writeSize is a memory size and its type should thus be size_t.  This
allows us to remove two explicit casts.
2009-02-10 21:24:35 +01:00
Max Kellermann
fe142647a5 osx: removed disabled debug messages
Nobody needs these debug messages anymore.
2009-02-10 20:57:21 +01:00
Max Kellermann
1ac328b553 shout: clear buffer before calling the encoder
Always assume the buffer is empty before calling the encoder.  Always
flush the buffer immediately after there has been added something.
This reduces the risk of buffer overruns, because there will never be
a "rest" in the current buffer.
2009-02-09 16:38:25 +01:00
Max Kellermann
7fc25ad567 shout: don't postpone metadata
Don't duplicate the tag received by the send_metadata() method - send
it to the shout server directly.
2009-02-09 16:38:22 +01:00
Max Kellermann
f5c43889c3 shout: use libshout's synchronization
Removed the manual timer synchronization from the shout plugin.
libshout's shout_sync() function does it for us.
2009-02-09 16:38:20 +01:00
Max Kellermann
f6455d5f79 shout: switch to blocking mode
The non-blocking mode of libshout is sparsely documented, and MPD's
implementation had several bugs.  Also removed connect throttling
code, that is done by the MPD core since 0.14.
2009-02-09 16:38:03 +01:00
Max Kellermann
cf94008b27 shout: removed shout_data.tag_to_send
When shout_data.tag!=NULL, there is a "tag to send".  The tag_to_send
flag is redundant.
2009-02-09 16:37:16 +01:00
Max Kellermann
044f2561ce shout: removed shout_data.shout_error
That variable is set in handle_shout_error(), but is never read.
2009-02-09 16:37:12 +01:00
Max Kellermann
3b0a78fe0d shout_mp3: call lame_close() in clear_encoder() method
The shout_mp3 encoder had two bugs: when no song was ever played, MPD
segfaulted during cleanup.  Second bug: memory leak, each time the
shout device was opened, lame_init() was called again, and
lame_close() is only called once during shutdown.

Fix this by shutting down LAME each time the clear_encoder() method is
called.
2009-02-02 18:22:56 +01:00
Max Kellermann
1fdf25214f shout_mp3: free the lame_data struct on exit
Make valgrind a little bit happier: free the global lame_data struct
in the finish() method.
2009-02-02 18:22:53 +01:00
Max Kellermann
231636b9eb output_api: moved the command check out of method pause()
Move the "while" loop which checks for commands to the caller
ao_pause().  This simplifies the pause() method, and lets us remove
audio_output_is_pending().
2009-01-30 20:12:38 +01:00
Max Kellermann
a2e0b71aad output_api: removed audio_output_closed()
The function is only used by the MVP output plugin, and this one call
is wrong.
2009-01-30 19:47:59 +01:00
Max Kellermann
eeec32feaa jack: don't override output_ports in connect()
If no ports are configured, don't overwrite the (NULL) configuration
with the port names of the first JACK server.  If the server changes
after a JACK reconnect, MPD won't attempt to auto-detect again.
2009-01-30 19:44:58 +01:00
Max Kellermann
a93e73bea8 jack: removed sample_rate callback
Currently, the JACK plugin manipulates the audio_format struct which
was passed to the open() method.  This is very likely to break,
because the plugin must not permanently store this pointer.  After
this patch, MPD ignores sample rate changes.  It looks like other
software is doing the same, and I guess this is a non-issue.

This patch converts the audio_format pointer within jack_data into a
static audio_format struct.
2009-01-30 19:43:31 +01:00
Max Kellermann
5900827675 configure.ac: detect jack_set_info_function()
jack_set_info_function() is not provided by older libjack versions.
Attempt to detect if it is available.
2009-01-30 19:43:25 +01:00
Max Kellermann
0d3dff9512 jack: print info messages
Use jack_set_info_function() to install an info callback.  Don't let
libjack print them to stderr.
2009-01-30 15:57:43 +01:00
Max Kellermann
27c5b90dc3 jack: don't manually close on shutdown
Return false from mpd_jack_play(), let the MPD core close the device.
2009-01-29 23:16:34 +01:00
Max Kellermann
846f126259 jack: initialize output_ports if not configured
Don't leave uninitialized bytes in the jack_data struct.
2009-01-29 23:16:30 +01:00
Max Kellermann
e959c8e084 jack: close JACK client on stop
When MPD stops playback, close the JACK client connection.
2009-01-29 23:16:21 +01:00
Max Kellermann
e68924435a jack: removed "bps" attribute
The "bps" attribute is calculated, but never used.
2009-01-29 23:15:55 +01:00
Max Kellermann
5a2949552b jack: make mpd_jack_connect() return bool
Return true/false instead of 1/-1.
2009-01-29 23:15:27 +01:00
Max Kellermann
eccc7c21bd jack: use loops for allocating/freeing ports/buffers
Preparation for supporting other channel numbers than stereo: use
loops instead of duplicating code for the second channel.  Most
likely, gcc will unroll these loops, so the binary won't be any
different.
2009-01-29 23:14:04 +01:00
Max Kellermann
3baeddbcae jack: fail if jack_get_ports() returns NULL
When jack_get_ports() returns NULL, we cannot have any ports to
connect to, and the device cannot play anything.
2009-01-29 23:12:16 +01:00
Max Kellermann
5bcf415ad0 jack: use jack_port_name() instead of g_malloc()+sprintf()
libjack's jack_port_name() function returns the effective port name,
we don't need to do it manually.
2009-01-29 23:12:10 +01:00
Max Kellermann
67cf2ee6e4 jack: initialize libjack's error function in mpd_jack_init()
Do the global libjack initialization in the global plugin
initialization function.
2009-01-29 23:12:08 +01:00
Max Kellermann
a73266962f jack: reduced sleep time to 1ms
When waiting for free space in the ring buffer, the JACK plugin
sleeped 10ms until there is enough space.  This delay was too large
for low-latency setups (<10ms), and created a lot of xruns.  Work
around that by reducing the sleep time to 1ms.

A proper solution for this would be to use an event based approach,
and we will do it, just not now.
2009-01-29 18:13:09 +01:00
Max Kellermann
1e0ceb3d88 jack: clear "shutdown" flag on reconnect
When the connection failed once, you had to restart MPD, because it
never cleared the jack_data.shutdown flag.  Instead, it refused to
play anything "because there is no client thread" (which is wrong at
that point).
2009-01-29 18:13:03 +01:00
Max Kellermann
3a070d3d23 jack: allocate ring buffers before connecting
If the ring buffers are allocated after jack_activate(),
mpd_jack_process() might segfault because it attempts to access them.
2009-01-29 18:12:52 +01:00
Max Kellermann
bbf0453709 jack: register ports before activating clients
Call jack_port_register() before jack_activate().
2009-01-29 18:12:25 +01:00
Max Kellermann
a45922cd66 use g_free() instead of free()
On some platforms, g_free() must be used for memory allocated by
GLib.  This patch intends to correct a lot of occurrences, but is
probably not complete.
2009-01-25 18:47:21 +01:00
Max Kellermann
8695b94232 mixer: removed mixer_configure(), configure mixer in mixer_new()
Allocate the mixer object when it is configured.

Merged mixer_configure() into mixer_new().  mixer_new() was quite
useless anyway.
2009-01-25 17:37:59 +01:00
Max Kellermann
763dd8c1dd mixer: return a mixer struct pointer
Don't use statically allocated mixer objects.
2009-01-25 17:37:55 +01:00
Max Kellermann
3635c93acb conf: allow param==NULL
Return the default value in the conf_get_block_*() functions when
param==NULL was passed.

This simplifies a lot of code, because all initialization can be done
in one code path, regardless whether configuration is present.
2009-01-25 16:04:03 +01:00
Max Kellermann
5f77910097 conf: const pointers in block get functions
All config_get_block_*() functions should accept constant config_param
pointers.
2009-01-25 16:03:49 +01:00
Max Kellermann
7cc15ffc08 alsa: added comments
Document alsa_data members.
2009-01-25 13:13:24 +01:00
Max Kellermann
fb3e43ed73 alsa: frame_size is size_t, not int
frame_size is a memory size and should be a size_t, not a signed integer.
2009-01-25 13:07:06 +01:00
Max Kellermann
d887b6353f alsa: no CamelCase
Renamed types, functions, variables.
2009-01-25 13:05:16 +01:00
Dan McGee
27baf6913e alsa: fix option parsing and restore default period_time
Two bugs here led to a large number of interrupts being generated on the
sound card when ALSA output is being used. Because we specify no default
period_time, the sound card gives us 3000 interrupts/sec rather than a more
sane 20 or 30. This completes the revert of dd7711 already started by
4ca24f.

The larger bug was in the change to config_get_block_unsigned() and using 0
as the default value for both 'buffer_time' and 'period_time'. This means
any pre-setting of these options in newAlsaData() gets wiped out. Add a new
default for period_time, and ensure default values for buffer_time and
period_time are used if none are provided by the user.

Signed-off-by: Dan McGee <dan@archlinux.org>
[mk: set defaults in newAlsaData() to fix auto-configuration; renamed
"_MS" back to "_US" because ALSA expects microseconds, not milliseconds]
Signed-off-by: Max Kellermann <max@duempel.org>
2009-01-25 12:52:37 +01:00
Max Kellermann
d47be76ce0 null: added option to disable timer synchronization
The null plugin synchronizes the playback so it will happen in real
time.  This patch adds a configuration option which disables this: the
playback will then be as fast as possible.  This can be useful to
profile MPD.
2009-01-22 16:06:47 +01:00
Max Kellermann
0122510f2c null: implemented finish() method
Free memory in the finish() method to make valgrind happy.
2009-01-22 16:06:45 +01:00
Max Kellermann
e1707c7ba3 null: no CamelCase
Renamed functions and variables.
2009-01-22 16:06:43 +01:00
Max Kellermann
65f2386b39 conf: added config_get_block_unsigned()
Eliminate some more getBlockParam() invocations.
2009-01-18 19:45:51 +01:00
Max Kellermann
a531a1e650 conf: added config_get_block_string()
This replaces lots of getBlockParam() invocations.
2009-01-18 19:37:27 +01:00
Max Kellermann
73e466cfef jack: parse "ports" setting with g_strsplit()
Don't modify the configured string.
2009-01-18 19:24:14 +01:00
Max Kellermann
86f6233f46 jack: use audio_output_get_name()
Determine the audio output name with audio_output_get_name() instead
of obtaining the name from the configuration again.
2009-01-18 19:17:52 +01:00
Max Kellermann
7acc62366c conf: replaced getBoolBlockParam() with config_get_block_bool()
No "force" parameter, pass a default value instead.
2009-01-17 20:23:56 +01:00
Max Kellermann
4d472c265e conf: no CamelCase, part I
Renamed functions, types, variables.
2009-01-17 20:23:27 +01:00
Max Kellermann
106bfaa726 oss: evaluate the oss_open() return value properly
It returns bool, not int.
2009-01-16 17:11:18 +01:00
Antoine Beaupré
b7fe09fa52 shout: enlarge buffer size to 32 kB
I was having problems with shoutcast stream outputs before applying
the attached patch, which enlarges the shoutcast output
buffer. Ideally, this should be configurable, but this resolves the
issue for my needs.
2009-01-14 23:28:26 +01:00
Viliam Mateicka
11c29cccb3 Introducing mixer api
This patch tryes to introduce pluggable mixer (struct mixer_plugin) along with some basic infrastructure (mixer_* functions). Instance of mixer (struct mixer) is used in
alsa and oss output plugin
2009-01-10 17:55:38 +01:00
Max Kellermann
5e93d3682f added missing explicit config.h includes 2009-01-08 21:37:02 +01:00
Max Kellermann
b40428b3fd pcm_utils: moved conversion code to pcm_convert.c
All what's left in pcm_utils.h is the pcm_range() utility function,
which is only used internally by pcm_volume and pcm_mix.
2009-01-07 18:53:36 +01:00
Max Kellermann
d9c2960a55 fix G_BYTE_ORDER check
"#ifdef G_BYTE_ORDER == G_BIG_ENDIAN" cannot work, of course.
2009-01-05 12:40:57 +01:00
Max Kellermann
ac0fe98ffb use GLib byte order macros 2009-01-05 08:17:22 +01:00
Viliam Mateicka
1a04e57168 renaming mixer.h to mixer_api.h 2009-01-04 19:15:18 +01:00
Max Kellermann
2189796b96 null, fifo: use GLib instead of utils.h 2009-01-03 14:51:34 +01:00
Max Kellermann
59067e6a92 ao: use g_strsplit() instead of strtok_r()
g_strsplit() is more portable than strtok_r().
2009-01-03 13:20:12 +01:00
Max Kellermann
1183236797 alsa: use GLib instead of utils.h 2009-01-02 17:56:08 +01:00
Max Kellermann
051e906d85 jack: use GLib instead of utils.h 2009-01-02 17:23:10 +01:00
Max Kellermann
1fe129330e jack: duplicate jack_get_ports() return values
JACK documentation states: "The caller is responsible for calling
free(3) any non-NULL returned value."

This does not seem to include the array elements.  Duplicate them
after jack_get_ports(), and free only the array.  Convert
JackData.output_ports to non-const.
2009-01-02 17:23:00 +01:00
Max Kellermann
7dfe301b54 output plugins: don't include gcc.h
Use GLib's G_GNUC_UNUSED instead of gcc.h's mpd_unused.
2009-01-01 18:08:29 +01:00
Max Kellermann
0734acf392 null: don't include gcc.h
Use GLib's G_GNUC_UNUSED instead of macros from gcc.h.
2009-01-01 18:00:46 +01:00
Viliam Mateicka
9a70c4d06d Moving mixers to audio outputs 2008-12-31 16:46:41 +01:00
Max Kellermann
ef308d9644 alsa: use GLib logging 2008-12-29 17:29:42 +01:00
Max Kellermann
74d4ec7fbb jack: use GLib logging 2008-12-29 17:29:36 +01:00
Max Kellermann
eddf5e1e5e fifo: use GLib logging 2008-12-29 17:29:31 +01:00
Thomas Jansen
c15ac57271 osx_plugin: migrate from pthread to glib threads 2008-12-28 22:09:42 +01:00
Viliam Mateicka
d96cda95a1 shout: fixed bad error message printout 2008-12-23 18:05:25 +01:00
Emanuele Giaquinta
213c021eac Remove useless statement. 2008-12-17 16:49:33 +01:00
Emanuele Giaquinta
25c04a97d3 Remove useless computation. After the pthread_cond_wait loop there are at least MIN(od->bufferSize, size) free bytes in the buffer. Thus MIN(od->bufferSize - od->len, size) is always equal to MIN(od->bufferSize, size). 2008-12-17 15:56:43 +01:00
Emanuele Giaquinta
c584d6b087 Remove useless statement, curpos is initialized at the beginning of the loop. 2008-12-17 15:56:43 +01:00
Emanuele Giaquinta
c36a6b0aee Factor computation. 2008-12-17 15:56:43 +01:00