TheoraDataSource::read - Dealing with Async IO

2014-07-23
2014-07-23
  • MorphingDragon

    MorphingDragon - 2014-07-23

    I'm writing a TheoraDataSource that deals primarily with an Async source. What was the intended way to deal with data not being ready? I assume if the data isn't ready we just block execution until it is?

     
  • Krešimir Špes

    Krešimir Špes - 2014-07-23

    What kind of async source? Internet streaming? Well essentially just feed data as it becomes available to the codec and when there's no more data, the decoder threads will wait for it, pausing frame decoding. This is where frame preaching feature of the lib comes in handy, so you can smooth out an uneven stream.

     
  • Krešimir Špes

    Krešimir Špes - 2014-07-23

    to answer your question, not exactly sure right now, try blocking execution (it's in another thread anyway so it won't block your main thread). alternately, return 0 bytes if nothing new is available. but I think input blocking should be ok.

     
  • MorphingDragon

    MorphingDragon - 2014-07-23

    Doesn't returning 0 bytes tell the decoder library that it's the end of the file though?

     
  • Krešimir Špes

    Krešimir Špes - 2014-07-23

    yeah, I thinks so too :)

    Anyway, try locking and if you run into problems, we'll fix it together

     
  • MorphingDragon

    MorphingDragon - 2014-07-23

    It seems that naive sleeping wont do the trick. Unfortunately, whether if its in the main thread or a C# thread Unity compute time gets tied up as the manager needs some data initially to compute the metadata. Since I'm just causing the thread to sleep, what ends up happening is the async IO basically has to complete anyway which is not what I want.

    I'm going to implement lazy video creation in the TheoraVideoManager. A worker thread will check a flag, and if it needs initial processing it will do it there.

     
  • Krešimir Špes

    Krešimir Špes - 2014-07-23

    ok, sure, let me know how it ends up working :)

     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks