Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,11 @@ jobs:
distribution: temurin
java-version: 21
- uses: android-actions/setup-android@v3
- run: yes | sdkmanager --licenses >/dev/null && sdkmanager "platforms;android-37" "build-tools;36.0.0" "ndk;27.2.12479018"
with:
# The default also asks for the legacy `tools` package, which the
# SDK repository no longer serves.
packages: platform-tools
- run: yes | sdkmanager --licenses >/dev/null && sdkmanager "platforms;android-37.1" "build-tools;36.0.0" "ndk;27.2.12479018"
- run: cargo install cargo-ndk typeshare-cli
- run: scripts/gen-bindings.sh
- run: scripts/build-android-core.sh release
Expand Down
4 changes: 1 addition & 3 deletions crates/hocket-core/src/audio/dsp/biquad.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,9 +208,7 @@ impl Biquad {
}

pub fn reset(&mut self) {
for s in &mut self.state {
*s = [0.0; 2];
}
self.state.fill([0.0; 2]);
}

/// Process one sample of one channel.
Expand Down
4 changes: 1 addition & 3 deletions crates/hocket-core/src/audio/dsp/loudness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,7 @@ impl LoudnessMeter {
.map(|(sum, w)| w * sum / n)
.sum();
self.sub_blocks.push(power);
for c in &mut self.current {
*c = 0.0;
}
self.current.fill(0.0);
self.current_frames = 0;
}

Expand Down
12 changes: 3 additions & 9 deletions crates/hocket-core/src/audio/dsp/normalise.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,9 @@ impl Normaliser {

pub fn reset(&mut self) {
self.filter.reset();
for c in &mut self.current {
*c = 0.0;
}
self.current.fill(0.0);
self.current_frames = 0;
for r in &mut self.ring {
*r = 0.0;
}
self.ring.fill(0.0);
self.ring_pos = 0;
self.ring_filled = 0;
self.gain_db = 0.0;
Expand All @@ -135,9 +131,7 @@ impl Normaliser {
self.ring[self.ring_pos] = power;
self.ring_pos = (self.ring_pos + 1) % self.ring.len();
self.ring_filled = (self.ring_filled + 1).min(self.ring.len());
for c in &mut self.current {
*c = 0.0;
}
self.current.fill(0.0);
self.current_frames = 0;
if let Some(l) = self.short_term_lufs() {
if l > GATE_LUFS {
Expand Down
29 changes: 25 additions & 4 deletions crates/hocket-core/src/audio/native/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1460,14 +1460,35 @@ mod tests {
rig.wait_for(Duration::from_secs(5), |r| {
matches!(r, BackendReport::Ended { .. })
});
// Discarded pre-buffers never report.
// Discarded pre-buffers never report. The load may finish before the
// discard is even sent, so only reports after it count: a seek
// reports its position synchronously, right after the engine has
// handled the discard.
rig.backend
.load(rig.wav("a.wav", 48_000, 48_000 * 2), None, 0, false)
.unwrap();
rig.wait_for(Duration::from_secs(5), |r| {
matches!(r, BackendReport::Paused { .. })
});
let b = rig.wav("b.wav", 48_000, 48_000);
rig.take();
rig.backend.pre_buffer(b, 0).unwrap();
rig.backend.discard_pre_buffer().unwrap();
rig.backend.seek(1234).unwrap();
let is_barrier = |r: &BackendReport| {
matches!(
r,
BackendReport::Position {
position_ms: 1234,
..
}
)
};
rig.wait_for(Duration::from_secs(5), is_barrier);
thread::sleep(Duration::from_millis(300));
assert!(!rig
.reports
.lock()
let reports = rig.reports.lock();
let barrier = reports.iter().position(is_barrier).unwrap();
assert!(!reports[barrier..]
.iter()
.any(|r| matches!(r, BackendReport::PreBufferReady { key } if key == "b.wav")));
}
Expand Down
4 changes: 2 additions & 2 deletions crates/hocket-core/src/connect/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1101,7 +1101,7 @@ impl Engine {
self.lan_blocklist.clear();
self.lan_strikes.clear();
// Inbound members were admitted under the old key.
let inbound: Vec<PeerId> = self.inbound.drain(..).collect();
let inbound: Vec<PeerId> = std::mem::take(&mut self.inbound);
for p in inbound {
self.out.push(Output::WireOut {
peer: p.clone(),
Expand Down Expand Up @@ -2681,7 +2681,7 @@ impl Engine {
self.last_ping_at = 0.0;
self.send_ping();
// Say goodbye to anyone we were serving: they'll re-elect.
let inbound: Vec<PeerId> = self.inbound.drain(..).collect();
let inbound: Vec<PeerId> = std::mem::take(&mut self.inbound);
for p in inbound {
self.out.push(Output::WireOut {
peer: p.clone(),
Expand Down
2 changes: 1 addition & 1 deletion crates/hocket-core/src/core/queries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ impl Actor {
let Some(api) = self.api() else {
// Offline: the artist's most played tracks from the mirror.
let mut tracks = self.db.artist_tracks(&id).unwrap_or_default();
tracks.sort_by(|a, b| b.play_count.cmp(&a.play_count));
tracks.sort_by_key(|t| std::cmp::Reverse(t.play_count));
tracks.truncate(count as usize);
let _ = reply.send(QueryResult::TrackList(tracks));
return;
Expand Down
Loading