Skip to content

Commit

Permalink
Added Mix_OpenAudioDevice() so you can specify the audio device to open
Browse files Browse the repository at this point in the history
  • Loading branch information
slouken committed Jan 29, 2016
1 parent 4389068 commit f7e9925
Show file tree
Hide file tree
Showing 9 changed files with 150 additions and 94 deletions.
4 changes: 4 additions & 0 deletions CHANGES.txt
@@ -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
Expand Down
3 changes: 3 additions & 0 deletions SDL_mixer.h
Expand Up @@ -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.
Expand Down
33 changes: 17 additions & 16 deletions effect_position.c
Expand Up @@ -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"
Expand Down Expand Up @@ -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);
}
}
Expand All @@ -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);
}

Expand All @@ -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);
}

Expand All @@ -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);
}
}
Expand All @@ -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);
}

Expand All @@ -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);
}
}
Expand Down Expand Up @@ -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);
}

Expand Down

0 comments on commit f7e9925

Please sign in to comment.