Commit 3ad480d0 authored by Felix Häcker's avatar Felix Häcker

automatically stop recording if gstreamer pipeline is not playing

parent 48bff4c7
Pipeline #73783 passed with stages
in 6 minutes and 35 seconds
......@@ -1421,6 +1421,7 @@ dependencies = [
"lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libhandy 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
"matches 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
"mdns 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"mpris-player 0.2.0 (git+https://gitlab.gnome.org/World/Rust/mpris-player)",
"pretty_env_logger 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
......
......@@ -28,3 +28,4 @@ serde = "1.0.89"
serde_json = "1.0.39"
serde_derive = "1.0.89"
lazy_static = "1.3.0"
matches = "0.1.8"
......@@ -9,6 +9,8 @@ extern crate glib;
extern crate lazy_static;
#[macro_use]
extern crate serde_derive;
#[macro_use]
extern crate matches;
mod model;
mod player;
......
......@@ -118,9 +118,6 @@ impl Player {
let _ = self.backend.lock().unwrap().set_state(gstreamer::State::Playing);
}
PlaybackState::Stopped => {
// Discard current recording because the song has not yet been completely recorded.
self.backend.lock().unwrap().stop_recording(false);
let _ = self.backend.lock().unwrap().set_state(gstreamer::State::Null);
}
_ => (),
......@@ -188,6 +185,11 @@ impl Player {
for con in &*controller {
con.set_playback_state(&state);
}
if matches!(state, PlaybackState::Failure(_)) || matches!(state, PlaybackState::Stopped) {
// Discard current recording because the song has not yet been completely recorded.
backend.lock().unwrap().stop_recording(false);
}
}
}
glib::Continue(true)
......
......@@ -194,7 +194,7 @@ impl GstreamerBackend {
}
pub fn stop_recording(&mut self, save_song: bool) -> Option<Song> {
debug!("Stop recording...");
debug!("Stop recording... (save song: {})", save_song);
if self.recorderbin.lock().unwrap().is_some() {
let rbin = self.recorderbin.clone();
......
#[derive(Clone)]
#[derive(Clone, PartialEq)]
pub enum PlaybackState {
Playing,
Stopped,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment