diff options
author | Max Kellermann <max@duempel.org> | 2011-03-19 09:58:07 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2011-03-19 09:58:07 +0100 |
commit | 0c9fc2f8090ed225c76296088e6760630eb42779 (patch) | |
tree | 9238436fb89ebf6a91d329eba0f5feec1ad137fd /src | |
parent | 1a954748a027aa5b4fc6c85b0ad96c2fa25d53b8 (diff) | |
parent | fe588a255ba713875a21bb98d3b7daf60af2844e (diff) | |
download | mpd-0c9fc2f8090ed225c76296088e6760630eb42779.tar.gz mpd-0c9fc2f8090ed225c76296088e6760630eb42779.tar.xz mpd-0c9fc2f8090ed225c76296088e6760630eb42779.zip |
Merge commit 'release-0.16.2'
Conflicts:
Makefile.am
NEWS
configure.ac
Diffstat (limited to 'src')
-rw-r--r-- | src/AudioCompress/compress.c | 28 | ||||
-rw-r--r-- | src/audio_format.h | 6 | ||||
-rw-r--r-- | src/audio_parser.c | 1 | ||||
-rw-r--r-- | src/command.c | 2 | ||||
-rw-r--r-- | src/decoder/audiofile_decoder_plugin.c | 2 | ||||
-rw-r--r-- | src/decoder/gme_decoder_plugin.c | 3 | ||||
-rw-r--r-- | src/encoder/flac_encoder.c | 6 | ||||
-rw-r--r-- | src/encoder/vorbis_encoder.c | 2 | ||||
-rw-r--r-- | src/encoder/wave_encoder.c | 4 | ||||
-rw-r--r-- | src/mixer/winmm_mixer_plugin.c | 10 | ||||
-rw-r--r-- | src/output/ao_plugin.c | 5 | ||||
-rw-r--r-- | src/output/httpd_internal.h | 2 | ||||
-rw-r--r-- | src/output/httpd_output_plugin.c | 2 | ||||
-rw-r--r-- | src/output/jack_output_plugin.c | 14 | ||||
-rw-r--r-- | src/output/mvp_plugin.c | 2 | ||||
-rw-r--r-- | src/output/oss_plugin.c | 23 | ||||
-rw-r--r-- | src/output_control.c | 1 | ||||
-rw-r--r-- | src/output_thread.c | 5 | ||||
-rw-r--r-- | src/pcm_byteswap.c | 2 | ||||
-rw-r--r-- | src/pipe.h | 2 | ||||
-rw-r--r-- | src/update_walk.c | 7 |
21 files changed, 90 insertions, 39 deletions
diff --git a/src/AudioCompress/compress.c b/src/AudioCompress/compress.c index d5c08372c..36cdfd8dd 100644 --- a/src/AudioCompress/compress.c +++ b/src/AudioCompress/compress.c @@ -16,16 +16,16 @@ struct Compressor { //! The compressor's preferences struct CompressorConfig prefs; - + //! History of the peak values int *peaks; - + //! History of the gain values int *gain; - + //! History of clip amounts int *clipped; - + unsigned int pos; unsigned int bufsz; }; @@ -41,9 +41,9 @@ struct Compressor *Compressor_new(unsigned int history) obj->peaks = obj->gain = obj->clipped = NULL; obj->bufsz = 0; obj->pos = 0; - + Compressor_setHistory(obj, history); - + return obj; } @@ -70,7 +70,7 @@ void Compressor_setHistory(struct Compressor *obj, unsigned int history) { if (!history) history = BUCKETS; - + obj->peaks = resizeArray(obj->peaks, history, obj->bufsz); obj->gain = resizeArray(obj->gain, history, obj->bufsz); obj->clipped = resizeArray(obj->clipped, history, obj->bufsz); @@ -82,7 +82,7 @@ struct CompressorConfig *Compressor_getConfig(struct Compressor *obj) return &obj->prefs; } -void Compressor_Process_int16(struct Compressor *obj, int16_t *audio, +void Compressor_Process_int16(struct Compressor *obj, int16_t *audio, unsigned int count) { struct CompressorConfig *prefs = Compressor_getConfig(obj); @@ -97,7 +97,7 @@ void Compressor_Process_int16(struct Compressor *obj, int16_t *audio, int *clipped = obj->clipped + slot; unsigned int ramp = count; int delta; - + ap = audio; for (i = 0; i < count; i++) { @@ -124,15 +124,15 @@ void Compressor_Process_int16(struct Compressor *obj, int16_t *audio, //! Determine target gain newGain = (1 << 10)*prefs->target/peakVal; - + //! Adjust the gain with inertia from the previous gain value - newGain = (curGain*((1 << prefs->smooth) - 1) + newGain) + newGain = (curGain*((1 << prefs->smooth) - 1) + newGain) >> prefs->smooth; - + //! Make sure it's no more than the maximum gain value if (newGain > (prefs->maxgain << 10)) newGain = prefs->maxgain << 10; - + //! Make sure it's no less than 1:1 if (newGain < (1 << 10)) newGain = 1 << 10; @@ -144,7 +144,7 @@ void Compressor_Process_int16(struct Compressor *obj, int16_t *audio, //! Truncate the ramp time ramp = peakPos; } - + //! Record the new gain obj->gain[slot] = newGain; diff --git a/src/audio_format.h b/src/audio_format.h index 340e4987d..1a54a092a 100644 --- a/src/audio_format.h +++ b/src/audio_format.h @@ -22,6 +22,7 @@ #include <stdint.h> #include <stdbool.h> +#include <assert.h> enum sample_format { SAMPLE_FORMAT_UNDEFINED = 0, @@ -219,6 +220,9 @@ static inline void audio_format_mask_apply(struct audio_format *af, const struct audio_format *mask) { + assert(audio_format_valid(af)); + assert(audio_format_mask_valid(mask)); + if (mask->sample_rate != 0) af->sample_rate = mask->sample_rate; @@ -227,6 +231,8 @@ audio_format_mask_apply(struct audio_format *af, if (mask->channels != 0) af->channels = mask->channels; + + assert(audio_format_valid(af)); } /** diff --git a/src/audio_parser.c b/src/audio_parser.c index bde48828e..1138c9588 100644 --- a/src/audio_parser.c +++ b/src/audio_parser.c @@ -192,6 +192,7 @@ audio_format_parse(struct audio_format *dest, const char *src, } audio_format_init(dest, rate, sample_format, channels); + assert(audio_format_valid(dest)); return true; } diff --git a/src/command.c b/src/command.c index 03d48a38a..bbfc84359 100644 --- a/src/command.c +++ b/src/command.c @@ -763,7 +763,7 @@ handle_load(struct client *client, G_GNUC_UNUSED int argc, char *argv[]) result = playlist_open_into_queue(argv[1], &g_playlist, client->player_control, true); if (result != PLAYLIST_RESULT_NO_SUCH_LIST) - return result; + return print_playlist_result(client, result); result = playlist_load_spl(&g_playlist, client->player_control, argv[1]); diff --git a/src/decoder/audiofile_decoder_plugin.c b/src/decoder/audiofile_decoder_plugin.c index 6f9d0dd20..c862168f8 100644 --- a/src/decoder/audiofile_decoder_plugin.c +++ b/src/decoder/audiofile_decoder_plugin.c @@ -244,7 +244,7 @@ static const char *const audiofile_suffixes[] = { static const char *const audiofile_mime_types[] = { "audio/x-wav", "audio/x-aiff", - NULL + NULL }; const struct decoder_plugin audiofile_decoder_plugin = { diff --git a/src/decoder/gme_decoder_plugin.c b/src/decoder/gme_decoder_plugin.c index 4a5220a3f..e14a52d32 100644 --- a/src/decoder/gme_decoder_plugin.c +++ b/src/decoder/gme_decoder_plugin.c @@ -153,6 +153,9 @@ gme_file_decode(struct decoder *decoder, const char *path_fs) if((gme_err = gme_start_track(emu, song_num)) != NULL) g_warning("%s", gme_err); + if(ti->length > 0) + gme_set_fade(emu, ti->length); + /* play */ do { gme_err = gme_play(emu, GME_BUFFER_SAMPLES, buf); diff --git a/src/encoder/flac_encoder.c b/src/encoder/flac_encoder.c index 4312fedb2..a7d35597e 100644 --- a/src/encoder/flac_encoder.c +++ b/src/encoder/flac_encoder.c @@ -55,7 +55,7 @@ static bool flac_encoder_configure(struct flac_encoder *encoder, const struct config_param *param, G_GNUC_UNUSED GError **error) { - encoder->compression = config_get_block_unsigned(param, + encoder->compression = config_get_block_unsigned(param, "compression", 5); return true; @@ -218,7 +218,7 @@ flac_encoder_open(struct encoder *_encoder, struct audio_format *audio_format, if (init_status != FLAC__STREAM_ENCODER_OK) { g_set_error(error, flac_encoder_quark(), 0, - "failed to initialize encoder: %s\n", + "failed to initialize encoder: %s\n", FLAC__StreamEncoderStateString[init_status]); flac_encoder_close(_encoder); return false; @@ -234,7 +234,7 @@ flac_encoder_open(struct encoder *_encoder, struct audio_format *audio_format, if(init_status != FLAC__STREAM_ENCODER_INIT_STATUS_OK) { g_set_error(error, flac_encoder_quark(), 0, - "failed to initialize encoder: %s\n", + "failed to initialize encoder: %s\n", FLAC__StreamEncoderInitStatusString[init_status]); flac_encoder_close(_encoder); return false; diff --git a/src/encoder/vorbis_encoder.c b/src/encoder/vorbis_encoder.c index 94816a7ac..5b3110988 100644 --- a/src/encoder/vorbis_encoder.c +++ b/src/encoder/vorbis_encoder.c @@ -276,6 +276,8 @@ vorbis_encoder_flush(struct encoder *_encoder, G_GNUC_UNUSED GError **error) vorbis_analysis_init(&encoder->vd, &encoder->vi); vorbis_block_init(&encoder->vd, &encoder->vb); + ogg_stream_reset(&encoder->os); + encoder->flush = true; return true; } diff --git a/src/encoder/wave_encoder.c b/src/encoder/wave_encoder.c index 7f1d4fcdf..6ebacab7d 100644 --- a/src/encoder/wave_encoder.c +++ b/src/encoder/wave_encoder.c @@ -58,7 +58,7 @@ wave_encoder_quark(void) } static void -fill_wave_header(struct wave_header *header, int channels, int bits, +fill_wave_header(struct wave_header *header, int channels, int bits, int freq, int block_size) { int data_size = 0x0FFFFFFF; @@ -142,7 +142,7 @@ wave_encoder_open(struct encoder *_encoder, buffer = pcm_buffer_get(&encoder->buffer, sizeof(struct wave_header) ); /* create PCM wave header in initial buffer */ - fill_wave_header((struct wave_header *) buffer, + fill_wave_header((struct wave_header *) buffer, audio_format->channels, encoder->bits, audio_format->sample_rate, diff --git a/src/mixer/winmm_mixer_plugin.c b/src/mixer/winmm_mixer_plugin.c index 174c1ec04..ceddf6afd 100644 --- a/src/mixer/winmm_mixer_plugin.c +++ b/src/mixer/winmm_mixer_plugin.c @@ -58,11 +58,11 @@ winmm_mixer_init(void *ao, G_GNUC_UNUSED const struct config_param *param, G_GNUC_UNUSED GError **error_r) { assert(ao != NULL); - + struct winmm_mixer *wm = g_new(struct winmm_mixer, 1); mixer_init(&wm->base, &winmm_mixer_plugin); wm->output = (struct winmm_output *) ao; - + return &wm->base; } @@ -79,13 +79,13 @@ winmm_mixer_get_volume(struct mixer *mixer, GError **error_r) DWORD volume; HWAVEOUT handle = winmm_output_get_handle(wm->output); MMRESULT result = waveOutGetVolume(handle, &volume); - + if (result != MMSYSERR_NOERROR) { g_set_error(error_r, 0, winmm_mixer_quark(), "Failed to get winmm volume"); return -1; } - + return winmm_volume_decode(volume); } @@ -102,7 +102,7 @@ winmm_mixer_set_volume(struct mixer *mixer, unsigned volume, GError **error_r) "Failed to set winmm volume"); return false; } - + return true; } diff --git a/src/output/ao_plugin.c b/src/output/ao_plugin.c index 21d60eb58..71e06bad9 100644 --- a/src/output/ao_plugin.c +++ b/src/output/ao_plugin.c @@ -26,6 +26,9 @@ #undef G_LOG_DOMAIN #define G_LOG_DOMAIN "ao" +/* An ao_sample_format, with all fields set to zero: */ +static const ao_sample_format OUR_AO_FORMAT_INITIALIZER; + static unsigned ao_output_ref; struct ao_data { @@ -167,7 +170,7 @@ static bool ao_output_open(void *data, struct audio_format *audio_format, GError **error) { - ao_sample_format format; + ao_sample_format format = OUR_AO_FORMAT_INITIALIZER; struct ao_data *ad = (struct ao_data *)data; switch (audio_format->format) { diff --git a/src/output/httpd_internal.h b/src/output/httpd_internal.h index d9c764bfd..67396b667 100644 --- a/src/output/httpd_internal.h +++ b/src/output/httpd_internal.h @@ -111,7 +111,7 @@ struct httpd_output { char buffer[32768]; /** - * The maximum and current number of clients connected + * The maximum and current number of clients connected * at the same time. */ guint clients_max, clients_cnt; diff --git a/src/output/httpd_output_plugin.c b/src/output/httpd_output_plugin.c index bcc27f884..7fde676c5 100644 --- a/src/output/httpd_output_plugin.c +++ b/src/output/httpd_output_plugin.c @@ -36,6 +36,7 @@ #include <errno.h> #ifdef HAVE_LIBWRAP +#include <sys/socket.h> /* needed for AF_UNIX */ #include <tcpd.h> #endif @@ -123,6 +124,7 @@ httpd_output_init(G_GNUC_UNUSED const struct audio_format *audio_format, /* initialize metadata */ httpd->metadata = NULL; + httpd->unflushed_input = 0; /* initialize encoder */ diff --git a/src/output/jack_output_plugin.c b/src/output/jack_output_plugin.c index 8ea5cb2fd..4df84fd23 100644 --- a/src/output/jack_output_plugin.c +++ b/src/output/jack_output_plugin.c @@ -40,7 +40,7 @@ enum { MAX_PORTS = 16, }; -static const size_t sample_size = sizeof(jack_default_audio_sample_t); +static const size_t jack_sample_size = sizeof(jack_default_audio_sample_t); struct jack_data { /** @@ -103,9 +103,9 @@ mpd_jack_available(const struct jack_data *jd) min = current; } - assert(min % sample_size == 0); + assert(min % jack_sample_size == 0); - return min / sample_size; + return min / jack_sample_size; } static int @@ -123,7 +123,7 @@ mpd_jack_process(jack_nframes_t nframes, void *arg) const jack_nframes_t available = mpd_jack_available(jd); for (unsigned i = 0; i < jd->audio_format.channels; ++i) jack_ringbuffer_read_advance(jd->ringbuffer[i], - available * sample_size); + available * jack_sample_size); /* generate silence while MPD is paused */ @@ -144,7 +144,7 @@ mpd_jack_process(jack_nframes_t nframes, void *arg) for (unsigned i = 0; i < jd->audio_format.channels; ++i) { out = jack_port_get_buffer(jd->ports[i], nframes); jack_ringbuffer_read(jd->ringbuffer[i], - (char *)out, available * sample_size); + (char *)out, available * jack_sample_size); for (jack_nframes_t f = available; f < nframes; ++f) /* ringbuffer underrun, fill with silence */ @@ -675,7 +675,7 @@ mpd_jack_play(void *data, const void *chunk, size_t size, GError **error_r) space = space1; } - if (space >= frame_size) + if (space >= jack_sample_size) break; /* XXX do something more intelligent to @@ -683,7 +683,7 @@ mpd_jack_play(void *data, const void *chunk, size_t size, GError **error_r) g_usleep(1000); } - space /= sample_size; + space /= jack_sample_size; if (space < size) size = space; diff --git a/src/output/mvp_plugin.c b/src/output/mvp_plugin.c index 64fc77016..be4c8dbc0 100644 --- a/src/output/mvp_plugin.c +++ b/src/output/mvp_plugin.c @@ -17,7 +17,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -/* +/* * Media MVP audio output based on code from MVPMC project: * http://mvpmc.sourceforge.net/ */ diff --git a/src/output/oss_plugin.c b/src/output/oss_plugin.c index bd3ccb774..d7df594d3 100644 --- a/src/output/oss_plugin.c +++ b/src/output/oss_plugin.c @@ -41,6 +41,15 @@ # include <sys/soundcard.h> #endif /* !(defined(__OpenBSD__) || defined(__NetBSD__) */ +/* We got bug reports from FreeBSD users who said that the two 24 bit + formats generate white noise on FreeBSD, but 32 bit works. This is + a workaround until we know what exactly is expected by the kernel + audio drivers. */ +#ifndef __linux__ +#undef AFMT_S24_PACKED +#undef AFMT_S24_NE +#endif + struct oss_data { int fd; const char *device; @@ -347,7 +356,7 @@ oss_setup_sample_rate(int fd, struct audio_format *audio_format, case SUCCESS: if (!audio_valid_sample_rate(sample_rate)) break; - + audio_format->sample_rate = sample_rate; return true; @@ -461,6 +470,12 @@ oss_setup_sample_format(int fd, struct audio_format *audio_format, break; audio_format->format = mpd_format; + +#ifdef AFMT_S24_PACKED + if (oss_format == AFMT_S24_PACKED) + audio_format->reverse_endian = + G_BYTE_ORDER != G_LITTLE_ENDIAN; +#endif return true; case ERROR: @@ -502,6 +517,12 @@ oss_setup_sample_format(int fd, struct audio_format *audio_format, break; audio_format->format = mpd_format; + +#ifdef AFMT_S24_PACKED + if (oss_format == AFMT_S24_PACKED) + audio_format->reverse_endian = + G_BYTE_ORDER != G_LITTLE_ENDIAN; +#endif return true; case ERROR: diff --git a/src/output_control.c b/src/output_control.c index d4bfc241c..8efe08f05 100644 --- a/src/output_control.c +++ b/src/output_control.c @@ -139,6 +139,7 @@ audio_output_open(struct audio_output *ao, { bool open; + assert(audio_format_valid(audio_format)); assert(mp != NULL); if (ao->fail_timer != NULL) { diff --git a/src/output_thread.c b/src/output_thread.c index 7d47baf46..21096eb04 100644 --- a/src/output_thread.c +++ b/src/output_thread.c @@ -96,6 +96,8 @@ ao_filter_open(struct audio_output *ao, struct audio_format *audio_format, GError **error_r) { + assert(audio_format_valid(audio_format)); + /* the replay_gain filter cannot fail here */ if (ao->replay_gain_filter != NULL) filter_open(ao->replay_gain_filter, audio_format, error_r); @@ -137,6 +139,7 @@ ao_open(struct audio_output *ao) assert(!ao->open); assert(ao->pipe != NULL); assert(ao->chunk == NULL); + assert(audio_format_valid(&ao->in_audio_format)); if (ao->fail_timer != NULL) { /* this can only happen when this @@ -165,6 +168,8 @@ ao_open(struct audio_output *ao) return; } + assert(audio_format_valid(filter_audio_format)); + ao->out_audio_format = *filter_audio_format; audio_format_mask_apply(&ao->out_audio_format, &ao->config_audio_format); diff --git a/src/pcm_byteswap.c b/src/pcm_byteswap.c index 9aabe592f..4e604c79a 100644 --- a/src/pcm_byteswap.c +++ b/src/pcm_byteswap.c @@ -49,7 +49,7 @@ const int16_t *pcm_byteswap_16(struct pcm_buffer *buffer, static inline uint32_t swab32(uint32_t x) { - return (x << 24) | + return (x << 24) | ((x & 0xff00) << 8) | ((x & 0xff0000) >> 8) | (x >> 24); diff --git a/src/pipe.h b/src/pipe.h index 512e7bf4f..785c1b943 100644 --- a/src/pipe.h +++ b/src/pipe.h @@ -20,9 +20,9 @@ #ifndef MPD_PIPE_H #define MPD_PIPE_H -#ifndef NDEBUG #include <stdbool.h> +#ifndef NDEBUG struct audio_format; #endif diff --git a/src/update_walk.c b/src/update_walk.c index a3272e618..e5ab4fc37 100644 --- a/src/update_walk.c +++ b/src/update_walk.c @@ -300,6 +300,9 @@ stat_directory(const struct directory *directory, struct stat *st) if (path_fs == NULL) return -1; ret = stat(path_fs, st); + if (ret < 0) + g_warning("Failed to stat %s: %s", path_fs, g_strerror(errno)); + g_free(path_fs); return ret; } @@ -316,6 +319,9 @@ stat_directory_child(const struct directory *parent, const char *name, return -1; ret = stat(path_fs, st); + if (ret < 0) + g_warning("Failed to stat %s: %s", path_fs, g_strerror(errno)); + g_free(path_fs); return ret; } @@ -557,6 +563,7 @@ directory_child_access(const struct directory *directory, /* access() is useless on WIN32 */ (void)directory; (void)name; + (void)mode; return true; #else char *path = map_directory_child_fs(directory, name); |