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 <Anna@OcarinaProject.net>
This commit is contained in:
parent
5b32bb16b4
commit
e7a8ad54bd
|
@ -88,7 +88,7 @@ void audio :: init(int *argc, char ***argv)
|
||||||
{
|
{
|
||||||
unsigned int id;
|
unsigned int id;
|
||||||
|
|
||||||
cur_driver->init(argc, argv, on_eos, audio :: next);
|
cur_driver->init(argc, argv, on_eos);
|
||||||
if (f_cur_track.exists()) {
|
if (f_cur_track.exists()) {
|
||||||
f_cur_track.open(OPEN_READ);
|
f_cur_track.open(OPEN_READ);
|
||||||
f_cur_track >> id;
|
f_cur_track >> id;
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2014 (c) Anna Schumaker.
|
* Copyright 2014 (c) Anna Schumaker.
|
||||||
*/
|
*/
|
||||||
|
#include <core/audio.h>
|
||||||
#include <core/driver.h>
|
#include <core/driver.h>
|
||||||
#include <gst/gst.h>
|
#include <gst/gst.h>
|
||||||
|
|
||||||
|
@ -38,9 +39,8 @@ public:
|
||||||
* @param argc Argc passed to the application's main() function.
|
* @param argc Argc passed to the application's main() function.
|
||||||
* @param argv Argv passed to the applicaiton's main() function.
|
* @param argv Argv passed to the applicaiton's main() function.
|
||||||
* @param eos_cb End-of-stream callback 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.
|
* 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;
|
GstBus *bus;
|
||||||
|
|
||||||
on_eos = eos_cb;
|
on_eos = eos_cb;
|
||||||
on_error = error_cb;
|
|
||||||
|
|
||||||
gst_init(argc, argv);
|
gst_init(argc, argv);
|
||||||
player = gst_element_factory_make("playbin", "ocarina_player");
|
player = gst_element_factory_make("playbin", "ocarina_player");
|
||||||
|
@ -201,7 +200,7 @@ void GSTDriver :: on_message(GstMessage *message)
|
||||||
switch (GST_MESSAGE_TYPE(message)) {
|
switch (GST_MESSAGE_TYPE(message)) {
|
||||||
case GST_MESSAGE_ERROR:
|
case GST_MESSAGE_ERROR:
|
||||||
parse_gst_error(message, cur_file);
|
parse_gst_error(message, cur_file);
|
||||||
on_error();
|
audio :: next();
|
||||||
break;
|
break;
|
||||||
case GST_MESSAGE_EOS:
|
case GST_MESSAGE_EOS:
|
||||||
on_eos();
|
on_eos();
|
||||||
|
|
|
@ -30,9 +30,8 @@ public:
|
||||||
* @param argc Argc passed to the application's main() function.
|
* @param argc Argc passed to the application's main() function.
|
||||||
* @param argv Argv passed to the applicaiton's main() function.
|
* @param argv Argv passed to the applicaiton's main() function.
|
||||||
* @param eos_cb End-of-stream callback 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;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -9,7 +9,6 @@
|
||||||
|
|
||||||
Track *TRACK_NULL = NULL;
|
Track *TRACK_NULL = NULL;
|
||||||
static unsigned int eos_count = 0;
|
static unsigned int eos_count = 0;
|
||||||
static unsigned int error_count = 0;
|
|
||||||
|
|
||||||
|
|
||||||
class TestDriver : public Driver
|
class TestDriver : public Driver
|
||||||
|
@ -23,10 +22,9 @@ public:
|
||||||
TestDriver() : playing(false), cur_pos(0), cur_duration(0) {}
|
TestDriver() : playing(false), cur_pos(0), cur_duration(0) {}
|
||||||
~TestDriver() {};
|
~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_eos = eos_cb;
|
||||||
on_error = error_cb;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void load(const std::string &file)
|
void load(const std::string &file)
|
||||||
|
@ -55,7 +53,6 @@ public:
|
||||||
long duration() { return cur_duration; }
|
long duration() { return cur_duration; }
|
||||||
|
|
||||||
void eos() { on_eos(); }
|
void eos() { on_eos(); }
|
||||||
void error() { on_error(); }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void on_eos()
|
void on_eos()
|
||||||
|
@ -63,11 +60,6 @@ void on_eos()
|
||||||
eos_count++;
|
eos_count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
void on_error()
|
|
||||||
{
|
|
||||||
error_count++;
|
|
||||||
}
|
|
||||||
|
|
||||||
void test_driver()
|
void test_driver()
|
||||||
{
|
{
|
||||||
test_equal(audio :: get_driver(), (Driver *)NULL);
|
test_equal(audio :: get_driver(), (Driver *)NULL);
|
||||||
|
@ -78,7 +70,7 @@ void test_driver()
|
||||||
test_not_equal(audio :: get_driver(), (Driver *)NULL);
|
test_not_equal(audio :: get_driver(), (Driver *)NULL);
|
||||||
test_equal((Driver *)&driver, audio :: get_driver());
|
test_equal((Driver *)&driver, audio :: get_driver());
|
||||||
|
|
||||||
driver.init(0, NULL, on_eos, on_error);
|
driver.init(0, NULL, on_eos);
|
||||||
|
|
||||||
driver.load(file);
|
driver.load(file);
|
||||||
test_equal(driver.cur_file, file);
|
test_equal(driver.cur_file, file);
|
||||||
|
@ -101,9 +93,6 @@ void test_driver()
|
||||||
driver.eos();
|
driver.eos();
|
||||||
test_equal(eos_count, (unsigned)1);
|
test_equal(eos_count, (unsigned)1);
|
||||||
|
|
||||||
driver.error();
|
|
||||||
test_equal(error_count, (unsigned)1);
|
|
||||||
|
|
||||||
driver.play();
|
driver.play();
|
||||||
driver.seek_to(4242);
|
driver.seek_to(4242);
|
||||||
driver.load(file);
|
driver.load(file);
|
||||||
|
@ -221,9 +210,6 @@ void test_track_controls()
|
||||||
test_equal(driver->is_playing(), true);
|
test_equal(driver->is_playing(), true);
|
||||||
test_equal(audio :: position(), (long)4242);
|
test_equal(audio :: position(), (long)4242);
|
||||||
|
|
||||||
driver->error();
|
|
||||||
test_not_equal(audio :: current_track(), track);
|
|
||||||
|
|
||||||
track = audio :: current_track();
|
track = audio :: current_track();
|
||||||
driver->eos();
|
driver->eos();
|
||||||
test_not_equal(audio :: current_track(), track);
|
test_not_equal(audio :: current_track(), track);
|
||||||
|
|
Loading…
Reference in New Issue