blob: aa0d862908a12798b00396aaf6cfdff4ed714e80 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
#include "TZR_resource.h"
#include "TZR_sound.h"
#include "sdl_error.h"
#include <SDL2/SDL_mixer.h>
#include <stdio.h>
int
_TZR_PlaySound(const TZR_PlaySoundArgs *args)
{
if (args->id == 0) {
SDL_Log("args->id is 0");
return -1;
}
if (TZR_GetResourceType(args->id) != TZR_RES_SOUND) {
SDL_Log("%u isn't a sound", args->id);
return -1;
}
TZR_Sound *const sound = &TZR_GetResourcePointer(args->id)->sound;
#ifdef TZR_SOLOUD
const unsigned handle = Soloud_play(___tzr_soloud, sound->ptr);
Soloud_setVolume(___tzr_soloud, handle, args->volume);
Soloud_setLooping(___tzr_soloud, handle, args->loop);
#else
Mix_VolumeChunk(sound->ptr, args->volume * MIX_MAX_VOLUME);
if (Mix_PlayChannel(-1, sound->ptr, args->loop) < 0)
return sdl_error(-1);
#endif
return 0;
}
|