DRY up constructors

This commit is contained in:
Roderick van Domburg 2021-04-05 23:14:02 +02:00
parent 78bc621ebb
commit 928a673653
7 changed files with 7 additions and 7 deletions

View file

@ -71,7 +71,7 @@ fn open_device(dev_name: &str, format: AudioFormat) -> Result<(PCM, Frames), Box
} }
impl Open for AlsaSink { impl Open for AlsaSink {
fn open(device: Option<String>, format: AudioFormat) -> AlsaSink { fn open(device: Option<String>, format: AudioFormat) -> Self {
info!("Using Alsa sink with format: {:?}", format); info!("Using Alsa sink with format: {:?}", format);
let name = match device.as_ref().map(AsRef::as_ref) { let name = match device.as_ref().map(AsRef::as_ref) {

View file

@ -16,7 +16,7 @@ pub struct GstreamerSink {
} }
impl Open for GstreamerSink { impl Open for GstreamerSink {
fn open(device: Option<String>, format: AudioFormat) -> GstreamerSink { fn open(device: Option<String>, format: AudioFormat) -> Self {
info!("Using GStreamer sink with format: {:?}", format); info!("Using GStreamer sink with format: {:?}", format);
gst::init().expect("failed to init GStreamer!"); gst::init().expect("failed to init GStreamer!");

View file

@ -41,7 +41,7 @@ impl ProcessHandler for JackData {
} }
impl Open for JackSink { impl Open for JackSink {
fn open(client_name: Option<String>, format: AudioFormat) -> JackSink { fn open(client_name: Option<String>, format: AudioFormat) -> Self {
if format != AudioFormat::F32 { if format != AudioFormat::F32 {
warn!("JACK currently does not support {:?} output", format); warn!("JACK currently does not support {:?} output", format);
} }

View file

@ -10,7 +10,7 @@ pub struct StdoutSink {
} }
impl Open for StdoutSink { impl Open for StdoutSink {
fn open(path: Option<String>, format: AudioFormat) -> StdoutSink { fn open(path: Option<String>, format: AudioFormat) -> Self {
info!("Using pipe sink with format: {:?}", format); info!("Using pipe sink with format: {:?}", format);
let output: Box<dyn Write> = match path { let output: Box<dyn Write> = match path {

View file

@ -17,7 +17,7 @@ pub struct PulseAudioSink {
} }
impl Open for PulseAudioSink { impl Open for PulseAudioSink {
fn open(device: Option<String>, format: AudioFormat) -> PulseAudioSink { fn open(device: Option<String>, format: AudioFormat) -> Self {
info!("Using PulseAudio sink with format: {:?}", format); info!("Using PulseAudio sink with format: {:?}", format);
// PulseAudio calls S24 and S24_3 different from the rest of the world // PulseAudio calls S24 and S24_3 different from the rest of the world

View file

@ -12,7 +12,7 @@ pub enum SdlSink {
} }
impl Open for SdlSink { impl Open for SdlSink {
fn open(device: Option<String>, format: AudioFormat) -> SdlSink { fn open(device: Option<String>, format: AudioFormat) -> Self {
info!("Using SDL sink with format: {:?}", format); info!("Using SDL sink with format: {:?}", format);
if device.is_some() { if device.is_some() {

View file

@ -12,7 +12,7 @@ pub struct SubprocessSink {
} }
impl Open for SubprocessSink { impl Open for SubprocessSink {
fn open(shell_command: Option<String>, format: AudioFormat) -> SubprocessSink { fn open(shell_command: Option<String>, format: AudioFormat) -> Self {
info!("Using subprocess sink with format: {:?}", format); info!("Using subprocess sink with format: {:?}", format);
if let Some(shell_command) = shell_command { if let Some(shell_command) = shell_command {