From b558a9043ca00ae0ab21f8c127820b9a48f0396e Mon Sep 17 00:00:00 2001 From: Anna Schumaker Date: Wed, 5 Apr 2017 08:59:09 -0400 Subject: [PATCH] core/audio: Rearrange global variables Add some whitespace to make it easier to follow what everything is. I also rename audio_bus to audio_old_id to make it easier to add in a new audio bus. Additionally, I changed test_audio_player() to test_old_player() to make room for the new pipeline. Signed-off-by: Anna Schumaker --- core/audio.c | 19 +++++++++++-------- include/core/audio.h | 2 +- tests/core/audio.c | 8 ++++---- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/core/audio.c b/core/audio.c index 813d4013..ddc76026 100644 --- a/core/audio.c +++ b/core/audio.c @@ -8,12 +8,15 @@ static const char *SETTINGS_TRACK = "core.audio.cur"; static const char *SETTINGS_VOLUME = "core.audio.volume"; -static struct file audio_file = FILE_INIT("cur_track", 0); -static struct track *audio_track = NULL; -static GstElement *audio_player = NULL; + +static struct file audio_file = FILE_INIT("cur_track", 0); +static struct track *audio_track = NULL; +static int audio_pause_count = -1; + +static GstElement *audio_player = NULL; +static guint audio_old_id = 0; + static struct audio_callbacks *audio_cb = NULL; -static int audio_pause_count = -1; -static guint audio_bus = 0; static bool __audio_change_state(GstState state) @@ -119,7 +122,7 @@ void audio_init(int *argc, char ***argv, struct audio_callbacks *callbacks) audio_cb = callbacks; bus = gst_pipeline_get_bus(GST_PIPELINE(audio_player)); - audio_bus = gst_bus_add_watch(bus, __audio_message, NULL); + audio_old_id = gst_bus_add_watch(bus, __audio_message, NULL); gst_object_unref(bus); if (settings_has(SETTINGS_VOLUME)) @@ -133,7 +136,7 @@ void audio_deinit() { gst_element_set_state(audio_player, GST_STATE_NULL); gst_object_unref(GST_ELEMENT(audio_player)); - g_source_remove(audio_bus); + g_source_remove(audio_old_id); audio_player = NULL; audio_track = NULL; @@ -290,7 +293,7 @@ void audio_pause_after(int n) } #ifdef CONFIG_TESTING -GstElement *test_audio_player() +GstElement *test_old_player() { return audio_player; } diff --git a/include/core/audio.h b/include/core/audio.h index c46ba19e..d8827369 100644 --- a/include/core/audio.h +++ b/include/core/audio.h @@ -82,6 +82,6 @@ void audio_error(GstMessage *); void audio_pause_after(int); #ifdef CONFIG_TESTING -GstElement *test_audio_player(); +GstElement *test_old_player(); #endif /* CONFIG_TESTING */ #endif /* OCARINA_CORE_AUDIO_H */ diff --git a/tests/core/audio.c b/tests/core/audio.c index cb4f9663..f69a3e06 100644 --- a/tests/core/audio.c +++ b/tests/core/audio.c @@ -25,7 +25,7 @@ static void test_send_error() GError *error; error = g_error_new(1, G_FILE_ERROR_BADF, "Simulated Error"); - message = gst_message_new_error(GST_OBJECT(test_audio_player()), + message = gst_message_new_error(GST_OBJECT(test_old_player()), error, "Fake error for testing"); audio_error(message); @@ -47,7 +47,7 @@ static struct audio_callbacks test_audio_cb = { static void test_init() { - g_assert_null(test_audio_player()); + g_assert_null(test_old_player()); g_assert_null(audio_cur_track()); g_assert_cmpuint(audio_cur_state(), ==, GST_STATE_NULL); g_assert_null(audio_next()); @@ -73,7 +73,7 @@ static void test_init() while (idle_run_task()) {}; g_assert_null(audio_cur_track()); - g_assert_nonnull(test_audio_player()); + g_assert_nonnull(test_old_player()); } static void test_playback() @@ -236,7 +236,7 @@ static void test_deinit() { core_deinit(); g_assert_null(audio_cur_track()); - g_assert_null(test_audio_player()); + g_assert_null(test_old_player()); }