Understanding How FIFO Exclusive Access to a Single Stream

Asked 2 years ago, Updated 2 years ago, 124 views

I am currently creating a music playback application on C#.
I'm looking for a Stream (or equivalent) that meets the following requirements, but I can't find it.

·You can write a byte array at the end of a single stream and read it from the beginning at the same time.

Create write and read threads and
In the writing thread, a music file divided into about 5 seconds is acquired from a web by an Http request and sequentially written in a stream as a byte array.
In order to realize streaming reproduction (while writing the music file to the stream), a byte array on the stream is read and reproduced from the head by a reading thread.

I want to realize these requirements, but they don't work very well.
MemoryStream does not provide FIFO or exclusive access.
If it's Queue, I can't help but get a cut when playing it.

Even if it is not a standard library, it would be fine if it could be implemented in succession.
Thank you for your cooperation.

c# stream audio-streaming

2022-09-30 21:19

2 Answers

How to: Use Anonymous Pipes for Local Interprocess Communication
Originally for inter-process communication, how about writing to AnonymousPipeServerStream and reading from AnonymousPipeClientStream?


2022-09-30 21:19

Streaming sound must essentially use APIs that allow access to low-level playback queues, such as XAudio 2.If it is C#, I think I will use rappers such as SharpDX.


2022-09-30 21:19

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.