<html><head></head><body>Hi,<br><br>Seen as this is OS-specific code, it might be simpler to use a constructor function than a one-time initialisation. I don't know macOs details though<br><br><div class="gmail_quote">Le 16 août 2019 11:55:33 GMT+03:00, Thomas Guillem <thomas@gllm.fr> a écrit :<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<pre class="k9mail"><hr> modules/audio_output/audiounit_ios.m | 5 ++++-<br> modules/audio_output/auhal.c | 4 ++++<br> modules/audio_output/coreaudio_common.c | 17 ++++++++++-------<br> modules/audio_output/coreaudio_common.h | 2 ++<br> 4 files changed, 20 insertions(+), 8 deletions(-)<br><br>diff --git a/modules/audio_output/audiounit_ios.m b/modules/audio_output/audiounit_ios.m<br>index cbac04c2b1..59f35b04fb 100644<br>--- a/modules/audio_output/audiounit_ios.m<br>+++ b/modules/audio_output/audiounit_ios.m<br>@@ -612,8 +612,11 @@ static int<br> Open(vlc_object_t *obj)<br> {<br> audio_output_t *aout = (audio_output_t *)obj;<br>- aout_sys_t *sys = calloc(1, sizeof (*sys));<br> <br>+ if (ca_OnceInit() != VLC_SUCCESS)<br>+ return VLC_EGENERIC;<br>+<br>+ aout_sys_t *sys = calloc(1, sizeof (*sys));<br> if (unlikely(sys == NULL))<br> return VLC_ENOMEM;<br> <br>diff --git a/modules/audio_output/auhal.c b/modules/audio_output/auhal.c<br>index 6ba2765754..d9a76ac257 100644<br>--- a/modules/audio_output/auhal.c<br>+++ b/modules/audio_output/auhal.c<br>@@ -1694,6 +1694,10 @@ static void Close(vlc_object_t *obj)<br> static int Open(vlc_object_t *obj)<br> {<br> audio_output_t *p_aout = (audio_output_t *)obj;<br>+<br>+ if (ca_OnceInit() != VLC_SUCCESS)<br>+ return VLC_EGENERIC;<br>+<br> aout_sys_t *p_sys = calloc(1, sizeof (*p_sys));<br> if (unlikely(p_sys == NULL))<br> return VLC_ENOMEM;<br>diff --git a/modules/audio_output/coreaudio_common.c b/modules/audio_output/coreaudio_common.c<br>index 1720a1a5f9..c25eaae1ca 100644<br>--- a/modules/audio_output/coreaudio_common.c<br>+++ b/modules/audio_output/coreaudio_common.c<br>@@ -61,7 +61,7 @@ ca_ClearOutBuffers(audio_output_t *p_aout)<br> }<br> <br> static void<br>-ca_init_once(void)<br>+init_once_cb(void)<br> {<br> unfair_lock.lock = os_unfair_lock_lock;<br> if (likely(unfair_lock.lock))<br>@@ -75,6 +75,15 @@ ca_init_once(void)<br> tinfo.numer = tinfo.denom = 0;<br> }<br> <br>+int<br>+ca_OnceInit(void)<br>+{<br>+ static pthread_once_t once = PTHREAD_ONCE_INIT;<br>+ pthread_once(&once, init_once_cb);<br>+<br>+ return likely(tinfo.denom != 0) ? VLC_SUCCESS : VLC_EGENERIC;<br>+}<br>+<br> static void<br> lock_init(struct aout_sys_common *p_sys)<br> {<br>@@ -114,9 +123,6 @@ ca_Open(audio_output_t *p_aout)<br> {<br> struct aout_sys_common *p_sys = (struct aout_sys_common *) p_aout->sys;<br> <br>- static pthread_once_t once = PTHREAD_ONCE_INIT;<br>- pthread_once(&once, ca_init_once);<br>-<br> vlc_sem_init(&p_sys->flush_sem, 0);<br> lock_init(p_sys);<br> p_sys->p_out_chain = NULL;<br>@@ -207,9 +213,6 @@ ca_TimeGet(audio_output_t *p_aout, vlc_tick_t *delay)<br> {<br> struct aout_sys_common *p_sys = (struct aout_sys_common *) p_aout->sys;<br> <br>- if (unlikely(tinfo.denom == 0))<br>- return -1;<br>-<br> lock_lock(p_sys);<br> <br> if (p_sys->i_render_host_time == 0)<br>diff --git a/modules/audio_output/coreaudio_common.h b/modules/audio_output/coreaudio_common.h<br>index 11c73b31e4..60ef1fe9ca 100644<br>--- a/modules/audio_output/coreaudio_common.h<br>+++ b/modules/audio_output/coreaudio_common.h<br>@@ -81,6 +81,8 @@ struct aout_sys_common<br> vlc_tick_t i_dev_latency_us;<br> };<br> <br>+int ca_OnceInit(void);<br>+<br> void ca_Open(audio_output_t *p_aout);<br> <br> void ca_Close(audio_output_t *p_aout);</pre></blockquote></div><br>-- <br>Envoyé de mon appareil Android avec Courriel K-9 Mail. Veuillez excuser ma brièveté.</body></html>