Why the OggContainerReader should use PageReaderLock ?

Sep 6, 2013 at 3:05 AM
Hi,

Thanks for the wonderful codebase!

There are some mutex lock:
using (var pageLock = TakePageReaderLock()) 
in FindNextStream() and GetTotalPageCount() in OggContainerReader.cs

Why?

I am using NVorbis in Unity WebPlayer which is not support the native code, but the mutex will call the native code. I remove these mutex code, and it does work in WebPlayer.

So can I just remove these mutex code without any problem?

Cheers,
duke
Coordinator
Sep 6, 2013 at 2:27 PM
The lock is to guard the core page reading logic from multi-threaded access. It has to operate sequentially through the file, so having two different threads trying to find the next page would be problematic at best.

If you want the simplest fix, just change from using a Mutex to using a Monitor. That maintains the behavior, but should actually work in WebPlayer (I think... the documentation is rather weak).
Sep 8, 2013 at 10:53 AM
ioctlLR wrote:
The lock is to guard the core page reading logic from multi-threaded access. It has to operate sequentially through the file, so having two different threads trying to find the next page would be problematic at best.

If you want the simplest fix, just change from using a Mutex to using a Monitor. That maintains the behavior, but should actually work in WebPlayer (I think... the documentation is rather weak).
The Monitor works in WebPlayer! Thank you!