Skip to content

Commit

Permalink
Accept "nan" for mixrampdelay, sets it to -1 (disblaed) Issue #9
Browse files Browse the repository at this point in the history
Changes types from double to float for mixrampdb and mixrampdelay
  • Loading branch information
jcorporation committed Jun 5, 2018
1 parent 5cf9b5f commit e906fd2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
7 changes: 4 additions & 3 deletions htdocs/js/mpd.js
Original file line number Diff line number Diff line change
Expand Up @@ -976,7 +976,7 @@ function confirmSettings() {
}
}
if (!$('#inputMixrampdb').is(':disabled')) {
value=parseFloat($('#inputMixrampdb').val());
var value=parseFloat($('#inputMixrampdb').val());
if (!isNaN(value)) {
$('#inputMixrampdb').val(value);
} else {
Expand All @@ -987,11 +987,12 @@ function confirmSettings() {
}
}
if (!$('#inputMixrampdelay').is(':disabled')) {
value=parseFloat($('#inputMixrampdelay').val());
if ($('#inputMixrampdelay').val() == 'nan') $('#inputMixrampdelay').val('-1');
var value=parseFloat($('#inputMixrampdelay').val());
if (!isNaN(value)) {
$('#inputMixrampdelay').val(value);
} else {
$('#inputMixrampdelay').popover({"content":"Must be a number","trigger":"manual"});
$('#inputMixrampdelay').popover({"content":"Must be a number, -1 to disable","trigger":"manual"});
$('#inputMixrampdelay').popover('show');
$('#inputMixrampdelay').focus();
formOK=false;
Expand Down
12 changes: 6 additions & 6 deletions src/mpd_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ int callback_mpd(struct mg_connection *c)
enum mpd_cmd_ids cmd_id = get_cmd_id(c->content);
size_t n = 0;
unsigned int uint_buf, uint_buf_2;
double double_buf;
int int_buf;
float float_buf;
char *p_charbuf = NULL, *token;
char *p_charbuf2 = NULL;
char *searchstr = NULL;
Expand Down Expand Up @@ -139,12 +139,12 @@ int callback_mpd(struct mg_connection *c)
mpd_run_crossfade(mpd.conn, uint_buf);
break;
case MPD_API_SET_MIXRAMPDB:
if(sscanf(c->content, "MPD_API_SET_MIXRAMPDB,%lf", &double_buf))
mpd_run_mixrampdb(mpd.conn, double_buf);
if(sscanf(c->content, "MPD_API_SET_MIXRAMPDB,%f", &float_buf))
mpd_run_mixrampdb(mpd.conn, float_buf);
break;
case MPD_API_SET_MIXRAMPDELAY:
if(sscanf(c->content, "MPD_API_SET_MIXRAMPDELAY,%lf", &double_buf))
mpd_run_mixrampdelay(mpd.conn, double_buf);
if(sscanf(c->content, "MPD_API_SET_MIXRAMPDELAY,%f", &float_buf))
mpd_run_mixrampdelay(mpd.conn, float_buf);
break;
case MPD_API_GET_OUTPUTS:
mpd.buf_size = mpd_put_outputs(mpd.buf, 1);
Expand Down Expand Up @@ -750,7 +750,7 @@ int mympd_put_settings(char *buffer)
len = snprintf(buffer, MAX_SIZE,
"{\"type\":\"settings\", \"data\":{"
"\"repeat\":%d, \"single\":%d, \"crossfade\":%d, \"consume\":%d, \"random\":%d, "
"\"mixrampdb\": %lf, \"mixrampdelay\": %lf, \"mpdhost\" : \"%s\", \"mpdport\": \"%d\", \"passwort_set\": %s, "
"\"mixrampdb\": %f, \"mixrampdelay\": %f, \"mpdhost\" : \"%s\", \"mpdport\": \"%d\", \"passwort_set\": %s, "
"\"streamport\": \"%d\",\"coverimage\": \"%s\", \"max_elements_per_page\": %d, \"replaygain\": \"%s\""
"}}",
mpd_status_get_repeat(status),
Expand Down

0 comments on commit e906fd2

Please sign in to comment.