mpv-player / mpv-examples

📚
224 stars 77 forks source link

Audio callback #14

Closed deltabeard closed 6 years ago

deltabeard commented 6 years ago

Does libmpv have an audio callback feature that returns audio samples for a video frame?

Thanks.

ghost commented 6 years ago

It doesn't. Though audio frames are not necessarily perfectly aligned with video frames.

deltabeard commented 6 years ago

Thanks for your reply. I'm looking into adding an audio driver to mpv that stores audio samples in a buffer that can then be retrieved using a function declared in client.h. All for the purpose of writing a libretro mpv core.

ghost commented 6 years ago

Potentially you could just use the internal pull API (like ao_sdl.c or ao_jack.c do), then you don't really need a buffer. But depends on the API user requirements. Also getting a timestamp to sync it with video will probably be a pain.

deltabeard commented 6 years ago

Thanks, I'll have a look. I was using the simple ao_pcm.c audio driver as a guideline to see if I can properly pass samples to libretro, and then I'll look in to issues such as syncing. I'll try and write a decent solution.

Edit: The pull API seems to be exactly what I need! Links for my future self: pull.c internal.h

g-l-i-t-c-h-o-r-s-e commented 1 month ago

Could this be something that could be added as an official feature? https://github.com/libretro/libretro-mpv/commit/ef16a4045e36cb9acd87ef2632d57f7380494781