Fix "build_input/output_stream_inner" methods
This commit is contained in:
parent
f65d0e65bc
commit
1021141d16
|
@ -626,7 +626,7 @@ impl Device {
|
||||||
pub(crate) fn build_input_stream_inner(
|
pub(crate) fn build_input_stream_inner(
|
||||||
&self,
|
&self,
|
||||||
format: &Format,
|
format: &Format,
|
||||||
) -> Result<Stream, BuildStreamError>
|
) -> Result<StreamInner, BuildStreamError>
|
||||||
{
|
{
|
||||||
unsafe {
|
unsafe {
|
||||||
// Making sure that COM is initialized.
|
// Making sure that COM is initialized.
|
||||||
|
@ -754,19 +754,13 @@ impl Device {
|
||||||
&mut *capture_client
|
&mut *capture_client
|
||||||
};
|
};
|
||||||
|
|
||||||
let new_stream_id = StreamId(self.next_stream_id.fetch_add(1, Ordering::Relaxed));
|
|
||||||
if new_stream_id.0 == usize::max_value() {
|
|
||||||
return Err(BuildStreamError::StreamIdOverflow);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Once we built the `StreamInner`, we add a command that will be picked up by the
|
// Once we built the `StreamInner`, we add a command that will be picked up by the
|
||||||
// `run()` method and added to the `RunContext`.
|
// `run()` method and added to the `RunContext`.
|
||||||
{
|
|
||||||
let client_flow = AudioClientFlow::Capture {
|
let client_flow = AudioClientFlow::Capture {
|
||||||
capture_client,
|
capture_client,
|
||||||
};
|
};
|
||||||
let inner = StreamInner {
|
|
||||||
id: new_stream_id.clone(),
|
Ok( StreamInner {
|
||||||
audio_client,
|
audio_client,
|
||||||
client_flow,
|
client_flow,
|
||||||
event,
|
event,
|
||||||
|
@ -774,19 +768,14 @@ impl Device {
|
||||||
max_frames_in_buffer,
|
max_frames_in_buffer,
|
||||||
bytes_per_frame: waveformatex.nBlockAlign,
|
bytes_per_frame: waveformatex.nBlockAlign,
|
||||||
sample_format: format.data_type,
|
sample_format: format.data_type,
|
||||||
};
|
})
|
||||||
|
|
||||||
self.push_command(Command::NewStream(inner));
|
|
||||||
};
|
|
||||||
|
|
||||||
Ok(new_stream_id)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn build_output_stream_inner(
|
pub(crate) fn build_output_stream_inner(
|
||||||
&self,
|
&self,
|
||||||
format: &Format,
|
format: &Format,
|
||||||
) -> Result<Stream, BuildStreamError>
|
) -> Result<StreamInner, BuildStreamError>
|
||||||
{
|
{
|
||||||
unsafe {
|
unsafe {
|
||||||
// Making sure that COM is initialized.
|
// Making sure that COM is initialized.
|
||||||
|
@ -915,19 +904,13 @@ impl Device {
|
||||||
&mut *render_client
|
&mut *render_client
|
||||||
};
|
};
|
||||||
|
|
||||||
let new_stream_id = StreamId(self.next_stream_id.fetch_add(1, Ordering::Relaxed));
|
|
||||||
if new_stream_id.0 == usize::max_value() {
|
|
||||||
return Err(BuildStreamError::StreamIdOverflow);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Once we built the `StreamInner`, we add a command that will be picked up by the
|
// Once we built the `StreamInner`, we add a command that will be picked up by the
|
||||||
// `run()` method and added to the `RunContext`.
|
// `run()` method and added to the `RunContext`.
|
||||||
{
|
|
||||||
let client_flow = AudioClientFlow::Render {
|
let client_flow = AudioClientFlow::Render {
|
||||||
render_client,
|
render_client,
|
||||||
};
|
};
|
||||||
let inner = StreamInner {
|
|
||||||
id: new_stream_id.clone(),
|
Ok(StreamInner {
|
||||||
audio_client,
|
audio_client,
|
||||||
client_flow,
|
client_flow,
|
||||||
event,
|
event,
|
||||||
|
@ -935,12 +918,7 @@ impl Device {
|
||||||
max_frames_in_buffer,
|
max_frames_in_buffer,
|
||||||
bytes_per_frame: waveformatex.nBlockAlign,
|
bytes_per_frame: waveformatex.nBlockAlign,
|
||||||
sample_format: format.data_type,
|
sample_format: format.data_type,
|
||||||
};
|
})
|
||||||
|
|
||||||
self.push_command(Command::NewStream(inner));
|
|
||||||
};
|
|
||||||
|
|
||||||
Ok(new_stream_id)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue