wip: rustfmt, clippy fixes for the Android target
This commit is contained in:
1 parent
545002a96e
commit
14d0d81fdf
8 files changed
+46
-17
No files matched your search
@@ -144,7 +144,7 @@ jobs:
|
||||
run: cargo install cargo-ndk --locked --version 4.1.2
|
||||
- name: clippy (Android target, deny warnings)
|
||||
run: |
|
||||
cargo ndk -t arm64-v8a --platform 29 clippy --locked -p tsc-android --no-deps -- -D warnings
|
||||
cargo ndk -t arm64-v8a --platform 29 clippy --locked -p tsc-android -p tsc-ui --no-deps -- -D warnings
|
||||
cargo ndk -t arm64-v8a --platform 29 clippy --locked -p tsc-media --no-default-features --no-deps -- -D warnings
|
||||
- name: Debug APK
|
||||
working-directory: android
|
||||
|
||||
@@ -111,10 +111,10 @@ fn watch_voice(host: &'static EngineHost) {
|
||||
loop {
|
||||
match events.recv().await {
|
||||
Ok(event) => {
|
||||
if let Some(text) = with_foreground(|f| f.update(&event)) {
|
||||
if let Err(e) = bridge::set_voice_notification(text.as_deref()) {
|
||||
warn!("voice service: {e}");
|
||||
}
|
||||
if let Some(text) = with_foreground(|f| f.update(&event))
|
||||
&& let Err(e) = bridge::set_voice_notification(text.as_deref())
|
||||
{
|
||||
warn!("voice service: {e}");
|
||||
}
|
||||
}
|
||||
Err(tokio::sync::broadcast::error::RecvError::Lagged(_)) => continue,
|
||||
|
||||
@@ -39,8 +39,13 @@ pub fn context<'local>(env: &mut Env<'local>) -> Result<JObject<'local>> {
|
||||
let class = BRIDGE
|
||||
.get()
|
||||
.ok_or_else(|| Error::ClassNotFound { name: "io.github.faumaray.tsc.Bridge".into() })?;
|
||||
env.call_static_method(class, jni_str!("context"), jni_sig!(() -> android.content.Context), &[])?
|
||||
.l()
|
||||
env.call_static_method(
|
||||
class,
|
||||
jni_str!("context"),
|
||||
jni_sig!(() -> android.content.Context),
|
||||
&[],
|
||||
)?
|
||||
.l()
|
||||
}
|
||||
|
||||
/// Ask for the microphone and notification permissions if not granted yet.
|
||||
|
||||
@@ -159,7 +159,13 @@ pub fn wants_frames() -> bool {
|
||||
}
|
||||
|
||||
/// A captured RGBA frame. Returns `false` once nobody wants frames.
|
||||
pub fn on_frame(pixels: Vec<u8>, width: u32, height: u32, stride: usize, timestamp_ns: i64) -> bool {
|
||||
pub fn on_frame(
|
||||
pixels: Vec<u8>,
|
||||
width: u32,
|
||||
height: u32,
|
||||
stride: usize,
|
||||
timestamp_ns: i64,
|
||||
) -> bool {
|
||||
with_state(|s| {
|
||||
let timestamp = since(&mut s.first_frame_ns, timestamp_ns);
|
||||
let Some(frames) = &s.frames else {
|
||||
|
||||
@@ -91,7 +91,10 @@ mod tests {
|
||||
capabilities: Capabilities::default(),
|
||||
};
|
||||
assert_eq!(fg.update(&info), Some(Some("Connecting to Home".into())));
|
||||
assert_eq!(fg.update(&voice(1, VoiceState::Connected)), Some(Some("In voice on Home".into())));
|
||||
assert_eq!(
|
||||
fg.update(&voice(1, VoiceState::Connected)),
|
||||
Some(Some("In voice on Home".into()))
|
||||
);
|
||||
assert_eq!(fg.update(&voice(1, VoiceState::Connected)), None, "no change");
|
||||
assert_eq!(
|
||||
fg.update(&voice(2, VoiceState::Connecting)),
|
||||
|
||||
@@ -22,13 +22,13 @@ use crate::frame::{AudioBuffer, VideoFrame};
|
||||
use crate::queue::FrameReceiver;
|
||||
use crate::{Error, Result};
|
||||
|
||||
pub mod external;
|
||||
#[cfg(all(target_os = "linux", feature = "pipewire"))]
|
||||
pub mod pipewire_audio;
|
||||
#[cfg(all(target_os = "linux", feature = "pipewire"))]
|
||||
pub mod portal;
|
||||
#[cfg(all(target_os = "linux", feature = "pipewire"))]
|
||||
mod pw;
|
||||
pub mod external;
|
||||
pub mod synthetic;
|
||||
#[cfg(windows)]
|
||||
pub mod windows;
|
||||
|
||||
@@ -130,7 +130,11 @@ impl ImageLayout {
|
||||
pub fn buffer_len(&self) -> usize {
|
||||
let (cw, ch) = chroma_size(self.width, self.height);
|
||||
let end = |p: &PlaneLayout, w: usize, h: usize| {
|
||||
if w == 0 || h == 0 { 0 } else { p.offset + (h - 1) * p.row_inc + (w - 1) * p.col_inc + 1 }
|
||||
if w == 0 || h == 0 {
|
||||
0
|
||||
} else {
|
||||
p.offset + (h - 1) * p.row_inc + (w - 1) * p.col_inc + 1
|
||||
}
|
||||
};
|
||||
let (w, h) = (self.width as usize, self.height as usize);
|
||||
end(&self.y, w, h).max(end(&self.u, cw, ch)).max(end(&self.v, cw, ch))
|
||||
@@ -163,7 +167,11 @@ impl ImageLayout {
|
||||
let uv = PlaneLayout { col_inc: 1, ..self.u };
|
||||
FrameData::Nv12 { y, uv: read_plane(buf, &uv, cw * 2, ch) }
|
||||
} else {
|
||||
FrameData::I420 { y, u: read_plane(buf, &self.u, cw, ch), v: read_plane(buf, &self.v, cw, ch) }
|
||||
FrameData::I420 {
|
||||
y,
|
||||
u: read_plane(buf, &self.u, cw, ch),
|
||||
v: read_plane(buf, &self.v, cw, ch),
|
||||
}
|
||||
};
|
||||
let frame = VideoFrame {
|
||||
width: self.width,
|
||||
@@ -303,9 +311,8 @@ mod tests {
|
||||
#[test]
|
||||
fn crop_and_size_checks() {
|
||||
// A decoder buffer of 8x6 (stride 8) showing 6x4.
|
||||
let layout = ImageLayout::from_color_format(COLOR_FORMAT_I420, 8, 6, 8, 6)
|
||||
.unwrap()
|
||||
.cropped(6, 4);
|
||||
let layout =
|
||||
ImageLayout::from_color_format(COLOR_FORMAT_I420, 8, 6, 8, 6).unwrap().cropped(6, 4);
|
||||
assert_eq!((layout.width, layout.height), (6, 4));
|
||||
assert_eq!(layout.u.offset, 48);
|
||||
assert!(ImageLayout::from_color_format(COLOR_FORMAT_FLEXIBLE, 8, 6, 8, 6).is_none());
|
||||
|
||||
@@ -25,7 +25,9 @@ use ndk::media::media_format::MediaFormat;
|
||||
use tracing::{debug, info};
|
||||
|
||||
use super::hw::HardwareEncoderFactory;
|
||||
use super::image_layout::{COLOR_FORMAT_FLEXIBLE, COLOR_FORMAT_I420, COLOR_FORMAT_NV12, ImageLayout};
|
||||
use super::image_layout::{
|
||||
COLOR_FORMAT_FLEXIBLE, COLOR_FORMAT_I420, COLOR_FORMAT_NV12, ImageLayout,
|
||||
};
|
||||
use super::{Codec, EncodedFrame, EncoderBackend, EncoderConfig, VideoDecoder, VideoEncoder};
|
||||
use crate::frame::{FrameData, VideoFrame};
|
||||
use crate::{Error, Result, convert};
|
||||
@@ -178,7 +180,13 @@ struct EncoderSession {
|
||||
}
|
||||
|
||||
impl MediaCodecEncoder {
|
||||
fn format(&self, width: u32, height: u32, color_format: i32, profile: Option<i32>) -> MediaFormat {
|
||||
fn format(
|
||||
&self,
|
||||
width: u32,
|
||||
height: u32,
|
||||
color_format: i32,
|
||||
profile: Option<i32>,
|
||||
) -> MediaFormat {
|
||||
let mut format = MediaFormat::new();
|
||||
format.set_str("mime", mime(self.codec));
|
||||
format.set_i32("width", width as i32);
|
||||
|
||||
Reference in new issue
Block a user