diff --git a/src/decode/mod.rs b/src/decode/mod.rs index 2117121..8963386 100644 --- a/src/decode/mod.rs +++ b/src/decode/mod.rs @@ -1,11 +1,13 @@ -use std::sync::mpsc; +use std::sync::{mpsc, Arc}; use std::error::Error; +use std::thread; + use crate::util; pub fn spawn( v: mpsc::Receiver, a: mpsc::Receiver, - metadata: &util::Metadata + metadata: &Arc ) -> Result< ( mpsc::Receiver, @@ -14,8 +16,18 @@ pub fn spawn( ), Box > { - let (_raw_v_in, raw_v_out) = mpsc::channel(); - let (_raw_a_in, raw_a_out) = mpsc::channel(); - let (_err_in, err_out) = mpsc::channel(); + let (raw_v_in, raw_v_out) = mpsc::channel(); + let (raw_a_in, raw_a_out) = mpsc::channel(); + let (err_in, err_out) = mpsc::channel(); + let metadata_handle = metadata.clone(); + thread::spawn(move || { + &raw_v_in; + &raw_a_in; + &err_in; + &metadata_handle; + &v; + &a; + thread::park(); + }); return Ok((raw_v_out, raw_a_out, err_out)); } diff --git a/src/encode/mod.rs b/src/encode/mod.rs index 6e3f157..efcb990 100644 --- a/src/encode/mod.rs +++ b/src/encode/mod.rs @@ -1,12 +1,13 @@ -use std::sync::mpsc; +use std::sync::{mpsc, Arc}; use std::error::Error; +use std::thread; use crate::util; pub fn spawn( v: mpsc::Receiver, a: mpsc::Receiver, - metadata: &util::Metadata + metadata: &Arc ) -> Result< ( mpsc::Receiver, @@ -18,5 +19,15 @@ pub fn spawn( let (v_in, v_out) = mpsc::channel(); let (a_in, a_out) = mpsc::channel(); let (err_in, err_out) = mpsc::channel(); + let metadata_handle = metadata.clone(); + thread::spawn(move || { + &v; + &a; + &v_in; + &a_in; + &err_in; + &metadata_handle; + thread::park(); + }); return Ok((v_out, a_out, err_out)); } diff --git a/src/muxer/mod.rs b/src/muxer/mod.rs index 110e4b9..3d79825 100644 --- a/src/muxer/mod.rs +++ b/src/muxer/mod.rs @@ -1,16 +1,25 @@ -use std::sync::mpsc; +use std::sync::{mpsc, Arc}; use std::error::Error; +use std::thread; use crate::util; pub fn spawn( v: mpsc::Receiver, a: mpsc::Receiver, - metadata: &util::Metadata + metadata: &Arc ) -> Result< mpsc::Receiver>, Box > { let (err_in, err_out) = mpsc::channel(); + let metadata_handle = metadata.clone(); + thread::spawn(move || { + &v; + &a; + &err_in; + &metadata_handle; + thread::park(); + }); return Ok(err_out); }