[FFmpeg-devel] [PATCH 2/2] av_lockmgr_register defines behavior on failure.

Manfred Georg mgeorg at google.com
Wed Oct 1 03:46:03 CEST 2014


Sure, I've made the change to the comment within my local code.  I'm sorry,
but I'm not familiar with FFmpeg development cycle: how would you like me
to post it?
1) A patch on top of the patch that is already in this thread (i.e.
something that will be squished into this patch).
2) A new patch in a new thread.
3) A new patch in this thread.
4) Something else.

Although I kind of doubt that's what you want, here is method (1):

Subject: [PATCH] Say av_lockmgr_register returns non-zero on error.

---
 libavcodec/avcodec.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 69e7012..2899ba0 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -5128,7 +5128,7 @@ enum AVLockOp {
  * state as when it was called.  However, when called with AV_LOCK_DESTROY
  * the mutex will always be assumed to have been successfully destroyed.
  * If av_lockmgr_register succeeds it will return 0, if it fails it will
- * return -1 and destroy all mutex and unregister all callbacks.
+ * return non-zero and destroy all mutex and unregister all callbacks.
  *
  * @param cb User defined callback.  FFmpeg invokes calls to this
  *           callback and the previously registered callback during the
-- 
2.1.0.rc2.206.gedb03e5


Manfred

On Tue, Sep 30, 2014 at 4:02 PM, Michael Niedermayer <michaelni at gmx.at>
wrote:

> On Tue, Sep 30, 2014 at 03:20:43PM -0700, Manfred Georg wrote:
> > The register function now specifies that the user callback should
> > leave things in the same state that it found them on failure but
> > that failure to destroy is ignored by ffmpeg.  The register
> > function is also now explicit about its behavior on failure (it now
> > unregisters the previous callback and destroys all mutex).
> > ---
> >  libavcodec/avcodec.h | 24 +++++++++++++++---------
> >  libavcodec/utils.c   | 31 +++++++++++++++++++++----------
> >  2 files changed, 36 insertions(+), 19 deletions(-)
> >
> > diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
> > index 94e82f7..69e7012 100644
> > --- a/libavcodec/avcodec.h
> > +++ b/libavcodec/avcodec.h
> > @@ -5120,16 +5120,22 @@ enum AVLockOp {
> >
> >  /**
> >   * Register a user provided lock manager supporting the operations
> > - * specified by AVLockOp. mutex points to a (void *) where the
> > - * lockmgr should store/get a pointer to a user allocated mutex. It's
> > - * NULL upon AV_LOCK_CREATE and != NULL for all other ops.
> > - *
> > - * @param cb User defined callback. Note: FFmpeg may invoke calls to
> this
> > - *           callback during the call to av_lockmgr_register().
> > - *           Thus, the application must be prepared to handle that.
> > + * specified by AVLockOp.  The "mutex" argument to the function points
> > + * to a (void *) where the lockmgr should store/get a pointer to a user
> > + * allocated mutex.  It is NULL upon AV_LOCK_CREATE and equal to the
> > + * value left by the last call for all other ops.  If the lock manager
> > + * is unable to perform the op then it should leave the mutex in the
> same
> > + * state as when it was called.  However, when called with
> AV_LOCK_DESTROY
> > + * the mutex will always be assumed to have been successfully destroyed.
> > + * If av_lockmgr_register succeeds it will return 0, if it fails it will
> > + * return -1 and destroy all mutex and unregister all callbacks.
>
> generally ffmpeg uses negative for errors, so this shouldnt
> specifically use just -1. This allows providing richer error codes
> at any later point
>
> [...]
>
> --
> Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> Rewriting code that is poorly written but fully understood is good.
> Rewriting code that one doesnt understand is a sign that one is less smart
> then the original author, trying to rewrite it will not make it better.
>


More information about the ffmpeg-devel mailing list