core API: move run_program to player.rs

This commit is contained in:
awiouy 2018-02-10 17:18:54 +01:00
parent 496a802248
commit a35edc6af4
2 changed files with 14 additions and 14 deletions

View file

@ -4,7 +4,6 @@ use num_integer::Integer;
use rand::{Rng, Rand};
use std::mem;
use std::ops::{Mul, Rem, Shr};
use std::process::Command;
mod int128;
mod spotify_id;
@ -16,16 +15,6 @@ pub fn rand_vec<G: Rng, R: Rand>(rng: &mut G, size: usize) -> Vec<R> {
rng.gen_iter().take(size).collect()
}
pub fn run_program(program: &str) {
info!("Running {}", program);
let mut v: Vec<&str> = program.split_whitespace().collect();
let status = Command::new(&v.remove(0))
.args(&v)
.status()
.expect("program failed to start");
info!("Exit status: {}", status);
}
pub fn powm(base: &BigUint, exp: &BigUint, modulus: &BigUint) -> BigUint {
let mut base = base.clone();
let mut exp = exp.clone();

View file

@ -4,13 +4,14 @@ use std;
use std::borrow::Cow;
use std::io::{Read, Seek, SeekFrom, Result};
use std::mem;
use std::process::Command;
use std::sync::mpsc::{RecvError, TryRecvError, RecvTimeoutError};
use std::thread;
use std::time::Duration;
use core::config::{Bitrate, PlayerConfig};
use core::session::Session;
use core::util::{self, SpotifyId};
use core::util::SpotifyId;
use audio_backend::Sink;
use audio::{AudioFile, AudioDecrypt};
@ -376,13 +377,13 @@ impl PlayerInternal {
fn run_onstart(&self) {
if let Some(ref program) = self.config.onstart {
util::run_program(program)
run_program(program)
}
}
fn run_onstop(&self) {
if let Some(ref program) = self.config.onstop {
util::run_program(program)
run_program(program)
}
}
@ -516,3 +517,13 @@ impl<T: Read + Seek> Seek for Subfile<T> {
}
}
}
fn run_program(program: &str) {
info!("Running {}", program);
let mut v: Vec<&str> = program.split_whitespace().collect();
let status = Command::new(&v.remove(0))
.args(&v)
.status()
.expect("program failed to start");
info!("Exit status: {}", status);
}