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 <Anna@NoWheyCreamery.com>
This commit is contained in:
Anna Schumaker 2017-04-05 08:59:09 -04:00
parent d95c693db2
commit b558a9043c
3 changed files with 16 additions and 13 deletions

View File

@ -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;
}

View File

@ -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 */

View File

@ -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());
}