changeset 2266:5395c85a8724

Make flacng plugin to clean up after itself (Bugzilla #19)
author Jussi Judin <jjudin+audacious@iki.fi>
date Tue, 25 Dec 2007 02:15:14 -0600
parents 349e659d34ca
children 2e961ce4bfe8
files src/flacng/plugin.c src/flacng/plugin.h src/flacng/tools.c src/flacng/tools.h
diffstat 4 files changed, 29 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/flacng/plugin.c	Tue Dec 25 02:14:39 2007 -0600
+++ b/src/flacng/plugin.c	Tue Dec 25 02:15:14 2007 -0600
@@ -32,6 +32,7 @@
 InputPlugin flac_ip = {
     .description = "FLACng Audio Plugin",
     .init = flac_init,
+    .cleanup = flac_cleanup,
     .about = flac_aboutbox,
     .is_our_file = flac_is_our_file,
     .play_file = flac_play_file,
@@ -152,6 +153,23 @@
 
 /* --- */
 
+void flac_cleanup(void)
+{
+    _ENTER;
+
+    FLAC__stream_decoder_delete(main_decoder);
+    clean_callback_info(main_info);
+
+    FLAC__stream_decoder_delete(test_decoder);
+    clean_callback_info(test_info);
+
+    plugin_initialized = FALSE;
+
+    _LEAVE;
+}
+
+/* --- */
+
 gboolean flac_is_our_fd(gchar* filename, VFSFile* fd) {
 
     _ENTER;
--- a/src/flacng/plugin.h	Tue Dec 25 02:14:39 2007 -0600
+++ b/src/flacng/plugin.h	Tue Dec 25 02:15:14 2007 -0600
@@ -2,6 +2,7 @@
 #define _PLUGIN_H
 
 void flac_init(void);
+void flac_cleanup(void);
 void flac_aboutbox(void);
 gboolean flac_is_our_file(gchar* filename);
 gboolean flac_is_our_fd(gchar* filename, VFSFile* fd);
--- a/src/flacng/tools.c	Tue Dec 25 02:14:39 2007 -0600
+++ b/src/flacng/tools.c	Tue Dec 25 02:15:14 2007 -0600
@@ -75,6 +75,15 @@
 
 /* --- */
 
+void clean_callback_info(callback_info* info)
+{
+    g_mutex_free(info->mutex);
+    free(info->output_buffer);
+    free(info);
+}
+
+/* --- */
+
 void reset_info(callback_info* info, gboolean close_fd) {
 
     _ENTER;
--- a/src/flacng/tools.h	Tue Dec 25 02:14:39 2007 -0600
+++ b/src/flacng/tools.h	Tue Dec 25 02:15:14 2007 -0600
@@ -40,6 +40,7 @@
     } while(0)
 
 callback_info* init_callback_info(gchar* name);
+void clean_callback_info(callback_info* info);
 void reset_info(callback_info* info, gboolean close_fd);
 gchar* get_title(const gchar* filename, callback_info* info);
 Tuple *get_tuple(const gchar *filename, callback_info* info);