cpal icon indicating copy to clipboard operation
cpal copied to clipboard

Allow creation of OutputCallbackInfo and InputCallbackInfo objects (for test purposes)

Open danutsu opened this issue 1 year ago • 3 comments

This change makes the fields of StreamInstant, OutputCallbackInfo and InputCallbackInfo pub.

The intent is to allow OutputCallbackInfo instances to be created, which then allows unit testing the data callback function. Because it is a self-contained function that simply fills data in a buffer, it is, in principle, very unit-testable -- but it's very difficult to do so today because the test code cannot create an OutputCallbackInfo for it.

I don't believe there's any good reason for these fields to not be pub. In particular, I noticed the fields of OutputStreamTimestamp are public, so the "middle" layer is already creatable, just not StreamInstant and OutputCallbackInfo. Also, the structures are pretty plain data objects with no special logic or anything like that, so there really is no harm in allowing them to be created.

danutsu avatar Jul 12 '24 19:07 danutsu

Fixed the emscripten issue, please take a look and let me know if I need to do anything else.

danutsu avatar Jul 12 '24 20:07 danutsu

It's been a while - sorry for that - but new maintainer here and I follow your rationale. Would you resolve the conflicts and update the PR?

roderickvd avatar Oct 12 '25 20:10 roderickvd

For consideration: instead of making everything pub, how about offering new constructors and some getters?

roderickvd avatar Oct 12 '25 20:10 roderickvd