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 <anna@ocarinaproject.net>
This commit is contained in:
Anna Schumaker 2015-03-05 11:00:33 -05:00 committed by Anna Schumaker
parent ce4923f8b9
commit 657ce8f0f4
4 changed files with 15 additions and 14 deletions

View File

@ -112,14 +112,14 @@ void audio :: stop()
seek_to(0); seek_to(0);
} }
long audio :: position() int64_t audio :: position()
{ {
if (cur_track) if (cur_track)
return cur_driver->position(); return cur_driver->position();
return 0; return 0;
} }
long audio :: duration() int64_t audio :: duration()
{ {
if (cur_track) if (cur_track)
return cur_driver->duration(); return cur_driver->duration();

View File

@ -105,9 +105,9 @@ public:
offset); offset);
} }
long position() int64_t position()
{ {
long position; int64_t position;
if (gst_element_query_position(gst_player, if (gst_element_query_position(gst_player,
GST_FORMAT_TIME, GST_FORMAT_TIME,
&position)) &position))
@ -115,9 +115,9 @@ public:
return 0; return 0;
} }
long duration() int64_t duration()
{ {
long duration; int64_t duration;
if (gst_element_query_duration(gst_player, if (gst_element_query_duration(gst_player,
GST_FORMAT_TIME, GST_FORMAT_TIME,
&duration)) &duration))

View File

@ -7,6 +7,7 @@
#include <core/tags/track.h> #include <core/tags/track.h>
#include <string> #include <string>
#include <stdint.h>
/** /**
@ -59,14 +60,14 @@ public:
* *
* @return The current playback position, in nanoseconds. * @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 currently loaded track.
* *
* @return The duration of the current track, in nanoseconds. * @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. * Called to handle reaching the end-of-stream.
@ -100,12 +101,12 @@ namespace audio
/** /**
* @return The current position of the audio playback (in nanoseconds). * @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). * @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 next(); /**< Find and load the next track that should be played. */
void prev(); /**< Call the deck :: previous() function and load the result. */ void prev(); /**< Call the deck :: previous() function and load the result. */

View File

@ -13,8 +13,8 @@ class TestDriver : public AudioDriver
{ {
public: public:
bool playing; bool playing;
long cur_pos; int64_t cur_pos;
long cur_duration; int64_t cur_duration;
std::string cur_file; std::string cur_file;
TestDriver() : playing(false), cur_pos(0), cur_duration(0) {} TestDriver() : playing(false), cur_pos(0), cur_duration(0) {}
@ -33,8 +33,8 @@ public:
bool is_playing() { return playing; } bool is_playing() { return playing; }
void seek_to(long offset) { cur_pos = offset; } void seek_to(long offset) { cur_pos = offset; }
long position() { return cur_pos; } int64_t position() { return cur_pos; }
long duration() { return cur_duration; } int64_t duration() { return cur_duration; }
}; };