Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sendSysEx() on Mac OSX #25

Open
denisgottardello opened this issue Oct 28, 2020 · 8 comments
Open

sendSysEx() on Mac OSX #25

denisgottardello opened this issue Oct 28, 2020 · 8 comments

Comments

@denisgottardello
Copy link

denisgottardello commented Oct 28, 2020

Hi, my program works well in Linux and Windows. It goes to crash on Mac OS X.
After a debug session I can't find the bug.
I can send not more than one or two midi massage (on Mac OS X).
My opinion is that MIDISendSysex() function is async.
Does anyone had the same problem?

@LeStahL
Copy link
Contributor

LeStahL commented Oct 28, 2020

Could you provide some information on your problem? Useful would be

  • steps to reproduce / minimal example
  • what did you try?

@waddlesplash
Copy link
Owner

CC @CodeforEvolution.

@denisgottardello
Copy link
Author

Please try it
http://www.denisgottardello.it/Test01.zip
On windows and Linux no problem.
On Mac OS X sometimes works, sometimes goes to crash.

@LeStahL
Copy link
Contributor

LeStahL commented Oct 28, 2020

You might be right - the request is made with a reference to a temporary (from your functions on_pushButton_clicked and on_pushButton_2_clicked), which is likely the cause for the crash. Those will return and the result of HexStringToByteArray(ui->lineEditNoteOn->text()) becomes invalid - and so does request.data.

Possible options:

  • Don't call sendSysEx on temporaries in your non-QMidi code.
  • Change QMidi_CoreMidi.cpp to alloc and copy the bytes, then use the completionProc of the request to free them again.

I do not have OS X available for testing, so I'm not the right person to implement such a thing ;)

@denisgottardello
Copy link
Author

Solved by changing the code
` MIDISysexSendRequest request;
request.bytesToSend = data.length();
request.complete = false;
request.completionProc = nullptr;
request.completionRefCon = nullptr;
request.data = (Byte *)data.constData();
request.destination = fMidiPtrs->destinationId;

MIDISendSysex(&request);`

to
` MIDISysexSendRequest *request= new MIDISysexSendRequest();
request->bytesToSend = data.length();
request->complete = false;
request->completionProc = nullptr;
request->completionRefCon = nullptr;
request->data = (Byte *)data.constData();
request->destination = fMidiPtrs->destinationId;

MIDISendSysex(request);`

When can I delete the object
request
?
On compile time I have a lot of warnings. Can I add as developer or there is anyone that will improve the code?

@LeStahL
Copy link
Contributor

LeStahL commented Oct 29, 2020

request->completionProc can be used to delete request again, after passing the pointer there with request->completionRefCon

refer to https://developer.apple.com/documentation/coremidi/midisysexsendrequest

completionProc will be called when you can delete the request.

@LeStahL
Copy link
Contributor

LeStahL commented Oct 29, 2020

Can I add as developer

@waddlesplash would have to answer that. :)

@waddlesplash
Copy link
Owner

You can submit a pull request with this, sure. It would be best if the warnings were fixed, and of course you need to write the callback to delete the request.

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

No branches or pull requests

3 participants