[vlc-devel] [PATCH] aout/coreaudio: Use symbols directly instead of dlsym

Marvin Scholz epirat07 at gmail.com
Fri Aug 2 15:24:53 CEST 2019


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


More information about the vlc-devel mailing list