mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-22 19:00:01 +08:00
优化代码
This commit is contained in:
parent
45c5f1ec4c
commit
1896b1d768
@ -210,17 +210,18 @@ public:
|
|||||||
* @param frame 帧
|
* @param frame 帧
|
||||||
*/
|
*/
|
||||||
void inputFrame(const Frame::Ptr &frame) override{
|
void inputFrame(const Frame::Ptr &frame) override{
|
||||||
//_delegates_read能确保是单线程操作的
|
|
||||||
for(auto &pr : _delegates_read){
|
|
||||||
pr.second->inputFrame(frame);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(_need_update){
|
if(_need_update){
|
||||||
//发现代理列表发生变化了,这里同步一次
|
//发现代理列表发生变化了,这里同步一次
|
||||||
lock_guard<mutex> lck(_mtx);
|
lock_guard<mutex> lck(_mtx);
|
||||||
_delegates_read = _delegates_write;
|
_delegates_read = _delegates_write;
|
||||||
_need_update = false;
|
_need_update = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//_delegates_read能确保是单线程操作的
|
||||||
|
for(auto &pr : _delegates_read){
|
||||||
|
pr.second->inputFrame(frame);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
mutex _mtx;
|
mutex _mtx;
|
||||||
|
Loading…
Reference in New Issue
Block a user