Skip to content

Commit bf4ebfd

Browse files
committed
MiniAL unit tests.
1 parent 240da7e commit bf4ebfd

19 files changed

Lines changed: 2286 additions & 61 deletions

src/gus.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,3 +270,14 @@ void GUSVoiceControl(uint8_t v, uint8_t b)
270270
outportb(Base + 0x103, 0);
271271
outportb(Base + 0x105, b);
272272
}
273+
274+
/* get channel status/mode */
275+
uint8_t GUSGetVoiceStatus(uint8_t v)
276+
{
277+
outportb(Base + 0x102, v);
278+
outportb(Base + 0x102, v);
279+
outportb(Base + 0x102, v);
280+
outportb(Base + 0x103, 0x80);
281+
uint8_t ret = inportb(Base + 0x105);
282+
return ret;
283+
}

src/gus.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ uint32_t GUSVoicePos(uint8_t v);
4545

4646
void GUSVoiceControl(uint8_t v, uint8_t b);
4747

48+
/* get channel status/mode */
49+
uint8_t GUSGetVoiceStatus(uint8_t v);
50+
4851
#define GUS_VOICE_STOPPED 1
4952
#define GUS_VOICE_STOP 2
5053
#define GUS_VOICE_16BIT 4

src/main.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,7 @@ int my_main (int argc, char** argv)
373373

374374
static const ALCint attribs[] = {
375375
ALC_FREQUENCY, ma_freq,
376+
ALC_MONO_SOURCES, 32,
376377
0, 0
377378
};
378379

src/minial.cpp

Lines changed: 60 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,10 @@ const ALCchar* alcGetString(ALCdevice* device, ALCenum param)
6767
ALCdevice* alcOpenDevice(const ALCchar* devicename)
6868
{
6969
ALCdevice* alcDevice = new ALCdevice;
70-
strncpy(alcDevice->deviceName, devicename, 255);
70+
if (devicename)
71+
{
72+
strncpy(alcDevice->deviceName, devicename, 255);
73+
}
7174
return alcDevice;
7275
}
7376

@@ -79,6 +82,7 @@ ALCcontext* alcCreateContext(const ALCdevice* device, const ALCint* attrlist)
7982
}
8083

8184
ALCint freq = 22050;
85+
ALCint monoSources = 32;
8286

