title: Clock_nanosleep() does not yet support CLOCK_MONOTONIC_RAW. How to deal with this?
body: <p>Currently <code>clock_nanosleep</code> with CLOCK_MONOTONIC_RAW on Debian Jessie returns EOPNOTSUPP.</p>
  
  <p>How to work around the issue and compensate for possible NTP adjustments which might get applied to CLOCK_MONOTONIC in the timer loop?</p>
  
  <p>Is <code>clock_nanosleep</code> itself also affected by NTP adjustments? If adjustments happen while sleeping, will <code>clock_nanosleep</code> sleep longer that expected?</p>
  
  <p>And should I be worried at all about possible CLOCK_MONOTONIC NTP adjustments in my specific case? What would be the largest possible "time jump" applied by NTP to CLOCK_MONOTONIC, considering that my code will be running on a system without real-time clock and it might lose Internet connection from time to time?</p>
  
  <p>The long story. I'm using a simple loop to emulate audio file playback and I need to maintain consistent playback position. </p>
  
  <p><code>clock_nanosleep</code> with TIMER_ABSTIME flag seems to be doing the job fine, but I'm not sure if CLOCK_MONOTONIC is enough to avoid noticeable jumps in playback position.</p>
  
  <p>Here is the code I'm using:</p>
  
  <pre><code>clock_gettime(CLOCK_MONOTONIC, &amp;deadline);
  
  // run until asked to stop
  while(!need_quit(stop_mutex_signal)) {
  
      // do stuff ...
  
      // add time ms to previous deadline
      deadline.tv_nsec += device-&gt;periodTime * NANOSECONDS_PER_MILLISEC;
  
      // normalize the time to account for the second boundary
      if(deadline.tv_nsec &gt;= NANOSECONDS_PER_SEC) {
          deadline.tv_nsec -= NANOSECONDS_PER_SEC;
          deadline.tv_sec++;
      }
  
      if(clock_nanosleep(CLOCK_MONOTONIC, TIMER_ABSTIME, &amp;deadline, NULL) != 0)
      {
          // something happened - error or exit signal, cannot continue
          return;
      }
  }
  </code></pre>
  
  <p>I'm curious, why support for CLOCK_MONOTONIC_RAW in <code>clock_nanosleep</code> is not yet implemented? Does it mean that CLOCK_MONOTONIC is enough for most cases, even for audio/video synchronization?</p>