Skip to content

Conversation

@yara-blue
Copy link
Member

Its basically the same as the microphone builder. It will replace the OutputStream. In the future we'll add more abstractions on top. Until its done it lives under an experimental flag.

Names are subject to change too, Speakers is probably not ideal but it conveys the meaning better then OutputStream. I'm thinking of having a Source -> Stream -> Sink terminolgy where a Sink could be the audio card, the network or a file (the wavwriter).

Its basically the same as the microphone builder. It will replace the
OutputStream. In the future we'll add more abstractions on top. Until
its done it lives under an experimental flag.

Names are subject to change too, Speakers is probably not ideal but it
conveys the meaning better then OutputStream. I'm thinking of having a
Source -> Stream -> Sink terminolgy where a Sink could be the audio
card, the network or a file (the wavwriter).
Copy link
Member

@roderickvd roderickvd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In RustAudio/cpal#956 I was also toying around with the idea of a StreamConfigBuilder - let me know how we can align those efforts!

/// Adds a new source to the end of the queue.
#[inline]
pub fn append<T>(&self, source: T)
pub fn append<T>(&self, source: T) -> usize
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the rationale for changing this to return a usize? By analogy, Vec::append doesn't return a value either.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh haha, I needed this for some tests in zed. I'll throw it out. Good catch!

#[derive(Debug, thiserror::Error, Clone)]
pub enum Error {
/// No output device is available on the system.
#[error("There is no input device")]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/input/output

//!
//! # fn main() -> Result<(), Box<dyn std::error::Error>> {
//! // List all available input devices
//! let inputs = available_outputs()?;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/inputs/outputs/g

.supported_output_configs()
.map_err(|source| Error::OutputConfigs {
source,
device_name: device.name().unwrap_or_else(|_| "unknown".to_string()),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Device::name has been deprecated in favor of Device::description().name() in cpal v0.17. You could also choose to pretty-print Device::description.

},
) => {
let n_samples = n_frames * self.channel_count.get() as u32;
(*min_samples..*max_samples).contains(&n_samples)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For cpal v0.18 I have the idea to have something like a cpal::BufferSize::Range { min, max } that you can request. Open to API ideas: RustAudio/cpal#956

@roderickvd
Copy link
Member

As for naming, here are some suggestions:

  • OutputBuilder, InputBuilder, Output, Input
  • PlaybackBuilder, CaptureBuilder, Playback, Capture

If we want to use Source → Stream → Sink terminology (pretty accurate actually) then to disambiguate we should rename the existing Sink to something like MixerQueue, AudioQueue, or QueuedOutput.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants