Browse Source

movies: set length of unseekable ogg/Opus streams upon reaching EOF

This is one of a series of commits that will make it possible to loop compressed ogg and Opus streams.
rdb 6 years ago
parent
commit
2f2354550d
2 changed files with 6 additions and 0 deletions
  1. 3 0
      panda/src/movies/opusAudioCursor.cxx
  2. 3 0
      panda/src/movies/vorbisAudioCursor.cxx

+ 3 - 0
panda/src/movies/opusAudioCursor.cxx

@@ -240,6 +240,9 @@ read_samples(int n, int16_t *data) {
       data += read_samples * _audio_channels;
       _samples_read += read_samples;
     } else {
+      if (read_samples == 0 && _length == 1.0E10) {
+        _length = op_pcm_tell(_op) / 48000.0;
+      }
       break;
     }
 

+ 3 - 0
panda/src/movies/vorbisAudioCursor.cxx

@@ -158,6 +158,9 @@ read_samples(int n, int16_t *data) {
       buffer += read_bytes;
       length -= read_bytes;
     } else {
+      if (read_bytes == 0 && _length == 1.0E10) {
+        _length = ov_time_tell(&_ov);
+      }
       break;
     }