torchaudio/csrc/ffmpeg/streamer.cpp
// Similar to `process_packet()`, but in case process_packet returns EAGAIN,
// it keeps retrying until timeout happens,
//
// timeout and backoff is given in millisecond
Similar to `process_packet()`, but in case process_packet returns EAGAIN,
it keeps retrying until timeout happens.

timeout and backoff is given in millisecond
Similar to ` process_packet () ` but in case process_packet returns EAGAIN it keeps retrying until timeout happens . timeout and backoff is given in millisecond
int Streamer::process_packet_block(double timeout, double backoff) {
  auto dead_line = [&]() {
    if (timeout < 0) {
      return std::chrono::time_point<std::chrono::steady_clock>::max();
    }
    auto timeout_ = static_cast<int64_t>(1000 * timeout);
    return std::chrono::steady_clock::now() +
        std::chrono::microseconds{timeout_};
  }();
  std::chrono::microseconds sleep{static_cast<int64_t>(1000 * backoff)};
  while (true) {
    int ret = process_packet();
    if (ret != AVERROR(EAGAIN)) {
      return ret;
    }
    if (dead_line < std::chrono::steady_clock::now()) {
      return ret;
    }
    std::this_thread::sleep_for(sleep);
  }
}
int Streamer :: process_packet_block ( double timeout , double backoff ) { auto dead_line = [ & ] ( ) { if ( timeout < 0 ) { return std :: chrono :: time_point < std :: chrono :: steady_clock > :: max ( ) ; } auto timeout_ = static_cast < int64_t > ( 1000 * timeout ) ; return std :: chrono :: steady_clock :: now ( ) + std :: chrono :: microseconds { timeout_ } ; } ( ) ; std :: chrono :: microseconds sleep { static_cast < int64_t > ( 1000 * backoff ) } ; while ( true ) { int ret = process_packet ( ) ; if ( ret != AVERROR ( EAGAIN ) ) { return ret ; } if ( dead_line < std :: chrono :: steady_clock :: now ( ) ) { return ret ; } std :: this_thread :: sleep_for ( sleep ) ; } }
Similar to `process_packet()`, but in case process_packet returns EAGAIN,
it keeps retrying until timeout happens,
Similar to ` process_packet () ` but in case process_packet returns EAGAIN it keeps retrying until timeout happens
// If timeout < 0, then it repeats forever // FYI: ffmpeg sleeps 10 milli seconds if the read happens in a separate // thread // https://github.com/FFmpeg/FFmpeg/blob/b0f8dbb0cacc45a19f18c043afc706d7d26bef74/fftools/ffmpeg.c#L3952 // https://github.com/FFmpeg/FFmpeg/blob/b0f8dbb0cacc45a19f18c043afc706d7d26bef74/fftools/ffmpeg.c#L4542 //