diff options
author | Anton Khirnov <anton@khirnov.net> | 2020-05-27 15:21:30 +0200 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2020-06-10 12:36:42 +0200 |
commit | 1b4a98b0296c7aa6d294ea73ec567d38cf5c5196 (patch) | |
tree | 3d96211f10f2637da14b83fc18feb62964b226da /libavutil/opt.c | |
parent | 202e06870eb4bbc4636aff5f461c1a0654ec2435 (diff) | |
download | ffmpeg-1b4a98b0296c7aa6d294ea73ec567d38cf5c5196.tar.gz |
lavu/opt: add a more general child class iteration API
Use opaque iteration state instead of the previous child class. This
mirrors similar changes done in lavf/lavc.
Deprecate the av_opt_child_class_next() API.
Diffstat (limited to 'libavutil/opt.c')
-rw-r--r-- | libavutil/opt.c | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/libavutil/opt.c b/libavutil/opt.c index 423313bce2..2c3f998d97 100644 --- a/libavutil/opt.c +++ b/libavutil/opt.c @@ -1679,8 +1679,9 @@ const AVOption *av_opt_find2(void *obj, const char *name, const char *unit, if (search_flags & AV_OPT_SEARCH_CHILDREN) { if (search_flags & AV_OPT_SEARCH_FAKE_OBJ) { - const AVClass *child = NULL; - while (child = av_opt_child_class_next(c, child)) + void *iter = NULL; + const AVClass *child; + while (child = av_opt_child_class_iterate(c, &iter)) if (o = av_opt_find2(&child, name, unit, opt_flags, search_flags, NULL)) return o; } else { @@ -1715,12 +1716,31 @@ void *av_opt_child_next(void *obj, void *prev) return NULL; } +#if FF_API_CHILD_CLASS_NEXT +FF_DISABLE_DEPRECATION_WARNINGS const AVClass *av_opt_child_class_next(const AVClass *parent, const AVClass *prev) { if (parent->child_class_next) return parent->child_class_next(prev); return NULL; } +FF_ENABLE_DEPRECATION_WARNINGS +#endif + +const AVClass *av_opt_child_class_iterate(const AVClass *parent, void **iter) +{ + if (parent->child_class_iterate) + return parent->child_class_iterate(iter); +#if FF_API_CHILD_CLASS_NEXT +FF_DISABLE_DEPRECATION_WARNINGS + if (parent->child_class_next) { + *iter = parent->child_class_next(*iter); + return *iter; + } +FF_ENABLE_DEPRECATION_WARNINGS +#endif + return NULL; +} void *av_opt_ptr(const AVClass *class, void *obj, const char *name) { |