mirror of
https://github.com/librespot-org/librespot.git
synced 2024-12-18 17:11:53 +00:00
Renamed variable
This commit is contained in:
parent
b4f9ae31e2
commit
3e9aee1d46
1 changed files with 23 additions and 23 deletions
46
src/main.rs
46
src/main.rs
|
@ -128,7 +128,7 @@ struct Setup {
|
||||||
emit_sink_events: bool,
|
emit_sink_events: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn setup(args: &[String]) -> Setup {
|
fn get_setup(args: &[String]) -> Setup {
|
||||||
let mut opts = getopts::Options::new();
|
let mut opts = getopts::Options::new();
|
||||||
opts.optopt(
|
opts.optopt(
|
||||||
"c",
|
"c",
|
||||||
|
@ -553,7 +553,7 @@ async fn main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
let args: Vec<String> = std::env::args().collect();
|
let args: Vec<String> = std::env::args().collect();
|
||||||
let setupp = setup(&args);
|
let setup = get_setup(&args);
|
||||||
|
|
||||||
let mut last_credentials = None;
|
let mut last_credentials = None;
|
||||||
let mut spirc: Option<Spirc> = None;
|
let mut spirc: Option<Spirc> = None;
|
||||||
|
@ -563,23 +563,23 @@ async fn main() {
|
||||||
let mut discovery = None;
|
let mut discovery = None;
|
||||||
let mut connecting: Pin<Box<dyn future::FusedFuture<Output = _>>> = Box::pin(future::pending());
|
let mut connecting: Pin<Box<dyn future::FusedFuture<Output = _>>> = Box::pin(future::pending());
|
||||||
|
|
||||||
if setupp.enable_discovery {
|
if setup.enable_discovery {
|
||||||
let config = setupp.connect_config.clone();
|
let config = setup.connect_config.clone();
|
||||||
let device_id = setupp.session_config.device_id.clone();
|
let device_id = setup.session_config.device_id.clone();
|
||||||
|
|
||||||
discovery = Some(
|
discovery = Some(
|
||||||
librespot_connect::discovery::discovery(config, device_id, setupp.zeroconf_port)
|
librespot_connect::discovery::discovery(config, device_id, setup.zeroconf_port)
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(credentials) = setupp.credentials {
|
if let Some(credentials) = setup.credentials {
|
||||||
last_credentials = Some(credentials.clone());
|
last_credentials = Some(credentials.clone());
|
||||||
connecting = Box::pin(
|
connecting = Box::pin(
|
||||||
Session::connect(
|
Session::connect(
|
||||||
setupp.session_config.clone(),
|
setup.session_config.clone(),
|
||||||
credentials,
|
credentials,
|
||||||
setupp.cache.clone(),
|
setup.cache.clone(),
|
||||||
)
|
)
|
||||||
.fuse(),
|
.fuse(),
|
||||||
);
|
);
|
||||||
|
@ -602,9 +602,9 @@ async fn main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
connecting = Box::pin(Session::connect(
|
connecting = Box::pin(Session::connect(
|
||||||
setupp.session_config.clone(),
|
setup.session_config.clone(),
|
||||||
credentials,
|
credentials,
|
||||||
setupp.cache.clone(),
|
setup.cache.clone(),
|
||||||
).fuse());
|
).fuse());
|
||||||
},
|
},
|
||||||
None => {
|
None => {
|
||||||
|
@ -615,22 +615,22 @@ async fn main() {
|
||||||
},
|
},
|
||||||
session = &mut connecting, if !connecting.is_terminated() => match session {
|
session = &mut connecting, if !connecting.is_terminated() => match session {
|
||||||
Ok(session) => {
|
Ok(session) => {
|
||||||
let mixer_config = setupp.mixer_config.clone();
|
let mixer_config = setup.mixer_config.clone();
|
||||||
let mixer = (setupp.mixer)(Some(mixer_config));
|
let mixer = (setup.mixer)(Some(mixer_config));
|
||||||
let player_config = setupp.player_config.clone();
|
let player_config = setup.player_config.clone();
|
||||||
let connect_config = setupp.connect_config.clone();
|
let connect_config = setup.connect_config.clone();
|
||||||
|
|
||||||
let audio_filter = mixer.get_audio_filter();
|
let audio_filter = mixer.get_audio_filter();
|
||||||
let format = setupp.format;
|
let format = setup.format;
|
||||||
let backend = setupp.backend;
|
let backend = setup.backend;
|
||||||
let device = setupp.device.clone();
|
let device = setup.device.clone();
|
||||||
let (player, event_channel) =
|
let (player, event_channel) =
|
||||||
Player::new(player_config, session.clone(), audio_filter, move || {
|
Player::new(player_config, session.clone(), audio_filter, move || {
|
||||||
(backend)(device, format)
|
(backend)(device, format)
|
||||||
});
|
});
|
||||||
|
|
||||||
if setupp.emit_sink_events {
|
if setup.emit_sink_events {
|
||||||
if let Some(player_event_program) = setupp.player_event_program.clone() {
|
if let Some(player_event_program) = setup.player_event_program.clone() {
|
||||||
player.set_sink_event_callback(Some(Box::new(move |sink_status| {
|
player.set_sink_event_callback(Some(Box::new(move |sink_status| {
|
||||||
match emit_sink_event(sink_status, &player_event_program) {
|
match emit_sink_event(sink_status, &player_event_program) {
|
||||||
Ok(e) if e.success() => (),
|
Ok(e) if e.success() => (),
|
||||||
|
@ -676,16 +676,16 @@ async fn main() {
|
||||||
auto_connect_times.push(Instant::now());
|
auto_connect_times.push(Instant::now());
|
||||||
|
|
||||||
connecting = Box::pin(Session::connect(
|
connecting = Box::pin(Session::connect(
|
||||||
setupp.session_config.clone(),
|
setup.session_config.clone(),
|
||||||
credentials,
|
credentials,
|
||||||
setupp.cache.clone(),
|
setup.cache.clone(),
|
||||||
).fuse());
|
).fuse());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
event = async { player_event_channel.as_mut().unwrap().recv().await }, if player_event_channel.is_some() => match event {
|
event = async { player_event_channel.as_mut().unwrap().recv().await }, if player_event_channel.is_some() => match event {
|
||||||
Some(event) => {
|
Some(event) => {
|
||||||
if let Some(program) = &setupp.player_event_program {
|
if let Some(program) = &setup.player_event_program {
|
||||||
if let Some(child) = run_program_on_events(event, program) {
|
if let Some(child) = run_program_on_events(event, program) {
|
||||||
let mut child = child.expect("program failed to start");
|
let mut child = child.expect("program failed to start");
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue