Displaying 1 result from an estimated 1 matches for "audiobuf_granulepos".
2010 Aug 15
2
Beginner Hurdles
...bes how Vorbis does
timing, so I came up with the following code, where I calculate my own
timing based on the current byte position in the audio stream:
*audioStartTime = audiobuf_time; // return the buffer time from the
last call, which was the start of the buffer
audiobuf_time = ((double) audiobuf_granulepos)/vi.rate;
audiobuf_granulepos += (*numBytes/2)/2; // a granule is a left/right
stereo pair, so the [size in bytes divided by 16 bits (2 bytes)
divided by stereo (2 chans)]
*audioStaleTime = audiobuf_time;
As far as I can tell, this results in proper syncing but I could be
off a frame and not...