Advertisement
Guest User

Midi kit no more int32

a guest
Dec 7th, 2014
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 4.04 KB | None | 0 0
  1. From 161ac80da861d36d628eea8e2477c65a8b6ec281 Mon Sep 17 00:00:00 2001
  2. From: Alexander von Gluck IV <kallisti5@unixzen.com>
  3. Date: Sun, 7 Dec 2014 17:26:13 +0000
  4. Subject: [PATCH] midi kit: API adjustment to use void*
  5.  
  6. * The midi kit passes around 32-bit int's
  7.   for pointers which doesn't work properly
  8.   on 64-bit systems resulting in a crash of
  9.   midi applications.
  10. * Introduce a new void* interface which will
  11.   replace the int32 interface when we no longer
  12.   have to worry about ABI compatibility.
  13. ---
  14. headers/os/midi/MidiStore.h              |  2 +-
  15.  headers/os/midi/MidiSynthFile.h          | 13 +++++++++++++
  16.  src/apps/midiplayer/MidiPlayerWindow.cpp |  7 ++++---
  17.  src/apps/midiplayer/MidiPlayerWindow.h   |  2 +-
  18.  src/kits/midi/MidiSynthFile.cpp          | 20 +++++++++++++++++++-
  19.  5 files changed, 38 insertions(+), 6 deletions(-)
  20.  
  21. diff --git a/headers/os/midi/MidiStore.h b/headers/os/midi/MidiStore.h
  22. index e519a27..0db934b 100644
  23. --- a/headers/os/midi/MidiStore.h
  24. +++ b/headers/os/midi/MidiStore.h
  25. @@ -123,7 +123,7 @@ private:
  26.  
  27.     bool* fInstruments;
  28.     synth_file_hook fHookFunc;
  29. -   int32 fHookArg;
  30. +   void* fHookArg;
  31.     bool fLooping;
  32.     bool fPaused;
  33.     bool fFinished;
  34. diff --git a/headers/os/midi/MidiSynthFile.h b/headers/os/midi/MidiSynthFile.h
  35. index ffd0cb3..d0aab41 100644
  36. --- a/headers/os/midi/MidiSynthFile.h
  37. +++ b/headers/os/midi/MidiSynthFile.h
  38. @@ -6,7 +6,14 @@
  39.  #include <MidiSynth.h>
  40.  #include <Entry.h>
  41.  
  42. +#if __GNUC__ < 4
  43. +// BeOS legacy compat, remove me post R1
  44.  typedef void (*synth_file_hook)(int32 arg);
  45. +typedef void (*synth_file_hook_new)(void* arg);
  46. +#else
  47. +typedef void (*synth_file_hook)(void* arg);
  48. +#endif
  49. +
  50.  
  51.  class BMidiStore;
  52.  
  53. @@ -33,7 +40,13 @@ public:
  54.  
  55.     status_t GetPatches(int16* pArray768, int16* pReturnedCount) const;
  56.  
  57. +#if __GNUC__ < 4
  58. +   // BeOS legacy compat, remove me post R1
  59.     void SetFileHook(synth_file_hook pSongHook, int32 arg);
  60. +   void SetFileHook(synth_file_hook_new pSongHook, void* arg);
  61. +#else
  62. +   void SetFileHook(synth_file_hook pSongHook, void* arg);
  63. +#endif
  64.  
  65.     bool IsFinished(void) const;
  66.  
  67. diff --git a/src/apps/midiplayer/MidiPlayerWindow.cpp b/src/apps/midiplayer/MidiPlayerWindow.cpp
  68. index ed82038..6506865 100644
  69. --- a/src/apps/midiplayer/MidiPlayerWindow.cpp
  70. +++ b/src/apps/midiplayer/MidiPlayerWindow.cpp
  71. @@ -406,7 +406,7 @@ void
  72.  MidiPlayerWindow::StartSynth()
  73.  {
  74.     fMidiSynthFile.Start();
  75. -   fMidiSynthFile.SetFileHook(_StopHook, (int32)(addr_t)this);
  76. +   fMidiSynthFile.SetFileHook(_StopHook, (void*)this);
  77.     fIsPlaying = true;
  78.  }
  79.  
  80. @@ -422,9 +422,10 @@ MidiPlayerWindow::StopSynth()
  81.  
  82.  
  83.  void
  84. -MidiPlayerWindow::_StopHook(int32 arg)
  85. +MidiPlayerWindow::_StopHook(void* arg)
  86.  {
  87. -   ((MidiPlayerWindow*)(addr_t)arg)->StopHook();
  88. +   if (arg != NULL)
  89. +       ((MidiPlayerWindow*)arg)->StopHook();
  90.  }
  91.  
  92.  
  93. diff --git a/src/apps/midiplayer/MidiPlayerWindow.h b/src/apps/midiplayer/MidiPlayerWindow.h
  94. index 2db5db5..c5dfcd0 100644
  95. --- a/src/apps/midiplayer/MidiPlayerWindow.h
  96. +++ b/src/apps/midiplayer/MidiPlayerWindow.h
  97. @@ -73,7 +73,7 @@ private:
  98.     void StartSynth();
  99.     void StopSynth();
  100.  
  101. -   static void _StopHook(int32 arg);
  102. +   static void _StopHook(void* arg);
  103.     void StopHook();
  104.  
  105.     void OnPlayStop();
  106. diff --git a/src/kits/midi/MidiSynthFile.cpp b/src/kits/midi/MidiSynthFile.cpp
  107. index 43e961d..51a96f6 100644
  108. --- a/src/kits/midi/MidiSynthFile.cpp
  109. +++ b/src/kits/midi/MidiSynthFile.cpp
  110. @@ -139,12 +139,30 @@ BMidiSynthFile::GetPatches(
  111.  }
  112.  
  113.  
  114. +#if __GNUC__ < 4
  115. +// BeOS ABI Compat, Remove me post-R1
  116.  void
  117. -BMidiSynthFile::SetFileHook(synth_file_hook pSongHook, int32 arg)
  118. +BMidiSynthFile::SetFileHook(synth_file_hook pSongHook, int32* arg)
  119. +{
  120. +   fStore->fHookFunc = pSongHook;
  121. +   fStore->fHookArg = (void*)arg;
  122. +}
  123. +
  124. +
  125. +void
  126. +BMidiSynthFile::SetFileHook(synth_file_hook_new pSongHook, void* arg)
  127. +{
  128. +   fStore->fHookFunc = pSongHook;
  129. +   fStore->fHookArg = arg;
  130. +}
  131. +#else
  132. +void
  133. +BMidiSynthFile::SetFileHook(synth_file_hook pSongHook, void* arg)
  134.  {
  135.     fStore->fHookFunc = pSongHook;
  136.     fStore->fHookArg = arg;
  137.  }
  138. +#endif
  139.  
  140.  
  141.  bool
  142. --
  143. 1.8.3.4
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement