libsamplerate icon indicating copy to clipboard operation
libsamplerate copied to clipboard

Doc omission regarding `src_process`

Open p-i- opened this issue 7 years ago • 3 comments

https://github.com/erikd/libsamplerate/blob/master/src/samplerate.h#L86

Doc is here: http://www.mega-nerd.com/SRC/api_simple.html

Documentation doesn't mention what happens if the output buffer is not big enough to hold the samplerate-converted input buffer.

It isn't certain if this will return an error or simply fill the output buffer, correctly making a note of how many input samples have been consumed in the data structure.

It would be very helpful to have this documented, as it would save a development test-cycle.

p-i- avatar May 19 '18 16:05 p-i-

The person who wrote the code is rarely the best person to document the API, because the author makes assumptions about it that a newcomer is unlikely to make.

PR more than welcome.

erikd avatar May 20 '18 00:05 erikd

Can you tell me off the top of your head what would be the actual behaviour?

p-i- avatar May 20 '18 00:05 p-i-

src_process is designed to to not overflow the input or output buffers, and to operate correctly in a loop where it is constantly being called with updated SRC_DATA data.

If you call it with a zero length output buffer, it may consume input (and store it internally, but there is a limit to its internal storage), but it will not generate output and it will not result in an error.

erikd avatar May 20 '18 00:05 erikd