summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2014-08-26 11:02:02 +0200
committerMax Kellermann <max@duempel.org>2014-08-26 11:02:02 +0200
commit316c72a4aea4319443e7ea43e06b027f2b7b1ced (patch)
treee3a77de7cc35a48a99bf1d3466f7cb7f7405c07a
parent9da88eec3e60e1e34d13d1a8cfe53f25fec4505a (diff)
DecoderAPI: add decoder_seek_where_ms()
Move to fixed-point integers instead of floating point.
-rw-r--r--src/decoder/DecoderAPI.cxx17
-rw-r--r--src/decoder/DecoderAPI.hxx10
-rw-r--r--test/FakeDecoderAPI.cxx6
3 files changed, 33 insertions, 0 deletions
diff --git a/src/decoder/DecoderAPI.cxx b/src/decoder/DecoderAPI.cxx
index ae600260f..926a3955e 100644
--- a/src/decoder/DecoderAPI.cxx
+++ b/src/decoder/DecoderAPI.cxx
@@ -220,6 +220,23 @@ double decoder_seek_where(gcc_unused Decoder & decoder)
return dc.seek_where;
}
+unsigned
+decoder_seek_where_ms(Decoder &decoder)
+{
+ const DecoderControl &dc = decoder.dc;
+
+ assert(dc.pipe != nullptr);
+
+ if (decoder.initial_seek_running)
+ return dc.start_ms;
+
+ assert(dc.command == DecoderCommand::SEEK);
+
+ decoder.seeking = true;
+
+ return unsigned(dc.seek_where * 1000);
+}
+
void decoder_seek_error(Decoder & decoder)
{
DecoderControl &dc = decoder.dc;
diff --git a/src/decoder/DecoderAPI.hxx b/src/decoder/DecoderAPI.hxx
index c57a02e01..ddcead4b1 100644
--- a/src/decoder/DecoderAPI.hxx
+++ b/src/decoder/DecoderAPI.hxx
@@ -89,6 +89,16 @@ double
decoder_seek_where(Decoder &decoder);
/**
+ * Call this when you have received the DecoderCommand::SEEK command.
+ *
+ * @param decoder the decoder object
+ * @return the destination position for the seek in milliseconds
+ */
+gcc_pure
+unsigned
+decoder_seek_where_ms(Decoder &decoder);
+
+/**
* Call this instead of decoder_command_finished() when seeking has
* failed.
*
diff --git a/test/FakeDecoderAPI.cxx b/test/FakeDecoderAPI.cxx
index 552854ed6..afa90b4ca 100644
--- a/test/FakeDecoderAPI.cxx
+++ b/test/FakeDecoderAPI.cxx
@@ -61,6 +61,12 @@ decoder_seek_where(gcc_unused Decoder &decoder)
return 1.0;
}
+unsigned
+decoder_seek_where_ms(gcc_unused Decoder &decoder)
+{
+ return 1;
+}
+
void
decoder_seek_error(gcc_unused Decoder &decoder)
{