mirror of
https://github.com/mpv-player/mpv.git
synced 2024-09-20 12:02:23 +02:00
audio/out/push: clean up properly on init error
Close the wakeup pipes, free the mutex and condition var.
This commit is contained in:
parent
e79de41b97
commit
650af29471
@ -364,6 +364,20 @@ static void *playthread(void *arg)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void destroy_no_thread(struct ao *ao)
|
||||||
|
{
|
||||||
|
struct ao_push_state *p = ao->api_priv;
|
||||||
|
|
||||||
|
ao->driver->uninit(ao);
|
||||||
|
|
||||||
|
for (int n = 0; n < 2; n++)
|
||||||
|
close(p->wakeup_pipe[n]);
|
||||||
|
|
||||||
|
pthread_cond_destroy(&p->wakeup);
|
||||||
|
pthread_cond_destroy(&p->wakeup_drain);
|
||||||
|
pthread_mutex_destroy(&p->lock);
|
||||||
|
}
|
||||||
|
|
||||||
static void uninit(struct ao *ao)
|
static void uninit(struct ao *ao)
|
||||||
{
|
{
|
||||||
struct ao_push_state *p = ao->api_priv;
|
struct ao_push_state *p = ao->api_priv;
|
||||||
@ -375,14 +389,7 @@ static void uninit(struct ao *ao)
|
|||||||
|
|
||||||
pthread_join(p->thread, NULL);
|
pthread_join(p->thread, NULL);
|
||||||
|
|
||||||
ao->driver->uninit(ao);
|
destroy_no_thread(ao);
|
||||||
|
|
||||||
for (int n = 0; n < 2; n++)
|
|
||||||
close(p->wakeup_pipe[n]);
|
|
||||||
|
|
||||||
pthread_cond_destroy(&p->wakeup);
|
|
||||||
pthread_cond_destroy(&p->wakeup_drain);
|
|
||||||
pthread_mutex_destroy(&p->lock);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int init(struct ao *ao)
|
static int init(struct ao *ao)
|
||||||
@ -407,7 +414,7 @@ static int init(struct ao *ao)
|
|||||||
goto err;
|
goto err;
|
||||||
return 0;
|
return 0;
|
||||||
err:
|
err:
|
||||||
ao->driver->uninit(ao);
|
destroy_no_thread(ao);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user