SuRGeoNix / Flyleaf

Media Player .NET Library for WinUI 3/ WPF/WinForms (based on FFmpeg/DirectX)
GNU Lesser General Public License v3.0
687 stars 92 forks source link

Audio render should be on different thread #441

Closed acidmeat closed 3 months ago

acidmeat commented 3 months ago

On low end gpu,video render takes too long to render a frame,which will cause audio render can't properly work. I notice you've already comment this tbr My question is will it be implented soon,ex. in a month?

SuRGeoNix commented 3 months ago

@acidmeat can you confirm that your issue is actually the delay of the video rendering? Because the TBR comment is still there as I've not notice any issues so far with these and even is better to use a single instead of two threads (imagine having multiple players threads will increase and that could cause other issues). Can you disable the video and confirm that audio works fine without video. Possible provide also a trace log?

acidmeat commented 3 months ago

@SuRGeoNix Thanks for this great project. I'm pretty sure about the problem is caused by rendering,Hardware is UHD630 on 4k screen without dual memory.Render.Present a frame will cost 60ms-110ms. the vDistanceMs are a bunch of negative values.Audio only works fine. comment the actually rendering funcs also works fine. I'm not able to access the low end pcs right now.if you do need the log,I can get that tomorrow

SuRGeoNix commented 3 months ago

@acidmeat In this case by running audio in different thread it will not resolve the issue. The current implementation considers as requirement that the decoding time and processing/rendering time will be able to finish within the FPS limit. Also gives priority to video, which means that if the video for some reason lags it will try to re-buffer to ensure smooth video playback.

To be honest, I don't see the point to play a 4K video in an old system that it cannot handle this and generally I was never planning to support old OS/hardware systems. Let me know your thoughts and I might reconsider this ;)

acidmeat commented 3 months ago

@SuRGeoNix I get your point. The scenario is like this: the manufacturer has been using a small box system to drive a TV since around 2015, I assume. They recently upgraded the hardware because the old CPUs are out of supply. But now they want the old devices to handle 4K streams, and their tolerance for lag is extremely high lol. I'll try syncing the video to the audio and skipping half of the frames.