core/audio: Move audio_duration() out of the audio namespace
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
parent
20bb01ef4e
commit
e1abe94b28
|
@ -188,10 +188,15 @@ gint64 audio_position()
|
|||
return 0;
|
||||
}
|
||||
|
||||
int64_t audio :: duration()
|
||||
int64_t audio_duration()
|
||||
{
|
||||
gint64 duration;
|
||||
if (gst_element_query_duration(audio_player,
|
||||
GST_FORMAT_TIME,
|
||||
&duration))
|
||||
return duration;
|
||||
if (audio_track)
|
||||
return cur_driver->duration();
|
||||
return audio_track->tr_length * GST_SECOND;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
12
gui/gst.cpp
12
gui/gst.cpp
|
@ -82,16 +82,6 @@ public:
|
|||
GST_CLOCK_TIME_NONE);
|
||||
return state == GST_STATE_PLAYING;
|
||||
}
|
||||
|
||||
int64_t duration()
|
||||
{
|
||||
int64_t duration;
|
||||
if (gst_element_query_duration(audio_get_player(),
|
||||
GST_FORMAT_TIME,
|
||||
&duration))
|
||||
return duration;
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
static GSTDriver *gst_driver;
|
||||
|
@ -164,7 +154,7 @@ static bool on_timeout()
|
|||
{
|
||||
gchar *pos = string_sec2str(audio_position() / GST_SECOND);
|
||||
|
||||
o_progress->set_upper(audio :: duration());
|
||||
o_progress->set_upper(audio_duration());
|
||||
o_progress->set_value(audio_position());
|
||||
o_position->set_text(pos);
|
||||
g_free(pos);
|
||||
|
|
|
@ -39,13 +39,6 @@ public:
|
|||
virtual bool is_playing() = 0;
|
||||
|
||||
|
||||
/**
|
||||
* Return the duration of the currently loaded track.
|
||||
*
|
||||
* @return The duration of the current track, in nanoseconds.
|
||||
*/
|
||||
virtual int64_t duration() = 0;
|
||||
|
||||
/**
|
||||
* Called to handle reaching the end-of-stream.
|
||||
*/
|
||||
|
@ -64,11 +57,6 @@ namespace audio
|
|||
*/
|
||||
void stop();
|
||||
|
||||
/**
|
||||
* @return The duration of the currently loaded track (in nanoseconds).
|
||||
*/
|
||||
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. */
|
||||
|
||||
|
@ -130,5 +118,8 @@ bool audio_seek(gint64);
|
|||
/* Called to find the current playback position, in nanoseconds. */
|
||||
gint64 audio_position();
|
||||
|
||||
/* Called to find the duration of the current track. */
|
||||
gint64 audio_duration();
|
||||
|
||||
GstElement *audio_get_player();
|
||||
#endif /* OCARINA_CORE_AUDIO_H */
|
||||
|
|
|
@ -31,15 +31,12 @@ class TestDriver : public AudioDriver
|
|||
{
|
||||
public:
|
||||
bool playing;
|
||||
int64_t cur_duration;
|
||||
std::string cur_file;
|
||||
|
||||
TestDriver() : playing(false), cur_duration(0) {}
|
||||
TestDriver() : playing(false) {}
|
||||
~TestDriver() {};
|
||||
|
||||
bool is_playing() { return playing; }
|
||||
|
||||
int64_t duration() { return cur_duration; }
|
||||
} driver;
|
||||
|
||||
static void test_audio_load(struct track *track, GstState state)
|
||||
|
@ -73,6 +70,7 @@ static void test_init()
|
|||
test_equal(audio_pause(), false);
|
||||
test_equal(audio_seek(7), false);
|
||||
test_equal(audio_position(), 0);
|
||||
test_equal(audio_duration(), 0);
|
||||
test_equal(audio :: current_track(), NULL);
|
||||
test_equal(load_count, 0);
|
||||
|
||||
|
@ -89,6 +87,7 @@ static void test_playback()
|
|||
test_equal(load_count, 1);
|
||||
test_equal(audio :: current_track(), track_get(0));
|
||||
test_equal(queue_size(history_get_queue()), 1);
|
||||
test_equal(audio_duration(), track_get(0)->tr_length * GST_SECOND);
|
||||
|
||||
test_equal(audio_load(NULL), false);
|
||||
test_equal(load_count, 1);
|
||||
|
@ -110,6 +109,9 @@ static void test_playback()
|
|||
|
||||
test_equal(test_audio_seek(0), true);
|
||||
test_equal(audio_position(), 0);
|
||||
|
||||
/* Check duration again now that track is fully loaded. */
|
||||
test_equal(audio_duration(), track_get(0)->tr_length * GST_SECOND);
|
||||
}
|
||||
|
||||
static void test_deinit()
|
||||
|
@ -140,9 +142,7 @@ void test_pre_init()
|
|||
audio_seek(4242);
|
||||
test_equal(audio_position(), (long)0);
|
||||
|
||||
driver->cur_duration = 4242;
|
||||
test_equal(audio :: duration(), (long)0);
|
||||
driver->cur_duration = 0;
|
||||
test_equal(audio_duration(), (long)0);
|
||||
|
||||
audio :: next();
|
||||
test_equal(audio :: current_track(), TRACK_NULL);
|
||||
|
@ -184,9 +184,8 @@ void test_playback_controls()
|
|||
test_equal(driver->playing, false);
|
||||
|
||||
audio_seek(4242);
|
||||
driver->cur_duration = 424242;
|
||||
test_equal(audio_position(), (long)4242);
|
||||
test_equal(audio :: duration(), (long)424242);
|
||||
test_equal(audio_duration(), (long)424242);
|
||||
}
|
||||
|
||||
void test_track_controls()
|
||||
|
|
Loading…
Reference in New Issue
Block a user