mirror of
https://github.com/XProger/OpenLara.git
synced 2025-08-11 15:45:05 +02:00
small rework on the SDL2 audio code (#196)
This commit is contained in:
committed by
Timur Gagiev
parent
634b27bfd9
commit
d10a2b693e
@@ -20,8 +20,9 @@ int osGetTimeMS() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// sound
|
// sound
|
||||||
|
#define SND_FRAME_SIZE 4
|
||||||
|
#define SND_FRAMES 1024
|
||||||
|
|
||||||
int SND_FRAMES = 512;
|
|
||||||
// A Frame is a struct containing: int16 L, int16 R.
|
// A Frame is a struct containing: int16 L, int16 R.
|
||||||
Sound::Frame *sndData;
|
Sound::Frame *sndData;
|
||||||
SDL_AudioDeviceID sdl_audiodev;
|
SDL_AudioDeviceID sdl_audiodev;
|
||||||
@@ -29,9 +30,9 @@ SDL_AudioDeviceID sdl_audiodev;
|
|||||||
void sndFill(void *udata, Uint8 *stream, int len) {
|
void sndFill(void *udata, Uint8 *stream, int len) {
|
||||||
// Let's milk the audio subsystem for SND_FRAMES frames!
|
// Let's milk the audio subsystem for SND_FRAMES frames!
|
||||||
Sound::fill(sndData, SND_FRAMES);
|
Sound::fill(sndData, SND_FRAMES);
|
||||||
// We have the number of samples, but each sample is sizeof(Sound::Frame) bytes long,
|
// We have the number of samples, but each sample is 4 bytes long (16bit stereo sound),
|
||||||
// and memcpy copies a number of bytes.
|
// and memcpy copies a number of bytes.
|
||||||
memcpy (stream, sndData, SND_FRAMES * sizeof(Sound::Frame));
|
memcpy (stream, sndData, SND_FRAMES * SND_FRAME_SIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool sndInit() {
|
bool sndInit() {
|
||||||
@@ -60,7 +61,7 @@ bool sndInit() {
|
|||||||
|
|
||||||
// Initialize audio buffer and fill it with zeros
|
// Initialize audio buffer and fill it with zeros
|
||||||
sndData = new Sound::Frame[SND_FRAMES];
|
sndData = new Sound::Frame[SND_FRAMES];
|
||||||
memset(sndData, 0, SND_FRAMES * sizeof(Sound::Frame));
|
memset(sndData, 0, SND_FRAMES * SND_FRAME_SIZE);
|
||||||
|
|
||||||
SDL_PauseAudioDevice(sdl_audiodev,0);
|
SDL_PauseAudioDevice(sdl_audiodev,0);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user