Skip to content

Commit 486ed38

Browse files
Merge pull request #17 from suve/update-sdl2_mixer-to-2.0.4
Update SDL2_mixer.pas to 2.0.4
2 parents 303be90 + 890db2e commit 486ed38

File tree

1 file changed

+52
-28
lines changed

1 file changed

+52
-28
lines changed

sdl2_mixer.pas

Lines changed: 52 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ interface
6565
const
6666
SDL_MIXER_MAJOR_VERSION = 2;
6767
SDL_MIXER_MINOR_VERSION = 0;
68-
SDL_MIXER_PATCHLEVEL = 0;
68+
SDL_MIXER_PATCHLEVEL = 4;
6969

7070
{* This macro can be used to fill a version structure with the compile-time
7171
* version of the SDL_mixer library.
@@ -89,12 +89,17 @@ function Mix_Linked_Version: PSDL_Version cdecl; external MIX_LibName {$IFDEF DE
8989
const
9090
MIX_INIT_FLAC = $00000001;
9191
MIX_INIT_MOD = $00000002;
92-
MIX_INIT_MODPLUG = $00000004;
9392
MIX_INIT_MP3 = $00000008;
9493
MIX_INIT_OGG = $00000010;
94+
MIX_INIT_MID = $00000020;
95+
MIX_INIT_OPUS = $00000040;
96+
97+
{ // Removed in SDL2_mixer 2.0.2
98+
MIX_INIT_MODPLUG = $00000004;
9599
MIX_INIT_FLUIDSYNTH = $00000020;
100+
}
96101
type
97-
TMIX_InitFlags = Byte;
102+
TMIX_InitFlags = Integer;
98103

99104
{* Loads dynamic libraries and prepares them for use. Flags should be
100105
one or more flags from MIX_InitFlags OR'd together.
@@ -116,7 +121,7 @@ procedure Mix_Quit() cdecl; external MIX_LibName {$IFDEF DELPHI} {$IFDEF MACOS}
116121
const
117122
MIX_DEFAULT_FREQUENCY = 22050;
118123
MIX_DEFAULT_CHANNELS = 2;
119-
MIX_MAX_VOLUME = 128; {* Volume of a chunk *}
124+
MIX_MAX_VOLUME = SDL2.SDL_MIX_MAXVOLUME; {* Volume of a chunk *}
120125

121126
{$IFDEF FPC}
122127
{$IF DEFINED(ENDIAN_LITTLE)}
@@ -142,16 +147,19 @@ TMix_Chunk = record
142147
type
143148
TMix_Fading = (MIX_NO_FADING, MIX_FADING_OUT, MIX_FADING_IN);
144149

145-
TMix_MusicType = (MUS_NONE,
146-
MUS_CMD,
147-
MUS_WAV,
148-
MUS_MOD,
149-
MUS_MID,
150-
MUS_OGG,
151-
MUS_MP3,
152-
MUS_MP3_MAD,
153-
MUS_FLAC,
154-
MUS_MODPLUG);
150+
TMix_MusicType = (
151+
MUS_NONE,
152+
MUS_CMD,
153+
MUS_WAV,
154+
MUS_MOD,
155+
MUS_MID,
156+
MUS_OGG,
157+
MUS_MP3,
158+
MUS_MP3_MAD_UNUSED,
159+
MUS_FLAC,
160+
MUS_MODPLUG_UNUSED,
161+
MUS_OPUS
162+
);
155163

156164
{* The internal format for a music chunk interpreted via mikmod *}
157165
PMix_Music = ^TMix_Music;
@@ -213,10 +221,18 @@ procedure Mix_FreeMusic(music: PMix_Music) cdecl; external MIX_LibName {$IFDEF D
213221
These return values are static, read-only data; do not modify or free it.
214222
The pointers remain valid until you call Mix_CloseAudio().
215223
*}
216-
function Mix_GetNumChunkDecoders: Integer cdecl; external MIX_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_MIX_GetNumChunkDecoders' {$ENDIF} {$ENDIF};
217-
function Mix_GetChunkDecoder(index: Integer): PAnsiChar cdecl; external MIX_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_MIX_GetChunkDecoder' {$ENDIF} {$ENDIF};
218-
function Mix_GetNumMusicDecoders: Integer cdecl; external MIX_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_MIX_GetNumMusicDecoders' {$ENDIF} {$ENDIF};
219-
function Mix_GetMusicDecoder(index: Integer): PAnsiChar cdecl; external MIX_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_MIX_GetMusicDecoder' {$ENDIF} {$ENDIF};
224+
function Mix_GetNumChunkDecoders: Integer cdecl;
225+
external MIX_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_MIX_GetNumChunkDecoders' {$ENDIF} {$ENDIF};
226+
function Mix_GetChunkDecoder(index: Integer): PAnsiChar cdecl;
227+
external MIX_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_MIX_GetChunkDecoder' {$ENDIF} {$ENDIF};
228+
function Mix_HasChunkDecoder(const name: PAnsiChar): TSDL_Bool cdecl;
229+
external MIX_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_MIX_HasChunkDecoder' {$ENDIF} {$ENDIF};
230+
function Mix_GetNumMusicDecoders: Integer cdecl;
231+
external MIX_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_MIX_GetNumMusicDecoders' {$ENDIF} {$ENDIF};
232+
function Mix_GetMusicDecoder(index: Integer): PAnsiChar cdecl;
233+
external MIX_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_MIX_GetMusicDecoder' {$ENDIF} {$ENDIF};
234+
function Mix_HasMusicDecoder(const name: PAnsiChar): TSDL_Bool cdecl;
235+
external MIX_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_MIX_HasMusicDecoder' {$ENDIF} {$ENDIF};
220236

221237
{* Find out the music format of a mixer music, or the currently playing
222238
music, if 'music' is NULL.
@@ -228,7 +244,7 @@ function Mix_GetMusicType(music: TMix_Music): TMix_MusicType cdecl; external MIX
228244
or add a custom mixer filter for the stream data.
229245
*}
230246
type
231-
TMix_Func = procedure(udata: Pointer; stream: PUInt8; len: Integer);
247+
TMix_Func = procedure(udata: Pointer; stream: PUInt8; len: Integer) cdecl;
232248

233249
procedure Mix_SetPostMix(func: TMix_Func; arg: Pointer) cdecl; external MIX_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_MIX_SetPostMix' {$ENDIF} {$ENDIF};
234250

@@ -237,12 +253,13 @@ procedure Mix_SetPostMix(func: TMix_Func; arg: Pointer) cdecl; external MIX_LibN
237253
*}
238254
procedure Mix_HookMusic(func: TMix_Func; arg: Pointer) cdecl; external MIX_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_MIX_HookMusic' {$ENDIF} {$ENDIF};
239255

240-
{* Add your own callback when the music has finished playing.
241-
This callback is only called if the music finishes naturally.
256+
{* Add your own callback when the music has finished playing
257+
* or when it is stopped from a call to Mix_HaltMusic.
242258
*}
243259
type
244260
PMix_Music_Finished = ^TMix_Music_Finished;
245-
TMix_Music_Finished = procedure();
261+
TMix_Music_Finished = procedure() cdecl;
262+
246263
procedure Mix_HookMusicFinished(music_finished: PMix_Music_Finished) cdecl; external MIX_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_MIX_HookMusicFinished' {$ENDIF} {$ENDIF};
247264

248265
{* Get a pointer to the user data for the current music hook *}
@@ -257,7 +274,8 @@ function Mix_GetMusicHookData: Pointer cdecl; external MIX_LibName {$IFDEF DELPH
257274
* before calling your callback.
258275
*}
259276
type
260-
TMix_Channel_Finished = procedure(channel: Integer);
277+
TMix_Channel_Finished = procedure(channel: Integer) cdecl;
278+
261279
procedure Mix_ChannelFinished(channel_finished: TMix_Channel_Finished) cdecl; external MIX_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_MIX_ChannelFinished' {$ENDIF} {$ENDIF};
262280

263281
{* Special Effects API by ryan c. gordon. (icculus@icculus.org) *}
@@ -282,7 +300,7 @@ procedure Mix_ChannelFinished(channel_finished: TMix_Channel_Finished) cdecl; ex
282300
* DO NOT EVER call SDL_LockAudio() from your callback function!
283301
*}
284302
type
285-
TMix_EffectFunc_t = procedure(chan: Integer; stream: Pointer; len: Integer; udata: Pointer);
303+
TMix_EffectFunc_t = procedure(chan: Integer; stream: Pointer; len: Integer; udata: Pointer) cdecl;
286304

287305
{*
288306
* This is a callback that signifies that a channel has finished all its
@@ -294,7 +312,7 @@ procedure Mix_ChannelFinished(channel_finished: TMix_Channel_Finished) cdecl; ex
294312
* DO NOT EVER call SDL_LockAudio() from your callback function!
295313
*}
296314
type
297-
TMix_EffectDone_t = procedure(chan: Integer; udata: Pointer);
315+
TMix_EffectDone_t = procedure(chan: Integer; udata: Pointer) cdecl;
298316

299317
{* Register a special effect function. At mixing time, the channel data is
300318
* copied into a buffer and passed through each registered effect function.
@@ -615,8 +633,8 @@ function Mix_PausedMusic: Integer cdecl; external MIX_LibName {$IFDEF DELPHI} {$
615633
{* Set the current position in the music stream.
616634
This returns 0 if successful, or -1 if it failed or isn't implemented.
617635
This function is only implemented for MOD music formats (set pattern
618-
order number) and for OGG, FLAC, MP3_MAD, and MODPLUG music (set
619-
position in seconds), at the moment.
636+
order number) and for OGG, FLAC, MP3_MAD, MP3_MPG and MODPLUG music
637+
(set position in seconds), at the moment.
620638
*}
621639
function Mix_SetMusicPosition(position: Double): Integer cdecl; external MIX_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_MIX_SetMusicPosition' {$ENDIF} {$ENDIF};
622640

@@ -638,7 +656,7 @@ function Mix_SetSoundFonts(paths: PAnsiChar): Integer cdecl; external MIX_LibNam
638656
function Mix_GetSoundFonts: PAnsiChar cdecl; external MIX_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_MIX_GetSoundFonts' {$ENDIF} {$ENDIF};
639657

640658
type
641-
TMix_SoundFunc = function(c: PAnsiChar; p: Pointer): Integer;
659+
TMix_SoundFunc = function(c: PAnsiChar; p: Pointer): Integer cdecl;
642660

643661
function Mix_EachSoundFont(func: TMix_SoundFunc; data: Pointer): Integer cdecl; external MIX_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_MIX_EachSoundFont' {$ENDIF} {$ENDIF};
644662

@@ -653,6 +671,7 @@ procedure Mix_CloseAudio cdecl; external MIX_LibName {$IFDEF DELPHI} {$IFDEF MAC
653671
{* We'll use SDL for reporting errors *}
654672
function Mix_SetError(const fmt: PAnsiChar): SInt32; cdecl;
655673
function Mix_GetError: PAnsiChar; cdecl;
674+
procedure Mix_ClearError(); cdecl;
656675

657676
implementation
658677

@@ -693,4 +712,9 @@ function Mix_GetError: PAnsiChar; cdecl;
693712
Result := SDL_GetError();
694713
end;
695714

715+
procedure Mix_ClearError; cdecl;
716+
begin
717+
SDL_ClearError()
718+
end;
719+
696720
end.

0 commit comments

Comments
 (0)