mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2026-09-12 10:34:24 +08:00
feat: UAC USB microphone passthrough
- Add UAC1 gadget function (ConfigFS) with optimized endpoint config - Browser mic capture with Opus encoding via WebCodecs AudioEncoder - WebSocket audio transport (Opus 64kbps, 100x bandwidth reduction vs raw PCM) - aplay subprocess for reliable PCM playback to USB gadget - Settings toggle + ActionBar mic button (hidden when UAC disabled) - Dynamic PCM device resolution (/proc/asound) - c_chmask=0 + req_number=4 fixes DWC3 composite isochronous endpoint issue
This commit is contained in:
36
src/web/handlers/config/uac.rs
Normal file
36
src/web/handlers/config/uac.rs
Normal file
@@ -0,0 +1,36 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use axum::{extract::State, Json};
|
||||
|
||||
use crate::error::Result;
|
||||
use crate::otg::service::UacConfig;
|
||||
use crate::state::AppState;
|
||||
|
||||
use super::apply::try_apply_lock;
|
||||
|
||||
pub async fn get_uac_config(State(state): State<Arc<AppState>>) -> Json<UacConfig> {
|
||||
Json(state.config.get().uac.clone())
|
||||
}
|
||||
|
||||
pub async fn update_uac_config(
|
||||
State(state): State<Arc<AppState>>,
|
||||
Json(req): Json<UacConfig>,
|
||||
) -> Result<Json<UacConfig>> {
|
||||
req.validate()?;
|
||||
let _guard = try_apply_lock(&state.config_apply_locks.otg, "uac")?;
|
||||
|
||||
let old_config = (*state.config.get()).clone();
|
||||
let mut new_config = old_config.clone();
|
||||
new_config.uac = req;
|
||||
|
||||
state
|
||||
.config
|
||||
.update(|config| {
|
||||
config.uac = new_config.uac.clone();
|
||||
})
|
||||
.await?;
|
||||
|
||||
super::apply::apply_usb_config(&state, &old_config, &new_config).await?;
|
||||
|
||||
Ok(Json(state.config.get().uac.clone()))
|
||||
}
|
||||
Reference in New Issue
Block a user