mirror of
https://github.com/johrpan/musicus.git
synced 2025-10-27 04:07:25 +01:00
import: Use watch channel for state updates
This commit is contained in:
parent
e43486367b
commit
690a150727
4 changed files with 61 additions and 27 deletions
|
|
@ -1,13 +1,17 @@
|
|||
use crate::error::{Error, Result};
|
||||
use crate::session::{ImportSession, ImportTrack};
|
||||
use crate::session::{ImportSession, ImportTrack, State};
|
||||
use gstreamer::ClockTime;
|
||||
use gstreamer_pbutils::Discoverer;
|
||||
use log::{warn, info};
|
||||
use sha2::{Sha256, Digest};
|
||||
use std::path::PathBuf;
|
||||
use std::sync::Mutex;
|
||||
use tokio::sync::watch;
|
||||
|
||||
/// Create a new import session for the specified folder.
|
||||
pub(super) fn new(path: PathBuf) -> Result<ImportSession> {
|
||||
let (state_sender, state_receiver) = watch::channel(State::Ready);
|
||||
|
||||
let mut tracks = Vec::new();
|
||||
let mut number: u32 = 1;
|
||||
let mut hasher = Sha256::new();
|
||||
|
|
@ -58,6 +62,8 @@ pub(super) fn new(path: PathBuf) -> Result<ImportSession> {
|
|||
source_id,
|
||||
tracks,
|
||||
copy: None,
|
||||
state_sender,
|
||||
state_receiver: Mutex::new(state_receiver),
|
||||
};
|
||||
|
||||
Ok(session)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue