aboutsummaryrefslogtreecommitdiffstats
path: root/src/decoder
diff options
context:
space:
mode:
authorYuriy Kaminskiy <yumkam@mail.ru>2011-01-21 16:25:52 +0300
committerMax Kellermann <max@duempel.org>2011-01-21 15:37:08 +0100
commit9ae3acf2e73f63550218c2af92243490a4344426 (patch)
tree8722935f11e9f39ceeda3fe0c0be59ecb28bdd55 /src/decoder
parent731ea9b489ec5e4134a07092f9eeb0a81865d841 (diff)
downloadmpd-9ae3acf2e73f63550218c2af92243490a4344426.tar.gz
mpd-9ae3acf2e73f63550218c2af92243490a4344426.tar.xz
mpd-9ae3acf2e73f63550218c2af92243490a4344426.zip
mpg123 decoder: implement seeking
Diffstat (limited to '')
-rw-r--r--src/decoder/mpg123_decoder_plugin.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/decoder/mpg123_decoder_plugin.c b/src/decoder/mpg123_decoder_plugin.c
index 84f12f29b..58c867709 100644
--- a/src/decoder/mpg123_decoder_plugin.c
+++ b/src/decoder/mpg123_decoder_plugin.c
@@ -24,6 +24,7 @@
#include <glib.h>
#include <mpg123.h>
+#include <stdio.h>
#undef G_LOG_DOMAIN
#define G_LOG_DOMAIN "mpg123"
@@ -125,7 +126,7 @@ mpd_mpg123_file_decode(struct decoder *decoder, const char *path_fs)
/* tell MPD core we're ready */
- decoder_initialized(decoder, &audio_format, false,
+ decoder_initialized(decoder, &audio_format, true,
(float)num_samples /
(float)audio_format.sample_rate);
@@ -172,7 +173,18 @@ mpd_mpg123_file_decode(struct decoder *decoder, const char *path_fs)
cmd = decoder_data(decoder, NULL, buffer, nbytes, info.bitrate);
- /* seeking not yet implemented */
+ if (cmd == DECODE_COMMAND_SEEK) {
+ off_t c = decoder_seek_where(decoder)*audio_format.sample_rate;
+ c = mpg123_seek(handle, c, SEEK_SET);
+ if (c < 0)
+ decoder_seek_error(decoder);
+ else {
+ decoder_command_finished(decoder);
+ decoder_timestamp(decoder, c/(double)audio_format.sample_rate);
+ }
+
+ cmd = DECODE_COMMAND_NONE;
+ }
} while (cmd == DECODE_COMMAND_NONE);
/* cleanup */