[vlc-devel] [PATCH] aout/coreaudio: Use symbols directly instead of dlsym
Rémi Denis-Courmont
remi at remlab.net
Fri Aug 2 16:04:55 CEST 2019
Hi,
Similar to weak ELF symbols then but they're a bit questionable for C/C++ semantics. A function cannot compare nul, as opposed to a function pointer.
Le 2 août 2019 16:24:53 GMT+03:00, Marvin Scholz <epirat07 at gmail.com> a écrit :
>On 2 Aug 2019, at 14:45, Rémi Denis-Courmont wrote:
>
>> Hi,
>>
>> That's not how symbol resolution normally works... Are you sure?
>
>Yes, thats the concept of partially available symbols (requires special
>annotation in the function declaration) which allows symbols to be
>undefined
>without causing a failure at runtime (essentially a weak symbol).
>
>Most macOS headers use some complex macro magic to mark symbols as
>partially
>available (weak) when targeting macOS versions that are lower than the
>macOS
>version where the symbol was introduced.
>
>The user must then check if the symbol is NULL before using it or just
>check
>the macOS version.
>
>The header declaring the symbol has it annotated correctly:
>https://opensource.apple.com/source/libplatform/libplatform-125/include/os/lock.h.auto.html
>
>>
>> Le 2 août 2019 14:59:13 GMT+03:00, Marvin Scholz <epirat07 at gmail.com>
>
>> a écrit :
>>> It is not needed to load the symbols using dlsym here, they will be
>>> automatically available if the OS version is recent enough or NULL
>if
>>> not.
>>> ---
>>> modules/audio_output/coreaudio_common.c | 4 ++--
>>> 1 file changed, 2 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/modules/audio_output/coreaudio_common.c
>>> b/modules/audio_output/coreaudio_common.c
>>> index 3a9ec69113..836a5f6de4 100644
>>> --- a/modules/audio_output/coreaudio_common.c
>>> +++ b/modules/audio_output/coreaudio_common.c
>>> @@ -63,10 +63,10 @@ ca_ClearOutBuffers(audio_output_t *p_aout)
>>> static void
>>> ca_init_once(void)
>>> {
>>> - unfair_lock.lock = dlsym(RTLD_DEFAULT, "os_unfair_lock_lock");
>>> + unfair_lock.lock = os_unfair_lock_lock;
>>> if (!unfair_lock.lock)
>>> return;
>>> - unfair_lock.unlock = dlsym(RTLD_DEFAULT,
>>> "os_unfair_lock_unlock");
>>> + unfair_lock.unlock = os_unfair_lock_unlock;
>>> if (!unfair_lock.unlock)
>>> unfair_lock.lock = NULL;
>>>
>>> --
>>> 2.19.1
>>>
>>> _______________________________________________
>>> vlc-devel mailing list
>>> To unsubscribe or modify your subscription options:
>>> https://mailman.videolan.org/listinfo/vlc-devel
>>
>> --
>> 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
>_______________________________________________
>vlc-devel mailing list
>To unsubscribe or modify your subscription options:
>https://mailman.videolan.org/listinfo/vlc-devel
--
Envoyé de mon appareil Android avec Courriel K-9 Mail. Veuillez excuser ma brièveté.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20190802/43a988f2/attachment.html>
More information about the vlc-devel
mailing list