示例#1
0
    bool pipeline::try_wait_for_frames(frame_holder* frame, unsigned int timeout_ms)
    {
        std::lock_guard<std::mutex> lock(_mtx);
        if (!_active_profile)
        {
            throw librealsense::wrong_api_call_sequence_exception("try_wait_for_frames cannot be called before start()");
        }

        if (_pipeline_process->dequeue(frame, timeout_ms))
        {
            return true;
        }

        //hub returns true even if device already reconnected
        if (!_hub.is_connected(*_active_profile->get_device()))
        {
            try
            {
                auto prev_conf = _prev_conf;
                unsafe_stop();
                unsafe_start(prev_conf);
                return _pipeline_process->dequeue(frame, timeout_ms);
            }
            catch (const std::exception& e)
            {
                return false;
            }
        }
        return false;
    }
示例#2
0
 std::shared_ptr<pipeline_profile> pipeline::start(std::shared_ptr<pipeline_config> conf)
 {
     std::lock_guard<std::mutex> lock(_mtx);
     if (_active_profile)
     {
         throw librealsense::wrong_api_call_sequence_exception("start() cannnot be called before stop()");
     }
     unsafe_start(conf);
     return unsafe_get_active_profile();
 }
示例#3
0
 std::shared_ptr<pipeline_profile> pipeline::start_with_record(std::shared_ptr<pipeline_config> conf, const std::string& file)
 {
     std::lock_guard<std::mutex> lock(_mtx);
     if (_active_profile)
     {
         throw librealsense::wrong_api_call_sequence_exception("start() cannnot be called before stop()");
     }
     conf->enable_record_to_file(file);
     unsafe_start(conf);
     return unsafe_get_active_profile();
 }
示例#4
0
    frame_holder pipeline::wait_for_frames(unsigned int timeout_ms)
    {
        std::lock_guard<std::mutex> lock(_mtx);
        if (!_active_profile)
        {
            throw librealsense::wrong_api_call_sequence_exception("wait_for_frames cannnot be called before start()");
        }

        frame_holder f;
        if (_queue->dequeue(&f, timeout_ms))
        {
            return f;
        }
        
        try
        {
            unsafe_start(_prev_conf);
            return frame_holder();
        }
        catch(const std::exception&)
        {
            throw std::runtime_error(to_string() << "Frame didn't arrived within " << timeout_ms);
        }
    }
示例#5
0
    frame_holder pipeline::wait_for_frames(unsigned int timeout_ms)
    {
        std::lock_guard<std::mutex> lock(_mtx);
        if (!_active_profile)
        {
            throw librealsense::wrong_api_call_sequence_exception("wait_for_frames cannot be called before start()");
        }

        frame_holder f;
        if (_pipeline_process->dequeue(&f, timeout_ms))
        {
            return f;
        }

        //hub returns true even if device already reconnected
        if (!_hub.is_connected(*_active_profile->get_device()))
        {
            try
            {
                auto prev_conf = _prev_conf;
                unsafe_stop();
                unsafe_start(prev_conf);

                if (_pipeline_process->dequeue(&f, timeout_ms))
                {
                    return f;
                }

            }
            catch (const std::exception& e)
            {
                throw std::runtime_error(to_string() << "Device disconnected. Failed to recconect: "<<e.what() << timeout_ms);
            }
        }
        throw std::runtime_error(to_string() << "Frame didn't arrived within " << timeout_ms);
    }