From d5287682d14c0f6e99ba721fa844fd29d90b583a Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Fri, 29 Aug 2014 23:46:38 +0200 Subject: ArgParser: allow fractional seconds in ParseCommandArg(SongTime) --- NEWS | 1 + doc/protocol.xml | 14 ++++++++------ src/protocol/ArgParser.cxx | 8 ++++---- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/NEWS b/NEWS index a2ab58f32..4f9c7da02 100644 --- a/NEWS +++ b/NEWS @@ -8,6 +8,7 @@ ver 0.19 (not yet released) - "list" on album artist falls back to the artist tag - "list" and "count" allow grouping - new "search"/"find" filter "modified-since" + - "seek*" allows fractional position - close connection after syntax error * database - proxy: forward "idle" events diff --git a/doc/protocol.xml b/doc/protocol.xml index cff685060..af2a312d2 100644 --- a/doc/protocol.xml +++ b/doc/protocol.xml @@ -877,8 +877,8 @@ Seeks to the position TIME (in - seconds) of entry SONGPOS in the - playlist. + seconds; fractions allowed) of entry + SONGPOS in the playlist. @@ -893,7 +893,8 @@ Seeks to the position TIME (in - seconds) of song SONGID. + seconds; fractions allowed) of song + SONGID. @@ -907,9 +908,10 @@ - Seeks to the position TIME within the - current song. If prefixed by '+' or '-', then the time - is relative to the current playing position. + Seeks to the position TIME (in + seconds; fractions allowed) within the current song. If + prefixed by '+' or '-', then the time is relative to the + current playing position. diff --git a/src/protocol/ArgParser.cxx b/src/protocol/ArgParser.cxx index 709d12962..e3a0c107c 100644 --- a/src/protocol/ArgParser.cxx +++ b/src/protocol/ArgParser.cxx @@ -191,8 +191,8 @@ check_float(Client &client, float *value_r, const char *s) bool ParseCommandArg(Client &client, SongTime &value_r, const char *s) { - unsigned value; - bool success = check_unsigned(client, &value, s); + float value; + bool success = check_float(client, &value, s) && value >= 0; if (success) value_r = SongTime::FromS(value); @@ -202,8 +202,8 @@ ParseCommandArg(Client &client, SongTime &value_r, const char *s) bool ParseCommandArg(Client &client, SignedSongTime &value_r, const char *s) { - int value; - bool success = check_int(client, &value, s); + float value; + bool success = check_float(client, &value, s); if (success) value_r = SignedSongTime::FromS(value); -- cgit v1.2.3