From 0a1a9f1394e41d703a36f2b5646769819fdc05d3 Mon Sep 17 00:00:00 2001 From: Anna Schumaker Date: Wed, 16 Dec 2015 08:26:49 -0500 Subject: [PATCH] core/audio: Move audio_cur_track() out of the audio namespace Signed-off-by: Anna Schumaker --- core/audio.cpp | 10 +++++----- gui/gst.cpp | 2 +- gui/playlist.cpp | 6 +++--- include/core/audio.h | 9 ++++----- tests/core/audio.cpp | 30 +++++++++++++++--------------- 5 files changed, 28 insertions(+), 29 deletions(-) diff --git a/core/audio.cpp b/core/audio.cpp index 9776bbdf..cfd00832 100644 --- a/core/audio.cpp +++ b/core/audio.cpp @@ -148,6 +148,11 @@ bool audio_load(struct track *track) return false; } +struct track *audio_cur_track() +{ + return audio_track; +} + bool audio_play() { if (!audio_track) @@ -216,11 +221,6 @@ void audio :: prev() GST_STATE_PLAYING : GST_STATE_PAUSED); } -struct track *audio :: current_track() -{ - return audio_track; -} - void audio :: pause_after(bool enabled, unsigned int n) { if (n > _pause_count) diff --git a/gui/gst.cpp b/gui/gst.cpp index da6b39df..1c338c9c 100644 --- a/gui/gst.cpp +++ b/gui/gst.cpp @@ -94,7 +94,7 @@ struct audio_ops audio_ops = { static int parse_gst_error(GstMessage *error) { GError *err; - struct track *track = audio :: current_track(); + struct track *track = audio_cur_track(); gchar *path; int ret = 0; diff --git a/gui/playlist.cpp b/gui/playlist.cpp index ad1e20cb..469c1111 100644 --- a/gui/playlist.cpp +++ b/gui/playlist.cpp @@ -137,7 +137,7 @@ public: static void on_ban() { - struct track *track = audio :: current_track(); + struct track *track = audio_cur_track(); if (o_ban->get_active()) { if (collection_ban(track)) audio :: next(); @@ -147,7 +147,7 @@ static void on_ban() static void on_favorite() { - struct track *track = audio :: current_track(); + struct track *track = audio_cur_track(); if (o_fav->get_active()) playlist_add(PL_FAVORITED, track); else @@ -198,7 +198,7 @@ void plist :: init() o_ban = gui :: get_widget("o_ban"); o_fav = gui :: get_widget("o_favorite"); - track_loaded(audio :: current_track()); + track_loaded(audio_cur_track()); o_ban->signal_toggled().connect(sigc::ptr_fun(on_ban)); o_fav->signal_toggled().connect(sigc::ptr_fun(on_favorite)); diff --git a/include/core/audio.h b/include/core/audio.h index afc6c26b..15e39b5d 100644 --- a/include/core/audio.h +++ b/include/core/audio.h @@ -55,11 +55,6 @@ namespace audio void next(); /**< Find and load the next track that should be played. */ 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. * @@ -101,6 +96,10 @@ void audio_deinit(); /* Called to load a track for playback. */ bool audio_load(struct track *); +/* Called to get the current track. */ +struct track *audio_cur_track(); + + /* Called to begin playback. */ bool audio_play(); diff --git a/tests/core/audio.cpp b/tests/core/audio.cpp index 92699019..6e4b5804 100644 --- a/tests/core/audio.cpp +++ b/tests/core/audio.cpp @@ -60,7 +60,7 @@ static struct core_init_data test_init_data = { static void test_init() { test_equal(audio_get_player(), NULL); - test_equal(audio :: current_track(), NULL); + test_equal(audio_cur_track(), NULL); test_equal(audio_get_player(), NULL); core :: init(NULL, NULL, &test_init_data); @@ -72,13 +72,13 @@ static void test_init() test_equal(audio_seek(7), false); test_equal(audio_position(), 0); test_equal(audio_duration(), 0); - test_equal(audio :: current_track(), NULL); + test_equal(audio_cur_track(), NULL); test_equal(load_count, 0); collection_add("tests/Music/Hyrule Symphony"); while (idle_run_task()) {}; - test_equal(audio :: current_track(), NULL); + test_equal(audio_cur_track(), 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(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(audio_duration(), track_get(0)->tr_length * GST_SECOND); test_equal(audio_load(NULL), false); 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(audio_load(track_get(0)), false); @@ -127,7 +127,7 @@ static void test_deinit() { core :: deinit(); - test_equal(audio :: current_track(), NULL); + test_equal(audio_cur_track(), NULL); test_equal(audio_get_player(), NULL); } @@ -136,7 +136,7 @@ void test_pre_init() { TestDriver *driver = (TestDriver *)audio :: get_driver(); - test_equal(audio :: current_track(), TRACK_NULL); + test_equal(audio_cur_track(), TRACK_NULL); audio_play(); test_equal(driver->playing, false); @@ -154,10 +154,10 @@ void test_pre_init() test_equal(audio_duration(), (long)0); audio :: next(); - test_equal(audio :: current_track(), TRACK_NULL); + test_equal(audio_cur_track(), TRACK_NULL); audio :: prev(); - test_equal(audio :: current_track(), TRACK_NULL); + test_equal(audio_cur_track(), TRACK_NULL); } void test_init2() @@ -167,11 +167,11 @@ void test_init2() test_cp_data_dir(); audio_init(NULL, NULL, &test_audio_ops); - track = audio :: current_track(); + track = audio_cur_track(); test_equal(track, TRACK_NULL); core :: init(NULL, NULL, &test_init_data); - track = audio :: current_track(); + track = audio_cur_track(); test_not_equal(track, TRACK_NULL); } @@ -184,7 +184,7 @@ void test_track_controls() driver->playing = audio_pause(); 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); audio_play(); @@ -192,7 +192,7 @@ void test_track_controls() test_equal(driver->is_playing(), true); audio_load(track); - test_not_equal(audio :: current_track(), track); + test_not_equal(audio_cur_track(), track); track = track_get(0); audio_seek(4242); @@ -205,9 +205,9 @@ void test_track_controls() test_equal(driver->is_playing(), true); test_equal(audio_position(), (long)4242); - track = audio :: current_track(); + track = audio_cur_track(); driver->eos(); - test_not_equal(audio :: current_track(), track); + test_not_equal(audio_cur_track(), track); } void test_autopause()