Skip to content

Commit

Permalink
Attempt to fix macos type infer
Browse files Browse the repository at this point in the history
  • Loading branch information
Meister1593 committed Jul 3, 2024
1 parent 4612699 commit 83e27b5
Showing 1 changed file with 41 additions and 44 deletions.
85 changes: 41 additions & 44 deletions alvr/server/src/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,7 @@ fn connection_pipeline(
)?;

let mut video_sender = stream_socket.request_stream(VIDEO);
let game_audio_sender: alvr_sockets::StreamSender<_> = stream_socket.request_stream(AUDIO);
let game_audio_sender = stream_socket.request_stream(AUDIO);
let mut microphone_receiver = stream_socket.subscribe_to_stream(AUDIO, MAX_UNREAD_PACKETS);
let mut tracking_receiver =
stream_socket.subscribe_to_stream::<Tracking>(TRACKING, MAX_UNREAD_PACKETS);
Expand Down Expand Up @@ -709,51 +709,48 @@ fn connection_pipeline(
}

#[cfg(windows)]
{
let device = match AudioDevice::new_output(config.device.as_ref()) {
Ok(data) => data,
Err(e) => {
warn!("New audio device failed: {e:?}");
thread::sleep(RETRY_CONNECT_MIN_INTERVAL);
continue;
}
};
if let Ok(id) = alvr_audio::get_windows_device_id(&device) {
ctx.events_queue
.lock()
.push_back(ServerCoreEvent::SetOpenvrProperty {
device_id: *alvr_common::HEAD_ID,
prop: alvr_session::OpenvrProperty::AudioDefaultPlaybackDeviceId(
id,
),
})
} else {
let device = match AudioDevice::new_output(config.device.as_ref()) {
Ok(data) => data,
Err(e) => {
warn!("New audio device failed: {e:?}");
thread::sleep(RETRY_CONNECT_MIN_INTERVAL);
continue;
};
if let Err(e) = alvr_audio::record_audio_blocking(
Arc::new({
let client_hostname = client_hostname.clone();
move || is_streaming(&client_hostname)
}),
game_audio_sender.clone(),
&device,
2,
config.mute_when_streaming,
) {
error!("Audio record error: {e:?}");
}
if let Ok(id) = AudioDevice::new_output(None)
.and_then(|d| alvr_audio::get_windows_device_id(&d))
{
ctx.events_queue
.lock()
.push_back(ServerCoreEvent::SetOpenvrProperty {
device_id: *alvr_common::HEAD_ID,
prop: alvr_session::OpenvrProperty::AudioDefaultPlaybackDeviceId(
id,
),
})
}
};
#[cfg(windows)]
if let Ok(id) = alvr_audio::get_windows_device_id(&device) {
ctx.events_queue
.lock()
.push_back(ServerCoreEvent::SetOpenvrProperty {
device_id: *alvr_common::HEAD_ID,
prop: alvr_session::OpenvrProperty::AudioDefaultPlaybackDeviceId(id),
})
} else {
continue;
};
#[cfg(windows)]
if let Err(e) = alvr_audio::record_audio_blocking(
Arc::new({
let client_hostname = client_hostname.clone();
move || is_streaming(&client_hostname)
}),
game_audio_sender.clone(),
&device,
2,
config.mute_when_streaming,
) {
error!("Audio record error: {e:?}");
}
#[cfg(windows)]
if let Ok(id) = AudioDevice::new_output(None)
.and_then(|d| alvr_audio::get_windows_device_id(&d))
{
ctx.events_queue
.lock()
.push_back(ServerCoreEvent::SetOpenvrProperty {
device_id: *alvr_common::HEAD_ID,
prop: alvr_session::OpenvrProperty::AudioDefaultPlaybackDeviceId(id),
})
}
}
})
Expand Down

0 comments on commit 83e27b5

Please sign in to comment.