-
Notifications
You must be signed in to change notification settings - Fork 267
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
Haiku port #1490
base: master
Are you sure you want to change the base?
Haiku port #1490
Conversation
Ugh, seems they missed the proper Haiku check 🤷 |
That should fix it. |
For some reason tests 25 & 27 fail now… !? |
Oh, yeah… nothing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for submitting. However, this is not yet in a shape that is ready to accept. It needs some work. Comments below. Also, it would be very helpful to have a Haiku CI build in place, to avoid breaking stuff in the future.
Edit: Here's an example of how SDL coped with Haiku CI: libsdl-org/SDL#6739
include ( TestBigEndian ) | ||
test_big_endian ( WORDS_BIGENDIAN ) | ||
endif ( NOT HAIKU ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is that if-ed out?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The macros were broken on Haiku I believe.
# Haiku | ||
if ( HAIKU ) | ||
set ( CMAKE_CXX_FLAGS "-fpermissive") | ||
endif ( HAIKU ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is that needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIRC it was needed because the compiler would start spitting out errors for what was seemingly valid C++ code for non-permissive builds.
message ( "Haiku MediaKit support: yes" ) | ||
else ( HAIKU_SUPPORT ) | ||
message ( "Haiku MediaKit support: no" ) | ||
endif ( HAIKU_SUPPORT ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is redundant to above and should be removed.
@@ -94,6 +94,8 @@ option ( enable-dsound "compile DirectSound support (if it is available)" on ) | |||
option ( enable-wasapi "compile Windows WASAPI support (if it is available)" on ) | |||
option ( enable-waveout "compile Windows WaveOut support (if it is available)" on ) | |||
option ( enable-winmidi "compile Windows MIDI support (if it is available)" on ) | |||
option ( enable-haiku "compile Haiku MediaKit audio support (if it is available)" on ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
option ( enable-haiku "compile Haiku MediaKit audio support (if it is available)" on ) | |
option ( enable-mediakit "compile Haiku MediaKit audio support (if it is available)" on ) |
IMO, the naming is unfortunate. enable-haiku
would enable the audio driver and not support for Haiku in general. I'd suggest to rename it mediakit
.
@@ -94,6 +94,8 @@ option ( enable-dsound "compile DirectSound support (if it is available)" on ) | |||
option ( enable-wasapi "compile Windows WASAPI support (if it is available)" on ) | |||
option ( enable-waveout "compile Windows WaveOut support (if it is available)" on ) | |||
option ( enable-winmidi "compile Windows MIDI support (if it is available)" on ) | |||
option ( enable-haiku "compile Haiku MediaKit audio support (if it is available)" on ) | |||
option ( enable-midikit2 "compile Haiku MidiKit2 MIDI support (if it is available)" on ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both of these cmake options should be wraped inside a if ( CMAKE_SYSTEM MATCHES "Haiku" )
, as we do it below, since they are platform-specific options.
driver->m_consumer->Release(); | ||
delete_fluid_midi_parser(driver->parser); | ||
FLUID_FREE(driver); | ||
return NULL; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're leaking driver->m_consumer
here. Pls. avoid these manual partial cleanup logic and instead, properly do the cleanup in delete_fluid_midikit2_driver
driver->m_consumer->Unregister(); | ||
driver->m_consumer->Release(); | ||
delete_fluid_midi_parser(driver->parser); | ||
FLUID_FREE(driver); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're leaking driver->m_consumer
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Release() will delete it by itself as it's ref-counted. I'll add a comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But how is it supposed to know that m_consumer
(an instance of fluid_midikit2_input
) was allocated via new
? And not via new[]
? And not on the stack either?? I have no doubt that Release()
will cleanup the internal state of the BMidiEndpoint
object (i.e. all the things that were ref-counted allocated in its constructor). But it surely cannot release the memory of the derived fluid_midikit2_input
, esp. because fluid_midikit2_input
currently has a non-virtual destructor.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Meanwhile I discovered the implementation of BMidiEndpoint: https://github.com/haiku/haiku/blob/c8252422b8b3a2a293fb3be039eec6f87b30b467/src/kits/midi2/MidiEndpoint.cpp#L118-L135
So it turns out that they do make a hard call to delete this
. If you used new[]
to allocate the endpoint this will cause undefined behavior. And if you stack allocated this you might get a log message: https://github.com/haiku/haiku/blob/c8252422b8b3a2a293fb3be039eec6f87b30b467/src/kits/midi2/MidiEndpoint.cpp#L258-L260
Poor implementation, IMO. But still: You must declare an empty destructor for fluid_midikit2_input
and mark it virtual
to make this cleanup work as intended.
char midiSettings[PATH_MAX] = ""; | ||
if (find_directory(B_USER_SETTINGS_DIRECTORY, -1, false, midiSettings, sizeof(midiSettings)) == B_OK) { | ||
strcat(midiSettings, "/Media/midi_settings"); | ||
if( access( midiSettings, F_OK ) != -1 ) { | ||
FILE *inFile = fopen(midiSettings, "rt"); | ||
if (inFile) { | ||
char sf2file[PATH_MAX]; | ||
if (fscanf(inFile, "# Midi\n\tsoundfont \"%[^\"]\"", sf2file)) { | ||
fluid_settings_register_str(settings, "synth.default-soundfont", sf2file, 0); | ||
} | ||
fclose(inFile); | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does that do??
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seemingly fetches the first path to the sound fonts from the Media preferences, as it is used internally.
|
Well I didn't write most of this code, just trying to upstream before it bit-rots, so I'll have to figure it out as well.
Yes, though our cross-compiler is only built as part of our build system, but there are a few solutions now. |
poke @Cacodemon345 @threedeyes :-) |
I can't directly push to the branch (and I don't have a working Haiku OS installation at the moment either at the moment to help out with the changes). |
It seems we had patches getting dust. I rebased them and dropped stuff that didn't seem needed anymore.
All tests pass though I haven't tried the audio or MIDI outputs, but the code worked in previous versions.