From e7a8ad54bd5124189aacca8655301aa0d3ca42f9 Mon Sep 17 00:00:00 2001 From: Anna Schumaker Date: Fri, 19 Dec 2014 17:25:36 -0500 Subject: [PATCH] Audio: Remove the driver on_error() callback function This was used to get around layering issues with the gstreamer driver. Now that the gstreamer implementation is in the gui code we can have it call audio::next() directly. Signed-off-by: Anna Schumaker --- core/audio.cpp | 2 +- gui/gst.cpp | 9 ++++----- include/core/driver.h | 3 +-- tests/core/audio.cpp | 18 ++---------------- 4 files changed, 8 insertions(+), 24 deletions(-) diff --git a/core/audio.cpp b/core/audio.cpp index 3d1b9088..0bd09b32 100644 --- a/core/audio.cpp +++ b/core/audio.cpp @@ -88,7 +88,7 @@ void audio :: init(int *argc, char ***argv) { unsigned int id; - cur_driver->init(argc, argv, on_eos, audio :: next); + cur_driver->init(argc, argv, on_eos); if (f_cur_track.exists()) { f_cur_track.open(OPEN_READ); f_cur_track >> id; diff --git a/gui/gst.cpp b/gui/gst.cpp index 3be6cb09..a7f84209 100644 --- a/gui/gst.cpp +++ b/gui/gst.cpp @@ -1,6 +1,7 @@ /* * Copyright 2014 (c) Anna Schumaker. */ +#include #include #include @@ -38,9 +39,8 @@ public: * @param argc Argc passed to the application's main() function. * @param argv Argv passed to the applicaiton's main() function. * @param eos_cb End-of-stream callback function. - * @param error_cb Callback function used when the audio library encounters an error. */ - void init(int *, char ***, void (*)(), void (*)()); + void init(int *, char ***, void (*)()); /** * Load a track into the gstreamer pipeline. @@ -133,12 +133,11 @@ bool GSTDriver :: change_state(GstState state) } } -void GSTDriver :: init(int *argc, char ***argv, void (*eos_cb)(), void (*error_cb)()) +void GSTDriver :: init(int *argc, char ***argv, void (*eos_cb)()) { GstBus *bus; on_eos = eos_cb; - on_error = error_cb; gst_init(argc, argv); player = gst_element_factory_make("playbin", "ocarina_player"); @@ -201,7 +200,7 @@ void GSTDriver :: on_message(GstMessage *message) switch (GST_MESSAGE_TYPE(message)) { case GST_MESSAGE_ERROR: parse_gst_error(message, cur_file); - on_error(); + audio :: next(); break; case GST_MESSAGE_EOS: on_eos(); diff --git a/include/core/driver.h b/include/core/driver.h index 03588ff8..4e482ef8 100644 --- a/include/core/driver.h +++ b/include/core/driver.h @@ -30,9 +30,8 @@ public: * @param argc Argc passed to the application's main() function. * @param argv Argv passed to the applicaiton's main() function. * @param eos_cb End-of-stream callback function. - * @param error_cb Callback function used when the audio library encounters an error. */ - virtual void init(int *argc, char ***argv, void (*eos_cb)(), void (*error_cb)()) = 0; + virtual void init(int *argc, char ***argv, void (*eos_cb)()) = 0; /** diff --git a/tests/core/audio.cpp b/tests/core/audio.cpp index 883908b7..03842dd4 100644 --- a/tests/core/audio.cpp +++ b/tests/core/audio.cpp @@ -9,7 +9,6 @@ Track *TRACK_NULL = NULL; static unsigned int eos_count = 0; -static unsigned int error_count = 0; class TestDriver : public Driver @@ -23,10 +22,9 @@ public: TestDriver() : playing(false), cur_pos(0), cur_duration(0) {} ~TestDriver() {}; - void init(int *argc, char ***argv, void (*eos_cb)(), void (*error_cb)()) + void init(int *argc, char ***argv, void (*eos_cb)()) { on_eos = eos_cb; - on_error = error_cb; } void load(const std::string &file) @@ -55,7 +53,6 @@ public: long duration() { return cur_duration; } void eos() { on_eos(); } - void error() { on_error(); } }; void on_eos() @@ -63,11 +60,6 @@ void on_eos() eos_count++; } -void on_error() -{ - error_count++; -} - void test_driver() { test_equal(audio :: get_driver(), (Driver *)NULL); @@ -78,7 +70,7 @@ void test_driver() test_not_equal(audio :: get_driver(), (Driver *)NULL); test_equal((Driver *)&driver, audio :: get_driver()); - driver.init(0, NULL, on_eos, on_error); + driver.init(0, NULL, on_eos); driver.load(file); test_equal(driver.cur_file, file); @@ -101,9 +93,6 @@ void test_driver() driver.eos(); test_equal(eos_count, (unsigned)1); - driver.error(); - test_equal(error_count, (unsigned)1); - driver.play(); driver.seek_to(4242); driver.load(file); @@ -221,9 +210,6 @@ void test_track_controls() test_equal(driver->is_playing(), true); test_equal(audio :: position(), (long)4242); - driver->error(); - test_not_equal(audio :: current_track(), track); - track = audio :: current_track(); driver->eos(); test_not_equal(audio :: current_track(), track);