Re: playing audio from an AVI file...
Posted by
Sven Gothel on
Mar 18, 2014; 10:23pm
URL: https://forum.jogamp.org/playing-audio-from-an-AVI-file-tp4031894p4031964.html
On 03/18/2014 06:31 PM, TheLittleP [via jogamp] wrote:
> Im quite taken aback that something I created is "neat" lol
>
> There is an issue with it though. It currently waits the frame time
> (66milliseconds) and then fetches the audio and video buffers. The problem is
> it takes too long to process the audio buffer so the audio sink effectives
> runs out and stops and hence why only a second or 2 plays.
>
> My solution has been to pre-fetch the buffers of the next frame and submit the
> audio buffer so it is processed and queued before the current buffer runs out.
> I then wait the 66ms before submitting the image buffer and it works a treat.
> I create a new thread for each buffer processing so the main thread with a
> wait of 66ms has minimal latency.
>
> I have wondered if the memory overhead of creating 16 new threads every second
> would cause a problem but I presume as they are most likely added to the
> garbage collector before the next 1 is created that it shouldn't be too much
> of an issue.
Creating and starting a thread is _very_ expensive.
Maybe look how we do it in our
stream worker (GLMediaPlayerImpl.StreamWorker) - just keep one thread
open .. while working w/ the stream - that should do it.
Ofc .. you may spawn of more threads for parallel decoding ..
but even here, I would use a thread pool and 'wait a while' before
killing them - maybe a user just pressed pause and wants to continue
a millisecond later ..
Further more, you may want to see how we use and impl. the ringbuffer,
which works lock free and allows a zero copy queuing of A/V data.
>
> I have been a right film director today with lights, camera and action lol.
> The performers I have to run the script with have been exceptional!
Sounds like fun, great.
~Sven