Throw error in v4l2 when time out
This commit is contained in:
		
							parent
							
								
									d4343b574a
								
							
						
					
					
						commit
						d80d506360
					
				@ -41,6 +41,9 @@ namespace uvc {
 | 
			
		||||
    LOG(severity) << str << " error " << errno << ", " << strerror(errno); \
 | 
			
		||||
  } while (0)
 | 
			
		||||
 | 
			
		||||
#define NO_DATA_MAX_COUNT 200
 | 
			
		||||
 | 
			
		||||
int no_data_count = 0;
 | 
			
		||||
/*
 | 
			
		||||
class device_error : public std::exception {
 | 
			
		||||
 public:
 | 
			
		||||
@ -194,6 +197,7 @@ struct device {
 | 
			
		||||
  ~device() {
 | 
			
		||||
    VLOG(2) << __func__;
 | 
			
		||||
    stop_streaming();
 | 
			
		||||
    no_data_count = 0;
 | 
			
		||||
    if (fd != -1 && close(fd) < 0) {
 | 
			
		||||
      LOG_ERROR(WARNING, "close");
 | 
			
		||||
    }
 | 
			
		||||
@ -386,6 +390,14 @@ struct device {
 | 
			
		||||
            throw_error("VIDIOC_QBUF");
 | 
			
		||||
        });
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      no_data_count = 0;
 | 
			
		||||
    } else {
 | 
			
		||||
      no_data_count++;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (no_data_count > NO_DATA_MAX_COUNT) {
 | 
			
		||||
      throw_error("v4l2 get stream time out!");
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user