diff --git a/libavdevice/alldevices.c b/libavdevice/alldevices.c index 6b2a5121998db..041eb85f32c17 100644 --- a/libavdevice/alldevices.c +++ b/libavdevice/alldevices.c @@ -105,6 +105,8 @@ static void av_device_init_next(void) } if (previn) previn->next = NULL; + + avpriv_register_devices(outdev_list, indev_list); } void avdevice_register_all(void) @@ -115,9 +117,11 @@ void avdevice_register_all(void) static void *device_next(void *prev, int output, AVClassCategory c1, AVClassCategory c2) { - pthread_once(&av_device_next_init, av_device_init_next); const AVClass *pc; AVClassCategory category = AV_CLASS_CATEGORY_NA; + + pthread_once(&av_device_next_init, av_device_init_next); + if (!prev && !(prev = (output ? (void*)outdev_list[0] : (void*)indev_list[0]))) return NULL; diff --git a/libavformat/allformats.c b/libavformat/allformats.c index a807f86d80048..52b7088adf624 100644 --- a/libavformat/allformats.c +++ b/libavformat/allformats.c @@ -501,6 +501,9 @@ const AVInputFormat *av_demuxer_iterate(void **opaque){ #if FF_API_NEXT pthread_once_t av_format_next_init = PTHREAD_ONCE_INIT; +static AVInputFormat **indev_list = NULL; +static AVOutputFormat **outdev_list = NULL; + static void av_format_init_next(void) { AVOutputFormat *prevout = NULL, *out; @@ -513,10 +516,12 @@ static void av_format_init_next(void) prevout = out; } - for (i = 0; (out = (AVOutputFormat*)av_outdev_iterate(&i));) { - if (prevout) - prevout->next = out; - prevout = out; + if (outdev_list) { + for (i = 0; (out = (AVOutputFormat*)outdev_list[(int)i]); i = (void*)(i + 1)) { + if (prevout) + prevout->next = out; + prevout = out; + } } if (prevout) @@ -528,16 +533,25 @@ static void av_format_init_next(void) previn = in; } - for (i = 0; (in = (AVInputFormat*)av_indev_iterate(&i));) { - if (previn) - previn->next = in; - previn = in; + if (indev_list) { + for (i = 0; (in = (AVInputFormat*)indev_list[(int)i]); i = (void*)(i + 1)) { + if (previn) + previn->next = in; + previn = in; + } } if (previn) previn->next = NULL; } +void avpriv_register_devices(AVOutputFormat *o[], AVInputFormat *i[]) +{ + outdev_list = o; + indev_list = i; + av_format_init_next(); +} + AVInputFormat *av_iformat_next(const AVInputFormat *f) { void *i = 0; diff --git a/libavformat/avformat.h b/libavformat/avformat.h index d38ca4e97b828..56ec41a18d5f2 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -2013,6 +2013,10 @@ int avformat_network_init(void); int avformat_network_deinit(void); #if FF_API_NEXT +/** + * Register devices in deprecated format linked list. + */ +void avpriv_register_devices(AVOutputFormat *o[], AVInputFormat *i[]); /** * If f is NULL, returns the first registered input format, * if f is non-NULL, returns the next registered input format after f