From 928a6736538da12e509ec55a626b29bb9e9d54da Mon Sep 17 00:00:00 2001 From: Roderick van Domburg Date: Mon, 5 Apr 2021 23:14:02 +0200 Subject: [PATCH] DRY up constructors --- playback/src/audio_backend/alsa.rs | 2 +- playback/src/audio_backend/gstreamer.rs | 2 +- playback/src/audio_backend/jackaudio.rs | 2 +- playback/src/audio_backend/pipe.rs | 2 +- playback/src/audio_backend/pulseaudio.rs | 2 +- playback/src/audio_backend/sdl.rs | 2 +- playback/src/audio_backend/subprocess.rs | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/playback/src/audio_backend/alsa.rs b/playback/src/audio_backend/alsa.rs index fc2a775c..1d551878 100644 --- a/playback/src/audio_backend/alsa.rs +++ b/playback/src/audio_backend/alsa.rs @@ -71,7 +71,7 @@ fn open_device(dev_name: &str, format: AudioFormat) -> Result<(PCM, Frames), Box } impl Open for AlsaSink { - fn open(device: Option, format: AudioFormat) -> AlsaSink { + fn open(device: Option, format: AudioFormat) -> Self { info!("Using Alsa sink with format: {:?}", format); let name = match device.as_ref().map(AsRef::as_ref) { diff --git a/playback/src/audio_backend/gstreamer.rs b/playback/src/audio_backend/gstreamer.rs index d3c736a4..d59677ac 100644 --- a/playback/src/audio_backend/gstreamer.rs +++ b/playback/src/audio_backend/gstreamer.rs @@ -16,7 +16,7 @@ pub struct GstreamerSink { } impl Open for GstreamerSink { - fn open(device: Option, format: AudioFormat) -> GstreamerSink { + fn open(device: Option, format: AudioFormat) -> Self { info!("Using GStreamer sink with format: {:?}", format); gst::init().expect("failed to init GStreamer!"); diff --git a/playback/src/audio_backend/jackaudio.rs b/playback/src/audio_backend/jackaudio.rs index 7449cc11..24a94a3e 100644 --- a/playback/src/audio_backend/jackaudio.rs +++ b/playback/src/audio_backend/jackaudio.rs @@ -41,7 +41,7 @@ impl ProcessHandler for JackData { } impl Open for JackSink { - fn open(client_name: Option, format: AudioFormat) -> JackSink { + fn open(client_name: Option, format: AudioFormat) -> Self { if format != AudioFormat::F32 { warn!("JACK currently does not support {:?} output", format); } diff --git a/playback/src/audio_backend/pipe.rs b/playback/src/audio_backend/pipe.rs index ae77e320..6948db94 100644 --- a/playback/src/audio_backend/pipe.rs +++ b/playback/src/audio_backend/pipe.rs @@ -10,7 +10,7 @@ pub struct StdoutSink { } impl Open for StdoutSink { - fn open(path: Option, format: AudioFormat) -> StdoutSink { + fn open(path: Option, format: AudioFormat) -> Self { info!("Using pipe sink with format: {:?}", format); let output: Box = match path { diff --git a/playback/src/audio_backend/pulseaudio.rs b/playback/src/audio_backend/pulseaudio.rs index 16800eb0..507e453c 100644 --- a/playback/src/audio_backend/pulseaudio.rs +++ b/playback/src/audio_backend/pulseaudio.rs @@ -17,7 +17,7 @@ pub struct PulseAudioSink { } impl Open for PulseAudioSink { - fn open(device: Option, format: AudioFormat) -> PulseAudioSink { + fn open(device: Option, format: AudioFormat) -> Self { info!("Using PulseAudio sink with format: {:?}", format); // PulseAudio calls S24 and S24_3 different from the rest of the world diff --git a/playback/src/audio_backend/sdl.rs b/playback/src/audio_backend/sdl.rs index 7e071dd1..0a3fd433 100644 --- a/playback/src/audio_backend/sdl.rs +++ b/playback/src/audio_backend/sdl.rs @@ -12,7 +12,7 @@ pub enum SdlSink { } impl Open for SdlSink { - fn open(device: Option, format: AudioFormat) -> SdlSink { + fn open(device: Option, format: AudioFormat) -> Self { info!("Using SDL sink with format: {:?}", format); if device.is_some() { diff --git a/playback/src/audio_backend/subprocess.rs b/playback/src/audio_backend/subprocess.rs index 586bb75b..bebb6ea0 100644 --- a/playback/src/audio_backend/subprocess.rs +++ b/playback/src/audio_backend/subprocess.rs @@ -12,7 +12,7 @@ pub struct SubprocessSink { } impl Open for SubprocessSink { - fn open(shell_command: Option, format: AudioFormat) -> SubprocessSink { + fn open(shell_command: Option, format: AudioFormat) -> Self { info!("Using subprocess sink with format: {:?}", format); if let Some(shell_command) = shell_command {