Commit 85115798 authored by Led's avatar Led

Merge commit '0.14-alpha3' into alt

parents cd6cf8d0 1a029af0
#! /bin/sh #! /bin/sh
# Guess values for system-dependent variables and create Makefiles. # Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.63 for mpd 0.14~alpha2. # Generated by GNU Autoconf 2.63 for mpd 0.14~alpha3.
# #
# Report bugs to <musicpd-dev-team@lists.sourceforge.net>. # Report bugs to <musicpd-dev-team@lists.sourceforge.net>.
# #
...@@ -596,8 +596,8 @@ SHELL=${CONFIG_SHELL-/bin/sh} ...@@ -596,8 +596,8 @@ SHELL=${CONFIG_SHELL-/bin/sh}
# Identity of this package. # Identity of this package.
PACKAGE_NAME='mpd' PACKAGE_NAME='mpd'
PACKAGE_TARNAME='mpd' PACKAGE_TARNAME='mpd'
PACKAGE_VERSION='0.14~alpha2' PACKAGE_VERSION='0.14~alpha3'
PACKAGE_STRING='mpd 0.14~alpha2' PACKAGE_STRING='mpd 0.14~alpha3'
PACKAGE_BUGREPORT='musicpd-dev-team@lists.sourceforge.net' PACKAGE_BUGREPORT='musicpd-dev-team@lists.sourceforge.net'
ac_unique_file="src/main.c" ac_unique_file="src/main.c"
...@@ -1478,7 +1478,7 @@ if test "$ac_init_help" = "long"; then ...@@ -1478,7 +1478,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing. # Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh. # This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF cat <<_ACEOF
\`configure' configures mpd 0.14~alpha2 to adapt to many kinds of systems. \`configure' configures mpd 0.14~alpha3 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]... Usage: $0 [OPTION]... [VAR=VALUE]...
...@@ -1548,7 +1548,7 @@ fi ...@@ -1548,7 +1548,7 @@ fi
if test -n "$ac_init_help"; then if test -n "$ac_init_help"; then
case $ac_init_help in case $ac_init_help in
short | recursive ) echo "Configuration of mpd 0.14~alpha2:";; short | recursive ) echo "Configuration of mpd 0.14~alpha3:";;
esac esac
cat <<\_ACEOF cat <<\_ACEOF
...@@ -1746,7 +1746,7 @@ fi ...@@ -1746,7 +1746,7 @@ fi
test -n "$ac_init_help" && exit $ac_status test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then if $ac_init_version; then
cat <<\_ACEOF cat <<\_ACEOF
mpd configure 0.14~alpha2 mpd configure 0.14~alpha3
generated by GNU Autoconf 2.63 generated by GNU Autoconf 2.63
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
...@@ -1760,7 +1760,7 @@ cat >config.log <<_ACEOF ...@@ -1760,7 +1760,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake. running configure, to aid debugging if configure makes a mistake.
It was created by mpd $as_me 0.14~alpha2, which was It was created by mpd $as_me 0.14~alpha3, which was
generated by GNU Autoconf 2.63. Invocation command line was generated by GNU Autoconf 2.63. Invocation command line was
$ $0 $@ $ $0 $@
...@@ -2457,7 +2457,7 @@ fi ...@@ -2457,7 +2457,7 @@ fi
# Define the identity of the package. # Define the identity of the package.
PACKAGE='mpd' PACKAGE='mpd'
VERSION='0.14~alpha2' VERSION='0.14~alpha3'
cat >>confdefs.h <<_ACEOF cat >>confdefs.h <<_ACEOF
...@@ -12937,7 +12937,7 @@ exec 6>&1 ...@@ -12937,7 +12937,7 @@ exec 6>&1
# report actual input values of CONFIG_FILES etc. instead of their # report actual input values of CONFIG_FILES etc. instead of their
# values after options handling. # values after options handling.
ac_log=" ac_log="
This file was extended by mpd $as_me 0.14~alpha2, which was This file was extended by mpd $as_me 0.14~alpha3, which was
generated by GNU Autoconf 2.63. Invocation command line was generated by GNU Autoconf 2.63. Invocation command line was
CONFIG_FILES = $CONFIG_FILES CONFIG_FILES = $CONFIG_FILES
...@@ -13000,7 +13000,7 @@ Report bugs to <bug-autoconf@gnu.org>." ...@@ -13000,7 +13000,7 @@ Report bugs to <bug-autoconf@gnu.org>."
_ACEOF _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_version="\\ ac_cs_version="\\
mpd config.status 0.14~alpha2 mpd config.status 0.14~alpha3
configured by $0, generated by GNU Autoconf 2.63, configured by $0, generated by GNU Autoconf 2.63,
with options \\"`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\" with options \\"`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\"
......
AC_PREREQ(2.60) AC_PREREQ(2.60)
AC_INIT(mpd, 0.14~alpha2, musicpd-dev-team@lists.sourceforge.net) AC_INIT(mpd, 0.14~alpha3, musicpd-dev-team@lists.sourceforge.net)
AC_CONFIG_SRCDIR([src/main.c]) AC_CONFIG_SRCDIR([src/main.c])
AM_INIT_AUTOMAKE([foreign 1.9 dist-bzip2]) AM_INIT_AUTOMAKE([foreign 1.9 dist-bzip2])
AM_CONFIG_HEADER(config.h) AM_CONFIG_HEADER(config.h)
......
...@@ -994,10 +994,7 @@ mp3_read(struct mp3_data *data, struct replay_gain_info **replay_gain_info_r) ...@@ -994,10 +994,7 @@ mp3_read(struct mp3_data *data, struct replay_gain_info **replay_gain_info_r)
cmd = mp3_synth_and_send(data, cmd = mp3_synth_and_send(data,
replay_gain_info_r != NULL replay_gain_info_r != NULL
? *replay_gain_info_r : NULL); ? *replay_gain_info_r : NULL);
if (cmd != DECODE_COMMAND_NONE) if (cmd == DECODE_COMMAND_SEEK) {
return false;
if (decoder_get_command(decoder) == DECODE_COMMAND_SEEK) {
unsigned long j; unsigned long j;
assert(data->input_stream->seekable); assert(data->input_stream->seekable);
...@@ -1015,7 +1012,8 @@ mp3_read(struct mp3_data *data, struct replay_gain_info **replay_gain_info_r) ...@@ -1015,7 +1012,8 @@ mp3_read(struct mp3_data *data, struct replay_gain_info **replay_gain_info_r)
data->mute_frame = MUTEFRAME_SEEK; data->mute_frame = MUTEFRAME_SEEK;
decoder_command_finished(decoder); decoder_command_finished(decoder);
} }
} } else if (cmd != DECODE_COMMAND_NONE)
return false;
} }
while (true) { while (true) {
......
...@@ -46,13 +46,19 @@ static struct { ...@@ -46,13 +46,19 @@ static struct {
{ "disc", TAG_ITEM_DISC }, { "disc", TAG_ITEM_DISC },
}; };
/** A pointer type for format converter function. */
typedef void (*format_samples_t)(
int bytes_per_sample,
void *buffer, uint32_t count
);
/* /*
* This function has been borrowed from the tiny player found on * This function has been borrowed from the tiny player found on
* wavpack.com. Modifications were required because mpd only handles * wavpack.com. Modifications were required because mpd only handles
* max 24-bit samples. * max 24-bit samples.
*/ */
static void static void
format_samples_int(int bytes_per_sample, void *buffer, uint32_t samcnt) format_samples_int(int bytes_per_sample, void *buffer, uint32_t count)
{ {
int32_t *src = buffer; int32_t *src = buffer;
...@@ -68,7 +74,7 @@ format_samples_int(int bytes_per_sample, void *buffer, uint32_t samcnt) ...@@ -68,7 +74,7 @@ format_samples_int(int bytes_per_sample, void *buffer, uint32_t samcnt)
assert(sizeof(uchar) <= sizeof(uint32_t)); assert(sizeof(uchar) <= sizeof(uint32_t));
/* pass through and align 8-bit samples */ /* pass through and align 8-bit samples */
while (samcnt--) { while (count--) {
*dst++ = *src++; *dst++ = *src++;
} }
break; break;
...@@ -78,7 +84,7 @@ format_samples_int(int bytes_per_sample, void *buffer, uint32_t samcnt) ...@@ -78,7 +84,7 @@ format_samples_int(int bytes_per_sample, void *buffer, uint32_t samcnt)
assert(sizeof(uint16_t) <= sizeof(uint32_t)); assert(sizeof(uint16_t) <= sizeof(uint32_t));
/* pass through and align 16-bit samples */ /* pass through and align 16-bit samples */
while (samcnt--) { while (count--) {
*dst++ = *src++; *dst++ = *src++;
} }
break; break;
...@@ -91,7 +97,7 @@ format_samples_int(int bytes_per_sample, void *buffer, uint32_t samcnt) ...@@ -91,7 +97,7 @@ format_samples_int(int bytes_per_sample, void *buffer, uint32_t samcnt)
assert(sizeof(uint32_t) <= sizeof(uint32_t)); assert(sizeof(uint32_t) <= sizeof(uint32_t));
/* downsample to 24-bit */ /* downsample to 24-bit */
while (samcnt--) { while (count--) {
*dst++ = *src++ >> 8; *dst++ = *src++ >> 8;
} }
break; break;
...@@ -104,13 +110,13 @@ format_samples_int(int bytes_per_sample, void *buffer, uint32_t samcnt) ...@@ -104,13 +110,13 @@ format_samples_int(int bytes_per_sample, void *buffer, uint32_t samcnt)
*/ */
static void static void
format_samples_float(mpd_unused int bytes_per_sample, void *buffer, format_samples_float(mpd_unused int bytes_per_sample, void *buffer,
uint32_t samcnt) uint32_t count)
{ {
int32_t *dst = buffer; int32_t *dst = buffer;
float *src = buffer; float *src = buffer;
assert(sizeof(int32_t) <= sizeof(float)); assert(sizeof(int32_t) <= sizeof(float));
while (samcnt--) { while (count--) {
*dst++ = (int32_t)(*src++ + 0.5f); *dst++ = (int32_t)(*src++ + 0.5f);
} }
} }
...@@ -120,18 +126,16 @@ format_samples_float(mpd_unused int bytes_per_sample, void *buffer, ...@@ -120,18 +126,16 @@ format_samples_float(mpd_unused int bytes_per_sample, void *buffer,
* Requires an already opened WavpackContext. * Requires an already opened WavpackContext.
*/ */
static void static void
wavpack_decode(struct decoder * decoder, WavpackContext *wpc, bool canseek, wavpack_decode(struct decoder *decoder, WavpackContext *wpc, bool can_seek,
struct replay_gain_info *replayGainInfo) struct replay_gain_info *replay_gain_info)
{ {
struct audio_format audio_format; struct audio_format audio_format;
void (*format_samples)(int bytes_per_sample, format_samples_t format_samples;
void *buffer, uint32_t samcnt);
char chunk[CHUNK_SIZE]; char chunk[CHUNK_SIZE];
float file_time; int samples_requested, samples_got;
int samplesreq, samplesgot; float total_time, current_time;
int allsamples; int bytes_per_sample, output_sample_size;
int position, outsamplesize; int position;
int bytes_per_sample;
audio_format.sample_rate = WavpackGetSampleRate(wpc); audio_format.sample_rate = WavpackGetSampleRate(wpc);
audio_format.channels = WavpackGetReducedChannels(wpc); audio_format.channels = WavpackGetReducedChannels(wpc);
...@@ -150,26 +154,30 @@ wavpack_decode(struct decoder * decoder, WavpackContext *wpc, bool canseek, ...@@ -150,26 +154,30 @@ wavpack_decode(struct decoder * decoder, WavpackContext *wpc, bool canseek,
format_samples = format_samples_int; format_samples = format_samples_int;
} }
allsamples = WavpackGetNumSamples(wpc); total_time = WavpackGetNumSamples(wpc);
total_time /= audio_format.sample_rate;
bytes_per_sample = WavpackGetBytesPerSample(wpc); bytes_per_sample = WavpackGetBytesPerSample(wpc);
outsamplesize = audio_format_frame_size(&audio_format); output_sample_size = bytes_per_sample;
if (output_sample_size == 3) {
output_sample_size = 4;
}
output_sample_size *= audio_format.channels;
/* wavpack gives us all kind of samples in a 32-bit space */ /* wavpack gives us all kind of samples in a 32-bit space */
samplesreq = sizeof(chunk) / (4 * audio_format.channels); samples_requested = sizeof(chunk) / (4 * audio_format.channels);
decoder_initialized(decoder, &audio_format, canseek, decoder_initialized(decoder, &audio_format, can_seek, total_time);
(float)allsamples / audio_format.sample_rate);
position = 0; position = 0;
do { do {
if (decoder_get_command(decoder) == DECODE_COMMAND_SEEK) { if (decoder_get_command(decoder) == DECODE_COMMAND_SEEK) {
if (canseek) { if (can_seek) {
int where; int where;
where = decoder_seek_where(decoder) * where = decoder_seek_where(decoder);
audio_format.sample_rate; where *= audio_format.sample_rate;
if (WavpackSeekSample(wpc, where)) { if (WavpackSeekSample(wpc, where)) {
position = where; position = where;
decoder_command_finished(decoder); decoder_command_finished(decoder);
...@@ -185,23 +193,29 @@ wavpack_decode(struct decoder * decoder, WavpackContext *wpc, bool canseek, ...@@ -185,23 +193,29 @@ wavpack_decode(struct decoder * decoder, WavpackContext *wpc, bool canseek,
break; break;
} }
samplesgot = WavpackUnpackSamples(wpc, samples_got = WavpackUnpackSamples(
(int32_t *)chunk, samplesreq); wpc, (int32_t *)chunk, samples_requested
if (samplesgot > 0) { );
if (samples_got > 0) {
int bitrate = (int)(WavpackGetInstantBitrate(wpc) / int bitrate = (int)(WavpackGetInstantBitrate(wpc) /
1000 + 0.5); 1000 + 0.5);
position += samplesgot; position += samples_got;
file_time = (float)position / audio_format.sample_rate; current_time = position;
current_time /= audio_format.sample_rate;
format_samples(bytes_per_sample, chunk,
samplesgot * audio_format.channels); format_samples(
bytes_per_sample, chunk,
decoder_data(decoder, NULL, chunk, samples_got * audio_format.channels
samplesgot * outsamplesize, );
file_time, bitrate,
replayGainInfo); decoder_data(
} decoder, NULL, chunk,
} while (samplesgot == samplesreq); samples_got * output_sample_size,
current_time, bitrate,
replay_gain_info
);
}
} while (samples_got > 0);
} }
/** /**
...@@ -230,17 +244,22 @@ wavpack_replaygain(WavpackContext *wpc) ...@@ -230,17 +244,22 @@ wavpack_replaygain(WavpackContext *wpc)
replay_gain_info = replay_gain_info_new(); replay_gain_info = replay_gain_info_new();
found = wavpack_tag_float(wpc, "replaygain_track_gain", found |= wavpack_tag_float(
&replay_gain_info->tuples[REPLAY_GAIN_TRACK].gain) wpc, "replaygain_track_gain",
|| &replay_gain_info->tuples[REPLAY_GAIN_TRACK].gain
wavpack_tag_float(wpc, "replaygain_track_peak", );
&replay_gain_info->tuples[REPLAY_GAIN_TRACK].peak) found |= wavpack_tag_float(
|| wpc, "replaygain_track_peak",
wavpack_tag_float(wpc, "replaygain_album_gain", &replay_gain_info->tuples[REPLAY_GAIN_TRACK].peak
&replay_gain_info->tuples[REPLAY_GAIN_ALBUM].gain) );
|| found |= wavpack_tag_float(
wavpack_tag_float(wpc, "replaygain_album_peak", wpc, "replaygain_album_gain",
&replay_gain_info->tuples[REPLAY_GAIN_ALBUM].peak); &replay_gain_info->tuples[REPLAY_GAIN_ALBUM].gain
);
found |= wavpack_tag_float(
wpc, "replaygain_album_peak",
&replay_gain_info->tuples[REPLAY_GAIN_ALBUM].peak
);
if (found) { if (found) {
return replay_gain_info; return replay_gain_info;
...@@ -261,38 +280,39 @@ wavpack_tagdup(const char *fname) ...@@ -261,38 +280,39 @@ wavpack_tagdup(const char *fname)
struct tag *tag; struct tag *tag;
char error[ERRORLEN]; char error[ERRORLEN];
char *s; char *s;
int ssize; int size, allocated_size;
int j;
wpc = WavpackOpenFileInput(fname, error, OPEN_TAGS, 0); wpc = WavpackOpenFileInput(fname, error, OPEN_TAGS, 0);
if (wpc == NULL) { if (wpc == NULL) {
g_warning("failed to open WavPack file \"%s\": %s\n", g_warning(
fname, error); "failed to open WavPack file \"%s\": %s\n",
fname, error
);
return NULL; return NULL;
} }
tag = tag_new(); tag = tag_new();
tag->time = tag->time = WavpackGetNumSamples(wpc);
(float)WavpackGetNumSamples(wpc) / WavpackGetSampleRate(wpc); tag->time /= WavpackGetSampleRate(wpc);
ssize = 0; allocated_size = 0;
s = NULL; s = NULL;
for (unsigned i = 0; i < G_N_ELEMENTS(tagtypes); ++i) { for (unsigned i = 0; i < G_N_ELEMENTS(tagtypes); ++i) {
j = WavpackGetTagItem(wpc, tagtypes[i].name, NULL, 0); size = WavpackGetTagItem(wpc, tagtypes[i].name, NULL, 0);
if (j > 0) { if (size > 0) {
++j; ++size; /* EOS */
if (s == NULL) { if (s == NULL) {
s = g_malloc(j); s = g_malloc(size);
ssize = j; allocated_size = size;
} else if (j > ssize) { } else if (size > allocated_size) {
char *t = (char *)g_realloc(s, j); char *t = (char *)g_realloc(s, size);
ssize = j; allocated_size = size;
s = t; s = t;
} }
WavpackGetTagItem(wpc, tagtypes[i].name, s, j); WavpackGetTagItem(wpc, tagtypes[i].name, s, size);
tag_add_item(tag, tagtypes[i].type, s); tag_add_item(tag, tagtypes[i].type, s);
} }
} }
...@@ -342,8 +362,9 @@ wavpack_input_read_bytes(void *id, void *data, int32_t bcount) ...@@ -342,8 +362,9 @@ wavpack_input_read_bytes(void *id, void *data, int32_t bcount)
/* wavpack fails if we return a partial read, so we just wait /* wavpack fails if we return a partial read, so we just wait
until the buffer is full */ until the buffer is full */
while (bcount > 0) { while (bcount > 0) {
size_t nbytes = decoder_read(wpin(id)->decoder, wpin(id)->is, size_t nbytes = decoder_read(
buf, bcount); wpin(id)->decoder, wpin(id)->is, buf, bcount
);
if (nbytes == 0) { if (nbytes == 0) {
/* EOF, error or a decoder command */ /* EOF, error or a decoder command */
break; break;
...@@ -450,8 +471,9 @@ wavpack_open_wvc(struct decoder *decoder, struct input_stream *is_wvc, ...@@ -450,8 +471,9 @@ wavpack_open_wvc(struct decoder *decoder, struct input_stream *is_wvc,
* And we try to buffer in order to get know * And we try to buffer in order to get know
* about a possible 404 error. * about a possible 404 error.
*/ */
nbytes = decoder_read(decoder, is_wvc, nbytes = decoder_read(
&first_byte, sizeof(first_byte)); decoder, is_wvc, &first_byte, sizeof(first_byte)
);
if (nbytes == 0) { if (nbytes == 0) {
input_stream_close(is_wvc); input_stream_close(is_wvc);
return false; return false;
...@@ -472,25 +494,30 @@ wavpack_streamdecode(struct decoder * decoder, struct input_stream *is) ...@@ -472,25 +494,30 @@ wavpack_streamdecode(struct decoder * decoder, struct input_stream *is)
char error[ERRORLEN]; char error[ERRORLEN];
WavpackContext *wpc; WavpackContext *wpc;
struct input_stream is_wvc; struct input_stream is_wvc;
int open_flags = OPEN_2CH_MAX | OPEN_NORMALIZE /*| OPEN_STREAMING*/; int open_flags = OPEN_2CH_MAX | OPEN_NORMALIZE;
struct wavpack_input isp, isp_wvc; struct wavpack_input isp, isp_wvc;
bool canseek = is->seekable; bool can_seek = is->seekable;
if (wavpack_open_wvc(decoder, &is_wvc, &isp_wvc)) { if (wavpack_open_wvc(decoder, &is_wvc, &isp_wvc)) {
open_flags |= OPEN_WVC; open_flags |= OPEN_WVC;
canseek &= is_wvc.seekable; can_seek &= is_wvc.seekable;
}
if (!can_seek) {
open_flags |= OPEN_STREAMING;
} }
wavpack_input_init(&isp, decoder, is); wavpack_input_init(&isp, decoder, is);
wpc = WavpackOpenFileInputEx(&mpd_is_reader, &isp, &isp_wvc, error, wpc = WavpackOpenFileInputEx(
open_flags, 23); &mpd_is_reader, &isp, &isp_wvc, error, open_flags, 23
);
if (wpc == NULL) { if (wpc == NULL) {
g_warning("failed to open WavPack stream: %s\n", error); g_warning("failed to open WavPack stream: %s\n", error);
return; return;
} }
wavpack_decode(decoder, wpc, canseek, NULL); wavpack_decode(decoder, wpc, can_seek, NULL);
WavpackCloseFile(wpc); WavpackCloseFile(wpc);
if (open_flags & OPEN_WVC) { if (open_flags & OPEN_WVC) {
...@@ -508,12 +535,15 @@ wavpack_filedecode(struct decoder *decoder, const char *fname) ...@@ -508,12 +535,15 @@ wavpack_filedecode(struct decoder *decoder, const char *fname)
WavpackContext *wpc; WavpackContext *wpc;
struct replay_gain_info *replay_gain_info; struct replay_gain_info *replay_gain_info;
wpc = WavpackOpenFileInput(fname, error, wpc = WavpackOpenFileInput(
OPEN_TAGS | OPEN_WVC | fname, error,
OPEN_2CH_MAX | OPEN_NORMALIZE, 23); OPEN_TAGS | OPEN_WVC | OPEN_2CH_MAX | OPEN_NORMALIZE, 23
);
if (wpc == NULL) { if (wpc == NULL) {
g_warning("failed to open WavPack file \"%s\": %s\n", g_warning(
fname, error); "failed to open WavPack file \"%s\": %s\n",
fname, error
);
return; return;
} }
...@@ -528,8 +558,15 @@ wavpack_filedecode(struct decoder *decoder, const char *fname) ...@@ -528,8 +558,15 @@ wavpack_filedecode(struct decoder *decoder, const char *fname)
WavpackCloseFile(wpc); WavpackCloseFile(wpc);
} }
static char const *const wavpack_suffixes[] = { "wv", NULL }; static char const *const wavpack_suffixes[] = {
static char const *const wavpack_mime_types[] = { "audio/x-wavpack", NULL }; "wv",
NULL
};
static char const *const wavpack_mime_types[] = {
"audio/x-wavpack",
NULL
};
const struct decoder_plugin wavpack_plugin = { const struct decoder_plugin wavpack_plugin = {
.name = "wavpack", .name = "wavpack",
......
...@@ -168,6 +168,9 @@ need_chunks(struct input_stream *is, bool wait) ...@@ -168,6 +168,9 @@ need_chunks(struct input_stream *is, bool wait)
if ((is == NULL || input_stream_buffer(is) <= 0) && wait) { if ((is == NULL || input_stream_buffer(is) <= 0) && wait) {
notify_wait(&dc.notify); notify_wait(&dc.notify);
notify_signal(&pc.notify); notify_signal(&pc.notify);
if (dc.command != DECODE_COMMAND_STOP)
return dc.command;
} }
return DECODE_COMMAND_NONE; return DECODE_COMMAND_NONE;
......
...@@ -75,6 +75,9 @@ mpd_log_func(G_GNUC_UNUSED const gchar *log_domain, ...@@ -75,6 +75,9 @@ mpd_log_func(G_GNUC_UNUSED const gchar *log_domain,
? stderr : stdout; ? stderr : stdout;
char *converted; char *converted;
if (log_level > (int)log_threshold)
return;
if (log_charset != NULL) { if (log_charset != NULL) {
converted = g_convert_with_fallback(message, -1, converted = g_convert_with_fallback(message, -1,
log_charset, "utf-8", log_charset, "utf-8",
......
...@@ -153,6 +153,9 @@ static void player_process_command(struct player *player) ...@@ -153,6 +153,9 @@ static void player_process_command(struct player *player)
case PLAYER_COMMAND_QUEUE: case PLAYER_COMMAND_QUEUE:
assert(pc.next_song != NULL); assert(pc.next_song != NULL);
assert(!player->queued);
assert(player->next_song_chunk == -1);
player->queued = true; player->queued = true;
player_command_finished(); player_command_finished();
break; break;
...@@ -352,10 +355,12 @@ static void do_play(void) ...@@ -352,10 +355,12 @@ static void do_play(void)
#endif #endif
if (decoder_is_idle() && !player.queued && if (decoder_is_idle() && !player.queued &&
player.next_song_chunk < 0 &&
pc.next_song != NULL && pc.next_song != NULL &&
pc.command == PLAYER_COMMAND_NONE) { pc.command == PLAYER_COMMAND_NONE) {
/* the decoder has finished the current song; /* the decoder has finished the current song;
request the next song from the playlist */ request the next song from the playlist */
pc.next_song = NULL; pc.next_song = NULL;
wakeup_main_task(); wakeup_main_task();
} }
...@@ -429,6 +434,7 @@ static void do_play(void) ...@@ -429,6 +434,7 @@ static void do_play(void)
/* wait for the /* wait for the
decoder */ decoder */
music_pipe_set_lazy(false); music_pipe_set_lazy(false);
notify_signal(&dc.notify);
notify_wait(&pc.notify); notify_wait(&pc.notify);
continue; continue;
} }
......
...@@ -79,14 +79,28 @@ static int volume_alsaSet = -1; ...@@ -79,14 +79,28 @@ static int volume_alsaSet = -1;
#ifdef HAVE_OSS #ifdef HAVE_OSS
#include <alloca.h> /* only alloca user in mpd atm, may change ... */
static void closeOssMixer(void) static void closeOssMixer(void)
{ {
while (close(volume_ossFd) && errno == EINTR) ; while (close(volume_ossFd) && errno == EINTR) ;
volume_ossFd = -1; volume_ossFd = -1;
} }
static int
oss_find_mixer(const char *name)
{
const char *labels[SOUND_MIXER_NRDEVICES] = SOUND_DEVICE_LABELS;
size_t name_length = strlen(name);
for (unsigned i = 0; i < SOUND_MIXER_NRDEVICES; i++) {
if (strncasecmp(name, labels[i], name_length) == 0 &&
(labels[i][name_length] == 0 ||
labels[i][name_length] == ' '))
return i;
}
return -1;
}
static int prepOssMixer(const char *device) static int prepOssMixer(const char *device)
{ {
ConfigParam *param; ConfigParam *param;
...@@ -97,7 +111,6 @@ static int prepOssMixer(const char *device) ...@@ -97,7 +111,6 @@ static int prepOssMixer(const char *device)
} }
if ((param = getConfigParam(CONF_MIXER_CONTROL))) { if ((param = getConfigParam(CONF_MIXER_CONTROL))) {
const char *labels[SOUND_MIXER_NRDEVICES] = SOUND_DEVICE_LABELS;
int i; int i;
int devmask = 0; int devmask = 0;
...@@ -107,20 +120,9 @@ static int prepOssMixer(const char *device) ...@@ -107,20 +120,9 @@ static int prepOssMixer(const char *device)
return -1; return -1;
} }
for (i = 0; i < SOUND_MIXER_NRDEVICES; i++) { i = oss_find_mixer(param->value);
ssize_t len = strlen(labels[i]);
char *duplicated = alloca(len + 1);
/* eliminate spaces at the end */
memcpy(duplicated, labels[i], len + 1);
len -= 2;
while (len >= 0 && duplicated[len] == ' ')
duplicated[len--] = '\0';
if (strcasecmp(duplicated, param->value) == 0)
break;
}
if (i >= SOUND_MIXER_NRDEVICES) { if (i < 0) {
WARNING("mixer control \"%s\" not found at line %i\n", WARNING("mixer control \"%s\" not found at line %i\n",
param->value, param->line); param->value, param->line);
closeOssMixer(); closeOssMixer();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment