aboutsummaryrefslogtreecommitdiff
path: root/backends/PalmOS/Src/snd_stream.cpp
blob: 976137305d120fe0b1c2e655c75ce0caf31c5979 (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
#include "common/stdafx.h"
#include "palm.h"

Err sndCallback(void* UserDataP, SndStreamRef stream, void* bufferP, UInt32 *bufferSizeP) {
	SoundDataType *snd = (SoundDataType *)UserDataP;
	UInt32 size = *bufferSizeP;

	if (snd->set && snd->size) {
		UInt32 *dst = (UInt32 *)bufferP;
		UInt32 *src = (UInt32 *)snd->dataP;

		size = (snd->size / 16);
		while (size--) {
			*dst++ = READ_LE_UINT32(src++);
			*dst++ = READ_LE_UINT32(src++);
			*dst++ = READ_LE_UINT32(src++);
			*dst++ = READ_LE_UINT32(src++);
		}
		snd->set = false;

	} else {
		snd->size = size;
		MemSet(bufferP, 128, 0);
		*bufferSizeP = 128;
	}

	return errNone;
}