Skip to content

Selecting a non-default Output is pretty much locked down #1

Description

@sandreas

Hey @yara-blue ,

as requested, here is some "early feedback". I'd like to select a non-default Output by the device.id from cpal. Unfortunately, the Output struct encapsulates cpal::Device and with it the ability to select a device by id:

Something like this is not possible for Output:

    let device = if let Some(device) = opt.device.clone() {
        let id = &device.parse().expect("failed to parse device id");
        host.device_by_id(id)
    } else {
        host.default_output_device()
    }.expect("failed to find output device");

   // fields are private
   let output = Output {
          default: false,
          inner: device
  };

When enumerating devices the id is not accessible either:

use rodio::speakers::{SpeakersBuilder, available_outputs};

// List all available output devices
let outputs = available_outputs()?;
for (i, output) in outputs.iter().enumerate() {
  // no access to output.device_id either.
    println!("output {}: {}", i, output);
}

// Use a specific device (e.g., the second one)
let speakers = SpeakersBuilder::new()
    .device(outputs[1].clone())?
    .default_config()?
    .open_mixer()?;

So saving and restoring a selected device by a unique device identifier is not possible despite I overlooked something important.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions