Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- From 161ac80da861d36d628eea8e2477c65a8b6ec281 Mon Sep 17 00:00:00 2001
- From: Alexander von Gluck IV <kallisti5@unixzen.com>
- Date: Sun, 7 Dec 2014 17:26:13 +0000
- Subject: [PATCH] midi kit: API adjustment to use void*
- * The midi kit passes around 32-bit int's
- for pointers which doesn't work properly
- on 64-bit systems resulting in a crash of
- midi applications.
- * Introduce a new void* interface which will
- replace the int32 interface when we no longer
- have to worry about ABI compatibility.
- ---
- headers/os/midi/MidiStore.h | 2 +-
- headers/os/midi/MidiSynthFile.h | 13 +++++++++++++
- src/apps/midiplayer/MidiPlayerWindow.cpp | 7 ++++---
- src/apps/midiplayer/MidiPlayerWindow.h | 2 +-
- src/kits/midi/MidiSynthFile.cpp | 20 +++++++++++++++++++-
- 5 files changed, 38 insertions(+), 6 deletions(-)
- diff --git a/headers/os/midi/MidiStore.h b/headers/os/midi/MidiStore.h
- index e519a27..0db934b 100644
- --- a/headers/os/midi/MidiStore.h
- +++ b/headers/os/midi/MidiStore.h
- @@ -123,7 +123,7 @@ private:
- bool* fInstruments;
- synth_file_hook fHookFunc;
- - int32 fHookArg;
- + void* fHookArg;
- bool fLooping;
- bool fPaused;
- bool fFinished;
- diff --git a/headers/os/midi/MidiSynthFile.h b/headers/os/midi/MidiSynthFile.h
- index ffd0cb3..d0aab41 100644
- --- a/headers/os/midi/MidiSynthFile.h
- +++ b/headers/os/midi/MidiSynthFile.h
- @@ -6,7 +6,14 @@
- #include <MidiSynth.h>
- #include <Entry.h>
- +#if __GNUC__ < 4
- +// BeOS legacy compat, remove me post R1
- typedef void (*synth_file_hook)(int32 arg);
- +typedef void (*synth_file_hook_new)(void* arg);
- +#else
- +typedef void (*synth_file_hook)(void* arg);
- +#endif
- +
- class BMidiStore;
- @@ -33,7 +40,13 @@ public:
- status_t GetPatches(int16* pArray768, int16* pReturnedCount) const;
- +#if __GNUC__ < 4
- + // BeOS legacy compat, remove me post R1
- void SetFileHook(synth_file_hook pSongHook, int32 arg);
- + void SetFileHook(synth_file_hook_new pSongHook, void* arg);
- +#else
- + void SetFileHook(synth_file_hook pSongHook, void* arg);
- +#endif
- bool IsFinished(void) const;
- diff --git a/src/apps/midiplayer/MidiPlayerWindow.cpp b/src/apps/midiplayer/MidiPlayerWindow.cpp
- index ed82038..6506865 100644
- --- a/src/apps/midiplayer/MidiPlayerWindow.cpp
- +++ b/src/apps/midiplayer/MidiPlayerWindow.cpp
- @@ -406,7 +406,7 @@ void
- MidiPlayerWindow::StartSynth()
- {
- fMidiSynthFile.Start();
- - fMidiSynthFile.SetFileHook(_StopHook, (int32)(addr_t)this);
- + fMidiSynthFile.SetFileHook(_StopHook, (void*)this);
- fIsPlaying = true;
- }
- @@ -422,9 +422,10 @@ MidiPlayerWindow::StopSynth()
- void
- -MidiPlayerWindow::_StopHook(int32 arg)
- +MidiPlayerWindow::_StopHook(void* arg)
- {
- - ((MidiPlayerWindow*)(addr_t)arg)->StopHook();
- + if (arg != NULL)
- + ((MidiPlayerWindow*)arg)->StopHook();
- }
- diff --git a/src/apps/midiplayer/MidiPlayerWindow.h b/src/apps/midiplayer/MidiPlayerWindow.h
- index 2db5db5..c5dfcd0 100644
- --- a/src/apps/midiplayer/MidiPlayerWindow.h
- +++ b/src/apps/midiplayer/MidiPlayerWindow.h
- @@ -73,7 +73,7 @@ private:
- void StartSynth();
- void StopSynth();
- - static void _StopHook(int32 arg);
- + static void _StopHook(void* arg);
- void StopHook();
- void OnPlayStop();
- diff --git a/src/kits/midi/MidiSynthFile.cpp b/src/kits/midi/MidiSynthFile.cpp
- index 43e961d..51a96f6 100644
- --- a/src/kits/midi/MidiSynthFile.cpp
- +++ b/src/kits/midi/MidiSynthFile.cpp
- @@ -139,12 +139,30 @@ BMidiSynthFile::GetPatches(
- }
- +#if __GNUC__ < 4
- +// BeOS ABI Compat, Remove me post-R1
- void
- -BMidiSynthFile::SetFileHook(synth_file_hook pSongHook, int32 arg)
- +BMidiSynthFile::SetFileHook(synth_file_hook pSongHook, int32* arg)
- +{
- + fStore->fHookFunc = pSongHook;
- + fStore->fHookArg = (void*)arg;
- +}
- +
- +
- +void
- +BMidiSynthFile::SetFileHook(synth_file_hook_new pSongHook, void* arg)
- +{
- + fStore->fHookFunc = pSongHook;
- + fStore->fHookArg = arg;
- +}
- +#else
- +void
- +BMidiSynthFile::SetFileHook(synth_file_hook pSongHook, void* arg)
- {
- fStore->fHookFunc = pSongHook;
- fStore->fHookArg = arg;
- }
- +#endif
- bool
- --
- 1.8.3.4
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement