Skip to content

Commit f53962f

Browse files
committed
don't use static var in decoder rather pass pointer to thread directly
1 parent 237e262 commit f53962f

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

jni/libmediaplayer/decoder.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,9 @@
33

44
#define TAG "FFMpegIDecoder"
55

6-
static IDecoder* sInstance;
7-
86
IDecoder::IDecoder()
97
{
108
mQueue = new PacketQueue();
11-
sInstance = this;
129
}
1310

1411
IDecoder::~IDecoder()
@@ -46,7 +43,7 @@ bool IDecoder::startAsync(const char* err)
4643
return false;
4744
}
4845

49-
pthread_create(&mThread, NULL, startDecoding, NULL);
46+
pthread_create(&mThread, NULL, startDecoding, this);
5047
return true;
5148
}
5249

@@ -73,9 +70,10 @@ void IDecoder::stop()
7370
void* IDecoder::startDecoding(void* ptr)
7471
{
7572
__android_log_print(ANDROID_LOG_INFO, TAG, "starting decoder thread");
76-
sInstance->mDecoding = true;
77-
sInstance->decode(ptr);
78-
sInstance->mDecoding = false;
73+
IDecoder* decoder = (IDecoder *) ptr;
74+
decoder->mDecoding = true;
75+
decoder->decode(ptr);
76+
decoder->mDecoding = false;
7977
}
8078

8179
bool IDecoder::prepare(const char *err)

0 commit comments

Comments
 (0)