Testing audio
This commit is contained in:
@@ -0,0 +1,25 @@
|
|||||||
|
use cpal::traits::{DeviceTrait, HostTrait};
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
|
#[serde(rename_all = "camelCase")]
|
||||||
|
pub struct AudioDevice {
|
||||||
|
pub name: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
pub fn list_input_devices() -> Result<Vec<AudioDevice>, String> {
|
||||||
|
let host = cpal::default_host();
|
||||||
|
|
||||||
|
let devices = host
|
||||||
|
.input_devices()
|
||||||
|
.map_err(|e| format!("Failed to enumerate input devices: {e}"))?;
|
||||||
|
|
||||||
|
Ok(devices
|
||||||
|
.filter_map(|d| {
|
||||||
|
Some(AudioDevice {
|
||||||
|
name: d.description().ok()?.name().to_string(),
|
||||||
|
})
|
||||||
|
})
|
||||||
|
.collect())
|
||||||
|
}
|
||||||
@@ -1,2 +1,3 @@
|
|||||||
pub mod accounts;
|
pub mod accounts;
|
||||||
|
pub mod audio;
|
||||||
pub mod server_list;
|
pub mod server_list;
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ pub fn run() {
|
|||||||
commands::server_list::get_server_list,
|
commands::server_list::get_server_list,
|
||||||
commands::accounts::save_accounts,
|
commands::accounts::save_accounts,
|
||||||
commands::accounts::get_accounts,
|
commands::accounts::get_accounts,
|
||||||
|
commands::audio::list_input_devices,
|
||||||
])
|
])
|
||||||
.run(tauri::generate_context!())
|
.run(tauri::generate_context!())
|
||||||
.expect("error while running tauri application");
|
.expect("error while running tauri application");
|
||||||
|
|||||||
Reference in New Issue
Block a user