Commit a0272c2d authored by Max Kellermann's avatar Max Kellermann

notify: added notify_deinit()

Destroy the mutex when it is not used anymore.
parent ee1d723a
...@@ -28,6 +28,11 @@ void dc_init(void) ...@@ -28,6 +28,11 @@ void dc_init(void)
dc.error = DECODE_ERROR_NOERROR; dc.error = DECODE_ERROR_NOERROR;
} }
void dc_deinit(void)
{
notify_deinit(&dc.notify);
}
void dc_command_wait(Notify *notify) void dc_command_wait(Notify *notify)
{ {
while (dc.command != DECODE_COMMAND_NONE) { while (dc.command != DECODE_COMMAND_NONE) {
......
...@@ -58,6 +58,8 @@ extern struct decoder_control dc; ...@@ -58,6 +58,8 @@ extern struct decoder_control dc;
void dc_init(void); void dc_init(void);
void dc_deinit(void);
static inline int decoder_is_idle(void) static inline int decoder_is_idle(void)
{ {
return dc.state == DECODE_STATE_STOP && return dc.state == DECODE_STATE_STOP &&
......
...@@ -459,12 +459,16 @@ int main(int argc, char *argv[]) ...@@ -459,12 +459,16 @@ int main(int argc, char *argv[])
DEBUG("closeMp3Directory took %f seconds\n", DEBUG("closeMp3Directory took %f seconds\n",
((float)(clock()-start))/CLOCKS_PER_SEC); ((float)(clock()-start))/CLOCKS_PER_SEC);
deinit_main_notify();
finishNormalization(); finishNormalization();
finishAudioDriver(); finishAudioDriver();
finishAudioConfig(); finishAudioConfig();
finishVolume(); finishVolume();
finishPaths(); finishPaths();
finishPermissions(); finishPermissions();
dc_deinit();
pc_deinit();
finishCommands(); finishCommands();
decoder_plugin_deinit_all(); decoder_plugin_deinit_all();
ob_free(); ob_free();
......
...@@ -68,6 +68,14 @@ void init_main_notify(void) ...@@ -68,6 +68,14 @@ void init_main_notify(void)
notify_init(&main_notify); 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) static int wakeup_via_pipe(void)
{ {
int ret = pthread_mutex_trylock(&select_mutex); int ret = pthread_mutex_trylock(&select_mutex);
......
...@@ -23,6 +23,8 @@ ...@@ -23,6 +23,8 @@
void init_main_notify(void); void init_main_notify(void);
void deinit_main_notify(void);
void wakeup_main_task(void); void wakeup_main_task(void);
void wait_main_task(void); void wait_main_task(void);
......
...@@ -34,6 +34,12 @@ void notify_init(struct notify *notify) ...@@ -34,6 +34,12 @@ void notify_init(struct notify *notify)
notify->pending = 0; 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) void notify_enter(struct notify *notify)
{ {
pthread_mutex_lock(&notify->mutex); pthread_mutex_lock(&notify->mutex);
......
...@@ -29,6 +29,8 @@ typedef struct notify { ...@@ -29,6 +29,8 @@ typedef struct notify {
void notify_init(struct notify *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 * The thread which shall be notified by this object must call this
* function before any notify_wait() invocation. It locks the mutex. * function before any notify_wait() invocation. It locks the mutex.
......
...@@ -38,6 +38,11 @@ void pc_init(unsigned int buffered_before_play) ...@@ -38,6 +38,11 @@ void pc_init(unsigned int buffered_before_play)
pc.softwareVolume = 1000; pc.softwareVolume = 1000;
} }
void pc_deinit(void)
{
notify_deinit(&pc.notify);
}
static void set_current_song(Song *song) static void set_current_song(Song *song)
{ {
assert(song != NULL); assert(song != NULL);
......
...@@ -107,6 +107,8 @@ extern struct player_control pc; ...@@ -107,6 +107,8 @@ extern struct player_control pc;
void pc_init(unsigned int buffered_before_play); void pc_init(unsigned int buffered_before_play);
void pc_deinit(void);
void playerPlay(Song * song); void playerPlay(Song * song);
void playerSetPause(int pause_flag); void playerSetPause(int pause_flag);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment