core/audio: Add audio_deinit() function

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
Anna Schumaker 2015-12-15 10:46:48 -05:00
parent d9540b29d6
commit e0c89556ed
5 changed files with 20 additions and 2 deletions

View File

@ -100,6 +100,15 @@ void audio_init(int *argc, char ***argv)
}
}
void audio_deinit()
{
gst_element_set_state(audio_player, GST_STATE_NULL);
gst_object_unref(audio_player);
audio_player = NULL;
gst_deinit();
}
void audio :: play()
{
if (cur_track)

View File

@ -26,6 +26,7 @@ void core :: init(int *argc, char ***argv, struct core_init_data *init)
void core :: deinit()
{
audio_deinit();
tempq_deinit();
history_deinit();
collection_deinit();

View File

@ -271,6 +271,4 @@ void gst :: init()
void gst :: quit()
{
delete gst_driver;
gst_change_state(GST_STATE_NULL);
gst_deinit();
}

View File

@ -158,6 +158,9 @@ namespace audio
/* Called to initialize the audio manager. */
void audio_init(int *, char ***);
/* Called to deinitialize the audio manager. */
void audio_deinit();
GstElement *audio_get_player();
#endif /* OCARINA_CORE_AUDIO_H */

View File

@ -57,8 +57,14 @@ static void test_init()
test_equal(audio :: current_track(), NULL);
test_not_equal(audio_get_player(), NULL);
}
static void test_deinit()
{
core :: deinit();
test_equal(audio :: current_track(), NULL);
test_equal(audio_get_player(), NULL);
}
@ -206,6 +212,7 @@ void test_autopause()
DECLARE_UNIT_TESTS(
UNIT_TEST("Audio Initialization", test_init),
UNIT_TEST("Audio Deinitialization", test_deinit),
UNIT_TEST("Test Audio Pre-Init", test_pre_init),
UNIT_TEST("Test Audio Init 2", test_init2),
UNIT_TEST("Test Audio Playback Controls", test_playback_controls),