aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/decoder_control.c5
-rw-r--r--src/decoder_control.h2
-rw-r--r--src/main.c4
-rw-r--r--src/main_notify.c8
-rw-r--r--src/main_notify.h2
-rw-r--r--src/notify.c6
-rw-r--r--src/notify.h2
-rw-r--r--src/player_control.c5
-rw-r--r--src/player_control.h2
9 files changed, 36 insertions, 0 deletions
diff --git a/src/decoder_control.c b/src/decoder_control.c
index a0e3b6143..58c4e75ee 100644
--- a/src/decoder_control.c
+++ b/src/decoder_control.c
@@ -28,6 +28,11 @@ void dc_init(void)
dc.error = DECODE_ERROR_NOERROR;
}
+void dc_deinit(void)
+{
+ notify_deinit(&dc.notify);
+}
+
void dc_command_wait(Notify *notify)
{
while (dc.command != DECODE_COMMAND_NONE) {
diff --git a/src/decoder_control.h b/src/decoder_control.h
index 8c19d3d50..af777fb31 100644
--- a/src/decoder_control.h
+++ b/src/decoder_control.h
@@ -58,6 +58,8 @@ extern struct decoder_control dc;
void dc_init(void);
+void dc_deinit(void);
+
static inline int decoder_is_idle(void)
{
return dc.state == DECODE_STATE_STOP &&
diff --git a/src/main.c b/src/main.c
index 3cfd75b3a..5b8377731 100644
--- a/src/main.c
+++ b/src/main.c
@@ -459,12 +459,16 @@ int main(int argc, char *argv[])
DEBUG("closeMp3Directory took %f seconds\n",
((float)(clock()-start))/CLOCKS_PER_SEC);
+ deinit_main_notify();
+
finishNormalization();
finishAudioDriver();
finishAudioConfig();
finishVolume();
finishPaths();
finishPermissions();
+ dc_deinit();
+ pc_deinit();
finishCommands();
decoder_plugin_deinit_all();
ob_free();
diff --git a/src/main_notify.c b/src/main_notify.c
index d7f429f0f..4e5b786a2 100644
--- a/src/main_notify.c
+++ b/src/main_notify.c
@@ -68,6 +68,14 @@ void init_main_notify(void)
notify_init(&main_notify);
}
+void deinit_main_notify(void)
+{
+ notify_deinit(&main_notify);
+ deregisterIO(&main_notify_IO);
+ xclose(main_pipe[0]);
+ xclose(main_pipe[1]);
+}
+
static int wakeup_via_pipe(void)
{
int ret = pthread_mutex_trylock(&select_mutex);
diff --git a/src/main_notify.h b/src/main_notify.h
index c7bba4440..dd30dc5d6 100644
--- a/src/main_notify.h
+++ b/src/main_notify.h
@@ -23,6 +23,8 @@
void init_main_notify(void);
+void deinit_main_notify(void);
+
void wakeup_main_task(void);
void wait_main_task(void);
diff --git a/src/notify.c b/src/notify.c
index 4f8a0d296..edb77f66d 100644
--- a/src/notify.c
+++ b/src/notify.c
@@ -34,6 +34,12 @@ void notify_init(struct notify *notify)
notify->pending = 0;
}
+void notify_deinit(struct notify *notify)
+{
+ pthread_mutex_destroy(&notify->mutex);
+ pthread_cond_destroy(&notify->cond);
+}
+
void notify_enter(struct notify *notify)
{
pthread_mutex_lock(&notify->mutex);
diff --git a/src/notify.h b/src/notify.h
index 0f3b4c1bc..e727a0a34 100644
--- a/src/notify.h
+++ b/src/notify.h
@@ -29,6 +29,8 @@ typedef struct notify {
void notify_init(struct notify *notify);
+void notify_deinit(struct notify *notify);
+
/**
* The thread which shall be notified by this object must call this
* function before any notify_wait() invocation. It locks the mutex.
diff --git a/src/player_control.c b/src/player_control.c
index d4f8fcaf8..5bc08b776 100644
--- a/src/player_control.c
+++ b/src/player_control.c
@@ -38,6 +38,11 @@ void pc_init(unsigned int buffered_before_play)
pc.softwareVolume = 1000;
}
+void pc_deinit(void)
+{
+ notify_deinit(&pc.notify);
+}
+
static void set_current_song(Song *song)
{
assert(song != NULL);
diff --git a/src/player_control.h b/src/player_control.h
index 8282a9245..805f0325d 100644
--- a/src/player_control.h
+++ b/src/player_control.h
@@ -107,6 +107,8 @@ extern struct player_control pc;
void pc_init(unsigned int buffered_before_play);
+void pc_deinit(void);
+
void playerPlay(Song * song);
void playerSetPause(int pause_flag);