提交 4c126bf5 编写于 作者: Z Zhang Rui

android/MediaCodec: atomic increament of g_amediacodec_object_serial

上级 7491f77c
...@@ -25,14 +25,13 @@ ...@@ -25,14 +25,13 @@
#include <assert.h> #include <assert.h>
#include "ijksdl/ijksdl_log.h" #include "ijksdl/ijksdl_log.h"
static int g_amediacodec_object_serial; static volatile int g_amediacodec_object_serial;
// TODO: thread-safe
int SDL_AMediaCodec_create_object_serial() int SDL_AMediaCodec_create_object_serial()
{ {
int object_serial = ++g_amediacodec_object_serial; int object_serial = __sync_add_and_fetch(&g_amediacodec_object_serial, 1);
if (object_serial == 0) if (object_serial == 0)
object_serial = SDL_AMediaCodec_create_object_serial(); object_serial = __sync_add_and_fetch(&g_amediacodec_object_serial, 1);
return object_serial; return object_serial;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册