naudio / NAudio

Audio and MIDI library for .NET
MIT License
5.55k stars 1.1k forks source link

NAudio needs support for asynchronicity (and probably .NET 4.0 and 4.5) #93

Open kkm000 opened 8 years ago

kkm000 commented 8 years ago

.NET 4.0 added asynchronous operations to the definition of System.IO.Stream, and 4.5 took that a step further by providing future-promise asynchronous model with Task *Async() methods. NAudio currently targets .NET 3.5. This version did have a basic support for asynch operation (Begin{Read,Write}, although harder to use than the new style); but NAudio does not support even that. This indeed creates a problem on servers, like in my case when I am using an instance of WebResponseStream to construct a WaveFileReader. The latter blocks when reading data from the underlying stream, and that requires a complex thread management in a service program (I cannot block in a thread pool thread, since they are scarce).

NAudio is an amazing library, and would be awesome to keep it up with the way current architectures are developing.

dlnieves commented 8 years ago

Totally agree. Think of game development also!!!!

kkm000 commented 8 years ago

@markheath: Is there interest in this at all? Looks like a profound change, as it would require building and packaging multiple versions of the library, akin to what is done now with separate projects in NAudio.Win8 and NAudio.Universal (I would use build targets rather than creating 2 more projects but your choice). I would start hacking it, but I am not very gung ho about maintaining a fork. What are your thoughts?

markheath commented 8 years ago

yeah, a lot of NAudio was written back in the days of .NET 1.0. Some parts would be hard to make async, but for things like WaveFileReader / Writer it would be a nice addition.

kkm000 commented 8 years ago

@markheath, I'm taking a liberty to hijack this space for questions on the NAudio build architecture. There is a feature in the FAKE script that looks sloppy at the first sight. The Debug build is unit tested, but the Release build is packaged. Is this a bug, or intended for a reason I do not comprehend?

"Clean" 
    ==> "DebugBuild"
    ==> "Test"
    ?=> "ReleaseBuild"
    ==> "Release"
kkm000 commented 8 years ago

Ahem? PTAL.

markheath commented 8 years ago

yes, I run the unit tests on the debug build but the nuget package contains the release build. Is there a problem with that?

kkm000 commented 8 years ago

No, not a problem as it is, just looks strange indeed. I could not understand what is the point of building a separate and (sometimes unintentionally) different configuration for unit testing only. I just want to understand the benefits.

But my main question is what is the better multitargeting approach. Could you please look at #99 and tell me what you think? (And as a side note, this is where testing one thing then releasing another may become even more tedious and risky, as the number of configuration needed to be kept in sync triples!)

kGurGaller commented 2 years ago

Any update on this? Seems like NAudio already has a build that targets newer .NET versions, so is it planned to support this? Async IO is a must in high-throughput server apps these days, so it is kind of a bummer that it is not supported by NAudio's WaveStreams