improve seek algorithmic complexity O(n) -> O(log(n))

This commit is contained in:
2026-02-27 07:05:23 -08:00
parent c3cca22839
commit 197f840246
7 changed files with 73 additions and 34 deletions

View File

@@ -53,16 +53,16 @@ impl<'a> PlayerWorker<'a>{
Instruction::SessionControl(SessionControlInstruction::SetPaused(paused))=>{
self.playback_head.set_paused(ins.time,paused);
},
Instruction::SessionControl(SessionControlInstruction::Restart)=>{
self.playback_head.set_time(ins.time,PlaybackTime::ZERO);
Instruction::SessionControl(SessionControlInstruction::Restart)=>if let Some(bot)=&self.bot{
self.playback_head.set_time(bot,ins.time,PlaybackTime::ZERO);
},
Instruction::SessionControl(SessionControlInstruction::SkipForward)=>{
Instruction::SessionControl(SessionControlInstruction::SkipForward)=>if let Some(bot)=&self.bot{
let head_time=self.playback_head.time(ins.time);
self.playback_head.set_time(ins.time,head_time+PlaybackTime::from_secs(2));
self.playback_head.set_time(bot,ins.time,head_time+PlaybackTime::from_secs(2));
},
Instruction::SessionControl(SessionControlInstruction::SkipBack)=>{
Instruction::SessionControl(SessionControlInstruction::SkipBack)=>if let Some(bot)=&self.bot{
let head_time=self.playback_head.time(ins.time);
self.playback_head.set_time(ins.time,head_time-PlaybackTime::from_secs(2));
self.playback_head.set_time(bot,ins.time,head_time-PlaybackTime::from_secs(2));
},
Instruction::SessionControl(SessionControlInstruction::DecreaseTimescale)=>{
self.playback_speed=self.playback_speed.saturating_sub(1).max(-27);