[vlc-devel] [vlc-commits] vout: fix picture lock/unlock with private pool

Thomas Guillem thomas at gllm.fr
Mon Nov 3 13:32:18 CET 2014


This commit doesn't allow direct rendering decoder with private pool. Is
it wanted ?
This breaks MediaCodec with direct rendering (android/opaque.c vout use
a private pool).


On Mon, Nov 3, 2014, at 11:48, Thomas Guillem wrote:
> This commit breaks MediaCodec on android.
> 
> It crashes in mediacodec because p_pic->p_sys is NULL;
> 
> p_pic and p_pic->p_sys are normally allocated from android/opaque.c and
> given to a pool.
> 
> So, I think decoder_NewPicture(p_dec) doesn't return a picture allocated
> by the pool anymore.
> 
> There is no problem with android/surface.c (sw rendering) that also use
> a pool and p_pic->p_sys. There may be a race condition somewhere.
> 
> 
> On Sat, Nov 1, 2014, at 15:00, Rémi Denis-Courmont wrote:
> > vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sat Nov  1
> > 15:59:55 2014 +0200| [6a6c23bf075ba70844f8e9b51991df74952d616f] |
> > committer: Rémi Denis-Courmont
> > 
> > vout: fix picture lock/unlock with private pool
> > 
> > > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=6a6c23bf075ba70844f8e9b51991df74952d616f
> > ---
> > 
> >  include/vlc_picture_pool.h      |    1 +
> >  src/misc/picture_pool.c         |    9 +++++++--
> >  src/video_output/vout_wrapper.c |    4 ++--
> >  3 files changed, 10 insertions(+), 4 deletions(-)
> > 
> > diff --git a/include/vlc_picture_pool.h b/include/vlc_picture_pool.h
> > index ad8835e..72278c9 100644
> > --- a/include/vlc_picture_pool.h
> > +++ b/include/vlc_picture_pool.h
> > @@ -133,6 +133,7 @@ VLC_USED;
> >   */
> >  VLC_API unsigned picture_pool_GetSize(const picture_pool_t *);
> >  
> > +bool picture_pool_NeedsLocking(const picture_pool_t *);
> >  
> >  #endif /* VLC_PICTURE_POOL_H */
> >  
> > diff --git a/src/misc/picture_pool.c b/src/misc/picture_pool.c
> > index e899f9e..15d0791 100644
> > --- a/src/misc/picture_pool.c
> > +++ b/src/misc/picture_pool.c
> > @@ -208,6 +208,8 @@ error:
> >  
> >  picture_pool_t *picture_pool_Reserve(picture_pool_t *master, unsigned
> >  count)
> >  {
> > +    assert(master->pic_unlock == NULL);
> > +
> >      picture_t *picture[count ? count : 1];
> >      unsigned i;
> >  
> > @@ -221,8 +223,6 @@ picture_pool_t *picture_pool_Reserve(picture_pool_t
> > *master, unsigned count)
> >      if (!pool)
> >          goto error;
> >  
> > -    pool->pic_lock   = master->pic_lock;
> > -    pool->pic_unlock = master->pic_unlock;
> >      return pool;
> >  
> >  error:
> > @@ -330,3 +330,8 @@ unsigned picture_pool_GetSize(const picture_pool_t
> > *pool)
> >  {
> >      return pool->picture_count;
> >  }
> > +
> > +bool picture_pool_NeedsLocking(const picture_pool_t *pool)
> > +{
> > +    return pool->pic_lock != NULL || pool->pic_unlock != NULL;
> > +}
> > diff --git a/src/video_output/vout_wrapper.c
> > b/src/video_output/vout_wrapper.c
> > index d172bcc..8b5174a 100644
> > --- a/src/video_output/vout_wrapper.c
> > +++ b/src/video_output/vout_wrapper.c
> > @@ -133,8 +133,8 @@ int vout_InitWrapper(vout_thread_t *vout)
> >      picture_pool_t *display_pool =
> >          vout_display_Pool(vd, allow_dr ? __MAX(VOUT_MAX_PICTURES,
> >                                                 reserved_picture +
> >                                                 decoder_picture) : 3);
> > -    if (allow_dr &&
> > -        picture_pool_GetSize(display_pool) >= reserved_picture +
> > decoder_picture) {
> > +    if (allow_dr && !picture_pool_NeedsLocking(display_pool)
> > +     && picture_pool_GetSize(display_pool) >= reserved_picture +
> > decoder_picture) {
> >          sys->dpb_size     = picture_pool_GetSize(display_pool) -
> >          reserved_picture;
> >          sys->decoder_pool = display_pool;
> >          sys->display_pool = display_pool;
> > 
> > _______________________________________________
> > 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



More information about the vlc-devel mailing list