[vlc-devel] [PATCH 3/6] coreaudio: a valid timebase is now mandatory
Thomas Guillem
thomas at gllm.fr
Fri Aug 16 12:07:47 CEST 2019
On Fri, Aug 16, 2019, at 12:05, Rémi Denis-Courmont wrote:
> Hi,
>
> 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
OK, specially since there is likely to be only one aout module in the lifetime of VLC.
>
> Le 16 août 2019 11:55:33 GMT+03:00, Thomas Guillem <thomas at gllm.fr> a écrit :
>> modules/audio_output/audiounit_ios.m | 5 ++++-
>> modules/audio_output/auhal.c | 4 ++++
>> modules/audio_output/coreaudio_common.c | 17 ++++++++++-------
>> modules/audio_output/coreaudio_common.h | 2 ++
>> 4 files changed, 20 insertions(+), 8 deletions(-)
>>
>> diff --git a/modules/audio_output/audiounit_ios.m b/modules/audio_output/audiounit_ios.m
>> index cbac04c2b1..59f35b04fb 100644
>> --- a/modules/audio_output/audiounit_ios.m
>> +++ b/modules/audio_output/audiounit_ios.m
>> @@ -612,8 +612,11 @@ static int
>> Open(vlc_object_t *obj)
>> {
>> audio_output_t *aout = (audio_output_t *)obj;
>> - aout_sys_t *sys = calloc(1, sizeof (*sys));
>>
>> + if (ca_OnceInit() != VLC_SUCCESS)
>> + return VLC_EGENERIC;
>> +
>> + aout_sys_t *sys = calloc(1, sizeof (*sys));
>> if (unlikely(sys == NULL))
>> return VLC_ENOMEM;
>>
>> diff --git a/modules/audio_output/auhal.c b/modules/audio_output/auhal.c
>> index 6ba2765754..d9a76ac257 100644
>> --- a/modules/audio_output/auhal.c
>> +++ b/modules/audio_output/auhal.c
>> @@ -1694,6 +1694,10 @@ static void Close(vlc_object_t *obj)
>> static int Open(vlc_object_t *obj)
>> {
>> audio_output_t *p_aout = (audio_output_t *)obj;
>> +
>> + if (ca_OnceInit() != VLC_SUCCESS)
>> + return VLC_EGENERIC;
>> +
>> aout_sys_t *p_sys = calloc(1, sizeof (*p_sys));
>> if (unlikely(p_sys == NULL))
>> return VLC_ENOMEM;
>> diff --git a/modules/audio_output/coreaudio_common.c b/modules/audio_output/coreaudio_common.c
>> index 1720a1a5f9..c25eaae1ca 100644
>> --- a/modules/audio_output/coreaudio_common.c
>> +++ b/modules/audio_output/coreaudio_common.c
>> @@ -61,7 +61,7 @@ ca_ClearOutBuffers(audio_output_t *p_aout)
>> }
>>
>> static void
>> -ca_init_once(void)
>> +init_once_cb(void)
>> {
>> unfair_lock.lock = os_unfair_lock_lock;
>> if (likely(unfair_lock.lock))
>> @@ -75,6 +75,15 @@ ca_init_once(void)
>> tinfo.numer = tinfo.denom = 0;
>> }
>>
>> +int
>> +ca_OnceInit(void)
>> +{
>> + static pthread_once_t once = PTHREAD_ONCE_INIT;
>> + pthread_once(&once, init_once_cb);
>> +
>> + return likely(tinfo.denom != 0) ? VLC_SUCCESS : VLC_EGENERIC;
>> +}
>> +
>> static void
>> lock_init(struct aout_sys_common *p_sys)
>> {
>> @@ -114,9 +123,6 @@ ca_Open(audio_output_t *p_aout)
>> {
>> struct aout_sys_common *p_sys = (struct aout_sys_common *) p_aout->sys;
>>
>> - static pthread_once_t once = PTHREAD_ONCE_INIT;
>> - pthread_once(&once, ca_init_once);
>> -
>> vlc_sem_init(&p_sys->flush_sem, 0);
>> lock_init(p_sys);
>> p_sys->p_out_chain = NULL;
>> @@ -207,9 +213,6 @@ ca_TimeGet(audio_output_t *p_aout, vlc_tick_t *delay)
>> {
>> struct aout_sys_common *p_sys = (struct aout_sys_common *) p_aout->sys;
>>
>> - if (unlikely(tinfo.denom == 0))
>> - return -1;
>> -
>> lock_lock(p_sys);
>>
>> if (p_sys->i_render_host_time == 0)
>> diff --git a/modules/audio_output/coreaudio_common.h b/modules/audio_output/coreaudio_common.h
>> index 11c73b31e4..60ef1fe9ca 100644
>> --- a/modules/audio_output/coreaudio_common.h
>> +++ b/modules/audio_output/coreaudio_common.h
>> @@ -81,6 +81,8 @@ struct aout_sys_common
>> vlc_tick_t i_dev_latency_us;
>> };
>>
>> +int ca_OnceInit(void);
>> +
>> void ca_Open(audio_output_t *p_aout);
>>
>> void ca_Close(audio_output_t *p_aout);
>
> --
> Envoyé de mon appareil Android avec Courriel K-9 Mail. Veuillez excuser ma brièveté.
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20190816/a0ea7e4a/attachment.html>
More information about the vlc-devel
mailing list