notify: added notify_deinit()

Destroy the mutex when it is not used anymore.
This commit is contained in:
Max Kellermann 2008-09-24 07:14:11 +02:00
parent ee1d723ad7
commit a0272c2d61
9 changed files with 36 additions and 0 deletions

View File

@ -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) {

View File

@ -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 &&

View File

@ -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();

View File

@ -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);

View File

@ -23,6 +23,8 @@
void init_main_notify(void);
void deinit_main_notify(void);
void wakeup_main_task(void);
void wait_main_task(void);

View File

@ -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);

View File

@ -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.

View File

@ -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);

View File

@ -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);