Skip to content

Conversation

@adsr
Copy link
Contributor

@adsr adsr commented Aug 23, 2025

Without setting a callback, all errors are printed to stderr, which may not be desirable.

Rename data field in wrapper struct to something more descriptive.

Delete rtmidi_error function as the prototype mismatched the implementation.

Templatize existing callback proxy class so we can reuse it for error callbacks.

This is an ABI break as it adds a field to the wrapper struct.

Test script:

#include <stdio.h>
#include <rtmidi_c.h>

static void error_cb(enum RtMidiErrorType type, const char *msg, void *udata) {
    printf("error_cb: type=%d msg=%s udata=%p\n", type, msg, udata);
}

int main(int argc, char **argv) {
    RtMidiOutPtr out = rtmidi_out_create(0, argv[0]);
    rtmidi_set_error_callback(out, error_cb, (void *)0xffff);
    rtmidi_open_port(out, 999, "invalid_port");
    rtmidi_out_free(out);
    return 0;
}
$ ./test
error_cb: type=6 msg=MidiOutAlsa::openPort: the 'portNumber' argument (999) is invalid. udata=0xffff

@garyscavone
Copy link
Contributor

There is a conflict, probably with the previous PR merge. Please see if you can resolve it, as I don't use the C API at all and it would take a while for me to evaluate the conflict.

Without setting a callback, all errors are printed to stderr, which
may not be desirable.

Rename `data` field in wrapper struct to something more descriptive.

Delete `rtmidi_error` function as the prototype mismatched the
implementation.

Templatize existing callback proxy class so we can reuse it for
error callbacks.

This is an ABI break as it adds a field to the wrapper struct.
@adsr
Copy link
Contributor Author

adsr commented Aug 30, 2025

@garyscavone I fixed the conflicts. The macOS CI failure looks unrelated to me.

@garyscavone garyscavone merged commit 0c7ca18 into thestk:master Sep 9, 2025
9 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants