media-core icon indicating copy to clipboard operation
media-core copied to clipboard

Migrate WavTrackImpl to NIO

Open hrosa opened this issue 10 years ago • 7 comments

Currently the Audio Player is using blocking IO which can result in bad performance of the MS. The Audio Player task is handled by the Scheduler where NO blocking operations should take place.

hrosa avatar Oct 21 '15 17:10 hrosa

in this case, we need to replace the IO Inputstream with a suitable NIO Channel to do the reading

deruelle avatar Mar 31 '16 16:03 deruelle

Regarding issue #45, i have made two approaches (two possible solutions). The first one is simpler and uses ByteBuffer and non-blocking ReadableByteChannel. I allocate initial buffer size of 128 bits, and do the packets reading through ReadableByteChannel.

The second approach i tried is with SocketChannel where i configure the blocking mode. This approach uses thread to check for input and do the reading. I opened a socket and connected the channel so i can read the URL path.

The code with ReadableByteChannel: https://github.com/atika2k/mediaserver/commit/be6bf8f98325f69bd8ba1b265a7705c2d35f1a49

My questions are: What should be the initial size of buffer? Is there a way to directly measure the performance (speed and CPU cycles)?

atika2k avatar May 17 '16 10:05 atika2k

#157

atika2k avatar May 17 '16 10:05 atika2k

I really want to work on this issue, after reading this issue and #157 its seems these are related. @hrosa can you please update what has been done and what left in this issue.?

ibrarahmad avatar Nov 29 '17 14:11 ibrarahmad

Hi @ibrarahmad solving this issue will bring some good benefits for MS :)

Indeed, this is related to PR #157 but unfortunately the contributor did not complete his work. The problem with the PR is that it uses a class that exposes a NIO interface, but under the hood the implementation is still blocking. A better alternative may be, for example, an AsynchronousFileChannel that can make asynchronous read operations to the target file.

Let me know what you think.

Regards

hrosa avatar Dec 01 '17 15:12 hrosa

Hi @hrosa I have done my study and I agree with you that AsynchronousFileChannel is good idea. I am currently working on that will send you patch soon. If you have anything more please let me know thanks.

ibrarahmad avatar Dec 15 '17 19:12 ibrarahmad

It's great that we agree on that @ibrarahmad That was the missing piece in the other contributor's work.

Let me know how this goes, I'm here in case you have any questions. Good luck!

hrosa avatar Dec 19 '17 17:12 hrosa