Skip to content

Commit 69571f9

Browse files
authored
Merge pull request #100 from tsirysndr/fix/high-cpu-usage
fix(playback): reduce high CPU usage
2 parents e4bed39 + 5a12bd6 commit 69571f9

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

graphql/src/schema/playback.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ impl PlaybackQuery {
5656
}
5757

5858
async fn get_player_state(&self, ctx: &Context<'_>) -> PlayerState {
59-
let _tracklist = ctx.data::<Arc<Mutex<Tracklist>>>().unwrap();
59+
let _tracklist = ctx.data::<Arc<std::sync::Mutex<Tracklist>>>().unwrap();
6060
todo!()
6161
}
6262
}

playback/src/player.rs

+2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ use std::{
1414
sync::Arc,
1515
task::{Context, Poll},
1616
thread,
17+
time::Duration,
1718
};
1819
use symphonia::core::{errors::Error, io::MediaSourceStream, probe::Hint};
1920
use tokio::{
@@ -335,6 +336,7 @@ impl Future for PlayerInternal {
335336
}
336337
};
337338
}
339+
thread::sleep(Duration::from_millis(10));
338340
}
339341
}
340342
}

src/main.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use std::{
55
net::SocketAddr,
66
sync::{self, mpsc, Arc},
77
thread,
8-
time::Instant,
8+
time::{Duration, Instant},
99
};
1010

1111
use app::{ActiveBlock, App, CurrentlyPlaybackContext, RouteId};
@@ -499,6 +499,7 @@ async fn listen_for_player_events(app: &Arc<Mutex<App>>) {
499499
_ => {}
500500
}
501501
}
502+
thread::sleep(Duration::from_millis(10));
502503
});
503504
}
504505
}

0 commit comments

Comments
 (0)