mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-12-02 00:12:33 +08:00
解决死锁问题
This commit is contained in:
parent
6cc56a758a
commit
f384f5e025
@ -253,8 +253,9 @@ MediaSource::Ptr MediaSource::find(const string &schema, const string &vhost_tmp
|
|||||||
vhost = DEFAULT_VHOST;
|
vhost = DEFAULT_VHOST;
|
||||||
}
|
}
|
||||||
|
|
||||||
lock_guard<recursive_mutex> lock(g_mtxMediaSrc);
|
|
||||||
MediaSource::Ptr ret;
|
MediaSource::Ptr ret;
|
||||||
|
{
|
||||||
|
lock_guard<recursive_mutex> lock(g_mtxMediaSrc);
|
||||||
//查找某一媒体源,找到后返回
|
//查找某一媒体源,找到后返回
|
||||||
searchMedia(g_mapMediaSrc, schema, vhost, app, id, [&](SchemaVhostAppStreamMap::iterator &it0,
|
searchMedia(g_mapMediaSrc, schema, vhost, app, id, [&](SchemaVhostAppStreamMap::iterator &it0,
|
||||||
VhostAppStreamMap::iterator &it1,
|
VhostAppStreamMap::iterator &it1,
|
||||||
@ -269,6 +270,8 @@ MediaSource::Ptr MediaSource::find(const string &schema, const string &vhost_tmp
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
if(!ret && bMake){
|
if(!ret && bMake){
|
||||||
//未查找媒体源,则创建一个
|
//未查找媒体源,则创建一个
|
||||||
ret = MP4Reader::onMakeMediaSource(schema, vhost,app,id);
|
ret = MP4Reader::onMakeMediaSource(schema, vhost,app,id);
|
||||||
@ -288,10 +291,14 @@ void MediaSource::regist() {
|
|||||||
InfoL << _strSchema << " " << _strVhost << " " << _strApp << " " << _strId;
|
InfoL << _strSchema << " " << _strVhost << " " << _strApp << " " << _strId;
|
||||||
NoticeCenter::Instance().emitEvent(Broadcast::kBroadcastMediaChanged, true, *this);
|
NoticeCenter::Instance().emitEvent(Broadcast::kBroadcastMediaChanged, true, *this);
|
||||||
}
|
}
|
||||||
bool MediaSource::unregist() {
|
|
||||||
//反注册该源
|
//反注册该源
|
||||||
|
bool MediaSource::unregist() {
|
||||||
|
bool ret;
|
||||||
|
{
|
||||||
lock_guard<recursive_mutex> lock(g_mtxMediaSrc);
|
lock_guard<recursive_mutex> lock(g_mtxMediaSrc);
|
||||||
return searchMedia(g_mapMediaSrc, _strSchema, _strVhost, _strApp, _strId,[&](SchemaVhostAppStreamMap::iterator &it0,
|
ret = searchMedia(g_mapMediaSrc, _strSchema, _strVhost, _strApp, _strId,
|
||||||
|
[&](SchemaVhostAppStreamMap::iterator &it0,
|
||||||
VhostAppStreamMap::iterator &it1,
|
VhostAppStreamMap::iterator &it1,
|
||||||
AppStreamMap::iterator &it2,
|
AppStreamMap::iterator &it2,
|
||||||
StreamMap::iterator &it3) {
|
StreamMap::iterator &it3) {
|
||||||
@ -302,15 +309,16 @@ bool MediaSource::unregist() {
|
|||||||
}
|
}
|
||||||
it2->second.erase(it3);
|
it2->second.erase(it3);
|
||||||
eraseIfEmpty(g_mapMediaSrc, it0, it1, it2);
|
eraseIfEmpty(g_mapMediaSrc, it0, it1, it2);
|
||||||
unregisted();
|
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
void MediaSource::unregisted(){
|
|
||||||
|
if(ret){
|
||||||
InfoL << "" << _strSchema << " " << _strVhost << " " << _strApp << " " << _strId;
|
InfoL << "" << _strSchema << " " << _strVhost << " " << _strApp << " " << _strId;
|
||||||
NoticeCenter::Instance().emitEvent(Broadcast::kBroadcastMediaChanged, false, *this);
|
NoticeCenter::Instance().emitEvent(Broadcast::kBroadcastMediaChanged, false, *this);
|
||||||
}
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
/////////////////////////////////////MediaInfo//////////////////////////////////////
|
/////////////////////////////////////MediaInfo//////////////////////////////////////
|
||||||
|
|
||||||
|
@ -151,7 +151,6 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
void regist() ;
|
void regist() ;
|
||||||
bool unregist() ;
|
bool unregist() ;
|
||||||
void unregisted();
|
|
||||||
private:
|
private:
|
||||||
string _strSchema;
|
string _strSchema;
|
||||||
string _strVhost;
|
string _strVhost;
|
||||||
|
Loading…
Reference in New Issue
Block a user