core/audio: Move audio_cur_track() out of the audio namespace

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
Anna Schumaker 2015-12-16 08:26:49 -05:00
parent d1d722a163
commit 0a1a9f1394
5 changed files with 28 additions and 29 deletions

View File

@ -148,6 +148,11 @@ bool audio_load(struct track *track)
return false; return false;
} }
struct track *audio_cur_track()
{
return audio_track;
}
bool audio_play() bool audio_play()
{ {
if (!audio_track) if (!audio_track)
@ -216,11 +221,6 @@ void audio :: prev()
GST_STATE_PLAYING : GST_STATE_PAUSED); GST_STATE_PLAYING : GST_STATE_PAUSED);
} }
struct track *audio :: current_track()
{
return audio_track;
}
void audio :: pause_after(bool enabled, unsigned int n) void audio :: pause_after(bool enabled, unsigned int n)
{ {
if (n > _pause_count) if (n > _pause_count)

View File

@ -94,7 +94,7 @@ struct audio_ops audio_ops = {
static int parse_gst_error(GstMessage *error) static int parse_gst_error(GstMessage *error)
{ {
GError *err; GError *err;
struct track *track = audio :: current_track(); struct track *track = audio_cur_track();
gchar *path; gchar *path;
int ret = 0; int ret = 0;

View File

@ -137,7 +137,7 @@ public:
static void on_ban() static void on_ban()
{ {
struct track *track = audio :: current_track(); struct track *track = audio_cur_track();
if (o_ban->get_active()) { if (o_ban->get_active()) {
if (collection_ban(track)) if (collection_ban(track))
audio :: next(); audio :: next();
@ -147,7 +147,7 @@ static void on_ban()
static void on_favorite() static void on_favorite()
{ {
struct track *track = audio :: current_track(); struct track *track = audio_cur_track();
if (o_fav->get_active()) if (o_fav->get_active())
playlist_add(PL_FAVORITED, track); playlist_add(PL_FAVORITED, track);
else else
@ -198,7 +198,7 @@ void plist :: init()
o_ban = gui :: get_widget<Gtk::ToggleButton>("o_ban"); o_ban = gui :: get_widget<Gtk::ToggleButton>("o_ban");
o_fav = gui :: get_widget<Gtk::ToggleButton>("o_favorite"); o_fav = gui :: get_widget<Gtk::ToggleButton>("o_favorite");
track_loaded(audio :: current_track()); track_loaded(audio_cur_track());
o_ban->signal_toggled().connect(sigc::ptr_fun(on_ban)); o_ban->signal_toggled().connect(sigc::ptr_fun(on_ban));
o_fav->signal_toggled().connect(sigc::ptr_fun(on_favorite)); o_fav->signal_toggled().connect(sigc::ptr_fun(on_favorite));

View File

@ -55,11 +55,6 @@ namespace audio
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. */
/**
* @return A pointer to the currently playing track object.
*/
struct track *current_track();
/** /**
* Configure the automatic pausing feature. * Configure the automatic pausing feature.
* *
@ -101,6 +96,10 @@ void audio_deinit();
/* Called to load a track for playback. */ /* Called to load a track for playback. */
bool audio_load(struct track *); bool audio_load(struct track *);
/* Called to get the current track. */
struct track *audio_cur_track();
/* Called to begin playback. */ /* Called to begin playback. */
bool audio_play(); bool audio_play();

View File

@ -60,7 +60,7 @@ static struct core_init_data test_init_data = {
static void test_init() static void test_init()
{ {
test_equal(audio_get_player(), NULL); test_equal(audio_get_player(), NULL);
test_equal(audio :: current_track(), NULL); test_equal(audio_cur_track(), NULL);
test_equal(audio_get_player(), NULL); test_equal(audio_get_player(), NULL);
core :: init(NULL, NULL, &test_init_data); core :: init(NULL, NULL, &test_init_data);
@ -72,13 +72,13 @@ static void test_init()
test_equal(audio_seek(7), false); test_equal(audio_seek(7), false);
test_equal(audio_position(), 0); test_equal(audio_position(), 0);
test_equal(audio_duration(), 0); test_equal(audio_duration(), 0);
test_equal(audio :: current_track(), NULL); test_equal(audio_cur_track(), NULL);
test_equal(load_count, 0); test_equal(load_count, 0);
collection_add("tests/Music/Hyrule Symphony"); collection_add("tests/Music/Hyrule Symphony");
while (idle_run_task()) {}; while (idle_run_task()) {};
test_equal(audio :: current_track(), NULL); test_equal(audio_cur_track(), NULL);
test_not_equal(audio_get_player(), NULL); test_not_equal(audio_get_player(), NULL);
} }
@ -86,13 +86,13 @@ static void test_playback()
{ {
test_equal(audio_load(track_get(0)), true); test_equal(audio_load(track_get(0)), true);
test_equal(load_count, 1); test_equal(load_count, 1);
test_equal(audio :: current_track(), track_get(0)); test_equal(audio_cur_track(), track_get(0));
test_equal(queue_size(history_get_queue()), 1); test_equal(queue_size(history_get_queue()), 1);
test_equal(audio_duration(), track_get(0)->tr_length * GST_SECOND); test_equal(audio_duration(), track_get(0)->tr_length * GST_SECOND);
test_equal(audio_load(NULL), false); test_equal(audio_load(NULL), false);
test_equal(load_count, 1); test_equal(load_count, 1);
test_equal(audio :: current_track(), track_get(0)); test_equal(audio_cur_track(), track_get(0));
test_equal(queue_size(history_get_queue()), 1); test_equal(queue_size(history_get_queue()), 1);
test_equal(audio_load(track_get(0)), false); test_equal(audio_load(track_get(0)), false);
@ -127,7 +127,7 @@ static void test_deinit()
{ {
core :: deinit(); core :: deinit();
test_equal(audio :: current_track(), NULL); test_equal(audio_cur_track(), NULL);
test_equal(audio_get_player(), NULL); test_equal(audio_get_player(), NULL);
} }
@ -136,7 +136,7 @@ void test_pre_init()
{ {
TestDriver *driver = (TestDriver *)audio :: get_driver(); TestDriver *driver = (TestDriver *)audio :: get_driver();
test_equal(audio :: current_track(), TRACK_NULL); test_equal(audio_cur_track(), TRACK_NULL);
audio_play(); audio_play();
test_equal(driver->playing, false); test_equal(driver->playing, false);
@ -154,10 +154,10 @@ void test_pre_init()
test_equal(audio_duration(), (long)0); test_equal(audio_duration(), (long)0);
audio :: next(); audio :: next();
test_equal(audio :: current_track(), TRACK_NULL); test_equal(audio_cur_track(), TRACK_NULL);
audio :: prev(); audio :: prev();
test_equal(audio :: current_track(), TRACK_NULL); test_equal(audio_cur_track(), TRACK_NULL);
} }
void test_init2() void test_init2()
@ -167,11 +167,11 @@ void test_init2()
test_cp_data_dir(); test_cp_data_dir();
audio_init(NULL, NULL, &test_audio_ops); audio_init(NULL, NULL, &test_audio_ops);
track = audio :: current_track(); track = audio_cur_track();
test_equal(track, TRACK_NULL); test_equal(track, TRACK_NULL);
core :: init(NULL, NULL, &test_init_data); core :: init(NULL, NULL, &test_init_data);
track = audio :: current_track(); track = audio_cur_track();
test_not_equal(track, TRACK_NULL); test_not_equal(track, TRACK_NULL);
} }
@ -184,7 +184,7 @@ void test_track_controls()
driver->playing = audio_pause(); driver->playing = audio_pause();
audio :: next(); audio :: next();
test_not_equal(audio :: current_track()->tr_dbe.dbe_index, (unsigned)2); test_not_equal(audio_cur_track()->tr_dbe.dbe_index, (unsigned)2);
test_equal(driver->is_playing(), false); test_equal(driver->is_playing(), false);
audio_play(); audio_play();
@ -192,7 +192,7 @@ void test_track_controls()
test_equal(driver->is_playing(), true); test_equal(driver->is_playing(), true);
audio_load(track); audio_load(track);
test_not_equal(audio :: current_track(), track); test_not_equal(audio_cur_track(), track);
track = track_get(0); track = track_get(0);
audio_seek(4242); audio_seek(4242);
@ -205,9 +205,9 @@ 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);
track = audio :: current_track(); track = audio_cur_track();
driver->eos(); driver->eos();
test_not_equal(audio :: current_track(), track); test_not_equal(audio_cur_track(), track);
} }
void test_autopause() void test_autopause()