Max Kellermann
d7b2d93ccc
osx: fix gcc warnings
...
Fix prototypes and unused variables.
2008-11-04 11:26:04 +01:00
Max Kellermann
37696dcbbf
osx: adapt to new output plugin API
...
The OS X output plugin wasn't adapted to the new output plugin yet,
because I had no Mac to test...
2008-11-04 11:19:37 +01:00
Max Kellermann
095a62a1d0
decoder: update dc.error after input stream failure
...
dc.error wasn't updated when the input stream failed to initialize.
2008-11-03 21:49:47 +01:00
Max Kellermann
75d2a39768
input_curl: use curl_multi_info_read()
...
The function curl_multi_info_read() provides access to errors from the
curl easy interface.
2008-11-03 21:49:43 +01:00
Max Kellermann
fdf0d46e3d
player: converted PLAYER_ERROR_* to enum
2008-11-03 21:49:40 +01:00
Max Kellermann
eca0e6db3b
player: removed "volatile" attributes
...
Removed the "volatile" attributes from several variables which are not
important for synchronization.
2008-11-03 21:49:36 +01:00
Max Kellermann
862bbc21a1
player: no CamelCase
...
Renamed variables and internal functions. Most of the
player_control.h API remains in CamelCase for now.
2008-11-03 21:49:29 +01:00
Max Kellermann
cfaf85e37d
decoder: converted DECODE_ERROR_* to enum
2008-11-03 21:48:17 +01:00
Max Kellermann
ec6d26788a
decoder: removed "volatile" modifier
...
The variable "next_song" is already protected by a memory barrier.
"total_time" is not important for synchronization, and we don't need
"volatile" here.
2008-11-03 21:44:12 +01:00
Max Kellermann
863badd91e
decoder: no CamelCase
...
Renamed variables and functions.
2008-11-03 21:43:02 +01:00
Max Kellermann
b3dfcfef52
decoder_api: send song tag in decoder_data()
...
Before passing the first chunk to the audio output device, send the
current song's tag.
2008-11-03 20:20:09 +01:00
Max Kellermann
ac96022c1d
decoder_api: automatically send stream tag
...
If an input stream provides tags (e.g. from an icecast server), send
them in the decoder_data() and decoder_tag() methods. Removed the
according code from the mp3 and oggvorbis plugins - decoders shouldn't
have to care about stream tags.
This patch also adds the missing decoder_tag() invocation to the mp3
plugin.
2008-11-03 18:24:01 +01:00
Max Kellermann
8bb2da063f
tag: added function tag_has_type()
...
tag_has_type() checks whether the tag contains one or more items with
the specified type.
2008-11-03 18:24:00 +01:00
Max Kellermann
b9d456a041
decoder_api: no CamelCase
...
Renamed variables.
2008-11-03 17:56:41 +01:00
Max Kellermann
f70dccdce1
configure.ac: separate the "aac" and "mp4" decoder tests
...
MPD used to have a copy of the mp4ff library. Since that has been
removed, AAC suport was disabled when there was no libmp4ff. Separate
the libmp4ff test, and enable AAC support no matter if libmp4ff is
available.
2008-11-03 16:48:12 +01:00
Max Kellermann
9074f924e9
alsa: initialize "device" with NULL
...
When using autodetection, AlsaData.device wasn't properly initialized
with NULL. This broke autodetection randomly.
2008-11-03 07:40:54 +01:00
Max Kellermann
e6f334a088
mod: removed boolean globals for lazy init
...
The variables mod_mikModInitiated and mod_mikModInitError were used to
control lazy initialization, but they are superfluous now.
2008-11-03 07:32:02 +01:00
Max Kellermann
bb15c3bd45
mod: always initialize libmikmod
...
The "mod" decoder plugin was being initialized lazily, but was
deinitialized unconditionally. That led to segmentation faults.
Convert mod_initMikMod() to be the global module initialization
method. The MPD core should care about lazy initialization.
2008-11-03 07:30:42 +01:00
Max Kellermann
79d70f124d
output: don't allow length==0
...
Nobody should call playAudio() with an empty chunk. Add some
assertions on that.
2008-11-02 20:16:56 +01:00
Max Kellermann
cc164cc884
player: don't play empty chunks
...
An empty chunk may happen when it only contains a tag, but no PCM
data. Don't call playAudio() then.
2008-11-02 20:14:55 +01:00
Max Kellermann
e5137706d1
ffmpeg: fix boolean inversion in ffmpeg_tag()
...
ffmpeg_tag() deleted the tag when ffmpeg_helper() returned success.
The return value was interpreted incorrectly, it should return the tag
on success.
2008-11-02 17:32:40 +01:00
Max Kellermann
1e0acb2e1a
removed unused sources
...
Cleaning up artifacts from a merge gone wrong. Also remove the
ringbuf library, which is not being used.
2008-11-02 17:16:07 +01:00
Max Kellermann
fb233df7a9
player: copy stream tag to the song struct
...
Non-local songs used to have no tags. If the decoder sends us a tag,
we should incorporate it into the song struct. This way, clients can
always show the correct song name (if provided by the server).
2008-11-02 17:13:26 +01:00
Max Kellermann
7e7704e42b
player: added player.song
...
Always remember which song is currently being sent to the audio
device.
2008-11-02 17:10:26 +01:00
Max Kellermann
accc82cd6c
ffmpeg: don't rewind stream in url_close()
...
Rewinding the stream here is not useful, but may consume valuable
resources (and time).
2008-11-02 17:10:12 +01:00
Max Kellermann
2124df1390
decoder: rewind input stream after try_decode()
...
The try_decode() method may have read some data from the stream, which
is now lost. To make this data available to other methods, get it
back by rewinding the input stream after each try_decode() invocation.
The ogg and wavpack plugins did this manually and inconsistently; this
code can now be removed.
2008-11-02 17:10:02 +01:00
Max Kellermann
395aa4e847
decoder: moved code to decoder_try_decode()
2008-11-02 17:07:39 +01:00
Max Kellermann
5183d85886
player: send chunk tag to audio device
...
If a chunk contains a tag, send it to the audio output device. Few
output plugins support this, e.g. shout has support for sending tags.
2008-11-02 17:07:31 +01:00
Max Kellermann
aa9b31f1cf
crossfade: copy tag
...
If the source chunk has a tag, merge it into the destination chunk.
The source chunk gets deleted after that, and this is our last chance
to grab the tag.
2008-11-02 17:07:13 +01:00
Max Kellermann
0f80428fda
ffmpeg: use decoder_read() wrapper instead of direct input_stream_read()
...
decoder_read() checks the decoder command. Without this patch, the
ffmpeg plugin could become unresponsive.
2008-11-02 17:06:53 +01:00
Max Kellermann
4d069b4991
ogg, ffmpeg: try to decode, even when the stream is not seekable
...
Ogg and ffmpeg detection was disabled when the stream was not
seekable, because the detection was too expensive. Since the curl
input stream can now rewind the stream cheaply, we can re-enable
detection on streams.
2008-11-02 17:06:32 +01:00
Max Kellermann
460b15d29c
input_curl: buffered rewinding
...
During codec detection, the beginning of the stream is consumed. This
is a common operation, which takes a lot of time when handling remote
resources. To optimize this, remember the first 64 kB of a stream.
This way, we can rewind the stream without actually fetching the start
of the stream again.
2008-11-02 17:06:15 +01:00
Max Kellermann
020c04e702
decoder_api: added decoder_tag()
...
Provide an API for submitting additional tags from the stream.
2008-11-02 17:02:28 +01:00
Max Kellermann
5b13f067cd
aac, mod: moved decoder command check into loop condition
...
Avoid while(true) loops, and convert them to a loop with a proper
condition.
2008-11-02 17:02:23 +01:00
Max Kellermann
3f6fcfd38e
aac, mod: don't check for SEEK command
...
Since the aac and mod plugins have told MPD that they cannot seek, MPD
will never send a SEEK command to them. Removed the SEEK comand
checks from both plugins.
2008-11-02 17:02:00 +01:00
Max Kellermann
c9e15bc418
decoder_api: pass "seekable" flag to decoder_initialized()
...
Don't pass the "seekable" flag with every decoder_data() invocation.
Since that flag won't change within the file, it is enough to pass it
to decoder_initialized() once per file.
2008-11-02 17:01:51 +01:00
Max Kellermann
c7a374bdcb
music_pipe: add tag pointer to the music_chunk struct
...
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-02 17:01:00 +01:00
Max Kellermann
fcc11bc9d8
music_pipe: added functions chunk_init() and chunk_free()
...
These two functions will care about memory allocation and deallocation
in the future.
2008-11-02 16:58:49 +01:00
Max Kellermann
85b6ff7b59
music_pipe: document struct music_chunk
...
Add doxygen compatible comments.
2008-11-02 16:58:45 +01:00
Max Kellermann
b42dad9b05
music_pipe: removed "volatile"
...
The "volatile" keyword doesn't help here, because we have proper
memory barriers, but it disables some optimizations. Remove it.
2008-11-02 16:58:42 +01:00
Max Kellermann
39bf84aa9f
music_pipe: renamed "size" to "num_chunks"
...
The name "num_chunks" expresses the meaning of the variable better.
2008-11-02 16:57:37 +01:00
Max Kellermann
5347cca29d
music_pipe: no CamelCase
...
Rename all variables and struct members.
2008-11-02 16:57:16 +01:00
Max Kellermann
8490c1b4cf
music_pipe: set bit_rate and time in music_pipe_append()
...
Don't bother to pass these values as parameters to tail_chunk().
2008-11-02 16:57:15 +01:00
Max Kellermann
cd61f6570f
music_pipe: moved code to music_chunk_append()
2008-11-02 16:56:49 +01:00
Max Kellermann
e9e9d2bc2d
music_pipe: renamed "ob" to "music_pipe"
...
Last music_pipe rename patch: renamed the global variable (singleton).
2008-11-02 16:56:09 +01:00
Max Kellermann
d430b1dc54
music_pipe: more wrapper functions
...
Replace all direct music_pipe struct accesses with wrapper functions.
The compiled machine code is the same, but this way, we can change
struct internals more easily.
2008-11-02 16:55:53 +01:00
Max Kellermann
260a0cc33c
music_pipe: use GLib instead of utils.h
...
Eliminate the deprecated utils.h memory allocation functions.
2008-11-02 16:55:48 +01:00
Max Kellermann
8b1f6ff3c8
decoder: replaced music_pipe.audioFormat with dc.out_audio_format
...
.. 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-02 16:55:43 +01:00
Max Kellermann
30fca5e5a9
music_pipe: pass frame size to tail_chunk()
...
Don't make tail_chunk() calculate the frame size again.
2008-11-02 14:18:34 +01:00
Max Kellermann
fd0f195bb7
music_pipe: renamed ob_* functions to music_pipe_*
...
Rename all functions to the new prefix.
2008-11-02 14:18:34 +01:00
Max Kellermann
8964c69a64
music_pipe: renamed struct output_buffer to struct music_pipe
...
.. and rename ob_chunk to struct music_chunk.
2008-11-02 14:15:47 +01:00
Max Kellermann
767b4c95bd
renamed outputBuffer.[ch] to pipe.[ch]
...
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-11-02 14:12:52 +01:00
Max Kellermann
b48ae8c26f
decoder: enable decoders even if they have no init() method
...
Commit 1a4a3e1f
moved decoders into a static array, but failed to
enable those plugins who did not have an init() method at all.
This patch corrects the "enabled" check.
2008-11-02 13:30:26 +01:00
Max Kellermann
4c1b96c307
decoder: make the suffixes and mime_types arrays really const
...
The strings were constant, but the pointers weren't. C syntax is
somewhat tricky..
2008-11-01 14:55:23 +01:00
Max Kellermann
0b614fbaae
decoder: make all decoder_plugin structs const
...
All decoder_plugin structs are initialized at compile time, and must
never change.
2008-11-01 14:54:09 +01:00
Max Kellermann
1a4a3e1f1f
decoder: manage decoder list in a static array
...
Currently, there is no way to dynamically load decoder plugins, thus
we don't need a dynamic list to manage them.
2008-11-01 14:53:30 +01:00
Max Kellermann
5036368f54
decoder: return const decoder_plugin structs
...
The decoder_plugin structs must never change. Don't work with
non-const pointers.
2008-11-01 14:51:41 +01:00
Max Kellermann
83f6222ae7
permission: store passwords in GHashTable
...
Eliminating the deprecated linked list library.
2008-11-01 14:33:25 +01:00
Max Kellermann
aa772ebc02
tag: use GLib instead of utils.h
...
Don't use the deprecated functions from utils.h.
2008-11-01 14:33:14 +01:00
Max Kellermann
35710a81ea
utils: use GUINT32_FROM_LE() instead of readLEuint32()
...
Eliminate code already provided by GLib.
2008-11-01 14:11:19 +01:00
Max Kellermann
b996108675
tag: don't return const string from fix_utf8()
...
Return NULL instead of the input value if there is nothing to fix.
This way, the caller doesn't have to use the xfree() hack.
2008-11-01 14:04:15 +01:00
Max Kellermann
aa33422de6
alsa, jack: no const pointers for allocated strings
...
Make the pointers "device" and "name" non-const, so we don't need the
xfree() hack. The default value is expressed as NULL.
2008-11-01 14:04:14 +01:00
Max Kellermann
9fdac529b4
path: removed sanitizePathDup()
...
We don't need to sanitize the path, because the mapper already checks
for malformed paths.
2008-10-31 16:50:51 +01:00
Max Kellermann
f291876772
mapper: check for "." and ".."
...
Make map_directory_child_fs() refuse the names "." and "..". This is
currently the interface where an attacker may inject a manipulated
path (through the "update" command).
2008-10-31 16:48:58 +01:00
Max Kellermann
a5f8d4386c
update: check return values
...
Nearly all mapper functions can fail and will then return NULL. Add
checks to all callers.
2008-10-31 16:47:21 +01:00
Max Kellermann
d8e877e335
path: moved playlist_dir to mapper.c
...
Added the function map_spl_utf8_to_fs() which replaces
utf8_to_fs_playlist_path().
2008-10-31 16:47:14 +01:00
Max Kellermann
ef54271619
mapper: use g_warning() for logging
...
g_error() is fatal by default. Use g_warning() for non-fatal
initialization errors.
2008-10-31 16:46:46 +01:00
Max Kellermann
f098db149e
decoder: eliminate gotos in decodeStart()
...
http://xkcd.com/292/
2008-10-31 16:29:45 +01:00
Max Kellermann
a1ca32168c
decoder: don't wake up player when command==NONE
...
If nobody sent a command, the player isn't waiting for the decoder.
Don't wake it up.
2008-10-31 16:29:39 +01:00
Max Kellermann
63682eb1b8
decoder: notify player after stop
...
The player should always be woken up when the decoder quits.
2008-10-31 16:29:34 +01:00
Max Kellermann
347e816247
decoder: reset state and command in decoder_task()
...
Eliminate one goto in decodeStart() by moving some cleanup to
decoder_task().
2008-10-31 16:29:24 +01:00
Max Kellermann
86fbac54fd
decoder: introduce switch statement in decoder_task()
...
switch looks much nicer than if/elseif/... and gcc generates nice
warnings when a new command is added to the enum.
2008-10-31 16:29:22 +01:00
Max Kellermann
78448fe1a5
decoder_api: pass constant path pointers
2008-10-31 15:56:43 +01:00
Max Kellermann
6d6e615825
input_stream: pass const url to input_stream_open()
2008-10-31 15:50:59 +01:00
Max Kellermann
a92903983d
client: use bool
...
Return bool instead of int.
2008-10-31 13:58:00 +01:00
Max Kellermann
6757c17689
removed UTF-8 library, use GLib instead
...
Removed duplicated code.
2008-10-31 13:57:10 +01:00
Alam Arias
78f60c9c6d
removed unneed check for protocol in shout plugin, will assume icecast2 protocol if not exist in config
2008-10-31 12:20:49 +01:00
Max Kellermann
71fe7ad81a
path: free GLib error in fs_charset_to_utf8()
...
g_error_free() was missing in case g_convert() failed.
2008-10-31 12:20:48 +01:00
Max Kellermann
8f9d9cc042
directory: directory_free() frees children
...
directory_free() should free all of its children (subdirectories and
songs). This way, db_finish() properly frees all allocated memory.
2008-10-31 09:20:02 +01:00
Max Kellermann
ea515494cb
added prefix to header macros
...
"LOG_H" is a macro which is also used by ffmpeg/log.h. This is
ffmpeg's fault, because short macros should be reserved for
applications, but since it's always a good idea to choose prefixed
macro names, even for applications, we are going to do that in MPD.
2008-10-31 09:19:53 +01:00
Max Kellermann
5ef17ac1aa
client: don't try again after partial write
...
After a partial write, chances are vanishing that another write() will
succeed. Don't try immediately.
2008-10-31 09:19:40 +01:00
Max Kellermann
b7ee6febaa
removed the sllist library
...
The "simple singly-linked-list" library has been replaced with GLib's
GList and GQueue.
2008-10-31 09:19:34 +01:00
Max Kellermann
94cbdffb72
client: use GQueue instead of sllist.h for deferred_send
...
Another custom data structore converted to GLib.
2008-10-31 09:18:11 +01:00
Max Kellermann
90e9079142
client: use GSList instead of struct strnode for command lists
...
Replace a custom data structure with a GLib one.
2008-10-31 09:17:56 +01:00
Max Kellermann
e5ef2d8a37
client: removed list_cache
...
The list cache aims to save memory allocations, and complicates the
code a bit. We should rather use GLib slices later, which are easy to
use.
2008-10-31 09:17:52 +01:00
Max Kellermann
8f37f7c838
ogg: don't include _flac_common.h
...
The source _ogg_common.c does not need any symbols from
_flac_common.h, but including it leads to compiler errors when libflac
isn't available.
2008-10-31 08:52:09 +01:00
Max Kellermann
d65d6548a3
oggflac: adapt to new API
...
Again, I forgot to adapt oggflac to the new API (struct input_stream,
bool return values).
2008-10-31 08:52:09 +01:00
Max Kellermann
5024f0b6cc
ffmpeg: pass input_stream pointer to decoder_data()
...
decoder_data() uses wait times to let the input stream continue its
transfer.
2008-10-30 19:09:20 +01:00
Max Kellermann
b15c4cdeb5
ffmpeg: use return value of decoder_data()
...
decoder_data() always returns the current command. If we use this, we
can save a lot of decoder_get_command() calls.
2008-10-30 19:03:41 +01:00
Max Kellermann
f3b4a28518
ffmpeg: output buffer size cannot be negative
...
Converted the runtime check to an assertion.
2008-10-30 19:03:38 +01:00
Max Kellermann
130fc58b36
ffmpeg: break immediately after av_read_frame()
...
Remove one indent level.
2008-10-30 19:03:31 +01:00
Max Kellermann
5f1df0a927
ffmpeg: moved code to ffmpeg_send_frame()
...
Move code from ffmpeg_decode_internal() to make it smaller and more
readable.
2008-10-30 19:03:20 +01:00
Max Kellermann
048d62a628
ffmpeg: report seek errors to MPD
...
The decoder API provides the function decoder_seek_error() to report
seek errors. Use this function instead of logging the error.
2008-10-30 19:02:38 +01:00
Max Kellermann
cd7a720426
ffmpeg: simplified mpdurl_read()
...
The function mpdurl_read() is too complicated, and uses the wrong data
types.
2008-10-30 19:02:01 +01:00
Max Kellermann
964442c5ad
ffmpeg: call tag_free() instead of free()
...
tag objects must be freed with tag_free() to ensure that all resources
are freed.
2008-10-30 19:01:36 +01:00
Max Kellermann
25f4efcdb8
ffmpeg: eliminated local variable "tag"
...
The function ffmpeg_tag() already has the variable base.tag, which can
be used for this.
2008-10-30 19:01:31 +01:00
Max Kellermann
7cbd9821c6
ffmpeg: make ffmpeg_helper() return bool
...
ffmpeg_try_decode() did not interpret ffmpeg_helper()'s return value
properly; migrate everything to bool to make it consistent.
2008-10-30 19:01:23 +01:00
Max Kellermann
078d83ca13
ffmpeg: removed debug messages
...
We don't need those anymore, they just fill the log.
2008-10-30 19:01:18 +01:00
Max Kellermann
b180d0b47f
ffmpeg: initialize base.decoder
...
ffmpeg_tag() did not initialize base.decoder, which made valgrind
unhappy, and can lead to a egmentation fault.
2008-10-30 18:08:52 +01:00
Max Kellermann
4d72bda4c3
listen: set file mode 666 on the unix socket
...
Depending on MPD's umask, the file permissions of the unix socket were
too restrictive, and many clients were not able to connect. Do a
chmod(0666) on the socket, to allow everybody to connect.
2008-10-30 18:03:18 +01:00
Max Kellermann
9ec695559f
pulse: fix segfault without sink name
...
Commit d692e9 broke configurations without explicit server or sink
configuration. Check for getBlockParam()==NULL.
2008-10-30 17:46:56 +01:00
Max Kellermann
5f6383d68c
mpc: provide 24 bit samples
...
Similar to libmad, libmpcdec provides samples with higher quality than
16 bit. Send 24 bit samples to MPD, which allows MPD to apply
dithering just in case the output devices are only 16 bit capable.
2008-10-30 08:45:00 +01:00
Max Kellermann
0db07a920e
mpc: moved sample size into a constant
...
Don't hard-code the "16 bits" or "2 bytes" in multiple locations.
2008-10-30 08:44:51 +01:00
Max Kellermann
6773dea5b0
mpc: renamed variable "s16" to "dest"
...
The name "s16" implies 16 bit integers. To make the code more
generic, rename it to "dest".
2008-10-30 08:44:43 +01:00
Max Kellermann
51348d6992
mpc: fix broken integer sample conversion
...
The conversion of integer samples was completely broken, which
presumably didn't annoy anybody because libmpcdec provides float
samples on most installations.
2008-10-30 08:44:28 +01:00
Max Kellermann
ecd485acbd
mpc: fix boolean interpretation of input_stream_seek()
...
When input_stream_seek() was converted to return a bool, this wasn't
adjusted in the musepack plugin.
2008-10-30 08:42:18 +01:00
Max Kellermann
62d4fa9306
decoder: use bool for return values and flags
...
Don't return 0/-1 on success/error, but true/false. Instead of int,
use bool for storing flags.
2008-10-30 08:38:54 +01:00
Max Kellermann
d29bad4410
mp3: make mp3_read() return bool
...
Its only caller in mp3_decode() just compared its value with
DECODE_BREAK. Convert that to bool, and return false if the loop
should be ended. Also eliminate some superfluous command checking
code, which was already done in the preceding while loop.
2008-10-30 06:09:28 +01:00
Max Kellermann
f8722913cf
output: removed audio_output.result
...
Since open() and play() close the device on error, we can simply check
audio_output.open instead of audio_output.result after a call.
2008-10-29 22:34:37 +01:00
Max Kellermann
7da0e005f3
output: delay reopen after device failure
...
When one of several output devices failed, MPD tried to reopen it
quite often, wasting a lot of resources. This patch adds a delay:
wait 10 seconds before retrying. This might be changed to exponential
delays later, but for now, it makes the problem go away.
2008-10-29 22:32:50 +01:00
Max Kellermann
0eae1c55ad
output: moved code to audio_output_update()
...
Moved code from syncAudioDeviceStates() to audio_output_update().
2008-10-29 22:17:44 +01:00
Max Kellermann
678314534a
output: always call cancel() before stop()
...
Stopping an audio output device without cancelling its buffer doesn't
make sense. Combine the two operations, which saves several cancel
calls.
2008-10-29 22:17:42 +01:00
Max Kellermann
07bb46de88
input_file: refuse to open non-regular files
...
Don't allow users to open a file which is non-regular (e.g. pipes,
devices).
2008-10-29 21:11:28 +01:00
Max Kellermann
84f7d9c6b3
input_file: check fstat() failure
2008-10-29 21:11:20 +01:00
Max Kellermann
fb08213659
input_file: use GLib for logging
2008-10-29 21:11:04 +01:00
Max Kellermann
8f3d962219
log: don't use utils.h
...
Prefer GLib over utils.h.
2008-10-29 21:02:22 +01:00
Max Kellermann
cf376b4bc8
output: moved audioDeviceStates to audio_output.enabled
2008-10-29 20:49:51 +01:00
Max Kellermann
2f76db4c78
output: close device on play error
...
When an output plugin fails to play a chunk, close it. This replaces
various manual close() calls in nearly all plugins.
2008-10-29 20:40:33 +01:00
Max Kellermann
58c5bee9f0
output: use bool for return values and flags
...
Don't return 0/-1 on success/error, but true/false. Instead of int,
use bool for storing flags.
2008-10-29 20:40:27 +01:00
Max Kellermann
03390d8be1
audio: call closeAudioDevice() on error
...
Instead of implementing another loop which calls audio_output_close()
on all configured devices, simply call closeAudioDevice().
2008-10-29 20:39:56 +01:00
Max Kellermann
030238bb10
audio: removed variable "audioOpened"
...
This variable is never read, and can be removed.
2008-10-29 20:39:48 +01:00
Max Kellermann
b967702059
pulse: clear pa_simple pointer in pulse_close()
...
The pointer becomes invalid due to pa_simple_free(), which may lead to
segmentation faults when the output is reopened later.
2008-10-29 20:38:20 +01:00
Max Kellermann
d692e925a4
pulse: use GLib instead of util.h/log.h
...
Use GLib allocation and logging functions.
2008-10-29 20:37:36 +01:00
Max Kellermann
38df17546a
pulse: no CamelCase
2008-10-29 20:37:15 +01:00
Max Kellermann
2867c8e9b1
player: handle songs shorter than the initial buffer
...
When the decoder exited before the buffer has grown big enough
("buffer_before_play"), the player thread waited forever. Add an
additional check which disables buffering as soon as the decoder
exits.
2008-10-29 18:35:10 +01:00
Max Kellermann
5c4dc8d03c
oss: check and override audio_format properly
...
Don't accept 24 bit audio. Force MPD to use 16 bit if anything other
than 8 or 16 bit is selected.
2008-10-29 18:35:03 +01:00
Max Kellermann
c6714f1755
player: added variable "play_audio_format"
...
The local variable "play_audio_format" is updated every time the
player starts playing a new song. This way, we always know exactly
which audio format is current. The old code broke when a new song had
a different format: ob.audio_format is the format of the next song,
not of the current one - using this caused breakage for the software
volume control.
2008-10-29 17:29:30 +01:00
Max Kellermann
528b7c3f5e
decoder: automatically flush the output buffer after decoder exits
...
A decoder_flush() invocation was missing in the FLAC plugin, resulting
in casual assertion failures due to a wrong assumption about the last
chunk's audio format. It's much easier to remove that decoder_flush()
function and make the decoder thread call ob_flush().
2008-10-29 17:29:06 +01:00
Max Kellermann
74c85811af
decoder_api: make the audio_format parameter mandatory
...
There are no callers which pass audio_format==NULL, and it shouldn't
be allowed.
2008-10-29 17:29:03 +01:00
Max Kellermann
c042faab42
player: request new song only if there is no pending command
...
Request the next song from the playlist (by clearing pc.next_song)
only if the player command is empty. If it is not, the player may be
clearing the song that has already been queued, leading to an
assertion failure.
2008-10-29 17:28:49 +01:00
Max Kellermann
be90199c5a
decoder_api: removed decoder_clear()
...
Call ob_clear() in decoder_command_finished() instead of implementing
that call in every decoder plugin.
2008-10-29 17:28:47 +01:00
Max Kellermann
d6c4441c78
mp3: seek in background
...
Remember the seek_where argument and call decoder_command_finished()
immediately. This way, the player thread can continue working, and we
can receive more commands.
This also fixes several issues which resulted in broken frames,
leading to erroneos "elapsed" values: frames weren't parsed properly,
since the code was checking for command!=NONE.
2008-10-29 17:22:56 +01:00
Max Kellermann
de588448df
mp3: return from mp3_synth_and_send() on any command
...
Previously, the function would only return when a STOP was issued. It
makes more sense to consider all possible commands.
2008-10-29 16:17:21 +01:00
Max Kellermann
6158858f82
mp3: moved code to mp3_synth_and_send()
...
Break the large function mp3_read() into smaller pieces.
2008-10-29 16:14:08 +01:00
Max Kellermann
e0532ae0a8
mp3: moved code to mp3_send_pcm()
...
Break the large function mp3_read() into smaller pieces.
2008-10-29 16:14:02 +01:00
Max Kellermann
a6ad0e4047
mp3: moved code to mp3_update_timer_next_frame()
...
Break the large function mp3_read() into smaller pieces.
2008-10-29 16:13:51 +01:00
Max Kellermann
0d079ee515
mp3: moved code to mp3_this_frame_offset()
...
Break the large function mp3_read() into smaller pieces.
2008-10-29 16:13:01 +01:00
Max Kellermann
a6f8776c94
mp3: moved code to mp3_time_to_frame()
...
Break the large function mp3_read() into smaller pieces.
2008-10-29 16:12:26 +01:00
Max Kellermann
ec3083948f
mp3: assert that the stream is seekable
...
dc_seek() won't send a SEEK command to the decoder thread unless the
stream is seekable. No need to do another check; convert that to an
assertion.
2008-10-29 16:11:16 +01:00
Max Kellermann
78b08f03f2
decoder_api: don't cast need_chunks() to int
...
need_chunks() returns a decoder_command enum. Store its return value
as this type.
2008-10-29 16:11:15 +01:00
Max Kellermann
a0b57f3782
mp3: moved code to mp3_filesize_to_song_length()
...
The function mp3_decode_first_frame() is too large. Move some code to
separate smaller functions.
2008-10-28 20:44:08 +01:00
Max Kellermann
898978a67d
mp3: no "goto"
...
http://xkcd.com/292/
2008-10-28 20:43:17 +01:00
Max Kellermann
28b47725ff
mp3: use GLib allocation functions
...
This removes the need for util.h.
2008-10-28 20:43:15 +01:00
Max Kellermann
56ebdf1cd1
mp3: use bool
...
Use the C99 bool data type for boolean values.
2008-10-28 20:42:33 +01:00
Max Kellermann
e4bbc120ac
mp3: no CamelCase
...
Renamed all functions and variables. Also removed the mp3DecodeData
typedef.
2008-10-28 20:42:01 +01:00
Max Kellermann
1f7c53e619
mp3: remove obsolete comments
2008-10-28 20:41:25 +01:00
Max Kellermann
25f98a41c4
input_file: don't use buffered I/O
...
Yet another superfluous buffering layer. input_file was using FILE*,
but we're better off with unbuffered I/O using open(), read(), ...
2008-10-28 20:41:24 +01:00
Max Kellermann
0a61877702
input_stream: convert offset and size to the off_t data type
...
size_t and long aren't 64 bit safe (i.e. files larger than 2 GB on a
32 bit OS). Use off_t instead, which is a 64 bit integer if compiled
with large file support.
2008-10-28 20:39:09 +01:00
Max Kellermann
016d996131
utils: use g_str_has_prefix() instead of prefixcmp()
...
Remove duplicated code from MPD.
2008-10-28 20:33:56 +01:00
Max Kellermann
4a71f66256
player: reset pc.command when decoder startup fails
...
When the decoder failed to start, the function do_play() returned,
still having pc.command==PLAY. This is because pc.command was reset
only when the decoder started up successfully. Add another
player_command_finished() call in the error handler.
2008-10-27 10:10:40 +01:00
Max Kellermann
0d30d51f07
input_file, input_curl: check URL type before attempting to open
...
Don't attempt to open a HTTP URL as a local file, and don't send a
local path to libcurl.
2008-10-27 10:10:24 +01:00
Max Kellermann
0800c6f4ca
output: don't compile plugins which are disabled
...
Don't compile the sources of disabled output plugins at all.
2008-10-26 21:58:37 +01:00
Max Kellermann
3dac99034a
dirvec: fixed GCC shadow warning
...
On some systems, string.h declares basename(). This emits a shadow
warning. Change the variable name.
2008-10-26 21:28:16 +01:00
Max Kellermann
5f2384001e
curl: read stream name from HTTP response headers
...
If the server sends the headers "icy-name", "ice-name",
"x-audiocast-name", set the stream title.
2008-10-26 21:20:02 +01:00
Max Kellermann
5d9ef0cd83
input_curl: set input_stream.mime from Content-Type response header
2008-10-26 21:19:32 +01:00
Max Kellermann
1437a56a11
input_curl: added local variable "value"
...
Replaced the local variable "colon" (which had only temporary meaning)
with the variable "value". It is a pointer to the first byte of the
header value.
2008-10-26 21:12:56 +01:00
Max Kellermann
d401589edf
input_stream: use g_free() in input_stream_close()
...
g_free() allows passing the NULL pointer.
2008-10-26 21:02:49 +01:00
Max Kellermann
5c19776f2f
input_stream: use "bool" instead of "int"
...
For boolean values and success flags, use bool instead of integer (1/0
for true/false, 0/-1 for success/failure).
2008-10-26 20:56:46 +01:00
Max Kellermann
464b611772
input_stream: input_stream_close() returns void
...
close() shouldn't fail with read-only streams.
2008-10-26 20:54:52 +01:00
Max Kellermann
f08041f0eb
input_stream: added struct input_plugin
...
Instead of managing a set of method pointers in each input_stream
struct, move these into the new input_plugin struct. Each
input_stream has only a pointer to the plugin struct. Pointers to all
implementations are kept in the array "input_plugins".
2008-10-26 20:38:44 +01:00
Max Kellermann
dbc7e9ba2f
input_stream: no CamelCase
...
Renamed all functions and variables.
2008-10-26 20:34:47 +01:00
Max Kellermann
97a9c7a8e0
input_file: removed global constructor
...
The global constructor is empty, and can be removed.
2008-10-26 20:34:33 +01:00
Max Kellermann
23552f89cc
input_file: don't export internal methods
...
The methods are only used in inputStream_fileOpen(), and should not be
exported.
2008-10-26 20:34:03 +01:00
Max Kellermann
21b8590b53
input_stream: removed the InputStream typedef
...
Everybody should use struct input_stream.
2008-10-26 19:54:57 +01:00
Max Kellermann
bbaedb17d5
input_stream: renamed sources, no CamelCase
...
Renamed inputStream.c and inputStream_file.c.
2008-10-26 19:38:50 +01:00
Max Kellermann
3609de8685
http: use libcurl
...
MPD's HTTP client code has always been broken, no matter how effort
was put into fixing it. Replace it with libcurl, which is known to be
quite stable. This adds a fat library dependency, but only for people
who need streaming.
2008-10-26 19:32:43 +01:00
Max Kellermann
6b09e4daef
input_stream: added input_stream_global_finish()
...
The hook input_stream_global_finish() deinitializes global structures
of all input stream implementations.
2008-10-26 19:30:13 +01:00
Max Kellermann
4bc2def15c
stored_playlist: fixed signed comparison warning
...
Cast playlist_max_length to off_t before comparing it to stat.st_size.
2008-10-26 16:26:44 +01:00
Max Kellermann
4fa36a15bf
command: removed range check from check_bool()
...
check_bool() accepts only "0" or "1". The range check is superfluous.
2008-10-26 16:19:33 +01:00
Max Kellermann
ece8c1347c
renamed src/audioOutputs/ to src/output/
...
Again, no CamelCase in the directory name.
2008-10-26 11:29:44 +01:00
Max Kellermann
e11355f47d
renamed src/inputPlugins/ to src/decoder/
...
These plugins are not input plugins, they are decoder plugins. No
CamelCase in the directory name.
2008-10-26 11:29:25 +01:00
Max Kellermann
1110a6d410
removed internal copy of libmp4ff
...
MPD shouldn't integrate sources of other libraries. Since libmp4ff is
part of libfaad, we should remove the old copy from src/mp4ff and link
with the current version from libfaad instead.
2008-10-25 20:59:36 +02:00
Max Kellermann
a02db57291
pulse: force 16 bit audio sample format
...
PA_SAMPLE_S16NE is the only sample format which is suported by both
MPD and pulseaudio. Unfortunately, pulse does not accept 24 bit
samples.
Instead of bailing out with an error message, we should tell the MPD
core to convert all samples to 16 bit for pulse.
2008-10-25 20:41:28 +02:00
Max Kellermann
ee499cb42f
player: don't clear command before do_play() returns
...
This bug caused the audio output devices to stay open, although MPD
wasn't playing: quitDecode() resetted player_control.command, assuming
that the command was STOP. This way, player_task() didn't see the
CLOSE_AUDIO command, and the device was kept open.
Don't clear player_control.command in quitDecode().
2008-10-24 17:50:24 +02:00
Max Kellermann
18c6ebb023
remove unused sources
...
These are results from failed merges which I didn't notice.
2008-10-24 17:41:13 +02:00
Max Kellermann
f4e6bb2815
jack: support for 24 bit samples
...
When the audio source provides 24 bit samples, don't bother to convert
(lossily) them to 16 bit before jack's floating point conversion - go
directly from 24 bit to float.
2008-10-24 17:36:11 +02:00
Max Kellermann
b1adfaae43
jack: moved code to jack_write_samples_16()
...
Move sample format dependent code to a separate function.
2008-10-24 17:34:47 +02:00
Max Kellermann
03a077e8a4
jack: eliminated CamelCase
...
Renamed all variables and functions. Add the prefix "mpd_jack_" to
function names.
2008-10-24 17:29:37 +02:00
Max Kellermann
e19f0a8dbc
jack: added assertions against partial frames
...
We must never pass partial frames. Added assertions to debug this.
2008-10-24 16:56:10 +02:00
Max Kellermann
e7cd237674
jack: optimize local variables
...
Merge the variables "avail_data" and "avail_frames" into "available".
Both variables are never used at the same time.
2008-10-24 16:56:08 +02:00
Max Kellermann
0a6704420b
jack: lockless data transfer to jack thread
...
The JACK documentation postulates that the process() callback must not
block, therefore locking is forbidden. Anyway, the old code was racy.
Remove all locks, and don't wait for more data to become available -
just send to the port what is already in the buffer.
2008-10-24 16:55:51 +02:00
Max Kellermann
4ecdaabbb0
jack: partial writes to ring buffer
...
Don't wait until there is room for the full data chunk passed to
jack_playAudio(). Try to incrementally send as much as possible into
the ring buffer.
2008-10-24 16:39:43 +02:00
Max Kellermann
91ad576aad
jack: added constant "frame_size"
...
Don't hard-code a frame size of "4" (16 bit stereo), calculate the
sample size from sizeof(*buffer), and create the constant
"frame_size".
2008-10-24 15:47:52 +02:00
Max Kellermann
9d6651d8b2
jack: fix indentation
...
Indent with tabs.
2008-10-24 08:44:40 +02:00
Max Kellermann
8b4829c2fe
pcm_resample: support for libsamplerate < 0.1.3
...
libsamplerate 0.1.2 didn't have the 32 bit <-> float conversion
routines. Emulate them in case they aren't supported.
2008-10-24 08:41:34 +02:00
Max Kellermann
5fefa954a3
player: don't send partial frames of silence
...
Another partial frame fix: the silence buffer was 1020 bytes, which
had room for 127.5 24 bit stereo frames. Don't send the partial last
frame in this case.
2008-10-23 20:54:52 +02:00
Max Kellermann
4eadb0f7aa
pcm_utils: added 24 bit conversion functions
...
24 bit output is as important as 16 bit output. Provide a
pcm_convert() implementation which can convert to 24 bit with as
little quality loss as possible.
2008-10-23 20:11:37 +02:00
Max Kellermann
ec37633f1c
pcm_utils: generic pcm_convert_size() implementation
...
The old pcm_convert_size() ignored most of the destination format,
e.g. it did not check its sample size, and assumed it is 16 bit.
Simplify and universalize it by using audio_format_frame_size().
2008-10-23 20:11:28 +02:00
Max Kellermann
98e4817548
pcm_utils: moved code to pcm_convert_16()
...
pcm_convert() converted only to 16 bit. To be able to support other
sample sizes, move that 16 bit specific code to a separate function.
2008-10-23 20:11:24 +02:00
Max Kellermann
8489e90c1e
pcm_channels: added 24 bit implementations
...
The 24 bit implementation is mostly copy'n'paste of the 16 bit
version, except that the data type is int32_t instead of int16_t.
2008-10-23 20:04:37 +02:00
Max Kellermann
a0bcbb37f4
pcm_utils: moved channel conversion functions to pcm_channels.c
...
Separate code from pcm_utils.c to keep it small and simple.
2008-10-23 20:03:14 +02:00
Max Kellermann
af7cb932fb
pcm_resample: implemented 24 bit resampling
...
Similar to pcm_resample_16(), implement pcm_resample_24(). The 24 bit
implementation is very similar, but it uses src_int_to_float_array()
instead of src_short_to_float_array() before sending data to
libsamplerate.
2008-10-23 20:02:51 +02:00
Max Kellermann
5bbcbfb7ce
pcm_resample: moved code to pcm_resample_set()
...
A future patch will implement a 24 bit resampler. To unify code, move
code which can be shared to a separate function.
2008-10-23 20:02:09 +02:00
Max Kellermann
1dcb946fb0
pcm_resample: eliminated "sample" local variables
...
Copy from source to destination buffer directly, don't use the
temporary variables "lsample" and "rsample".
2008-10-23 20:01:37 +02:00
Max Kellermann
124f79a2a6
pcm_resample: don't resample partial samples
...
Added assertions which ensure that there are no partial samples in the
source buffer.
2008-10-23 20:01:12 +02:00
Max Kellermann
b13d656f81
pcm_resample: don't hard-code sample size
...
Use sizeof(sample) instead of hard-coding "2". Although we're in 16
bit right now, this will make code sharing easier when we support
other sample sizes.
2008-10-23 20:01:08 +02:00
Max Kellermann
6b1c54ef96
pcm_utils: moved code to pcm_resample.c
...
Separate the resampling code from the rest of pcm_utils.c. Create two
sub-libraries: pcm_resample_libsamplerate.c and
pcm_resample_fallback.c.
2008-10-23 20:00:51 +02:00
Max Kellermann
098991f8e8
command: fix boolean value parser
...
Due to a logic error, no value was valid for the boolean value
parser. Replace "||" with "&&".
2008-10-23 18:06:05 +02:00
Max Kellermann
2cc2420f8c
mp3: send 24 bit PCM data
...
libmad produces samples of more than 24 bit. Rounding that down to 16
bits using dithering makes those people lose quality who have a 24 bit
capable sound device. Send 24 bit PCM data, and let the receiver
decide whether to apply 16 bit dithering.
2008-10-23 16:58:38 +02:00
Max Kellermann
bf5774edbd
mp3: use sizeof(sample) instead of hard-coded "2"
...
We are going to convert the code to 24 bit; don't hard-code a sample
size of 2 bytes.
2008-10-23 16:58:14 +02:00