[vlc-devel] [PATCH] aout/vout: initialize reference count at 1
Quentin Chateau
quentin.chateau at deepskycorp.com
Fri Feb 21 15:13:12 CET 2020
Hi, you're right, I'm changing it straight away.
Don't apply this
On 21/02/2020 14:56, Alexandre Janniaux wrote:
> Hi,
>
> It might be a better idea to use vlc_atomic_rc
> instead.
>
> Regards,
> --
> Alexandre Janniaux
> Videolabs
>
> On Fri, Feb 21, 2020 at 02:53:03PM +0100, quentin.chateau at deepskycorp.com wrote:
>> From: Quentin Chateau <quentin.chateau at deepskycorp.com>
>>
>> This help identifying bad memory accesses.
>> This commit also fixes uninitialized refence
>> counter in vout_CreateDummy.
>> ---
>> src/audio_output/output.c | 4 ++--
>> src/video_output/video_output.c | 6 ++----
>> 2 files changed, 4 insertions(+), 6 deletions(-)
>>
>> diff --git a/src/audio_output/output.c b/src/audio_output/output.c
>> index 526489e5f6..a4029c1681 100644
>> --- a/src/audio_output/output.c
>> +++ b/src/audio_output/output.c
>> @@ -222,7 +222,7 @@ audio_output_t *aout_New (vlc_object_t *parent)
>> vlc_mutex_init (&owner->vp.lock);
>> vlc_viewpoint_init (&owner->vp.value);
>> atomic_init (&owner->vp.update, false);
>> - atomic_init(&owner->refs, 0);
>> + atomic_init(&owner->refs, 1);
>>
>> /* Audio output module callbacks */
>> var_Create (aout, "volume", VLC_VAR_FLOAT);
>> @@ -380,7 +380,7 @@ void aout_Release(audio_output_t *aout)
>> {
>> aout_owner_t *owner = aout_owner(aout);
>>
>> - if (atomic_fetch_sub_explicit(&owner->refs, 1, memory_order_release))
>> + if (atomic_fetch_sub_explicit(&owner->refs, 1, memory_order_release) > 1)
>> return;
>>
>> atomic_thread_fence(memory_order_acquire);
>> diff --git a/src/video_output/video_output.c b/src/video_output/video_output.c
>> index edda78d731..ed94e28e9b 100644
>> --- a/src/video_output/video_output.c
>> +++ b/src/video_output/video_output.c
>> @@ -1834,7 +1834,7 @@ void vout_Release(vout_thread_t *vout)
>> {
>> vout_thread_sys_t *sys = vout->p;
>>
>> - if (atomic_fetch_sub_explicit(&sys->refs, 1, memory_order_release))
>> + if (atomic_fetch_sub_explicit(&sys->refs, 1, memory_order_release) > 1)
>> return;
>>
>> if (sys->dummy)
>> @@ -1879,6 +1879,7 @@ static vout_thread_t *vout_CreateCommon(vlc_object_t *object)
>> vout_CreateVars(vout);
>>
>> vout_thread_sys_t *sys = (vout_thread_sys_t *)&vout[1];
>> + atomic_init(&sys->refs, 1);
>>
>> vout->p = sys;
>> return vout;
>> @@ -1964,9 +1965,6 @@ vout_thread_t *vout_Create(vlc_object_t *object)
>> /* Arbitrary initial time */
>> vout_chrono_Init(&sys->render, 5, VLC_TICK_FROM_MS(10));
>>
>> - /* */
>> - atomic_init(&sys->refs, 0);
>> -
>> if (var_InheritBool(vout, "video-wallpaper"))
>> vout_window_SetState(sys->display_cfg.window, VOUT_WINDOW_STATE_BELOW);
>> else if (var_InheritBool(vout, "video-on-top"))
>> --
>> 2.17.1
>>
>> _______________________________________________
>> 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
More information about the vlc-devel
mailing list