From 657ce8f0f491d8aab6f6d2cb3820fd49bfed1a77 Mon Sep 17 00:00:00 2001 From: Anna Schumaker Date: Thu, 5 Mar 2015 11:00:33 -0500 Subject: [PATCH] audio: Ensure position and duration results are 64 bits A long int is shorter on ARM than x86, which could cause position and duration values to get truncated. Additionally, quering gstreamer with a long int causes a compile error on ARM. Let's just do the right thing and make this value an int64_t. Signed-off-by: Anna Schumaker --- core/audio.cpp | 4 ++-- gui/gst.cpp | 8 ++++---- include/core/audio.h | 9 +++++---- tests/core/audio.cpp | 8 ++++---- 4 files changed, 15 insertions(+), 14 deletions(-) diff --git a/core/audio.cpp b/core/audio.cpp index 372871f5..8c8c6735 100644 --- a/core/audio.cpp +++ b/core/audio.cpp @@ -112,14 +112,14 @@ void audio :: stop() seek_to(0); } -long audio :: position() +int64_t audio :: position() { if (cur_track) return cur_driver->position(); return 0; } -long audio :: duration() +int64_t audio :: duration() { if (cur_track) return cur_driver->duration(); diff --git a/gui/gst.cpp b/gui/gst.cpp index 28d1898e..f2de2fde 100644 --- a/gui/gst.cpp +++ b/gui/gst.cpp @@ -105,9 +105,9 @@ public: offset); } - long position() + int64_t position() { - long position; + int64_t position; if (gst_element_query_position(gst_player, GST_FORMAT_TIME, &position)) @@ -115,9 +115,9 @@ public: return 0; } - long duration() + int64_t duration() { - long duration; + int64_t duration; if (gst_element_query_duration(gst_player, GST_FORMAT_TIME, &duration)) diff --git a/include/core/audio.h b/include/core/audio.h index fb8ac410..414f7f70 100644 --- a/include/core/audio.h +++ b/include/core/audio.h @@ -7,6 +7,7 @@ #include #include +#include /** @@ -59,14 +60,14 @@ public: * * @return The current playback position, in nanoseconds. */ - virtual long position() = 0; + virtual int64_t position() = 0; /** * Return the duration of the currently loaded track. * * @return The duration of the current track, in nanoseconds. */ - virtual long duration() = 0; + virtual int64_t duration() = 0; /** * Called to handle reaching the end-of-stream. @@ -100,12 +101,12 @@ namespace audio /** * @return The current position of the audio playback (in nanoseconds). */ - long position(); + int64_t position(); /** * @return The duration of the currently loaded track (in nanoseconds). */ - long duration(); + int64_t duration(); void next(); /**< Find and load the next track that should be played. */ void prev(); /**< Call the deck :: previous() function and load the result. */ diff --git a/tests/core/audio.cpp b/tests/core/audio.cpp index 2a5bef99..f8eb9954 100644 --- a/tests/core/audio.cpp +++ b/tests/core/audio.cpp @@ -13,8 +13,8 @@ class TestDriver : public AudioDriver { public: bool playing; - long cur_pos; - long cur_duration; + int64_t cur_pos; + int64_t cur_duration; std::string cur_file; TestDriver() : playing(false), cur_pos(0), cur_duration(0) {} @@ -33,8 +33,8 @@ public: bool is_playing() { return playing; } void seek_to(long offset) { cur_pos = offset; } - long position() { return cur_pos; } - long duration() { return cur_duration; } + int64_t position() { return cur_pos; } + int64_t duration() { return cur_duration; } };