mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-25 12:11:36 +08:00
修复FrameDispatcher可能导致死锁的问题
This commit is contained in:
parent
6eb36ec883
commit
f6cba98a8e
@ -1 +1 @@
|
|||||||
Subproject commit 7af363c4015a63fa48079af2cb08da2ceb1f69e6
|
Subproject commit c7e301ec82fa6feb117e824ff522acd8a740cc9e
|
@ -292,7 +292,7 @@ public:
|
|||||||
* 添加代理
|
* 添加代理
|
||||||
*/
|
*/
|
||||||
FrameWriterInterface* addDelegate(FrameWriterInterface::Ptr delegate) {
|
FrameWriterInterface* addDelegate(FrameWriterInterface::Ptr delegate) {
|
||||||
std::lock_guard<std::mutex> lck(_mtx);
|
std::lock_guard<std::recursive_mutex> lck(_mtx);
|
||||||
return _delegates.emplace(delegate.get(), std::move(delegate)).first->second.get();
|
return _delegates.emplace(delegate.get(), std::move(delegate)).first->second.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -302,7 +302,7 @@ public:
|
|||||||
* 删除代理
|
* 删除代理
|
||||||
*/
|
*/
|
||||||
void delDelegate(FrameWriterInterface *ptr) {
|
void delDelegate(FrameWriterInterface *ptr) {
|
||||||
std::lock_guard<std::mutex> lck(_mtx);
|
std::lock_guard<std::recursive_mutex> lck(_mtx);
|
||||||
_delegates.erase(ptr);
|
_delegates.erase(ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -310,7 +310,7 @@ public:
|
|||||||
* 写入帧并派发
|
* 写入帧并派发
|
||||||
*/
|
*/
|
||||||
bool inputFrame(const Frame::Ptr &frame) override {
|
bool inputFrame(const Frame::Ptr &frame) override {
|
||||||
std::lock_guard<std::mutex> lck(_mtx);
|
std::lock_guard<std::recursive_mutex> lck(_mtx);
|
||||||
++_frames;
|
++_frames;
|
||||||
if (frame->keyFrame() && frame->getTrackType() == TrackVideo) {
|
if (frame->keyFrame() && frame->getTrackType() == TrackVideo) {
|
||||||
++_video_key_frames;
|
++_video_key_frames;
|
||||||
@ -328,12 +328,12 @@ public:
|
|||||||
* 返回代理个数
|
* 返回代理个数
|
||||||
*/
|
*/
|
||||||
size_t size() const {
|
size_t size() const {
|
||||||
std::lock_guard<std::mutex> lck(_mtx);
|
std::lock_guard<std::recursive_mutex> lck(_mtx);
|
||||||
return _delegates.size();
|
return _delegates.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
void clear() {
|
void clear() {
|
||||||
std::lock_guard<std::mutex> lck(_mtx);
|
std::lock_guard<std::recursive_mutex> lck(_mtx);
|
||||||
_delegates.clear();
|
_delegates.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -341,7 +341,7 @@ public:
|
|||||||
* 获取累计关键帧数
|
* 获取累计关键帧数
|
||||||
*/
|
*/
|
||||||
uint64_t getVideoKeyFrames() const {
|
uint64_t getVideoKeyFrames() const {
|
||||||
std::lock_guard<std::mutex> lck(_mtx);
|
std::lock_guard<std::recursive_mutex> lck(_mtx);
|
||||||
return _video_key_frames;
|
return _video_key_frames;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -349,14 +349,14 @@ public:
|
|||||||
* 获取帧数
|
* 获取帧数
|
||||||
*/
|
*/
|
||||||
uint64_t getFrames() const {
|
uint64_t getFrames() const {
|
||||||
std::lock_guard<std::mutex> lck(_mtx);
|
std::lock_guard<std::recursive_mutex> lck(_mtx);
|
||||||
return _frames;
|
return _frames;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
uint64_t _frames = 0;
|
uint64_t _frames = 0;
|
||||||
uint64_t _video_key_frames = 0;
|
uint64_t _video_key_frames = 0;
|
||||||
mutable std::mutex _mtx;
|
mutable std::recursive_mutex _mtx;
|
||||||
std::map<void *, FrameWriterInterface::Ptr> _delegates;
|
std::map<void *, FrameWriterInterface::Ptr> _delegates;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user