nothings / stb

stb single-file public domain libraries for C/C++
https://twitter.com/nothings
Other
26.83k stars 7.72k forks source link

stb_vorbis: Add I/O callback support #478

Open rygorous opened 7 years ago

rygorous commented 7 years ago

This has been requested.

nothings commented 7 years ago

See https://github.com/nothings/stb/pull/456

rygorous commented 7 years ago

I added this as a new issue because while the feature request is definitely reasonable, I feel like that particular implementation isn't up to snuff. (See my comments on the pull request.)

ghost commented 4 years ago

I just ran into this because it appears this is essential for fully featured streaming from custom locations - because yes, there is pushdata, but that one seems useless for users who need sample-exact seeking since it only seems to support approximates. (Or is there a way to do exact seeks with pushdata which I missed?) So that makes pushdata unusable for use cases where such a guess isn't good enough, and stb_vorbis_decode_memory doesn't support streaming.

Therefore, it seems like custom callbacks are required for feature completion here, and I can report I had a great experience using them with the dr-mp3 & dr-flac libs while the pushdata API just looks weird to me. Is there any advantage to it at all over custom callbacks? Maybe it could even be considered (after intense discussion of course!!) for a potential removal later.

ghost commented 4 years ago

Here a few problems custom callbacks (and possibly abandoning pushdata) would solve:

On the flip side, I haven't found a reason yet why pushdata is better or solves anything custom callbacks don't. But I'd be curious to know if there is anything.

nothings commented 4 years ago

pushdata exists because the company that paid for me to write stb_vorbis wanted that api. so there is no value in critiquing it.

ghost commented 4 years ago

Oh, interesting! Fair enough, I hope it's still useful info for why custom callbacks might be a better match for many and possibly worth adding.

(Also some time in the future, if you wanted to reduce the maintenance effort maybe the company could be asked if they want to switch their usage to custom callbacks, too? Feel free to link anyone curious to my comment above)