1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-28 20:53:54 +02:00

avdevice/alldevices: make avdevice_register_all thread safe

use ff_thread_once

Suggested-by: wm4 <nfxjfg@googlemail.com>
Signed-off-by: Muhammad Faiz <mfcc64@gmail.com>
This commit is contained in:
Muhammad Faiz 2017-03-07 15:55:38 +07:00
parent af7010ad05
commit 776f289c0f
2 changed files with 9 additions and 8 deletions

View File

@ -19,6 +19,7 @@
*/
#include "config.h"
#include "libavutil/thread.h"
#include "avdevice.h"
#define REGISTER_OUTDEV(X, x) \
@ -37,14 +38,8 @@
#define REGISTER_INOUTDEV(X, x) REGISTER_OUTDEV(X, x); REGISTER_INDEV(X, x)
void avdevice_register_all(void)
static void register_all(void)
{
static int initialized;
if (initialized)
return;
initialized = 1;
/* devices */
REGISTER_INOUTDEV(ALSA, alsa);
REGISTER_INDEV (AVFOUNDATION, avfoundation);
@ -76,3 +71,10 @@ void avdevice_register_all(void)
REGISTER_INDEV (LIBCDIO, libcdio);
REGISTER_INDEV (LIBDC1394, libdc1394);
}
void avdevice_register_all(void)
{
AVOnce control = AV_ONCE_INIT;
ff_thread_once(&control, register_all);
}

View File

@ -67,7 +67,6 @@ const char *avdevice_license(void);
/**
* Initialize libavdevice and register all the input and output devices.
* @warning This function is not thread safe.
*/
void avdevice_register_all(void);