avoptions: Fix av_opt_flag_is_set

Message ID 1318873938-88908-1-git-send-email-martin@martin.st
State Committed
Headers show

Commit Message

Martin Storsjö Oct. 17, 2011, 5:52 p.m.
With the changes in 3b3ea34655db02d9cd9ea1a4122e920a7fdec602,
"Remove all uses of deprecated AVOptions API", av_opt_flag_is_set
was broken, since it now uses av_opt_find, which doesn't return
named constants unless a unit to look for the constant in is given.

This broke enabling LATM encapsulated AAC output in RTP.
---
 libavutil/opt.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

Comments

Anton Khirnov Oct. 17, 2011, 6:01 p.m. | #1
On Mon, 17 Oct 2011 20:52:18 +0300, Martin Storsjö <martin@martin.st> wrote:
> With the changes in 3b3ea34655db02d9cd9ea1a4122e920a7fdec602,
> "Remove all uses of deprecated AVOptions API", av_opt_flag_is_set
> was broken, since it now uses av_opt_find, which doesn't return
> named constants unless a unit to look for the constant in is given.
> 
> This broke enabling LATM encapsulated AAC output in RTP.
> ---
>  libavutil/opt.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/libavutil/opt.c b/libavutil/opt.c
> index bf63bef..db1f575 100644
> --- a/libavutil/opt.c
> +++ b/libavutil/opt.c
> @@ -501,7 +501,7 @@ int av_opt_get_q(void *obj, const char *name, int search_flags, AVRational *out_
>  int av_opt_flag_is_set(void *obj, const char *field_name, const char *flag_name)
>  {
>      const AVOption *field = av_opt_find(obj, field_name, NULL, 0, 0);
> -    const AVOption *flag  = av_opt_find(obj, flag_name,  NULL, 0, 0);
> +    const AVOption *flag  = av_opt_find(obj, flag_name,  field->unit, 0, 0);

field might be NULL

Patch

diff --git a/libavutil/opt.c b/libavutil/opt.c
index bf63bef..db1f575 100644
--- a/libavutil/opt.c
+++ b/libavutil/opt.c
@@ -501,7 +501,7 @@  int av_opt_get_q(void *obj, const char *name, int search_flags, AVRational *out_
 int av_opt_flag_is_set(void *obj, const char *field_name, const char *flag_name)
 {
     const AVOption *field = av_opt_find(obj, field_name, NULL, 0, 0);
-    const AVOption *flag  = av_opt_find(obj, flag_name,  NULL, 0, 0);
+    const AVOption *flag  = av_opt_find(obj, flag_name,  field->unit, 0, 0);
     int64_t res;
 
     if (!field || !flag || flag->type != AV_OPT_TYPE_CONST ||