leon 1 mesiac pred
rodič
commit
b8fdadbec3

+ 1 - 1
src/nodes/base/base.hpp

@@ -82,7 +82,7 @@ protected:
     std::mutex mutex_;
     std::shared_ptr<std::condition_variable> cond_var_ =
         std::make_shared<std::condition_variable>();
-    bool running_ = false;
+    std::atomic<bool> running_ = false;
     std::unordered_map<std::string, std::shared_ptr<SharedQueue<std::shared_ptr<meta::MetaData>>>> input_buffers_;
     std::unordered_map<std::string, std::shared_ptr<SharedQueue<std::shared_ptr<meta::MetaData>>>> output_buffers_;
 };

+ 1 - 1
src/nodes/draw/drawNode.hpp

@@ -11,7 +11,7 @@ class DrawNode : public BaseNode
 public:
     DrawNode() = delete;
     DrawNode(const std::string& name) : BaseNode(name, NODE_TYPE::DES_NODE) {}
-    virtual ~DrawNode() { running_ = false; };
+    virtual ~DrawNode() { };
 
     void work() override;
 };

+ 1 - 1
src/nodes/infer/inferNode.hpp

@@ -13,7 +13,7 @@ class InferNode : public BaseNode
 public:
     InferNode() = delete;
     InferNode(const std::string& name) : BaseNode(name, NODE_TYPE::MID_NODE) {}
-    virtual ~InferNode()  { running_ = false; };
+    virtual ~InferNode()  { };
 
     void set_model_instance(std::shared_ptr<Infer> model)
     {

+ 7 - 2
src/nodes/stream/streamNode.cpp

@@ -63,8 +63,13 @@ void StreamNode::work_gpu()
 	printf("packet_size = %d\n", packet_size);
 
     unsigned int frame_index = 0;
-    do{
+    while(running_)
+    {
         demuxer_->demux(&packet_data, &packet_size, &pts);
+        if (packet_size <= 0 || !running_)
+        {
+            break;
+        }
         int ndecoded_frame = decoder_->decode(packet_data, packet_size, pts);
         for(int i = 0; i < ndecoded_frame; ++i){
 
@@ -94,7 +99,7 @@ void StreamNode::work_gpu()
                 // printf("Node %s push data to %s\n", name_.c_str(), output_buffer.first.c_str());
             }
         }
-    }while(packet_size > 0 && running_);
+    };
 	printf("C++ Demo: %d frames\n", frame_index);
 }