music.c
changeset 718 fb0562cc1559
parent 711 f40c5ac95b12
child 725 bdf7b8d20566
     1.1 --- a/music.c	Tue Jan 12 05:56:16 2016 -0800
     1.2 +++ b/music.c	Fri Jan 29 12:44:13 2016 -0800
     1.3 @@ -30,6 +30,7 @@
     1.4  #include "SDL_timer.h"
     1.5  
     1.6  #include "SDL_mixer.h"
     1.7 +#include "mixer.h"
     1.8  
     1.9  #ifdef CMD_MUSIC
    1.10  #include "music_cmd.h"
    1.11 @@ -185,9 +186,9 @@
    1.12  
    1.13  void Mix_HookMusicFinished(void (*music_finished)(void))
    1.14  {
    1.15 -    SDL_LockAudio();
    1.16 +    Mix_LockAudio();
    1.17      music_finished_hook = music_finished;
    1.18 -    SDL_UnlockAudio();
    1.19 +    Mix_UnlockAudio();
    1.20  }
    1.21  
    1.22  
    1.23 @@ -765,19 +766,19 @@
    1.24  {
    1.25      if ( music ) {
    1.26          /* Stop the music if it's currently playing */
    1.27 -        SDL_LockAudio();
    1.28 +        Mix_LockAudio();
    1.29          if ( music == music_playing ) {
    1.30              /* Wait for any fade out to finish */
    1.31              while ( music->fading == MIX_FADING_OUT ) {
    1.32 -                SDL_UnlockAudio();
    1.33 +                Mix_UnlockAudio();
    1.34                  SDL_Delay(100);
    1.35 -                SDL_LockAudio();
    1.36 +                Mix_LockAudio();
    1.37              }
    1.38              if ( music == music_playing ) {
    1.39                  music_internal_halt();
    1.40              }
    1.41          }
    1.42 -        SDL_UnlockAudio();
    1.43 +        Mix_UnlockAudio();
    1.44          switch (music->type) {
    1.45  #ifdef CMD_MUSIC
    1.46              case MUS_CMD:
    1.47 @@ -861,11 +862,11 @@
    1.48      if ( music ) {
    1.49          type = music->type;
    1.50      } else {
    1.51 -        SDL_LockAudio();
    1.52 +        Mix_LockAudio();
    1.53          if ( music_playing ) {
    1.54              type = music_playing->type;
    1.55          }
    1.56 -        SDL_UnlockAudio();
    1.57 +        Mix_UnlockAudio();
    1.58      }
    1.59      return(type);
    1.60  }
    1.61 @@ -1018,12 +1019,12 @@
    1.62      music->fade_steps = ms/ms_per_step;
    1.63  
    1.64      /* Play the puppy */
    1.65 -    SDL_LockAudio();
    1.66 +    Mix_LockAudio();
    1.67      /* If the current music is fading out, wait for the fade to complete */
    1.68      while ( music_playing && (music_playing->fading == MIX_FADING_OUT) ) {
    1.69 -        SDL_UnlockAudio();
    1.70 +        Mix_UnlockAudio();
    1.71          SDL_Delay(100);
    1.72 -        SDL_LockAudio();
    1.73 +        Mix_LockAudio();
    1.74      }
    1.75      music_active = 1;
    1.76      if (loops == 1) {
    1.77 @@ -1032,7 +1033,7 @@
    1.78      }
    1.79      music_loops = loops;
    1.80      retval = music_internal_play(music, position);
    1.81 -    SDL_UnlockAudio();
    1.82 +    Mix_UnlockAudio();
    1.83  
    1.84      return(retval);
    1.85  }
    1.86 @@ -1096,7 +1097,7 @@
    1.87  {
    1.88      int retval;
    1.89  
    1.90 -    SDL_LockAudio();
    1.91 +    Mix_LockAudio();
    1.92      if ( music_playing ) {
    1.93          retval = music_internal_position(position);
    1.94          if ( retval < 0 ) {
    1.95 @@ -1106,7 +1107,7 @@
    1.96          Mix_SetError("Music isn't playing");
    1.97          retval = -1;
    1.98      }
    1.99 -    SDL_UnlockAudio();
   1.100 +    Mix_UnlockAudio();
   1.101  
   1.102      return(retval);
   1.103  }
   1.104 @@ -1204,11 +1205,11 @@
   1.105          volume = SDL_MIX_MAXVOLUME;
   1.106      }
   1.107      music_volume = volume;
   1.108 -    SDL_LockAudio();
   1.109 +    Mix_LockAudio();
   1.110      if ( music_playing ) {
   1.111          music_internal_volume(music_volume);
   1.112      }
   1.113 -    SDL_UnlockAudio();
   1.114 +    Mix_UnlockAudio();
   1.115      return(prev_volume);
   1.116  }
   1.117  
   1.118 @@ -1289,14 +1290,14 @@
   1.119  }
   1.120  int Mix_HaltMusic(void)
   1.121  {
   1.122 -    SDL_LockAudio();
   1.123 +    Mix_LockAudio();
   1.124      if ( music_playing ) {
   1.125          music_internal_halt();
   1.126          if ( music_finished_hook ) {
   1.127              music_finished_hook();
   1.128          }
   1.129      }
   1.130 -    SDL_UnlockAudio();
   1.131 +    Mix_UnlockAudio();
   1.132  
   1.133      return(0);
   1.134  }
   1.135 @@ -1316,7 +1317,7 @@
   1.136          return 1;
   1.137      }
   1.138  
   1.139 -    SDL_LockAudio();
   1.140 +    Mix_LockAudio();
   1.141      if ( music_playing) {
   1.142                  int fade_steps = (ms + ms_per_step - 1)/ms_per_step;
   1.143                  if ( music_playing->fading == MIX_NO_FADING ) {
   1.144 @@ -1337,7 +1338,7 @@
   1.145          music_playing->fade_steps = fade_steps;
   1.146          retval = 1;
   1.147      }
   1.148 -    SDL_UnlockAudio();
   1.149 +    Mix_UnlockAudio();
   1.150  
   1.151      return(retval);
   1.152  }
   1.153 @@ -1346,11 +1347,11 @@
   1.154  {
   1.155      Mix_Fading fading = MIX_NO_FADING;
   1.156  
   1.157 -    SDL_LockAudio();
   1.158 +    Mix_LockAudio();
   1.159      if ( music_playing ) {
   1.160          fading = music_playing->fading;
   1.161      }
   1.162 -    SDL_UnlockAudio();
   1.163 +    Mix_UnlockAudio();
   1.164  
   1.165      return(fading);
   1.166  }
   1.167 @@ -1478,11 +1479,11 @@
   1.168  {
   1.169      int playing = 0;
   1.170  
   1.171 -    SDL_LockAudio();
   1.172 +    Mix_LockAudio();
   1.173      if ( music_playing ) {
   1.174          playing = music_loops || music_internal_playing();
   1.175      }
   1.176 -    SDL_UnlockAudio();
   1.177 +    Mix_UnlockAudio();
   1.178  
   1.179      return(playing);
   1.180  }