[vlc-devel] [vlc-commits] aout: add reference count
Thomas Guillem
thomas at gllm.fr
Mon Mar 18 09:11:48 CET 2019
On Mon, Mar 18, 2019, at 09:07, Steve Lhomme wrote:
> "internals" would work as well (especially since it's in aout_internal).
>
> "private" may be left for each aout module specific code (although it
> could be the opposite and be called internals).
Agree (but please don't do it now for aout, I have lot of aout patches right now)
>
> On 3/18/2019 8:35 AM, Steve Lhomme wrote:
> > Can we rename the aout owner to aout private ? The naming is
> > confusing, it seem to imply it's at a higher level than the object
> > when in fact it's part of it.
> >
> > (same thing for input and vout).
> >
> > On 3/17/2019 2:39 AM, Rémi Denis-Courmont wrote:
> >> vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sat
> >> Mar 16 10:56:09 2019 +0200|
> >> [829437ddb2dfcec12b3d0cd87235a9b094c51b07] | committer: Rémi
> >> Denis-Courmont
> >>
> >> aout: add reference count
> >>
> >>> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=829437ddb2dfcec12b3d0cd87235a9b094c51b07
> >>>
> >> ---
> >>
> >> src/audio_output/aout_internal.h | 2 ++
> >> src/audio_output/output.c | 15 ++++++++++++---
> >> 2 files changed, 14 insertions(+), 3 deletions(-)
> >>
> >> diff --git a/src/audio_output/aout_internal.h
> >> b/src/audio_output/aout_internal.h
> >> index 1dd92e96aa..9073988ae6 100644
> >> --- a/src/audio_output/aout_internal.h
> >> +++ b/src/audio_output/aout_internal.h
> >> @@ -84,6 +84,8 @@ typedef struct
> >> atomic_uint buffers_lost;
> >> atomic_uint buffers_played;
> >> atomic_uchar restart;
> >> +
> >> + atomic_uintptr_t refs;
> >> } aout_owner_t;
> >> typedef struct
> >> diff --git a/src/audio_output/output.c b/src/audio_output/output.c
> >> index 3eaa415976..33a73bb3d1 100644
> >> --- a/src/audio_output/output.c
> >> +++ b/src/audio_output/output.c
> >> @@ -244,6 +244,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);
> >> vlc_object_set_destructor (aout, aout_Destructor);
> >> @@ -365,7 +366,9 @@ audio_output_t *aout_New (vlc_object_t *parent)
> >> audio_output_t *aout_Hold(audio_output_t *aout)
> >> {
> >> - (vlc_object_hold)(VLC_OBJECT(aout));
> >> + aout_owner_t *owner = aout_owner(aout);
> >> +
> >> + atomic_fetch_add_explicit(&owner->refs, 1, memory_order_relaxed);
> >> return aout;
> >> }
> >> @@ -391,12 +394,18 @@ void aout_Destroy (audio_output_t *aout)
> >> var_SetFloat (aout, "volume", -1.f);
> >> var_DelCallback(aout, "volume", var_Copy,
> >> vlc_object_parent(aout));
> >> var_DelCallback (aout, "stereo-mode", StereoModeCallback, NULL);
> >> - vlc_object_delete(aout);
> >> + aout_Release(aout);
> >> }
> >> void aout_Release(audio_output_t *aout)
> >> {
> >> - (vlc_object_release)(VLC_OBJECT(aout));
> >> + aout_owner_t *owner = aout_owner(aout);
> >> +
> >> + if (atomic_fetch_sub_explicit(&owner->refs, 1,
> >> memory_order_release))
> >> + return;
> >> +
> >> + atomic_thread_fence(memory_order_acquire);
> >> + vlc_object_delete(VLC_OBJECT(aout));
> >> }
> >> /**
> >>
> >> _______________________________________________
> >> vlc-commits mailing list
> >> vlc-commits at videolan.org
> >> https://mailman.videolan.org/listinfo/vlc-commits
> >
> > _______________________________________________
> > 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