提交 5f00a1b2 编写于 作者: Z Zhang Rui

android: fix mp.release() and mp.reset()

上级 730d8c5f
...@@ -249,18 +249,19 @@ IjkMediaPlayer_release(JNIEnv *env, jobject thiz) ...@@ -249,18 +249,19 @@ IjkMediaPlayer_release(JNIEnv *env, jobject thiz)
ijkmp_dec_ref_p(&mp); ijkmp_dec_ref_p(&mp);
} }
static void IjkMediaPlayer_native_setup(JNIEnv *env, jobject thiz, jobject weak_this);
static void static void
IjkMediaPlayer_reset(JNIEnv *env, jobject thiz) IjkMediaPlayer_reset(JNIEnv *env, jobject thiz)
{ {
MPTRACE("IjkMediaPlayer_reset"); MPTRACE("IjkMediaPlayer_reset");
IjkMediaPlayer *mp = jni_get_media_player(env, thiz); IjkMediaPlayer *mp = jni_get_media_player(env, thiz);
JNI_CHECK_GOTO(mp, env, NULL, "mpjni: reset: null mp", LABEL_RETURN); if (!mp)
return;
ijkmp_android_set_surface(env, mp, NULL); jobject weak_thiz = (jobject) ijkmp_set_weak_thiz(mp, NULL);
ijkmp_reset(mp);
LABEL_RETURN: IjkMediaPlayer_release(env, thiz);
ijkmp_dec_ref_p(&mp); IjkMediaPlayer_native_setup(env, thiz, weak_thiz);
} }
static void static void
......
...@@ -165,8 +165,6 @@ inline static void msg_queue_flush(MessageQueue *q) ...@@ -165,8 +165,6 @@ inline static void msg_queue_flush(MessageQueue *q)
inline static void msg_queue_destroy(MessageQueue *q) inline static void msg_queue_destroy(MessageQueue *q)
{ {
msg_queue_flush(q); msg_queue_flush(q);
SDL_DestroyMutex(q->mutex);
SDL_DestroyCond(q->cond);
SDL_LockMutex(q->mutex); SDL_LockMutex(q->mutex);
while(q->recycle_msg) { while(q->recycle_msg) {
...@@ -176,6 +174,9 @@ inline static void msg_queue_destroy(MessageQueue *q) ...@@ -176,6 +174,9 @@ inline static void msg_queue_destroy(MessageQueue *q)
av_freep(&msg); av_freep(&msg);
} }
SDL_UnlockMutex(q->mutex); SDL_UnlockMutex(q->mutex);
SDL_DestroyMutex(q->mutex);
SDL_DestroyCond(q->cond);
} }
inline static void msg_queue_abort(MessageQueue *q) inline static void msg_queue_abort(MessageQueue *q)
......
...@@ -166,8 +166,6 @@ static void packet_queue_flush(PacketQueue *q) ...@@ -166,8 +166,6 @@ static void packet_queue_flush(PacketQueue *q)
static void packet_queue_destroy(PacketQueue *q) static void packet_queue_destroy(PacketQueue *q)
{ {
packet_queue_flush(q); packet_queue_flush(q);
SDL_DestroyMutex(q->mutex);
SDL_DestroyCond(q->cond);
SDL_LockMutex(q->mutex); SDL_LockMutex(q->mutex);
while(q->recycle_pkt) { while(q->recycle_pkt) {
...@@ -177,6 +175,9 @@ static void packet_queue_destroy(PacketQueue *q) ...@@ -177,6 +175,9 @@ static void packet_queue_destroy(PacketQueue *q)
av_freep(&pkt); av_freep(&pkt);
} }
SDL_UnlockMutex(q->mutex); SDL_UnlockMutex(q->mutex);
SDL_DestroyMutex(q->mutex);
SDL_DestroyCond(q->cond);
} }
static void packet_queue_abort(PacketQueue *q) static void packet_queue_abort(PacketQueue *q)
......
...@@ -183,28 +183,6 @@ void ijkmp_shutdown(IjkMediaPlayer *mp) ...@@ -183,28 +183,6 @@ void ijkmp_shutdown(IjkMediaPlayer *mp)
return ijkmp_shutdown_l(mp); return ijkmp_shutdown_l(mp);
} }
void ijkmp_reset_l(IjkMediaPlayer *mp)
{
assert(mp);
ijkmp_shutdown_l(mp);
ffp_reset_internal(mp->ffplayer);
av_freep(&mp->data_source);
ijkmp_change_state_l(mp, MP_STATE_IDLE);
}
void ijkmp_reset(IjkMediaPlayer *mp)
{
assert(mp);
MPTRACE("ijkmp_reset()\n");
pthread_mutex_lock(&mp->mutex);
ijkmp_reset_l(mp);
pthread_mutex_unlock(&mp->mutex);
MPTRACE("ijkmp_reset()=void\n");
}
void ijkmp_inc_ref(IjkMediaPlayer *mp) void ijkmp_inc_ref(IjkMediaPlayer *mp)
{ {
assert(mp); assert(mp);
......
...@@ -173,7 +173,6 @@ int ijkmp_get_state(IjkMediaPlayer *mp); ...@@ -173,7 +173,6 @@ int ijkmp_get_state(IjkMediaPlayer *mp);
bool ijkmp_is_playing(IjkMediaPlayer *mp); bool ijkmp_is_playing(IjkMediaPlayer *mp);
long ijkmp_get_current_position(IjkMediaPlayer *mp); long ijkmp_get_current_position(IjkMediaPlayer *mp);
long ijkmp_get_duration(IjkMediaPlayer *mp); long ijkmp_get_duration(IjkMediaPlayer *mp);
void ijkmp_reset(IjkMediaPlayer *mp);
void *ijkmp_set_weak_thiz(IjkMediaPlayer *mp, void *weak_thiz); void *ijkmp_set_weak_thiz(IjkMediaPlayer *mp, void *weak_thiz);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册