8387
if (attrlist)
8488
{
@@ -89,6 +93,9 @@ ALCcontext* alcCreateContext(const ALCdevice* device, const ALCint* attrlist)
8993
case ALC_FREQUENCY:
9094
freq = attrlist[i * 2 + 1];
9195
break;
96+
case ALC_MONO_SOURCES:
97+
monoSources = attrlist[i * 2 + 1];
98+
break;
9299
default:
93100
break;
94101
}
@@ -108,7 +115,7 @@ ALCcontext* alcCreateContext(const ALCdevice* device, const ALCint* attrlist)
108115
}
109116
else if (strcmp(device->deviceName, "gus") == 0)
110117
{
111-
alcContext->minialInterface = new MinialGUS();
118+
alcContext->minialInterface = new MinialGUS(monoSources);
112119
}
113120
else
114121
{
@@ -120,6 +127,7 @@ ALCcontext* alcCreateContext(const ALCdevice* device, const ALCint* attrlist)
120127
{
121128
if (!alcContext->minialInterface->valid())
122129
{
130+
printf("a%d\n", __LINE__);
123131
delete alcContext->minialInterface;
124132
delete alcContext;
125133
return 0;
@@ -228,6 +236,12 @@ void alSourcePlay(ALuint source)
228236
minialInterface->SourcePlay(source);
229237
}
230238

239+
void alSourcePause(ALuint source)
240+
{
241+
if (minialInterface)
242+
minialInterface->SourcePause(source);
243+
}
244+
231245
void alSourceStop(ALuint source)
232246
{
233247
if (minialInterface)
@@ -248,3 +262,47 @@ ALint alGetInteger(ALenum param)
248262
}
249263
return -1;
250264
}
265+
266+
void alGetSourcef(ALuint source, ALenum param, ALfloat* value)
267+
{
268+
if (minialInterface)
269+
{
270+
return minialInterface->GetSourcef(source, param, value);
271+
}
272+
}
273+
274+
ALenum alGetError(void)
275+
{
276+
if (minialInterface)
277+
{
278+
return minialInterface->GetError();
279+
}
280+
else
281+
{
282+
return AL_NO_ERROR;
283+
}
284+
}
285+
286+
void alListenerf(ALenum param, ALfloat value)
287+
{
288+
if (minialInterface)
289+
{
290+
return minialInterface->Listenerf(param, value);
291+
}
292+
}
293+
294+
void alGetSourcei(ALuint source, ALenum param, ALint *value)
295+
{
296+
if (minialInterface)
297+
{
298+
return minialInterface->GetSourcei(source, param, value);
299+
}
300+
}
301+
302+
void alGetListenerf(ALenum param, ALfloat *value)
303+
{
304+
if (minialInterface)
305+
{
306+
return minialInterface->GetListenerf(param, value);
307+
}
308+
}

src/minial.h

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ typedef unsigned int ALuint;
1717
#define ALC_DEVICE_SPECIFIER 0x1005
1818
#define ALC_ALL_DEVICES_SPECIFIER 0x1013
1919
#define ALC_FREQUENCY 0x1007
20+
#define ALC_MONO_SOURCES 0x1010
2021

2122
ALCboolean alcCloseDevice(ALCdevice *device);
2223
ALCcontext* alcCreateContext(const ALCdevice *device, const ALCint *attrlist);
@@ -42,6 +43,24 @@ typedef void ALvoid;
4243
#define AL_ORIENTATION 0x100F
4344
#define AL_SAMPLE_OFFSET 0x1025
4445
#define AL_FORMAT_MONO16 0x1101
46+
#define AL_EXT_GUS_RAM_KB 0xE0001
47+
48+
#define AL_NO_ERROR 0
49+
#define AL_INVALID_NAME 0xA001
50+
#define AL_INVALID_ENUM 0xA002
51+
#define AL_INVALID_VALUE 0xA003
52+
#define AL_INVALID_OPERATION 0xA004
53+
#define AL_OUT_OF_MEMORY 0xA005
54+
55+
#define AL_SOURCE_STATE 0x1010
56+
#define AL_INITIAL 0x1011
57+
#define AL_PLAYING 0x1012
58+
#define AL_PAUSED 0x1013
59+
#define AL_STOPPED 0x1014
60+
61+
#define AL_NONE 0
62+
#define AL_FALSE 0
63+
#define AL_TRUE 1
4564

4665
void alBufferData(ALuint buffer, ALenum format, const ALvoid *data, ALsizei size, ALsizei freq);
4766
void alDeleteBuffers(ALsizei n, const ALuint *buffers);
@@ -53,12 +72,15 @@ void alSourcef(ALuint source, ALenum param, ALfloat value);
5372
void alSourcefv(ALuint source, ALenum param, const ALfloat *values);
5473
void alSourcei(ALuint source, ALenum param, ALint value);
5574
void alSourcePlay(ALuint source);
75+
void alSourcePause(ALuint source);
5676
void alSourceRewind(ALuint source);
5777
void alSourceStop(ALuint source);
58-
59-
#define AL_EXT_GUS_RAM_KB 0xE0001
60-
6178
ALint alGetInteger(ALenum param);
79+
void alGetSourcef(ALuint source, ALenum param, ALfloat* value);
80+
ALenum alGetError(void);
81+
void alListenerf(ALenum param, ALfloat value);
82+
void alGetSourcei(ALuint source, ALenum param, ALint *value);
83+
void alGetListenerf(ALenum param, ALfloat *value);
6284

6385
void MA_periodicStream(void);
6486

0 commit comments

Comments
 (0)