Esempio n. 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;
    }
Esempio n. 2
0
 pipeline::~pipeline()
 {
     try
     {
         unsafe_stop();
     }
     catch (...) {}
 }
Esempio n. 3
0
 void pipeline::stop()
 {
     std::lock_guard<std::mutex> lock(_mtx);
     if (!_active_profile)
     {
         throw librealsense::wrong_api_call_sequence_exception("stop() cannnot be called before start()");
     }
     unsafe_stop();
 }
Esempio n. 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 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);
    }