ref: 2862e2eaf4d655d6aaa358f8dc76068f4f49a1fb
parent: 14da0dd29b05dc4772f124bc386d576d0f323ff6
author: Timothy B. Terriberry <[email protected]>
date: Mon May 6 16:07:48 EDT 2013
Fix seeking near the start of saved live streams. If a stream starts with a non-zero granpos, we would subtract 80 ms from the target time, and then report failure when the best page we could find (the first page in the link) had a granpos larger than that. This worked for normal streams because the subtraction would fail (granpos can't wrap past -1) and we checked for that.
--- a/src/opusfile.c
+++ b/src/opusfile.c
@@ -2194,7 +2194,8 @@
/*We discard the first 80 ms of data after a seek, so seek back that much
farther.
If we can't, simply seek to the beginning of the link.*/
- if(OP_UNLIKELY(op_granpos_add(&_target_gp,_target_gp,-80*48)<0)){
+ if(OP_UNLIKELY(op_granpos_add(&_target_gp,_target_gp,-80*48)<0)
+ ||OP_UNLIKELY(op_granpos_cmp(_target_gp,pcm_start)<0)){
_target_gp=pcm_start;
}
/*Special case seeking to the start of the link.*/