alsa-project / alsa-lib

The Advanced Linux Sound Architecture (ALSA) - library
GNU Lesser General Public License v2.1
366 stars 177 forks source link

rawmidi: hide the frame structure using a decoder function #173

Closed perexg closed 3 years ago

perexg commented 3 years ago

The frame structure should be hidden. Remove it and add snd_rawmidi_decode_frame0() which returns the timestamp and the midi chunk pointer to the application.

BugLink: https://github.com/alsa-project/alsa-lib/issues/172

diwic commented 3 years ago

@perexg No, please don't!

This: 1) Is more complicated, 2) gives worse performance, 3) is a potential SIGBUS on platforms where unaligned access is not allowed

Remember that reading rawmidi might be done from extremely latency sensitive threads; and we don't give any real time guarantees in alsa-lib. So even if there is not much performance overhead right now, we don't guarantee that it won't be later on.

I know that alsa-lib hides the fields of other structs, and most of the time, I've found that to be unnecessary complicated there as well. Making bad decisions in the past should not be an argument to make the same bad decision again just to be consistent with previous bad decisions. Ok?

diwic commented 3 years ago

And 4) it's not compatible with other frame types we might add in the future

perexg commented 3 years ago

The new redesigned API is available in https://github.com/alsa-project/alsa-lib/pull/179 . Closing this.