mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2026-09-12 18:44:25 +08:00
feat: 完善 OTG UAC 音频支持
This commit is contained in:
@@ -2,11 +2,11 @@ use std::sync::Arc;
|
||||
|
||||
use axum::{extract::State, Json};
|
||||
|
||||
use crate::config::UacConfig;
|
||||
use crate::error::Result;
|
||||
use crate::otg::service::UacConfig;
|
||||
use crate::state::AppState;
|
||||
|
||||
use super::apply::try_apply_lock;
|
||||
use super::usb_update::update_usb_config;
|
||||
|
||||
pub async fn get_uac_config(State(state): State<Arc<AppState>>) -> Json<UacConfig> {
|
||||
Json(state.config.get().uac.clone())
|
||||
@@ -14,23 +14,13 @@ pub async fn get_uac_config(State(state): State<Arc<AppState>>) -> Json<UacConfi
|
||||
|
||||
pub async fn update_uac_config(
|
||||
State(state): State<Arc<AppState>>,
|
||||
Json(req): Json<UacConfig>,
|
||||
Json(request): 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()))
|
||||
request.validate()?;
|
||||
let config = update_usb_config(&state, move |staged| {
|
||||
staged.uac = request;
|
||||
Ok(None)
|
||||
})
|
||||
.await?;
|
||||
Ok(Json(config.uac))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user