diff --git a/core/audio.cpp b/core/audio.cpp index 22296abc..31ac8cf3 100644 --- a/core/audio.cpp +++ b/core/audio.cpp @@ -57,7 +57,7 @@ static void _load_track(Track *track, bool start_playback) if (!track) return; - cur_driver->load(track->path()); + cur_driver->load(track); get_callbacks()->on_track_loaded(track); if (start_playback) audio :: play(); diff --git a/gui/gst.cpp b/gui/gst.cpp index e013e182..b92e2a2e 100644 --- a/gui/gst.cpp +++ b/gui/gst.cpp @@ -30,9 +30,9 @@ static bool gst_change_state(GstState state) class GSTDriver : public Driver { public: - void load(const std::string &filepath) + void load(Track *track) { - gchar *uri = gst_filename_to_uri(filepath.c_str(), NULL); + gchar *uri = gst_filename_to_uri(track->path().c_str(), NULL); gst_change_state(GST_STATE_NULL); g_object_set(G_OBJECT(gst_player), "uri", uri, NULL); diff --git a/include/core/driver.h b/include/core/driver.h index b15f45e5..a8b6d379 100644 --- a/include/core/driver.h +++ b/include/core/driver.h @@ -5,6 +5,7 @@ #ifndef OCARINA_CORE_DRIVER_H #define OCARINA_CORE_DRIVER_H +#include #include /** Use to convert nanoseconds to seconds */ @@ -27,9 +28,9 @@ public: /** * Loads an audio file for playback. * - * @param file Filepath of the track to load. + * @param track The Track to load. */ - virtual void load(const std::string &file) = 0; + virtual void load(Track *track) = 0; /** * Called to begin playback on the currently loaded track. diff --git a/tests/core/audio.cpp b/tests/core/audio.cpp index 747dcf15..09caf190 100644 --- a/tests/core/audio.cpp +++ b/tests/core/audio.cpp @@ -21,9 +21,9 @@ public: TestDriver() : playing(false), cur_pos(0), cur_duration(0) {} ~TestDriver() {}; - void load(const std::string &file) + void load(Track *track) { - cur_file = file; + cur_file = track->path(); playing = false; cur_pos = 0; } @@ -48,41 +48,6 @@ public: }; -void test_driver() -{ - test_equal(audio :: get_driver(), (Driver *)NULL); - TestDriver driver; - - const std::string file = "/home/Zelda/Music/Wind Waker/1 - Outset Isle.ogg"; - - test_not_equal(audio :: get_driver(), (Driver *)NULL); - test_equal((Driver *)&driver, audio :: get_driver()); - - driver.load(file); - test_equal(driver.cur_file, file); - - test_equal(driver.play(), true); - test_equal(driver.playing, true); - test_equal(driver.is_playing(), true); - - test_equal(driver.pause(), true); - test_equal(driver.playing, false); - test_equal(driver.is_playing(), false); - - driver.seek_to(4242); - test_equal(driver.cur_pos, (long)4242); - test_equal(driver.position(), (long)4242); - - driver.cur_duration = 424242; - test_equal(driver.duration(), (long)424242); - - driver.play(); - driver.seek_to(4242); - driver.load(file); - test_equal(driver.is_playing(), false); - test_equal(driver.position(), (long)0); -} - void test_pre_init() { TestDriver *driver = (TestDriver *)audio :: get_driver(); @@ -233,8 +198,6 @@ void test_autopause() int main(int argc, char **argv) { - run_test("Test Audio Driver", test_driver); - TestDriver driver; run_test("Test Audio Pre-Init", test_pre_init); run_test("Test Audio Init", test_init);