我正在尝试在曲面上渲染视频,当我尝试在渲染过程中更改渲染曲面但应用程序因渲染循环中的mNativeSurface = NULL
而崩溃。我做错了什么
Decoder.h
class Decoder {
private:
ANativeWindow* mNativeSurface;
static void* threadStartCallback(void *myself);
pthread_mutex_t _mutex_window;
public:
void changeSurface(JEnv* env,jobject surface);
}
Decoder.cpp
class Decoder{
public Decoder(JEnv* env,jobject surface){
pthread_mutex_init(&_mutex_window, 0);
mNativeSurface= ANativeWindow_fromSurface(env,surface);
// create a thread and pass surface as widow
pthread_create(&_threadId, 0, threadStartCallback, this);
}
void changeSurface(JEnv* env,jobject surface){
//after some time i am changinf surface
pthread_mutex_lock(&_mutex_window);
mNativeSurface= ANativeWindow_fromSurface(env,surface);
pthread_mutex_unlock(&_mutex_window);
}
void* Decoder::threadStartCallback(void *myself)
{
while(/* condition */){
//When i change surface while loop in sleep
pthread_mutex_lock(&_mutex_window);
Rendering on mNativeSurface //rendering ----
pthread_mutex_unlock(&_mutex_window);
/*
*Decoding + Rendering in while loop
*/
}
return 0;
}
}
提前致谢。