aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/command.c16
-rw-r--r--src/decoder/ffmpeg_decoder_plugin.c5
-rw-r--r--src/playlist.h12
-rw-r--r--src/playlist_control.c24
4 files changed, 57 insertions, 0 deletions
diff --git a/src/command.c b/src/command.c
index eb2b9ae4f..e6bf36ac9 100644
--- a/src/command.c
+++ b/src/command.c
@@ -1532,6 +1532,21 @@ handle_seekid(struct client *client, G_GNUC_UNUSED int argc, char *argv[])
}
static enum command_return
+handle_seekcur(struct client *client, G_GNUC_UNUSED int argc, char *argv[])
+{
+ const char *p = argv[1];
+ bool relative = *p == '+' || *p == '-';
+ int seek_time;
+ if (!check_int(client, &seek_time, p, check_integer, p))
+ return COMMAND_RETURN_ERROR;
+
+ enum playlist_result result =
+ playlist_seek_current(&g_playlist, client->player_control,
+ seek_time, relative);
+ return print_playlist_result(client, result);
+}
+
+static enum command_return
handle_listallinfo(struct client *client, G_GNUC_UNUSED int argc, char *argv[])
{
const char *directory = "";
@@ -2159,6 +2174,7 @@ static const struct command commands[] = {
{ "save", PERMISSION_CONTROL, 1, 1, handle_save },
{ "search", PERMISSION_READ, 2, -1, handle_search },
{ "seek", PERMISSION_CONTROL, 2, 2, handle_seek },
+ { "seekcur", PERMISSION_CONTROL, 1, 1, handle_seekcur },
{ "seekid", PERMISSION_CONTROL, 2, 2, handle_seekid },
{ "sendmessage", PERMISSION_CONTROL, 2, 2, handle_send_message },
{ "setvol", PERMISSION_CONTROL, 1, 1, handle_setvol },
diff --git a/src/decoder/ffmpeg_decoder_plugin.c b/src/decoder/ffmpeg_decoder_plugin.c
index 14727715b..5dc95ccf8 100644
--- a/src/decoder/ffmpeg_decoder_plugin.c
+++ b/src/decoder/ffmpeg_decoder_plugin.c
@@ -432,6 +432,11 @@ ffmpeg_decode(struct decoder *decoder, struct input_stream *input)
decoder_initialized(decoder, &audio_format,
input->seekable, total_time);
+ AVDictionaryEntry *entry =
+ av_dict_get(format_context->metadata, "replaygain_track_gain", NULL, 0);
+ if (entry != NULL)
+ g_printerr("replaygain_track_gain=%s\n", entry->value);
+
enum decoder_command cmd;
do {
AVPacket packet;
diff --git a/src/playlist.h b/src/playlist.h
index 4c5f29e5d..caed0a220 100644
--- a/src/playlist.h
+++ b/src/playlist.h
@@ -239,6 +239,18 @@ enum playlist_result
playlist_seek_song_id(struct playlist *playlist, struct player_control *pc,
unsigned id, float seek_time);
+/**
+ * Seek within the current song. Fails if MPD is not currently
+ * playing.
+ *
+ * @param time the time in seconds
+ * @param relative if true, then the specified time is relative to the
+ * current position
+ */
+enum playlist_result
+playlist_seek_current(struct playlist *playlist, struct player_control *pc,
+ float seek_time, bool relative);
+
void
playlist_increment_version_all(struct playlist *playlist);
diff --git a/src/playlist_control.c b/src/playlist_control.c
index 998294845..0dea7676a 100644
--- a/src/playlist_control.c
+++ b/src/playlist_control.c
@@ -262,3 +262,27 @@ playlist_seek_song_id(struct playlist *playlist, struct player_control *pc,
return playlist_seek_song(playlist, pc, song, seek_time);
}
+
+enum playlist_result
+playlist_seek_current(struct playlist *playlist, struct player_control *pc,
+ float seek_time, bool relative)
+{
+ if (!playlist->playing)
+ return PLAYLIST_RESULT_NOT_PLAYING;
+
+ if (relative) {
+ struct player_status status;
+ pc_get_status(pc, &status);
+
+ if (status.state != PLAYER_STATE_PLAY &&
+ status.state != PLAYER_STATE_PAUSE)
+ return PLAYLIST_RESULT_NOT_PLAYING;
+
+ seek_time += (int)status.elapsed_time;
+ }
+
+ if (seek_time < 0)
+ seek_time = 0;
+
+ return playlist_seek_song(playlist, pc, playlist->current, seek_time);
+}