Skip to content
Permalink
Browse files
Added Mix_OpenAudioDevice() so you can specify the audio device to open
  • Loading branch information
slouken committed Jan 29, 2016
1 parent 4389068 commit f7e9925195c3943d02cdfd1cf4ff622a415ff19c
Showing with 150 additions and 94 deletions.
  1. +4 −0 CHANGES.txt
  2. +3 −0 SDL_mixer.h
  3. +17 −16 effect_position.c
  4. +65 −45 mixer.c
  5. +25 −0 mixer.h
  6. +25 −24 music.c
  7. +3 −2 native_midi/native_midi_mac.c
  8. +6 −5 native_midi/native_midi_macosx.c
  9. +2 −2 wavestream.c
@@ -1,3 +1,7 @@
2.0.1:
Juha Kuikka - Fri Jan 29 12:44:01 PST 2016
* Added Mix_OpenAudioDevice() so you can specify the audio device to open

2.0.1:
Sam Lantinga - Tue Jul 7 11:40:33 PDT 2015
* Added support for 'smpl' format loop points in music WAV files
@@ -133,6 +133,9 @@ typedef struct _Mix_Music Mix_Music;
/* Open the mixer with a certain audio format */
extern DECLSPEC int SDLCALL Mix_OpenAudio(int frequency, Uint16 format, int channels, int chunksize);

/* Open the mixer with specific device and certain audio format */
extern DECLSPEC int SDLCALL Mix_OpenAudioDevice(int frequency, Uint16 format, int channels, int chunksize, const char* device, int allowed_changes);

/* Dynamically change the number of channels managed by the mixer.
If decreasing the number of channels, the upper channels are
stopped.
@@ -31,8 +31,9 @@
#include <string.h>

#include "SDL.h"
#include "SDL_mixer.h"
#include "SDL_endian.h"
#include "SDL_mixer.h"
#include "mixer.h"

#define __MIX_INTERNAL_EFFECT__
#include "effects_internal.h"
@@ -1453,21 +1454,21 @@ int Mix_SetPanning(int channel, Uint8 left, Uint8 right)
if (f == NULL)
return(0);

SDL_LockAudio();
Mix_LockAudio();
args = get_position_arg(channel);
if (!args) {
SDL_UnlockAudio();
Mix_UnlockAudio();
return(0);
}

/* it's a no-op; unregister the effect, if it's registered. */
if ((args->distance_u8 == 255) && (left == 255) && (right == 255)) {
if (args->in_use) {
retval = _Mix_UnregisterEffect_locked(channel, f);
SDL_UnlockAudio();
Mix_UnlockAudio();
return(retval);
} else {
SDL_UnlockAudio();
Mix_UnlockAudio();
return(1);
}
}
@@ -1483,7 +1484,7 @@ int Mix_SetPanning(int channel, Uint8 left, Uint8 right)
retval=_Mix_RegisterEffect_locked(channel, f, _Eff_PositionDone, (void*)args);
}

SDL_UnlockAudio();
Mix_UnlockAudio();
return(retval);
}

@@ -1501,10 +1502,10 @@ int Mix_SetDistance(int channel, Uint8 distance)
if (f == NULL)
return(0);

SDL_LockAudio();
Mix_LockAudio();
args = get_position_arg(channel);
if (!args) {
SDL_UnlockAudio();
Mix_UnlockAudio();
return(0);
}

@@ -1514,10 +1515,10 @@ int Mix_SetDistance(int channel, Uint8 distance)
if ((distance == 255) && (args->left_u8 == 255) && (args->right_u8 == 255)) {
if (args->in_use) {
retval = _Mix_UnregisterEffect_locked(channel, f);
SDL_UnlockAudio();
Mix_UnlockAudio();
return(retval);
} else {
SDL_UnlockAudio();
Mix_UnlockAudio();
return(1);
}
}
@@ -1529,7 +1530,7 @@ int Mix_SetDistance(int channel, Uint8 distance)
retval = _Mix_RegisterEffect_locked(channel, f, _Eff_PositionDone, (void *) args);
}

SDL_UnlockAudio();
Mix_UnlockAudio();
return(retval);
}

@@ -1550,21 +1551,21 @@ int Mix_SetPosition(int channel, Sint16 angle, Uint8 distance)

angle = SDL_abs(angle) % 360; /* make angle between 0 and 359. */

SDL_LockAudio();
Mix_LockAudio();
args = get_position_arg(channel);
if (!args) {
SDL_UnlockAudio();
Mix_UnlockAudio();
return(0);
}

/* it's a no-op; unregister the effect, if it's registered. */
if ((!distance) && (!angle)) {
if (args->in_use) {
retval = _Mix_UnregisterEffect_locked(channel, f);
SDL_UnlockAudio();
Mix_UnlockAudio();
return(retval);
} else {
SDL_UnlockAudio();
Mix_UnlockAudio();
return(1);
}
}
@@ -1610,7 +1611,7 @@ int Mix_SetPosition(int channel, Sint16 angle, Uint8 distance)
retval = _Mix_RegisterEffect_locked(channel, f, _Eff_PositionDone, (void *) args);
}

SDL_UnlockAudio();
Mix_UnlockAudio();
return(retval);
}

0 comments on commit f7e9925

Please sign in to comment.