aboutsummaryrefslogtreecommitdiff
path: root/backends/PalmOS/Src/snd_stream.cpp
blob: 43e9333e8ffb68778c9e3603541eb00ec2229100 (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 "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;
}