mackron / miniaudio

Audio playback and capture library written in C, in a single source file.
https://miniaud.io
Other
4.07k stars 361 forks source link

ma_sound_seek_to_pcm_frame seeks to wrong place with ogg file #629

Closed erikjalevik closed 1 year ago

erikjalevik commented 1 year ago

I'm using ma_sound_seek_to_pcm_frame to jump to a specific frame in a playing sound. When testing with the same frame value on the same sound encoded in wav, flac, mp3, and ogg format, the first three seem to do the right thing, while the ogg jumps to a position roughly halfway to where it should be.

Just wanted to check if this is a known issue before providing a detailed repro example?

Here's my debug output (but it doesn't seem to contain anything relevant to the seek):

DEBUG: Failed to initialize WASAPI backend.
DEBUG: Failed to initialize DirectSound backend.
DEBUG: Failed to initialize WinMM backend.
DEBUG: Attempting to initialize Core Audio backend...
DEBUG: Loading library: CoreFoundation.framework/CoreFoundation
DEBUG: Loading symbol: CFStringGetCString
DEBUG: Loading symbol: CFRelease
DEBUG: Loading library: CoreAudio.framework/CoreAudio
DEBUG: Loading symbol: AudioObjectGetPropertyData
DEBUG: Loading symbol: AudioObjectGetPropertyDataSize
DEBUG: Loading symbol: AudioObjectSetPropertyData
DEBUG: Loading symbol: AudioObjectAddPropertyListener
DEBUG: Loading symbol: AudioObjectRemovePropertyListener
DEBUG: Loading library: AudioUnit.framework/AudioUnit
DEBUG: Loading symbol: AudioComponentFindNext
DEBUG: Loading symbol: AudioComponentFindNext
DEBUG: Loading symbol: AudioComponentInstanceDispose
DEBUG: Loading symbol: AudioComponentInstanceNew
DEBUG: Loading symbol: AudioOutputUnitStart
DEBUG: Loading symbol: AudioOutputUnitStop
DEBUG: Loading symbol: AudioUnitAddPropertyListener
DEBUG: Loading symbol: AudioUnitGetPropertyInfo
DEBUG: Loading symbol: AudioUnitGetProperty
DEBUG: Loading symbol: AudioUnitSetProperty
DEBUG: Loading symbol: AudioUnitInitialize
DEBUG: Loading symbol: AudioUnitRender
DEBUG: System Architecture:
DEBUG:   Endian: LE
DEBUG:   SSE2:   NO
DEBUG:   AVX2:   NO
DEBUG:   NEON:   YES
INFO: [Core Audio]
INFO:   MacBook Pro Speakers (Playback)
INFO:     Format:      32-bit IEEE Floating Point -> 32-bit IEEE Floating Point
INFO:     Channels:    2 -> 2
INFO:     Sample Rate: 44100 -> 44100
INFO:     Buffer Size: 441*3 (1323)
INFO:     Conversion:
INFO:       Pre Format Conversion:  NO
INFO:       Post Format Conversion: NO
INFO:       Channel Routing:        NO
INFO:       Resampling:             NO
INFO:       Passthrough:            YES
INFO:       Channel Map In:         {CHANNEL_FRONT_LEFT CHANNEL_FRONT_RIGHT}
INFO:       Channel Map Out:        {CHANNEL_FRONT_LEFT CHANNEL_FRONT_RIGHT}
mackron commented 1 year ago

This is a known bug. It's because miniaudio uses stb_vorbis' push mode which doesn't have any easy to use seek function.

mackron commented 1 year ago

I've pushed a potential fix for this to the dev branch. It's horribly inefficient, but I think it should work.