mirror of
				https://github.com/gnif/LookingGlass.git
				synced 2025-11-04 06:31:54 +00:00 
			
		
		
		
	[client] all: use nanosleep instead of usleep for better precision
This commit is contained in:
		@@ -305,7 +305,20 @@ static int cursorThread(void * unused)
 | 
			
		||||
          lgSignalEvent(e_frame);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        usleep(params.cursorPollInterval);
 | 
			
		||||
        const struct timespec req =
 | 
			
		||||
        {
 | 
			
		||||
          .tv_sec  = 0,
 | 
			
		||||
          .tv_nsec = params.cursorPollInterval * 1000L
 | 
			
		||||
        };
 | 
			
		||||
 | 
			
		||||
        struct timespec rem;
 | 
			
		||||
        while(nanosleep(&req, &rem) < 0)
 | 
			
		||||
          if (errno != -EINTR)
 | 
			
		||||
          {
 | 
			
		||||
            DEBUG_ERROR("nanosleep failed");
 | 
			
		||||
            break;
 | 
			
		||||
          }
 | 
			
		||||
 | 
			
		||||
        continue;
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
@@ -439,7 +452,20 @@ static int frameThread(void * unused)
 | 
			
		||||
    {
 | 
			
		||||
      if (status == LGMP_ERR_QUEUE_EMPTY)
 | 
			
		||||
      {
 | 
			
		||||
        usleep(params.framePollInterval);
 | 
			
		||||
        const struct timespec req =
 | 
			
		||||
        {
 | 
			
		||||
          .tv_sec  = 0,
 | 
			
		||||
          .tv_nsec = params.framePollInterval * 1000L
 | 
			
		||||
        };
 | 
			
		||||
 | 
			
		||||
        struct timespec rem;
 | 
			
		||||
        while(nanosleep(&req, &rem) < 0)
 | 
			
		||||
          if (errno != -EINTR)
 | 
			
		||||
          {
 | 
			
		||||
            DEBUG_ERROR("nanosleep failed");
 | 
			
		||||
            break;
 | 
			
		||||
          }
 | 
			
		||||
 | 
			
		||||
        continue;
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user