确保mk_player_release后不再触发回调

This commit is contained in:
xiongziliang 2020-04-26 19:09:38 +08:00
parent ff7cf5f4d3
commit 3651609a5f

View File

@ -45,6 +45,13 @@ public:
}); });
} }
void unset(){
lock_guard<recursive_mutex> lck(_mtx);
_on_play = nullptr;
_on_shutdown = nullptr;
_on_data = nullptr;
}
void onEvent(bool is_shutdown, const SockException &ex){ void onEvent(bool is_shutdown, const SockException &ex){
lock_guard<recursive_mutex> lck(_mtx); lock_guard<recursive_mutex> lck(_mtx);
if(is_shutdown){ if(is_shutdown){
@ -125,6 +132,7 @@ API_EXPORT mk_player API_CALL mk_player_create() {
API_EXPORT void API_CALL mk_player_release(mk_player ctx) { API_EXPORT void API_CALL mk_player_release(mk_player ctx) {
assert(ctx); assert(ctx);
MediaPlayerForC::Ptr *obj = (MediaPlayerForC::Ptr *)ctx; MediaPlayerForC::Ptr *obj = (MediaPlayerForC::Ptr *)ctx;
(*obj)->unset();
delete obj; delete obj;
} }