Struct ether_dream_dac_emulator::stream::Stream
[−]
[src]
pub struct Stream { /* fields omitted */ }
A stream of communication between a DAC and a user.
The stream expects to receive Commands and responseds with DacResponses.
All communication occurs over a single TCP stream.
Processed data is submitted to the stream::Output with which the user may do what they like.
Methods
impl Stream
[src]
pub fn new(
dac: Addressed,
tcp_stream: TcpStream,
output_frame_rate: u32
) -> Result<Self>
[src]
dac: Addressed,
tcp_stream: TcpStream,
output_frame_rate: u32
) -> Result<Self>
Initialise a new Stream.
Internally this allocates a buffer of bytes whose size is the size of the largest possible Data command that may be received based on the DAC's buffer capacity.
Enables TCP_NODELAY
on the given TCP socket in order to adhere to the low-latency,
realtime requirements.
This function also spawns a thread used for processing output.
pub fn run(&mut self) -> Error
[src]
Handle TCP messages received on the given stream by attempting to interpret them as commands.
Once processed, each command will be responded to.
This runs forever until either an error occurs or the TCP stream is shutdown.
Returns the io::Error that caused the loop to end.
pub fn spawn(self) -> Result<Handle>
[src]
Spawn a stream that receives Commands sent by the user via the given TCP stream, processes them, updates the DAC state accordingly and responds via the TCP stream.
Returns a Handle to the thread.