Browse Source

iOS/macOS interface matching

Pal Lockheart 7 years ago
parent
commit
c217f24b46
2 changed files with 13 additions and 12 deletions
  1. 6 6
      ios/SDLPal/SDLPal/native_midi.m
  2. 7 6
      macos/native_midi_macosx.c

+ 6 - 6
ios/SDLPal/SDLPal/native_midi.m

@@ -93,7 +93,7 @@ void native_midi_freesong(NativeMidiSong *song)
 {
     if (song != NULL)
     {
-        native_midi_stop();
+        native_midi_stop(song);
         if (currentsong == song)
             currentsong = NULL;
         free(song);
@@ -104,9 +104,9 @@ void native_midi_freesong(NativeMidiSong *song)
     }
 }
 
-void native_midi_start(NativeMidiSong *song)
+void native_midi_start(NativeMidiSong *song, int looping)
 {
-    native_midi_stop();
+    native_midi_stop(song);
     if (song != NULL)
     {
         currentsong = song;
@@ -114,7 +114,7 @@ void native_midi_start(NativeMidiSong *song)
         [midiPlayer play:^(){
             if( currentsong ) {
                 midiPlayer.currentPosition = 0;
-                native_midi_start(currentsong);
+                native_midi_start(currentsong,looping);
             }
         }];
     }
@@ -133,11 +133,11 @@ int native_midi_active()
     return currentsong ? currentsong->playing : 0;
 }
 
-void native_midi_setvolume(int volume)
+void native_midi_setvolume(NativeMidiSong *song, int volume)
 {
 }
 
-const char *native_midi_error(void)
+const char *native_midi_error(NativeMidiSong *song)
 {
     return "";  /* !!! FIXME */
 }

+ 7 - 6
macos/native_midi_macosx.c

@@ -41,6 +41,7 @@ struct _NativeMidiSong
     MusicSequence sequence;
     MusicTimeStamp endTime;
     AudioUnit audiounit;
+    int Loopinng;
 };
 
 static NativeMidiSong *currentsong = NULL;
@@ -245,7 +246,7 @@ void native_midi_freesong(NativeMidiSong *song)
     }
 }
 
-void native_midi_start(NativeMidiSong *song)
+void native_midi_start(NativeMidiSong *song, int looping)
 {
     int vol;
 
@@ -265,7 +266,7 @@ void native_midi_start(NativeMidiSong *song)
 
     vol = latched_volume;
     latched_volume++;  /* just make this not match. */
-    native_midi_setvolume(vol);
+    native_midi_setvolume(song,vol);
 
     SDL_LockAudio();
     SDL_PauseAudio(0);
@@ -294,20 +295,20 @@ int native_midi_active()
             (currentTime >= kMusicTimeStamp_EndOfTrack));
 }
 
-void native_midi_setvolume(int volume)
+void native_midi_setvolume(NativeMidiSong *song, int volume)
 {
     if (latched_volume == volume)
         return;
 
     latched_volume = volume;
-    if ((currentsong) && (currentsong->audiounit)) {
+    if ((song) && (song->audiounit)) {
         const float floatvol = ((float) volume) / ((float) 128);
-        AudioUnitSetParameter(currentsong->audiounit, kHALOutputParam_Volume,
+        AudioUnitSetParameter(song->audiounit, kHALOutputParam_Volume,
                               kAudioUnitScope_Global, 0, floatvol, 0);
     }
 }
 
-const char *native_midi_error(void)
+const char *native_midi_error(NativeMidiSong *song)
 {
     return "";  /* !!! FIXME */
 }