gui/audio: Disable the audio timeout function during shutdown

Otherwise we may try to use the gstreamer playbin after destroying it,
leading to various error messages showing up in the console.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This commit is contained in:
Anna Schumaker 2017-03-30 09:50:03 -04:00
parent a4049f8d01
commit a36fd137d5
4 changed files with 15 additions and 1 deletions

View File

@ -11,6 +11,8 @@
#include <gui/view.h>
#include <gui/window.h>
static guint audio_timeout = 0;
static inline void __audio_set_label(const gchar *label, const gchar *size,
const gchar *text)
{
@ -123,11 +125,17 @@ struct audio_ops audio_ops = {
void gui_audio_init()
{
GtkScaleButton *volume = GTK_SCALE_BUTTON(gui_builder_widget("o_volume"));
g_timeout_add(500, __audio_timeout, gui_builder_object("o_progress"));
audio_timeout = g_timeout_add(500, __audio_timeout,
gui_builder_object("o_progress"));
gtk_scale_button_set_value(volume, audio_get_volume());
gtk_button_set_relief(GTK_BUTTON(volume), GTK_RELIEF_NORMAL);
}
void gui_audio_deinit()
{
g_source_remove(audio_timeout);
}
#ifdef CONFIG_TESTING
void test_gui_audio_timeout()
{

View File

@ -123,6 +123,7 @@ static void __ocarina_startup(GApplication *application, gpointer data)
static void __ocarina_shutdown(GApplication *application, gpointer data)
{
gui_idle_disable();
gui_audio_deinit();
core_deinit();
gui_treeview_deinit();

View File

@ -10,6 +10,9 @@ extern struct audio_ops audio_ops;
/* Called to initialize the GUI audio controls. */
void gui_audio_init();
/* Called to stop the GUI audio timeout function. */
void gui_audio_deinit();
#ifdef CONFIG_TESTING
void test_gui_audio_timeout();
#endif /* CONFIG_TESTING */

View File

@ -136,6 +136,7 @@ int main(int argc, char **argv)
gui_builder_init("share/ocarina/ocarina.ui");
gui_model_init();
core_init(&argc, NULL, &init_data);
gui_audio_init();
playlist_new(PL_LIBRARY, "tests/Music/Hyrule Symphony");
while (idle_run_task()) {};
@ -143,6 +144,7 @@ int main(int argc, char **argv)
g_test_add_func("/Gui/Audio", test_audio);
ret = g_test_run();
gui_audio_deinit();
gui_window_deinit();
gui_model_deinit();
gui_builder_deinit();