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

CoreMIDI MIDI Driver #17569

Merged
merged 1 commit into from
Feb 15, 2025
Merged

Conversation

JoeMatt
Copy link
Contributor

@JoeMatt JoeMatt commented Feb 15, 2025

Guidelines

  1. Rebase before opening a pull request
  2. If you are sending several unrelated fixes or features, use a branch and a separate pull request for each
  3. If possible try squashing everything in a single commit. This is particularly beneficial in the case of feature merges since it allows easy bisecting when a problem arises

Description

Adds a CoreMIDI driver in raw C.

I wasn't sure how to properly impliment it into the build, since I use my own frontend, but I tried my best to figure it out. Only issue was if I should include it in configuration.c et al;

Related Issues

#12146

Related Pull Requests

[Any other PRs from related repositories that might be needed for this pull request to work]

Reviewers

[If possible @mention all the people that should review your pull request]

Signed-off-by: Joseph Mattiello <git@joemattiello.com>

CoreMIDI install into build

Signed-off-by: Joseph Mattiello <git@joemattiello.com>
Copy link
Contributor

@viachaslavic viachaslavic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How will be set HAVE_COREMIDI?

size_t length = packet->length;
const MIDITimeStamp timestamp = packet->timeStamp;

while (length > 0) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll take care of it later

coremidi_queue_t input_queue; ///< Queue for incoming MIDI events
} coremidi_t;

/// Write to the queue
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ItemCount count = MIDIGetNumberOfDestinations();
union string_list_elem_attr attr = {0};

for (ItemCount i = 0; i < count; i++) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Incompatible with c89

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... maybe but this code only ever gets built with Xcode and Apple clang, which defaults to gnu99, though on macOS we change that to c99. There's a ton of other places throughout the Apple-only code that does not follow c89.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll fix it up later, we can still merge it as is.

// Create a MIDIPacketList with sufficient buffer size
char packetListBuffer[sizeof(MIDIPacketList) + sizeof(MIDIPacket) + event->data_size];
MIDIPacketList *packetList = (MIDIPacketList *)packetListBuffer;
MIDIPacket *packet = MIDIPacketListInit(packetList);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this an deprecated API? Maybe you can take care of the version restrictions?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deprecated but not removed, and we support versions prior to when the new API was added. Again, there are a bunch of places where we use "deprecated" APIs that still work on the newer versions because we want to maintain compatibility with older versions, so many so that I've even turned off the deprecation warnings during the build.

@LibretroAdmin LibretroAdmin merged commit eb2928e into libretro:master Feb 15, 2025
30 checks passed
@viachaslavic
Copy link
Contributor

viachaslavic commented Feb 15, 2025

I wasn't sure how to properly impliment it into the build, since I use my own frontend, but I tried my best to figure it out. Only issue was if I should include it in configuration.c et al;

Probably you can use coreaudio implementation as a clue:

grep -rn COREAUDIO --exclude-dir=intl/ ./ intl/msg_hash_us.h

Something like check_lib '' COREMIDI "-framework CoreMIDI" in qb/config.libs.sh , explicitly add to OTHER_CFLAGS in pkg/apple/BaseConfig.xcconfig and so on. @warmenhoven please correct me if I'm wrong.

@warmenhoven
Copy link
Contributor

Yeah it needs to get set in BaseConfig.xcconfig. The libraries and frameworks aren't typically set from there though (though maybe they should be), they're set inside the Xcode project files. I'll take care of all that.

@JoeMatt
Copy link
Contributor Author

JoeMatt commented Feb 15, 2025

Thanks for taking care of this for me!

And yes, I used the "deprecated" api's since I know RA likes to support older OSes. I believe the deprecation was only as recent as ios14.

Thanks again for the merge and fixing it up for me, cheers,
Joe

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.

4 participants