mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Comment out audio device picker
This commit is contained in:
parent
ea1bc2941b
commit
e1fcb3744e
@ -412,6 +412,12 @@
|
||||
],
|
||||
threshold: 0.3,
|
||||
),
|
||||
Inventory(CollectedItem("ShinyGem")): (
|
||||
files: [
|
||||
"voxygen.audio.sfx.weapon.staff_out",
|
||||
],
|
||||
threshold: 0.3,
|
||||
),
|
||||
Inventory(CollectFailed): (
|
||||
files: [
|
||||
"voxygen.audio.sfx.inventory.add_failed",
|
||||
|
BIN
assets/voxygen/audio/sfx/footsteps/wood_step_1.wav
(Stored with Git LFS)
Normal file
BIN
assets/voxygen/audio/sfx/footsteps/wood_step_1.wav
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
assets/voxygen/audio/sfx/footsteps/wood_step_2.wav
(Stored with Git LFS)
Normal file
BIN
assets/voxygen/audio/sfx/footsteps/wood_step_2.wav
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
assets/voxygen/audio/sfx/footsteps/wood_step_3.wav
(Stored with Git LFS)
Normal file
BIN
assets/voxygen/audio/sfx/footsteps/wood_step_3.wav
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
assets/voxygen/audio/sfx/footsteps/wood_step_4.wav
(Stored with Git LFS)
Normal file
BIN
assets/voxygen/audio/sfx/footsteps/wood_step_4.wav
(Stored with Git LFS)
Normal file
Binary file not shown.
@ -14,8 +14,8 @@ use std::time::Duration;
|
||||
use tracing::warn;
|
||||
|
||||
use common::assets;
|
||||
use cpal::traits::{DeviceTrait, HostTrait};
|
||||
use rodio::{source::Source, Decoder, Device, OutputStream, OutputStreamHandle, StreamError};
|
||||
//use cpal::traits::{DeviceTrait, HostTrait};
|
||||
use rodio::{source::Source, Decoder, OutputStream, OutputStreamHandle, StreamError};
|
||||
use vek::*;
|
||||
|
||||
#[derive(Default, Clone)]
|
||||
@ -32,9 +32,9 @@ pub struct Listener {
|
||||
/// Voxygen's [`GlobalState`](../struct.GlobalState.html#structfield.audio) to
|
||||
/// provide access to devices and playback control in-game
|
||||
pub struct AudioFrontend {
|
||||
pub device: String,
|
||||
pub device_list: Vec<String>,
|
||||
pub audio_device: Option<Device>,
|
||||
//pub device: String,
|
||||
//pub device_list: Vec<String>,
|
||||
//pub audio_device: Option<Device>,
|
||||
pub stream: Option<rodio::OutputStream>,
|
||||
audio_stream: Option<rodio::OutputStreamHandle>,
|
||||
sound_cache: SoundCache,
|
||||
@ -49,25 +49,17 @@ pub struct AudioFrontend {
|
||||
|
||||
impl AudioFrontend {
|
||||
/// Construct with given device
|
||||
pub fn new(dev: String, max_sfx_channels: usize) -> Self {
|
||||
let audio_device = get_device_raw(&dev);
|
||||
pub fn new(/* dev: String, */ max_sfx_channels: usize) -> Self {
|
||||
//let audio_device = get_device_raw(&dev);
|
||||
|
||||
let device = match get_default_device() {
|
||||
Some(d) => d,
|
||||
None => "".to_string(),
|
||||
};
|
||||
//let device = match get_default_device() {
|
||||
// Some(d) => d,
|
||||
// None => "".to_string(),
|
||||
//};
|
||||
|
||||
//let (stream, audio_stream) = match get_default_stream() {
|
||||
let (stream, audio_stream) = if get_device_raw(&dev).is_some() {
|
||||
match get_stream(&get_device_raw(&dev).unwrap()) {
|
||||
Ok(s) => (Some(s.0), Some(s.1)),
|
||||
Err(_) => (None, None),
|
||||
}
|
||||
} else {
|
||||
match get_default_stream() {
|
||||
Ok(s) => (Some(s.0), Some(s.1)),
|
||||
Err(_) => (None, None),
|
||||
}
|
||||
let (stream, audio_stream) = match get_default_stream() {
|
||||
Ok(s) => (Some(s.0), Some(s.1)),
|
||||
Err(_) => (None, None),
|
||||
};
|
||||
|
||||
let mut sfx_channels = Vec::with_capacity(max_sfx_channels);
|
||||
@ -78,9 +70,9 @@ impl AudioFrontend {
|
||||
};
|
||||
|
||||
Self {
|
||||
device,
|
||||
device_list: list_devices(),
|
||||
audio_device,
|
||||
//device,
|
||||
//device_list: list_devices(),
|
||||
//audio_device,
|
||||
stream,
|
||||
audio_stream,
|
||||
sound_cache: SoundCache::default(),
|
||||
@ -96,9 +88,9 @@ impl AudioFrontend {
|
||||
/// Construct in `no-audio` mode for debugging
|
||||
pub fn no_audio() -> Self {
|
||||
Self {
|
||||
device: "".to_string(),
|
||||
device_list: Vec::new(),
|
||||
audio_device: None,
|
||||
//device: "".to_string(),
|
||||
//device_list: Vec::new(),
|
||||
//audio_device: None,
|
||||
stream: None,
|
||||
audio_stream: None,
|
||||
sound_cache: SoundCache::default(),
|
||||
@ -352,81 +344,55 @@ impl AudioFrontend {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: figure out how badly this will break things when it is called
|
||||
pub fn set_device(&mut self, name: String) {
|
||||
self.device = name.clone();
|
||||
self.audio_device = get_device_raw(&name);
|
||||
}
|
||||
//// TODO: figure out how badly this will break things when it is called
|
||||
//pub fn set_device(&mut self, name: String) {
|
||||
// self.device = name.clone();
|
||||
// self.audio_device = get_device_raw(&name);
|
||||
//}
|
||||
}
|
||||
|
||||
///// Returns the default audio device.
|
||||
///// Does not return rodio Device struct in case our audio backend changes.
|
||||
//pub fn get_default_device() -> Option<String> {
|
||||
// match rodio::default_output_device() {
|
||||
// match cpal::default_host().default_output_device() {
|
||||
// Some(x) => Some(x.name().ok()?),
|
||||
// None => None,
|
||||
// }
|
||||
//}
|
||||
pub fn get_default_device() -> Option<String> {
|
||||
match cpal::default_host().default_output_device() {
|
||||
Some(x) => Some(x.name().ok()?),
|
||||
None => None,
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns the default stream
|
||||
pub fn get_default_stream() -> Result<(OutputStream, OutputStreamHandle), StreamError> {
|
||||
rodio::OutputStream::try_default()
|
||||
}
|
||||
|
||||
/// Returns a stream on the specified device
|
||||
pub fn get_stream(
|
||||
device: &rodio::Device,
|
||||
) -> Result<(OutputStream, OutputStreamHandle), StreamError> {
|
||||
rodio::OutputStream::try_from_device(device)
|
||||
}
|
||||
|
||||
///// Returns a vec of the audio devices available.
|
||||
///// Does not return rodio Device struct in case our audio backend changes.
|
||||
//pub fn list_devices() -> Vec<String> {
|
||||
// list_devices_raw()
|
||||
// .iter()
|
||||
// .map(|x| x.name().unwrap())
|
||||
// .collect()
|
||||
///// Returns a stream on the specified device
|
||||
//pub fn get_stream(
|
||||
// device: &rodio::Device,
|
||||
//) -> Result<(OutputStream, OutputStreamHandle), StreamError> {
|
||||
// rodio::OutputStream::try_from_device(device)
|
||||
//}
|
||||
|
||||
///// Returns vec of devices
|
||||
//fn list_devices_raw() -> Vec<Device> {
|
||||
// match rodio::output_devices() {
|
||||
// Ok(devices) => {
|
||||
// // Filter out any devices that the name isn't available for
|
||||
// devices.filter(|d| d.name().is_ok()).collect()
|
||||
// },
|
||||
//
|
||||
//fn list_devices_raw() -> Vec<cpal::Device> {
|
||||
// match cpal::default_host().devices() {
|
||||
// Ok(devices) => devices.filter(|d| d.name().is_ok()).collect(),
|
||||
// Err(_) => {
|
||||
// warn!("Failed to enumerate audio output devices, audio will not be
|
||||
// available"); Vec::new()
|
||||
// },
|
||||
// }
|
||||
//}
|
||||
fn list_devices_raw() -> Vec<cpal::Device> {
|
||||
match cpal::default_host().devices() {
|
||||
Ok(devices) => devices.filter(|d| d.name().is_ok()).collect(),
|
||||
Err(_) => {
|
||||
warn!("Failed to enumerate audio output devices, audio will not be available");
|
||||
Vec::new()
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
fn list_devices() -> Vec<String> {
|
||||
list_devices_raw()
|
||||
.iter()
|
||||
.map(|x| x.name().unwrap())
|
||||
.collect()
|
||||
}
|
||||
//
|
||||
fn get_device_raw(device: &str) -> Option<Device> {
|
||||
list_devices_raw()
|
||||
.into_iter()
|
||||
.find(|d| d.name().unwrap() == device)
|
||||
}
|
||||
///// Returns a vec of the audio devices available.
|
||||
///// Does not return rodio Device struct in case our audio backend changes.
|
||||
//fn list_devices() -> Vec<String> {
|
||||
// list_devices_raw()
|
||||
// .iter()
|
||||
// .map(|x| x.name().unwrap())
|
||||
// .collect()
|
||||
//}
|
||||
//
|
||||
//fn get_device_raw(device: &str) -> Option<Device> {
|
||||
// list_devices_raw()
|
||||
// .into_iter()
|
||||
// .find(|d| d.name().unwrap() == device)
|
||||
//}
|
||||
|
@ -174,6 +174,7 @@ pub enum SfxEvent {
|
||||
pub enum SfxInventoryEvent {
|
||||
Collected,
|
||||
CollectedTool(ToolKind),
|
||||
CollectedItem(String),
|
||||
CollectFailed,
|
||||
Consumed(String),
|
||||
Debug,
|
||||
@ -187,12 +188,18 @@ impl From<&InventoryUpdateEvent> for SfxEvent {
|
||||
fn from(value: &InventoryUpdateEvent) -> Self {
|
||||
match value {
|
||||
InventoryUpdateEvent::Collected(item) => {
|
||||
// Handle sound effects for types of collected items, falling back to the
|
||||
// default Collected event
|
||||
// Handle sound effects for types of collected items, falling
|
||||
// back to the default Collected event
|
||||
match &item.kind() {
|
||||
ItemKind::Tool(tool) => {
|
||||
SfxEvent::Inventory(SfxInventoryEvent::CollectedTool(tool.kind.clone()))
|
||||
},
|
||||
ItemKind::Ingredient { kind } => match &kind[..] {
|
||||
"ShinyGem" => {
|
||||
SfxEvent::Inventory(SfxInventoryEvent::CollectedItem(kind.clone()))
|
||||
},
|
||||
_ => SfxEvent::Inventory(SfxInventoryEvent::Collected),
|
||||
},
|
||||
_ => SfxEvent::Inventory(SfxInventoryEvent::Collected),
|
||||
}
|
||||
},
|
||||
|
@ -319,7 +319,7 @@ pub enum Event {
|
||||
AdjustFigureLoDRenderDistance(u32),
|
||||
AdjustMusicVolume(f32),
|
||||
AdjustSfxVolume(f32),
|
||||
ChangeAudioDevice(String),
|
||||
//ChangeAudioDevice(String),
|
||||
ChangeMaxFPS(u32),
|
||||
ChangeFOV(u16),
|
||||
ChangeGamma(f32),
|
||||
@ -2131,9 +2131,9 @@ impl Hud {
|
||||
settings_window::Event::MaximumFPS(max_fps) => {
|
||||
events.push(Event::ChangeMaxFPS(max_fps));
|
||||
},
|
||||
settings_window::Event::ChangeAudioDevice(name) => {
|
||||
events.push(Event::ChangeAudioDevice(name));
|
||||
},
|
||||
//settings_window::Event::ChangeAudioDevice(name) => {
|
||||
// events.push(Event::ChangeAudioDevice(name));
|
||||
//},
|
||||
settings_window::Event::CrosshairType(crosshair_type) => {
|
||||
events.push(Event::CrosshairType(crosshair_type));
|
||||
},
|
||||
|
@ -291,7 +291,7 @@ pub enum Event {
|
||||
ChangeRenderMode(Box<RenderMode>),
|
||||
AdjustMusicVolume(f32),
|
||||
AdjustSfxVolume(f32),
|
||||
ChangeAudioDevice(String),
|
||||
//ChangeAudioDevice(String),
|
||||
MaximumFPS(u32),
|
||||
CrosshairTransp(f32),
|
||||
CrosshairType(CrosshairType),
|
||||
@ -2693,30 +2693,32 @@ impl<'a> Widget for SettingsWindow<'a> {
|
||||
events.push(Event::AdjustSfxVolume(new_val));
|
||||
}
|
||||
|
||||
// Audio Device Selector --------------------------------------------
|
||||
let device = &self.global_state.audio.device;
|
||||
let device_list = &self.global_state.audio.device_list;
|
||||
Text::new(&self.localized_strings.get("hud.settings.audio_device"))
|
||||
.down_from(state.ids.sfx_volume_slider, 10.0)
|
||||
.font_size(self.fonts.cyri.scale(14))
|
||||
.font_id(self.fonts.cyri.conrod_id)
|
||||
.color(TEXT_COLOR)
|
||||
.set(state.ids.audio_device_text, ui);
|
||||
// Audio Device Selector
|
||||
// --------------------------------------------
|
||||
// let device = &self.global_state.audio.device;
|
||||
//let device_list = &self.global_state.audio.device_list;
|
||||
//Text::new(&self.localized_strings.get("hud.settings.audio_device"
|
||||
// )) .down_from(state.ids.sfx_volume_slider, 10.0)
|
||||
// .font_size(self.fonts.cyri.scale(14))
|
||||
// .font_id(self.fonts.cyri.conrod_id)
|
||||
// .color(TEXT_COLOR)
|
||||
// .set(state.ids.audio_device_text, ui);
|
||||
|
||||
// Get which device is currently selected
|
||||
let selected = device_list.iter().position(|x| x.contains(device));
|
||||
//// Get which device is currently selected
|
||||
//let selected = device_list.iter().position(|x|
|
||||
// x.contains(device));
|
||||
|
||||
if let Some(clicked) = DropDownList::new(&device_list, selected)
|
||||
.w_h(400.0, 22.0)
|
||||
.color(MENU_BG)
|
||||
.label_color(TEXT_COLOR)
|
||||
.label_font_id(self.fonts.opensans.conrod_id)
|
||||
.down_from(state.ids.audio_device_text, 10.0)
|
||||
.set(state.ids.audio_device_list, ui)
|
||||
{
|
||||
let new_val = device_list[clicked].clone();
|
||||
events.push(Event::ChangeAudioDevice(new_val));
|
||||
}
|
||||
//if let Some(clicked) = DropDownList::new(&device_list, selected)
|
||||
// .w_h(400.0, 22.0)
|
||||
// .color(MENU_BG)
|
||||
// .label_color(TEXT_COLOR)
|
||||
// .label_font_id(self.fonts.opensans.conrod_id)
|
||||
// .down_from(state.ids.audio_device_text, 10.0)
|
||||
// .set(state.ids.audio_device_list, ui)
|
||||
//{
|
||||
// let new_val = device_list[clicked].clone();
|
||||
// events.push(Event::ChangeAudioDevice(new_val));
|
||||
//}
|
||||
}
|
||||
|
||||
// 5) Languages Tab -----------------------------------
|
||||
|
@ -9,7 +9,7 @@ use veloren_voxygen::{
|
||||
logging,
|
||||
profile::Profile,
|
||||
run,
|
||||
settings::{AudioOutput, Settings},
|
||||
settings::Settings,
|
||||
window::Window,
|
||||
GlobalState,
|
||||
};
|
||||
@ -142,13 +142,14 @@ fn main() {
|
||||
anim::init();
|
||||
|
||||
// Setup audio
|
||||
let mut audio = match settings.audio.output {
|
||||
AudioOutput::Off => None,
|
||||
AudioOutput::Automatic => audio::get_default_device(),
|
||||
AudioOutput::Device(ref dev) => Some(dev.clone()),
|
||||
}
|
||||
.map(|dev| AudioFrontend::new(dev, settings.audio.max_sfx_channels))
|
||||
.unwrap_or_else(AudioFrontend::no_audio);
|
||||
//let mut audio = match settings.audio.output {
|
||||
// AudioOutput::Off => None,
|
||||
// AudioOutput::Automatic => audio::get_default_device(),
|
||||
// AudioOutput::Device(ref dev) => Some(dev.clone()),
|
||||
//}
|
||||
//.map(|dev| AudioFrontend::new(dev, settings.audio.max_sfx_channels))
|
||||
//.unwrap_or_else(AudioFrontend::no_audio);
|
||||
let mut audio = AudioFrontend::new(settings.audio.max_sfx_channels);
|
||||
|
||||
audio.set_music_volume(settings.audio.music_volume);
|
||||
audio.set_sfx_volume(settings.audio.sfx_volume);
|
||||
|
@ -7,7 +7,7 @@ use crate::{
|
||||
menu::char_selection::CharSelectionState,
|
||||
render::Renderer,
|
||||
scene::{camera, CameraMode, Scene, SceneData},
|
||||
settings::{AudioOutput, ControlSettings, Settings},
|
||||
settings::{ControlSettings, Settings},
|
||||
window::{AnalogGameInput, Event, GameInput},
|
||||
Direction, Error, GlobalState, PlayState, PlayStateResult,
|
||||
};
|
||||
@ -901,12 +901,12 @@ impl PlayState for SessionState {
|
||||
global_state.settings.audio.sfx_volume = sfx_volume;
|
||||
global_state.settings.save_to_file_warn();
|
||||
},
|
||||
HudEvent::ChangeAudioDevice(name) => {
|
||||
global_state.audio.set_device(name.clone());
|
||||
//HudEvent::ChangeAudioDevice(name) => {
|
||||
// global_state.audio.set_device(name.clone());
|
||||
|
||||
global_state.settings.audio.output = AudioOutput::Device(name);
|
||||
global_state.settings.save_to_file_warn();
|
||||
},
|
||||
// global_state.settings.audio.output = AudioOutput::Device(name);
|
||||
// global_state.settings.save_to_file_warn();
|
||||
//},
|
||||
HudEvent::ChangeMaxFPS(fps) => {
|
||||
global_state.settings.graphics.max_fps = fps;
|
||||
global_state.settings.save_to_file_warn();
|
||||
|
Loading…
Reference in New Issue
Block a user