Skip to main content

set_output_device

Function set_output_device 

Source
pub fn set_output_device(
    device_service: State<'_, DeviceService>,
    audio_service: State<'_, Mutex<AudioService>>,
    device_id: String,
) -> Result<(), String>
Expand description

Switches the active output device.

Looks up the device by ID in the DeviceService, then delegates to AudioService::set_output_device to perform the hot-swap without interrupting playback longer than necessary.

§Arguments

  • device_service - The shared DeviceService state for device lookup.
  • audio_service - The shared AudioService state for performing the switch.
  • device_id - The ID of the output device to activate.

§Returns

Returns Ok(()) on success, or Err(String) if the device ID is not found or the service state cannot be locked.