Adding backend discovery
Some checks failed
ci/woodpecker/push/pre_commit_test Pipeline was successful
ci/woodpecker/push/code_tests Pipeline failed

Signed-off-by: Nikolai Rodionov <allanger@badhouseplants.net>
This commit is contained in:
2025-11-30 22:41:48 +01:00
parent 85aac6c8aa
commit 2385d3901f

View File

@@ -1,7 +1,7 @@
mod audio_engine; mod audio_engine;
use clap::Parser; use clap::Parser;
use lib::termix::audio_backend::{FILE_DESCRIPTOR_SET, audio_backend_server::{AudioBackend, AudioBackendServer}}; use lib::termix::audio_backend::{Backend, BackendList, FILE_DESCRIPTOR_SET, audio_backend_server::{AudioBackend, AudioBackendServer}};
use tonic::{transport::Server, Request, Response, Status}; use tonic::{Request, Response, Result, Status, transport::Server};
use log::{debug, error, log_enabled, info, Level}; use log::{debug, error, log_enabled, info, Level};
use tonic_reflection::server::v1::{ReflectionService, ServerReflection}; use tonic_reflection::server::v1::{ReflectionService, ServerReflection};
/// Simple program to greet a person /// Simple program to greet a person
@@ -17,7 +17,7 @@ pub struct TermixAudioBackend {}
#[tonic::async_trait] #[tonic::async_trait]
impl AudioBackend for TermixAudioBackend { impl AudioBackend for TermixAudioBackend {
async fn start_client(&self,request:tonic::Request<()>,) -> std::result::Result<tonic::Response<()>,tonic::Status> { async fn start_client(&self,requesa:tonic::Request<()>,) -> std::result::Result<tonic::Response<()>,tonic::Status> {
info!("starting the audio backend client"); info!("starting the audio backend client");
todo!() todo!()
} }
@@ -26,12 +26,23 @@ impl AudioBackend for TermixAudioBackend {
info!("initializing the connection to the audio backend"); info!("initializing the connection to the audio backend");
todo!() todo!()
} }
async fn get_available_backends(&self, request:tonic::Request<()>) -> Result<Response<BackendList>, tonic::Status> {
info!("discovering available backends");
let mut response = BackendList::default();
if cfg!(feature = "jack") {
response.backends.push(Backend{ name: "jack".to_string() });
} }
Ok(Response::new(response))
}
}
#[tokio::main] #[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> { async fn main() -> Result<(), Box<dyn std::error::Error>> {
env_logger::init(); env_logger::init();
let args = Args::parse(); let args = Args::parse();
// start_grpc_server()
info!("starting the grpc server on port {}", args.grpc_port); info!("starting the grpc server on port {}", args.grpc_port);
let reflections = tonic_reflection::server::Builder::configure().register_encoded_file_descriptor_set(FILE_DESCRIPTOR_SET).build_v1().unwrap(); let reflections = tonic_reflection::server::Builder::configure().register_encoded_file_descriptor_set(FILE_DESCRIPTOR_SET).build_v1().unwrap();
let addr = "[::1]:50051".parse()?; let addr = "[::1]:50051".parse()?;