diff --git a/README.md b/README.md index 9d817d8..e8595cb 100644 --- a/README.md +++ b/README.md @@ -60,3 +60,17 @@ This is an emulation of the driver that games use to route sound out of the Crea ## Config A default configuration file is provided in `docs/lindbergh.conf`. It should be placed in the same folder as the game is run from. If no config file is present a default setting will be used. + +## Installation + +1. Make sure you have the nvidia drivers + +``` +sudo dpkg --add-architecture i386 +sudo apt-get install gcc-multilib +sudo apt-get install freeglut3:i386 freeglut3-dev:i386 libglew-dev +sudo apt-get install xorg-dev +sudo apt-get install libopenal1 libopenal-dev +sudo apt-get install libxmu6:i386 +sudo apt-get install libstdc++5:i386 +``` diff --git a/src/libsegaapi/segaapi.c b/src/libsegaapi/segaapi.c index ba07a4b..5861cb6 100644 --- a/src/libsegaapi/segaapi.c +++ b/src/libsegaapi/segaapi.c @@ -31,20 +31,6 @@ //#define DUMP_WAV //#define DUMP_BUFFER -#define CHECK() \ - { \ - printf("%s %d\n", __func__, __LINE__); \ - unsigned int err; \ - if ((err = alGetError()) != AL_NO_ERROR) \ - { \ - printf("%s %d\n", __func__, __LINE__); \ - dbgPrint(":%i AL Error: 0x%08X\n", __LINE__, err); \ - exit(2); \ - } \ - } - -int g_LastStatus = SEGA_SUCCESS; - // outrun2 will complain if these aren't present const GUID EAX_NULL_GUID; // DEFINE_GUID(EAX_NULL_GUID, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); @@ -70,6 +56,7 @@ const GUID EAXPROPERTYID_EAX40_FXSlot3; typedef struct { + // SEGA API Parts void *userData; HAWOSEGABUFFERCALLBACK callback; bool synthesizer; @@ -84,19 +71,16 @@ typedef struct size_t size; bool playing; bool paused; - bool playWithSetup; + // OpenAL Parts ALuint alBuffer; ALuint alSource; + // TinySoundFont Parts tsf *synth; struct tsf_region *region; } segaapiContext_t; -// LPALBUFFERSAMPLESSOFT alBufferSamplesSOFT = NULL; -// LPALBUFFERSUBSAMPLESSOFT alBufferSubSamplesSOFT = NULL; -// LPALGETBUFFERSAMPLESSOFT alGetBufferSamplesSOFT = NULL; - #ifdef DEBUG_OUTPUT void dbgPrint(const char *format, ...) { @@ -113,106 +97,6 @@ void dbgPrint(const char *format, ...) } #endif -#ifdef DUMP_BUFFER -static void dumpBuffer(const char *path, void *data, size_t size) -{ - FILE *soundFile = NULL; - - soundFile = fopen(path, "wb"); - fwrite(data, size, 1, soundFile); - fclose(soundFile); -} -#endif - -#ifdef DUMP_WAV -static void dumpWaveBuffer(const char *path, unsigned int channels, unsigned int sampleRate, unsigned int sampleBits, void *data, size_t size) -{ - - struct RIFF_Header - { - char chunkID[4]; - long chunkSize; // size not including chunkSize or chunkID - char format[4]; - }; - - struct WAVE_Format - { - char subChunkID[4]; - long subChunkSize; - short audioFormat; - short numChannels; - long sampleRate; - long byteRate; - short blockAlign; - short bitsPerSample; - }; - - struct WAVE_Data - { - char subChunkID[4]; // should contain the word data - long subChunk2Size; // Stores the size of the data block - }; - - // Local Declarations - FILE *soundFile = NULL; - struct WAVE_Format wave_format; - struct RIFF_Header riff_header; - struct WAVE_Data wave_data; - - soundFile = fopen(path, "wb"); - - // check for RIFF and WAVE tag in memeory - riff_header.chunkID[0] = 'R'; - riff_header.chunkID[1] = 'I'; - riff_header.chunkID[2] = 'F'; - riff_header.chunkID[3] = 'F'; - riff_header.format[0] = 'W'; - riff_header.format[1] = 'A'; - riff_header.format[2] = 'V'; - riff_header.format[3] = 'E'; - - // Read in the first chunk into the struct - fwrite(&riff_header, sizeof(struct RIFF_Header), 1, soundFile); - - // check for fmt tag in memory - wave_format.subChunkID[0] = 'f'; - wave_format.subChunkID[1] = 'm'; - wave_format.subChunkID[2] = 't'; - wave_format.subChunkID[3] = ' '; - - wave_format.audioFormat = 1; - wave_format.sampleRate = sampleRate; - wave_format.numChannels = channels; - wave_format.bitsPerSample = sampleBits; - wave_format.byteRate = (sampleRate * sampleBits * channels) / 8; - wave_format.blockAlign = (sampleBits * channels) / 8; - wave_format.subChunkSize = 16; - - // Read in the 2nd chunk for the wave info - fwrite(&wave_format, sizeof(struct WAVE_Format), 1, soundFile); - - // Read in the the last byte of data before the sound file - - // check for data tag in memory - wave_data.subChunkID[0] = 'd'; - wave_data.subChunkID[1] = 'a'; - wave_data.subChunkID[2] = 't'; - wave_data.subChunkID[3] = 'a'; - - wave_data.subChunk2Size = size; - - fwrite(&wave_data, sizeof(struct WAVE_Data), 1, soundFile); - - // Read in the sound data into the soundData variable - fwrite(data, wave_data.subChunk2Size, 1, soundFile); - - // clean up and return true if successful - fclose(soundFile); - - return; -} -#endif - ALsizei FramesToBytes(ALsizei size, ALenum channels, ALenum type) { switch (channels) @@ -272,34 +156,29 @@ ALsizei FramesToBytes(ALsizei size, ALenum channels, ALenum type) } static unsigned int bufferSampleSize(segaapiContext_t *context) -{ // printf("%s %d\n", __func__, __LINE__); +{ return context->channels * ((context->sampleFormat == HASF_SIGNED_16PCM) ? 2 : 1); } static void updateBufferLoop(segaapiContext_t *context) -{ // printf("%s %d\n", __func__, __LINE__); +{ if (context == NULL) return; + unsigned int sampleSize = bufferSampleSize(context); alSourcei(context->alSource, AL_BUFFER, AL_NONE); - // CHECK(); + /* FIXME: Re-enable, only crashed before - so fix this too.. ALint loopPoints[] = { buffer->startLoop / sampleSize, buffer->endLoop / sampleSize }; alBufferiv(buffer->alBuffer,AL_LOOP_POINTS_SOFT,loopPoints); CHECK(); */ - return; -} - -void AL_APIENTRY alBufferSamplesSOFT(ALuint buffer, ALuint samplerate, ALenum internalformat, ALsizei samples, ALenum channels, ALenum type, const ALvoid *data) -{ - alBufferData(buffer, internalformat, data, FramesToBytes(samples, channels, type), samplerate); } AL_API void AL_APIENTRY alBufferSubSamplesSOFT(ALuint buffer, ALsizei offset, ALsizei samples, ALenum channels, ALenum type, const ALvoid *data, ALuint samplerate, ALenum internalformat) { - + ALsizei FrameSize = FramesToBytes(samples, channels, type); offset *= FrameSize; @@ -350,63 +229,44 @@ static void updateBufferData(segaapiContext_t *context, unsigned int offset, siz default: break; } + if (alFormat == -1) { dbgPrint("Unknown format! 0x%X with %u channels!\n", context->sampleFormat, context->channels); + abort(); } ALint position; alGetSourcei(context->alSource, AL_SAMPLE_OFFSET, &position); // TODO: Patch if looping is active - // CHECK(); ALint unsafe[2]; alGetSourceiv(context->alSource, AL_BYTE_RW_OFFSETS_SOFT, unsafe); // AL_BYTE_OFFSET - // CHECK(); + + // We should update the playing buffer + // OpenAL doesn't want to let us do this!! if (offset != -1) { - alBufferSubSamplesSOFT(context->alBuffer, offset / bufferSampleSize(context), length / bufferSampleSize(context), alChannels, alType, &context->data[offset], context->sampleRate, alFormat); - // CHECK(); + // alBufferSubSamplesSOFT(context->alBuffer, offset / bufferSampleSize(context), length / bufferSampleSize(context), alChannels, alType, &context->data[offset], context->sampleRate, alFormat); dbgPrint("Soft update in buffer %X at %u (%u bytes) - buffer playing at %u, unsafe region is %u to %u\n", (uintptr_t)context, offset, length, position, unsafe[0], unsafe[1]); - } - else - { + ALint position; + alGetSourcei(context->alSource, AL_BYTE_OFFSET, &position); alSourcei(context->alSource, AL_BUFFER, AL_NONE); - // CHECK(); - alBufferSamplesSOFT(context->alBuffer, context->sampleRate, alFormat, context->size / bufferSampleSize(context), alChannels, alType, context->data); - // CHECK(); + alBufferData(context->alBuffer, alFormat, context->data, FramesToBytes(context->size / bufferSampleSize(context), alChannels, alType), context->sampleRate); alSourcei(context->alSource, AL_BUFFER, context->alBuffer); - // CHECK(); - updateBufferLoop(context); - dbgPrint("Hard update in buffer %X (%u bytes) - buffer playing at %u, unsafe region is %u to %u\n", (uintptr_t)context, context->size, position, unsafe[0], unsafe[1]); + alSourcei(context->alSource, AL_BYTE_OFFSET, position); + + + return; } -#ifdef DUMP_WAV - // This dumps the buffer - if (context->data != NULL) - { - uint8_t *nonZero = context->data; - while (*nonZero++ == 0x00) - ; - if ((nonZero - (uint8_t *)context->data) < context->size) - { - printf("%s %d\n", __func__, __LINE__); - char buf[1000]; - sprintf(buf, "SAMPLE-%X-%i-%04X-%u.wav", (uintptr_t)context, context->channels, context->sampleFormat, context->sampleRate); - dbgPrint("Writing: %s (%i)", buf, context->size); - void *tmp = malloc(context->size); - if (tmp != NULL) - { - alGetBufferSamplesSOFT(context->alBuffer, 0, context->size / bufferSampleSize(context), alChannels, alType, tmp); - // CHECK(); - dumpWaveBuffer(buf, context->channels, context->sampleRate, (context->sampleFormat == HASF_SIGNED_16PCM) ? 16 : 8, tmp, context->size); - free(tmp); - } - } - } -#endif - return; + // Clear the buffer and write again + alSourcei(context->alSource, AL_BUFFER, AL_NONE); + alBufferData(context->alBuffer, alFormat, context->data, FramesToBytes(context->size / bufferSampleSize(context), alChannels, alType), context->sampleRate); + alSourcei(context->alSource, AL_BUFFER, context->alBuffer); + // updateBufferLoop(context); + dbgPrint("Hard update in buffer %X (%u bytes) - buffer playing at %u, unsafe region is %u to %u\n", (uintptr_t)context, context->size, position, unsafe[0], unsafe[1]); } static void resetBuffer(segaapiContext_t *context) @@ -425,7 +285,6 @@ static void resetBuffer(segaapiContext_t *context) // * - No loop. context->loop = false; context->paused = false; - context->playWithSetup = false; tsf *res = (tsf *)TSF_MALLOC(sizeof(tsf)); TSF_MEMSET(res, 0, sizeof(tsf)); @@ -456,24 +315,10 @@ static void resetBuffer(segaapiContext_t *context) int SEGAAPI_Play(void *hHandle) { dbgPrint("SEGAAPI_Play() 0x%x", hHandle); + segaapiContext_t *context = hHandle; if (context == NULL) return SEGAERR_BAD_PARAM; -#ifdef DUMP_BUFFER - if (context->data != NULL) - { - if (context->synthesizer) - { - if (context->data) - { - char filename[1000]; - sprintf(filename, "SYNTH-%X-%i-%04X-%u.bin", (uintptr_t)context, context->channels, context->sampleFormat, context->sampleRate); - dbgPrint("Writing: %s (%i)", filename, context->size); - dumpBuffer(filename, context->data, context->size); - } - } - } -#endif alSourcei(context->alSource, AL_LOOPING, context->loop ? AL_TRUE : AL_FALSE); alSourcei(context->alSource, AL_BUFFER, context->alBuffer); @@ -554,10 +399,10 @@ int SEGAAPI_GetFormat(void *hHandle, HAWOSEFORMAT *pFormat) int SEGAAPI_SetSampleRate(void *hHandle, unsigned int dwSampleRate) { dbgPrint("SEGAAPI_SetSampleRate() 0x%x 0x%x", hHandle, dwSampleRate); + if (hHandle == NULL) - { // Not sure if this is correct here, but ABC currently tries to call this with a null pointer.. return SEGAERR_BAD_HANDLE; - } + segaapiContext_t *context = hHandle; context->sampleRate = dwSampleRate; updateBufferData(context, -1, -1); @@ -926,16 +771,17 @@ int SEGAAPI_CreateBuffer(HAWOSEBUFFERCONFIG *pConfig, HAWOSEGABUFFERCALLBACK pCa dbgPrint("SEGAAPI_CreateBuffer() 0x%x 0x%x 0x%x 0x%x", pConfig, pCallback, dwFlags, phHandle); if ((phHandle == NULL) || (pConfig == NULL)) { - g_LastStatus = SEGAERR_BAD_POINTER; dbgPrint("SEGAAPI_CreateBuffer() SEGAERR_BAD_POINTER"); return SEGAERR_BAD_POINTER; } + segaapiContext_t *context = malloc(sizeof(segaapiContext_t)); if (context == NULL) { dbgPrint("SEGAAPI_CreateBuffer() SEGAERR_OUT_OF_MEMORY"); return SEGAERR_OUT_OF_MEMORY; } + // dbgPrint("SEGAAPI_CreateBuffer() allocated %i bytes",sizeof(segaapiContext_t)); context->playing = false; context->callback = pCallback; @@ -1131,38 +977,14 @@ int SEGAAPI_Init(void) { dbgPrint("SEGAAPI_Init()"); - int res = alutInit(NULL, NULL); - if (res == AL_FALSE) + if (alutInit(NULL, NULL) == AL_FALSE) { - dbgPrint("SEGAAPI_Init() alutInit failed"); + dbgPrint("SEGAAPI_Init() alutInit() failed!"); return SEGAERR_FAIL; } - /* - alBufferSamplesSOFT = alGetProcAddress("alBufferSamplesSOFT"); - if (alBufferSamplesSOFT == NULL) - { - dbgPrint("Warning: Could not resolve AL extension!\n"); - // exit(1); - } - alBufferSubSamplesSOFT = alGetProcAddress("alBufferSubSamplesSOFT"); - if (alBufferSubSamplesSOFT == NULL) - { - dbgPrint("Warning: Could not resolve AL extension!\n"); - // exit(1); - } - alGetBufferSamplesSOFT = alGetProcAddress("alGetBufferSamplesSOFT"); - if (alGetBufferSamplesSOFT == NULL) - { - dbgPrint("Warning: Could not resolve AL extension!\n"); - // exit(1); - } - */ SEGAAPI_SetGlobalEAXProperty((GUID *)&EAXPROPERTYID_EAX40_FXSlot2, 0, (void *)&EAX_NULL_GUID, 16); - SEGAAPI_SetSPDIFOutChannelRouting(0, 0); - SEGAAPI_SetSPDIFOutChannelRouting(1, 1); - SEGAAPI_SetSPDIFOutSampleRate(1); return SEGA_SUCCESS; } diff --git a/src/libsegaapi/segaapi.h b/src/libsegaapi/segaapi.h index 0302c33..d6de015 100644 --- a/src/libsegaapi/segaapi.h +++ b/src/libsegaapi/segaapi.h @@ -1,75 +1,3 @@ -/** - * Copyright (C) 2004-2005 Creative Technology Ltd. All rights reserved. - * - **************************************************************************** - * \file segaapi.h - * \brief - * This file contains the definition of the interfaces that requested by SEGA - * for audio output support. - * - * - * @author Creative - * - * $Date: 2006/01/03 06:54:39 $ - * - **************************************************************************** - * Revision History: - * - * 0.5 - * 1st release to SEGA for review. - * - * 0.51 - * Added other interfaces to control effects, volume, optical-out etc. - * Cleanup and added more information on the wave playback interfaces. - * - * 0.52 - * Added correlation between HASYNTHPARAMSEXT enumerators with SoundFont parameters. - * - * 0.53 - * Change name to segaapi.h (was WaveOutSegaAPI.h) as the API covers more than - * just wave out. - * Add prefix SEGAAPI_ to each of the functions to avoid names conflict. - * Change HAERR_ to SEGAERR_, HA_SUCCESS to SEGA_SUCCESS - * - * 0.54 - * Added more documentation. - * - * 0.80 - * Added SetLastStatus and GetLastStatus functions. - * Change version to 0.80 to indicate close to final. - * - * 0.9 - * Made the header file both gcc and g++ compliance as per request. - * - * 0.91 - * Updated voice priority description. - * - * 0.92 - * Added SEGAAPI_Reset, and updated CreateBuffer() to support synthesizer buffer. - * - * 0.93 - * Added SEGAAPI_GetSendRouting and SEGAAPI_GetSetLevel per request. - * - * 0.94 - * Changed default send levels in SEGAAPI_CreateBuffer to 0. - * - * 1.00 - * Added SEGAAPI_Init() and SEGAAPI_Exit() per request. - * - * 1.01 - * Updated SEGAAPI_SetReleaseState() document. - * - * 1.02 - * Added SEGAAPI_SetSynthParamMultiple(0 and SEGAAPI_GetSynthParamMultiple(). - * Updated SEGAAPI_CreateBuffer() for user-mode buffer support. - * - **************************************************************************** - * Released under NDA. - * - * This document has been reviewed by SEGA. - **************************************************************************** - */ - #ifndef __SEGAAPI_H #define __SEGAAPI_H @@ -92,24 +20,9 @@ #define SEGAERR_OUT_OF_MEMORY SEGARESULT_FAILURE(31) #define SEGAERR_INIT_FAILED SEGARESULT_FAILURE(39) -/** - * The following defines SEGA custom EAX40 properties. - */ - // {A7FEEC3F-2BFD-4a40-891F-7423E38BAC1F} -DEFINE_GUID(EAXPROPERTYID_EAX40_SEGA_Custom, - 0xa7feec3f, 0x2bfd, 0x4a40, 0x89, 0x1f, 0x74, 0x23, 0xe3, 0x8b, 0xac, 0x1f); +DEFINE_GUID(EAXPROPERTYID_EAX40_SEGA_Custom, 0xa7feec3f, 0x2bfd, 0x4a40, 0x89, 0x1f, 0x74, 0x23, 0xe3, 0x8b, 0xac, 0x1f); -// SEGA custom EAX40 properties -/* - * The only property now is to switch the FX returns for - * FXSlot2 and FXSlot3 when non-reverb is loaded to these slots. - * - * EAXSEGA_STEREO_RETURN - * ulDataSize = unsigned int - * value = 0 denotes route to front L/R (default) - * value = 1 denotes route to Rear L/R - */ typedef enum { EAXSEGA_STEREO_RETURN_FX2 = 0, @@ -345,1252 +258,61 @@ How this SYNTH PARAMS EXT maps to Sega API requests: */ -/* - * Interfaces expose. These interfaces will be exposed in user mode. - * - * Note: - * 1. hHandle that passes into these functions is An opaque identifier - * obtained from CreateBuffer. - * - * 2. A mono buffer uses one voice. A stereo buffer uses two voices. - * - */ - -/*********************************************************** - * @section - * API for playback operation controls. - * - */ - -/** - * Starts sample playback of a buffer. - * Playback position is not modified when Play is called and will - * start incrementing from its previous value at the sample - * rate. - * - * CALL LEVELS: PASSIVE - * - * @param hHandle - * An opaque identifier obtained from CreateBuffer. - * - * @return - * Returns SEGA_SUCCESS if playback can start. Otherwise, returns an appropriate - * error code. - */ int SEGAAPI_Play(void *hHandle); - -/** - * Halts playback and freezes the current counter at its last - * value. - * - * CALL LEVELS: PASSIVE - * - * @param hHandle - * An opaque identifier obtained from CreateBuffer. - * - * @return - * Returns SEGA_SUCCESS if playback was successfully paused. - * Otherwise, returns an appropriate error code. - */ int SEGAAPI_Pause(void *hHandle); - -/** - * Stops playback and resets the sample counter. - * - * - * CALL LEVELS: PASSIVE - * - * @param hHandle - * An opaque identifier obtained from CreateBuffer. - * - * @return - * Returns SEGA_SUCCESS if playback was successfully paused. - * Otherwise, returns an appropriate error code. - * - */ int SEGAAPI_Stop(void *hHandle); - int SEGAAPI_PlayWithSetup(void *hHandle); - -/** - * Returns a current playback status of a buffer. - * - * CALL LEVELS: DPC, PASSIVE - * - * @param hHandle - * An opaque identifier obtained from CreateBuffer. - * - * @return - * One of the playback status defined in the PlaybackStatus enumration type. - * If the returned status is PLAYBACK_STATUS_INVALID, use GetLastStatus() to check the error code. - */ PlaybackStatus SEGAAPI_GetPlaybackStatus(void *hHandle); - -/*********************************************************** - * @section - * API for playback format controls. - * - */ - -/** - * Changes the buffer's format to the values specified in - * the new format pFormat. In some cases, it is possible that - * an attempt to change the configuration may fail, as the change may - * require more resources than were previously allocated. - * - * The playback buffer configuration may not be changed while the buffer is - * playing. - * - * CALL LEVELS: PASSIVE - * - * @param hHandle - * An opaque identifier obtained from CreateBuffer. - * - * @param pFormat - * The new format to change to. - * - * @return - * Returns SEGA_SUCCESS if successful. Otherwise, returns an appropriate - * error code. - * - * @retval SEGAERR_PLAYING if the buffer is currently playing - * @retval SEGAERR_BAD_POINTER if pFormat is NULL - * @retval SEGAERR_NO_RESOURCES if insufficient resources are available - * @retval SEGAERR_BAD_CONFIG if something in the given configuration is - * invalid. - */ int SEGAAPI_SetFormat(void *hHandle, HAWOSEFORMAT *pFormat); - -/** - * Returns the current format of the buffer. - * - * CALL LEVELS: PASSIVE - * - * @param hHandle - * An opaque identifier obtained from CreateBuffer. - * - * @param pFormat - * Pointer to an address where the current format to return to. - * - * @return - * Returns SEGA_SUCCESS if successful. Otherwise, returns an appropriate - * error code. - */ int SEGAAPI_GetFormat(void *hHandle, HAWOSEFORMAT *pFormat); - -/** - * Changes the playback sample rate for the current client to the - * value specified. The new value only pertains to this buffer. - * If hardware cannot support changing sample rates for individual - * buffers, it can return an error in response to this routine. - * - * CALL LEVELS: PASSIVE - * - * @param hHandle - * An opaque identifier obtained from CreateBuffer. - * - * @param dwSampleRate - * The desired sample rate. - * - * @return - * Returns SEGA_SUCCESS if successful. Otherwise, returns an appropriate - * error code. - */ int SEGAAPI_SetSampleRate(void *hHandle, unsigned int dwSampleRate); - -/** - * Returns the current sample rate. - * - * CALL LEVELS: PASSIVE - * - * @param hHandle - * An opaque identifier obtained from CreateBuffer. - * - * @return - * Returns the current sample rate. - * If the returned value is 0, use GetLastStatus() to check the error code. - */ unsigned int SEGAAPI_GetSampleRate(void *hHandle); - -/*********************************************************** - * @section - * API for Voice priority management. - * - */ - -/** - * Changes the buffer's priority to the specified value. - * - * If all the voices are set to HAWOSEP_MAXIMUM (0xFFFFFFFF) priority, - * CreateBuffer() call will return failure when running out of voices. - * - * CALL LEVEL: DPC, PASSIVE - * - * @param hHandle - * An opaque identifier obtained from CreateBuffer. - * - * @param dwPriority - * The new priority for the buffer. - * - * @return - * Returns SEGA_SUCCESS if successful. Otherwise, returns an appropriate - * error code. - */ int SEGAAPI_SetPriority(void *hHandle, unsigned int dwPriority); - -/** - * Returns the buffer's current priority. - * - * CALL LEVEL: DPC, PASSIVE - * - * @param hHandle - * An opaque identifier obtained from CreateBuffer. - * - * @return - * Returns the buffer's current priority. - * Note that returned value is also set to 0 if error invoked this function. - */ unsigned int SEGAAPI_GetPriority(void *hHandle); - -/*********************************************************** - * @section - * API for storing an User-defined data. - * - */ - -/** - * Stores a handle to user-defined data defined by the client structure. - * This allows caller to associate caller-specific data. The caller is - * responsible for managing this data area. - * - * Note that caller can specify an user-defined data in the CreateBuffer() - * call. Caller can use SetUserData() to update the user-defined data. - * - * CALL LEVELS: DPC, PASSIVE - * - * @param hHandle - * An opaque identifier obtained from CreateBuffer. - * - * @param hUserData - * A handle to user-defined data. - * - * @return - * Returns SEGA_SUCCESS if successful. Otherwise, returns an appropriate - * error code. - */ int SEGAAPI_SetUserData(void *hHandle, void *hUserData); - -/** - * Returns the last user-defined data set by the caller. - * - * CALL LEVELS: DPC, PASSIVE - * - * @param hHandle - * An opaque identifier obtained from CreateBuffer. - * - * @return - * Returns the user-defined data. - * Note that returned value is set to 0 if error invoked this function. - */ void *SEGAAPI_GetUserData(void *hHandle); - -/*********************************************************** - * @section - * API for Send routing and Send Level controls. - * - */ - -/** - * Changes the destination to which a channel send is connected. - * Each channel has the possibility of supporting multiple sends. - * For Tina chip, each channel has seven sends. - * Each of these sends can be connected to a destination. - * - * Note that it is invalid to have more than one sends routed to - * a same destination. For example, if send 0 is previously routed - * to front-left, send 0 will need to be disconnected before another - * send can route to front-left. - * - * CALL LEVELS: PASSIVE - * - * @param hHandle - * An opaque identifier obtained from CreateBuffer. - * - * @param dwChannel - * The channel to reroute. - * - * @param dwSend - * The send number being addressed. - * - * @param dwDest - * The destination to which the send should be connected. - * If the send doesn't need to be connected to anything, - * specify HAWOSE_UNUSED_SEND. See HAROUTING for the details - * of the destination enumeration list. - * - * @return - * Returns SEGA_SUCCESS if successful. Otherwise, returns an appropriate - * error code. - * - * @retval SEGAERR_UNSUPPORTED if channels can't be rerouted. - * @retval SEGAERR_INVALID_CHANNEL if the specified channel isn't in use. - * @retval SEGAERR_INVALID_SEND if the specified send isn't supported. - */ -int SEGAAPI_SetSendRouting(void *hHandle, unsigned int dwChannel, unsigned int dwSend, - HAROUTING dwDest); - -/** - * Returns the destination of which a channel send is connected to. - * - * CALL LEVELS: PASSIVE - * - * @param hHandle - * An opaque identifier obtained from CreateBuffer. - * - * @param dwChannel - * The channel requested. - * - * @param dwSend - * The send number being addressed. - * - * @return - * Returns the current destination. - * Note that returned value is set to HA_UNUSED_PORT if error invoked this function. - */ +int SEGAAPI_SetSendRouting(void *hHandle, unsigned int dwChannel, unsigned int dwSend, HAROUTING dwDest); HAROUTING SEGAAPI_GetSendRouting(void *hHandle, unsigned int dwChannel, unsigned int dwSend); - -/** - * Sets the output level of a particular send on a channel to the specified - * level. - * - * CALL LEVELS: PASSIVE - * - * @param hHandle - * An opaque identifier obtained from CreateBuffer. - * - * @param dwChannel - * The channel whose output level is to be set. - * - * @param dwSend - * The send being addressed. - * - * @param dwLevel - * The output level. Output levels are specified - * in linear values. A value of 0xFFFFFFFF indicates - * full on (0 attenuation). A value of 0x0 indicates - * infinite attenuation. - * - * @return - * Returns SEGA_SUCCESS if successful. Otherwise, returns an appropriate - * error code. - * - * @retval SEGAERR_UNSUPPORTED if the device doesn't support channel levels in - * general. - * @retval SEGAERR_INVALID_CHANNEL if the specified channel isn't valid. - * @retval SEGAERR_INVALID_SEND if the specified send isn't valid. - */ -int SEGAAPI_SetSendLevel(void *hHandle, unsigned int dwChannel, unsigned int dwSend, - unsigned int dwLevel); - -/** - * Returns the output level of a particular send on a channel. - * - * CALL LEVELS: PASSIVE - * - * @param hHandle - * An opaque identifier obtained from CreateBuffer. - * - * @param dwChannel - * The channel requested. - * - * @param dwSend - * The send number being addressed. - * - * @return - * Returns the current send level. - * Note that returned value is set to 0 if error invoked this function. - */ +int SEGAAPI_SetSendLevel(void *hHandle, unsigned int dwChannel, unsigned int dwSend, unsigned int dwLevel); unsigned int SEGAAPI_GetSendLevel(void *hHandle, unsigned int dwChannel, unsigned int dwSend); - -/*********************************************************** - * @section - * API for volume level controls. - * - */ - -/** - * Sets the volume to a specific linear value. Volumes are specified - * as fractional fixed-point linear values between HAWOSEVOL_MAX (0xFFFFFFFF) - * and 0x0. The dwVolume is specified in linear increments from 0 to 1 - * (actually to 65535 divided by 65536). A 0 value represents 96db of attenuation, - * while a 1 value represents full volume. Default is full volume. - * - * Volume is a global value and is applied pre-send. - * - * CALL LEVELS: PASSIVE - * - * @param hHandle - * An opaque identifier obtained from CreateBuffer. - * - * @param dwChannel - * The channel to change. - * - * @param dwVolume - * The new volume level to change to. - * - * @return - * Returns SEGA_SUCCESS if successful. Otherwise, returns an appropriate - * error code. - * - * @retval SEGAERR_UNSUPPORTED if the device can't change volume. - * @retval SEGAERR_INVALID_CHANNEL if the given send isn't valid. - */ int SEGAAPI_SetChannelVolume(void *hHandle, unsigned int dwChannel, unsigned int dwVolume); - -/** - * Returns the current volume level for the requested channel. - * - * CALL LEVELS: PASSIVE - * - * @param hHandle - * An opaque identifier obtained from CreateBuffer. - * - * @param dwChannel - * The channel requested. - * - * @return - * Returns the current volume. - * Note that returned value is set to 0 if error invoked this function. - */ unsigned int SEGAAPI_GetChannelVolume(void *hHandle, unsigned int dwChannel); - -/*********************************************************** - * @section * API for playback position controls. - * - */ - -/** - * Changes the buffer position pointer from which hardware - * is fetching samples. Changes take place immediately and - * can be made while playback is occurring. - * - * CALL LEVELS: DPC, PASSIVE - * - * @param hHandle - * An opaque identifier obtained from CreateBuffer. - * - * @param dwPlaybackPos - * The buffer position (IN BYTES) where the playback - * pointer should be moved. - * - * @return - * Returns SEGA_SUCCESS if successful. Otherwise, returns an appropriate - * error code. - */ int SEGAAPI_SetPlaybackPosition(void *hHandle, unsigned int dwPlaybackPos); - -/** - * Returns the position in the buffer (IN BYTES) where the - * hardware is currently playing samples from. - * - * CALL LEVELS: DPC, PASSIVE - * - * @param hHandle - * An opaque identifier obtained from CreateBuffer. - * - * @return - * Returns the current playback position. - * Note that returned value is set to 0 if error invoked this function. - */ unsigned int SEGAAPI_GetPlaybackPosition(void *hHandle); - -/*********************************************************** - * @section - * API for buffer update, loop regions and notification controls. - * - */ - -/** - * This function sets the frequency at which a callback will be generated. - * The callback will be invoked periodically at a fixed interval - * specified by the dwFrameCount. dwFrameCount is in the units of - * sample frames. - * - * This notification method is typically used for ring buffer that need - * periodic notification to update the ring buffer data. - * - * Note that callback execution is scheduled at the later time (DPC), not at - * the interrupt time. - * - * - * CALL LEVELS: PASSIVE - * - * @param hHandle - * An opaque identifier obtained from CreateBuffer. - * - * @param dwFrameCount - * The frequency, in sample frames, at which the the notification is invoked. - * Specifying a value of zero cancels the callback. - * - * @return - * Returns SEGA_SUCCESS if successful. Otherwise, returns an appropriate - * error code. - */ int SEGAAPI_SetNotificationFrequency(void *hHandle, unsigned int dwFrameCount); - -/** - * This function can be used to set a notification point in the ring - * buffer. Whenever the play position passes over a notification point - * the device will schedule a callback to the function indicated when - * the ring buffer was created. - * - * Note that callback execution is scheduled at the later time (DPC), not at - * the interrupt time. - * - * CALL LEVELS: PASSIVE, DPC - * - * @param hHandle - * An opaque identifier obtained from CreateBuffer. - * - * @param dwBufferOffset - * The offset (in bytes) in the buffer where the notification - * point is to be set. - * - * @return - * Returns SEGA_SUCCESS if successful. Otherwise, returns an appropriate - * error code. - */ int SEGAAPI_SetNotificationPoint(void *hHandle, unsigned int dwBufferOffset); - -/** - * Removes a previously set notification point. - * - * CALL LEVELS: PASSIVE, DPC - * - * @param hHandle - * An opaque identifier obtained from CreateBuffer. - * - * @param dwBufferOffset - * The offset (in bytes) of the notification point to - * remove. - * - * @return - * Returns SEGA_SUCCESS if successful. Otherwise, returns an appropriate - * error code. - */ int SEGAAPI_ClearNotificationPoint(void *hHandle, unsigned int dwBufferOffset); - -/** - * Sets the start loop offset. The start loop offset controls where - * the play pointer will jump when it crosses the End Loop Offset. - * There is no requirement that the start loop offset preceed the - * End Loop Offset. It is illegal to set Start Loop Offset and - * End Loop Offset to the same value, however, and in general it is - * a bad idea to have the difference between the two be less than - * 16 samples. - * - * GetStartLoopOffset() just returns the current start loop offset - * value and may be called at any interrupt level. - * - * CALL LEVELS: DPC, PASSIVE. - * - * @param hHandle - * An opaque identifier obtained from CreateBuffer. - * - * @param dwOffset - * The offset in bytes from the beginning of the buffer of - * the loop start point. - * - * @return - * Returns SEGA_SUCCESS if the loop offset is changed successful. - * Otherwise, returns an appropriate error code. - */ int SEGAAPI_SetStartLoopOffset(void *hHandle, unsigned int dwOffset); - -/** - * Returns the current start loop offest. - * - * CALL LEVELS: DPC, PASSIVE. - * - * @param hHandle - * An opaque identifier obtained from CreateBuffer. - * - * @return - * Returns the current start loop offset. - * Note that returned value is set to 0 if error invoked this function. - */ unsigned int SEGAAPI_GetStartLoopOffset(void *hHandle); - -/** - * Sets the End Loop Offset position. When the play pointer crosses - * the End Loop Offset it will jump to the Start Loop Offset - * position if buffer is in looping state (bDoContinuousLooping - * is set to TRUE). - * - * GetEndLoopOffset() just returns the current value and may be called - * at any interrupt level. - * - * Note that EndLoopOffset must not be larger than EndOffset. - * - * CALL LEVELS: DPC, PASSIVE. - * - * @param hHandle - * An opaque identifier obtained from CreateBuffer. - * - * @param dwOffset - * An offset in bytes from the beginning of the buffer, - * dwOffset specifies the location for the End Loop point. - * - * @return - * Returns SEGA_SUCCESS if successful. Otherwise, returns an appropriate - * error code. - */ int SEGAAPI_SetEndLoopOffset(void *hHandle, unsigned int dwOffset); - -/** - * Returns the current end loop offest. - * - * CALL LEVELS: DPC, PASSIVE. - * - * @param hHandle - * An opaque identifier obtained from CreateBuffer. - * - * @return - * Returns the current end loop offest. - * Note that returned value is set to 0 if error invoked this function. - */ unsigned int SEGAAPI_GetEndLoopOffset(void *hHandle); - -/** - * Sets the End Offset position. When the play pointer crosses - * the End Offset (assuming the buffer isn't currently looping) - * the buffer will halt. - * - * Only change the End offset position when buffer is not at - * PLAYBACK_STATUS_ACTIVE state. End Offset must be sample frame aligned. - * For example, 16-bit 1 channel is WORD aligned, 16-bit 2 channel - * is DWORD aligned. - * - * Note that EndOffset must not be larger than pConfig->mapdata.dwSize - * specified in the CreateBuffer(). - * - * CALL LEVELS: DPC, PASSIVE. - * - * @param hHandle - * An opaque identifier obtained from CreateBuffer. - * - * @param dwOffset - * An offset in bytes from the beginning of the buffer, - * dwOffset specifies the location for the End point. - * - * @return - * Returns SEGA_SUCCESS if successful. Otherwise, returns an appropriate - * error code. - */ int SEGAAPI_SetEndOffset(void *hHandle, unsigned int dwOffset); - -/** - * Returns the current end offest. - * - * CALL LEVELS: DPC, PASSIVE. - * - * @param hHandle - * An opaque identifier obtained from CreateBuffer. - * - * @return - * Returns the current end offest. - * Note that returned value is set to 0 if error invoked this function. - */ unsigned int SEGAAPI_GetEndOffset(void *hHandle); - -/** - * Allows the user to control whether the voice loops back to the - * Start Loop Offset when it crosses the End Loop Point or whether - * it goes into the release phase (i.e. post end loop). Note that - * setting the loop state doesn't actually cause the device - * to transition to the stopped state. - * - * - * CALL LEVELS: DPC, PASSIVE. - * - * @param hHandle - * An opaque identifier obtained from CreateBuffer. - * - * @param bDoContinuousLooping - * If TRUE, the buffer will loop from start-loop to end - * loop and back again. If FALSE, loop points are ignored - * and buffer will play until the sample end, as programmed - * with SetEndOffset. This may be programmed when as the buffer - * is playing. - * - * @return - * Returns SEGA_SUCCESS if successful. Otherwise, returns an appropriate - * error code. - */ int SEGAAPI_SetLoopState(void *hHandle, int bDoContinuousLooping); - -/** - * Returns the current loop status. - * - * CALL LEVELS: DPC, PASSIVE. - * - * @param hHandle - * An opaque identifier obtained from CreateBuffer. - * - * @return - * Returns TRUE if it is in loop state. Otherwise, returns FALSE. - * Note that returned value is set to FALSE if error invoked this function. - */ int SEGAAPI_GetLoopState(void *hHandle); - -/** - * Advises the driver code that some portion of the buffer - * has been written with new data. This method is required for devices - * which don't support a memory-mapped ring buffer and allows the - * underlying software to perform any necessary copying or format - * conversion. - * - * The caller should call this function *after* they have filled - * the data into the ring buffer that they passed - * to the driver in the CreateBuffer() call. - * - * Although this routine takes it values in bytes, the caller - * is responsible for insuring that the starting offset and - * length are a integer multiple of the sample size. - * - * CALL LEVELS: DPC, PASSIVE. - * - * @param hHandle - * An opaque identifier obtained from CreateBuffer. - * - * @param dwStartOffset - * The offset of the first byte in the buffer which - * has changed (between 0 and bufferSize-1) - * @param dwLength - * The number of bytes which have changed. - * - * @return - * Returns SEGA_SUCCESS if successful. Otherwise, returns an appropriate - * error code. - */ int SEGAAPI_UpdateBuffer(void *hHandle, unsigned int dwStartOffset, unsigned int dwLength); - -/*********************************************************** - * @section - * Low level API to control Synth buffer parameters - * - */ - -/** - * Sets and stores a synthesizer parameter, in Perceptually-Additive Real-World (PARW) units - * - * The parameter is applied for mono buffer only. - * - * CALL LEVELS: DPC, PASSIVE. - * - * @param hHandle - * An opaque identifier obtained from CreateBuffer. - * - * @param param - * The parameter to apply - * - * @param lPARWValue - * The value in PARW units - * - * @return - * Returns SEGA_SUCCESS if successful. Otherwise, returns an appropriate - * error code. - */ int SEGAAPI_SetSynthParam(void *hHandle, HASYNTHPARAMSEXT param, int lPARWValue); - -/** - * Returns the most recent call to SetSynthParam() in PARW units. This is the cache value - * of the most recent PARW value set by SetSynthParam(). If the parameter has not been set - * before, this function will return 0. - * - * The parameter is applied for mono buffer only. - * - * CALL LEVELS: DPC, PASSIVE. - * - * @param hHandle - * An opaque identifier obtained from CreateBuffer. - * - * @param param - * The parameter to retrieve - * - * @return - * The returned value in PARW units. - * Note that returned value is set to -1 if error invoked this function. - */ int SEGAAPI_GetSynthParam(void *hHandle, HASYNTHPARAMSEXT param); - -/** - * Sets and stores an array of synthesizer parameters, in Perceptually-Additive Real-World (PARW) units. - * - * The parameter is applied for mono buffer only. - * - * CALL LEVELS: DPC, PASSIVE. - * - * @param hHandle - * An opaque identifier obtained from CreateBuffer. - * - * @param dwNumParams - * Number of parameters to apply - * - * @param pSynthParams - * Pointer to the Synth Parameters array to apply. - * - * @return - * Returns SEGA_SUCCESS if successful. Otherwise, returns an appropriate - * error code. - */ int SEGAAPI_SetSynthParamMultiple(void *hHandle, unsigned int dwNumParams, SynthParamSet *pSynthParams); - -/** - * Retrieves an array of synthesizer parameters, in Perceptually-Additive Real-World (PARW) units. - * - * The parameter is applied for mono buffer only. - * - * CALL LEVELS: DPC, PASSIVE. - * - * @param hHandle - * An opaque identifier obtained from CreateBuffer. - * - * @param dwNumParams - * Number of parameters to retrieve. - * - * @param pSynthParams - * Pointer to the Synth Parameters array to retrieve. - * - * @return - * Returns SEGA_SUCCESS if successful. Otherwise, returns an appropriate - * error code. - */ int SEGAAPI_GetSynthParamMultiple(void *hHandle, unsigned int dwNumParams, SynthParamSet *pSynthParams); - -/** - * Set the voice into the release phase of the volume envelope engines when set to TRUE. - * This will automatically stop the voice when the voice reaches end of release phase. - * - * CALL LEVELS: DPC, PASSIVE. - * - * @param hHandle - * An opaque identifier obtained from CreateBuffer. - * - * @param bSet - * TRUE for enter releaes phase - * - * @return - * Returns SEGA_SUCCESS if successful. Otherwise, returns an appropriate - * error code. - */ int SEGAAPI_SetReleaseState(void *hHandle, int bSet); - -/*********************************************************** - * @section - * Playback buffers (voices) callback notification function. - * - */ - -/** - * A callback function of this type is passed into the - * CreateBuffer() function and gets invoked when a WaveOutBuffer - * client needs to notify the OS of some event. Currently, the following event - * types are defined: - * - * HAWOS_RESOURCE_STOLEN -- Indicates the resources used to - * play the audio have been stolen. - * - * HAWOS_NOTIFY -- Indicates that the current play position - * has passed over one of the notification points set - * with SetNotificationPoint. - * - * CALL LEVELS: The callback is invoked at DPC level. - * - * @param hHandle - * An opaque identifier obtained from CreateBuffer. - * - * @param HAWOSMESSAGETYPE message - * The callback message. - */ -typedef void (*HAWOSEGABUFFERCALLBACK)(void *hHandle, - HAWOSMESSAGETYPE message); - -/*********************************************************** - * @section - * API to create playback buffers (voices). - * - * This is the entry call to obtain the voice handle - * and perform further voice operations. - */ - -/** - * Creates a new buffer (voice) of the output device using - * the configuration specified in pConfig. - * - * There are two types of buffers: normal buffer and synthesizer buffer. - * Typically, a buffer is created as normal buffer. Synthesizer buffer - * is used if a buffer requires synthesizer type of parameter controls. - * - * Caller specifies the configuration to create in pConfig structure. - * Driver will allocate memory and hardware resources needed for this - * voice creation. If successful, the pConfig->mapdata.hBufferHdr contains - * the memory address that user-space application can access. Caller - * should write the valid sound data into this memory buffer. - * - * Caller can indicate to the sound driver to use the caller allocated sound - * data memory buffer for efficiency purpose if the same buffer is re-used frequently. - * In such a case, caller needs to provide the sound buffer address in the - * pConfig->mapdata.hBufferHdr and sets the HABUF_ALLOC_USER_MEM bit - * of dwFlags parameter. Caller needs to ensure that the sound buffer - * memory is page-aligned and locked. - * - * pConfig->mapdata.dwSize must be sample frame aligned. For example, - * 16-bit 1 channel is WORD aligned, 16-bit 2 channel is DWORD aligned. - * For more efficient memory management, pConfig->mapdata.dwSize is - * recomended to be page aligned. - * - * The size of the ring buffer is fixed throughout the lifetime of the - * buffer until it is destroyed. During the lifetime of the buffer, - * caller can periodically update the data of the buffer if necessary or - * modulate the buffer with SetSynthParam or SetSynthParamMultiple functions - * if the buffer is created as synthesizer buffer. - * - * If all the voices are currently in use, CreateBuffer will perform voice-stealing - * to fulfill the request. Note that voice stealing may fail if all voices that are - * currently in use are set to HAWOSEP_MAXIMUM priority. - * - * The followings are default values for a newly created buffer: - * - Send Routing - * - for 1 channel buffer, channel is routed to Front-Left and Front-Right. - * - for 2 channel buffer, channel 0 is routed Front-Left, channel 1 is routed Front-Right - * - Send Levels are set to 0 (infinite attenuation) - * - Channel Volume is set to 0xFFFFFFFF (no attenuation) - * - No notification. - * - StartLoopOffset is set to 0. - * - EndLoopOffset and EndOffset are set to pConfig->mapdata.dwSize. - * - No loop. - * - Buffer is in the stop state. - * - Play position is set to 0. - * - * CALL LEVELS: PASSIVE. - * - * @param pConfig - * A pointers to configuration structures containing - * information about how the clients should be opened. - * - * @param pCallback - * A pointer to the callback function. - * - * @param dwFlags - * HABUF_SYNTH_BUFFER bit when set indicates synthesizer buffer. - * HABUF_ALLOC_USER_MEM bit when set indicates caller allocate sound data memory buffer. - * - * @param phHandle - * A pointer to a memory address where the token of new client identifier - * should be placed. - * - * @return - * Returns SEGA_SUCCESS if successful. Otherwise, returns an appropriate - * error code. - * - * @retval SEGAERR_BAD_POINTER if either the pConfig or phHandle pointers are - * NULL. - * @retval SEGAERR_OUT_OF_MEMORY if buffer size requested in pConfig cannot be - * allocated. - * @retval SEGAERR_BAD_CONFIG if the device can't support the configuration - * requested. - * @retval SEGAERR_NO_RESOURCES if no resources are available for creating - * the device. Generally, increasing the client's priority - * will allow a subsequent creation request to succeed. - */ -int SEGAAPI_CreateBuffer(HAWOSEBUFFERCONFIG *pConfig, - HAWOSEGABUFFERCALLBACK pCallback, - unsigned int dwFlags, - void **phHandle); - -/** - * Destroys the buffer previously created with CreateBuffer(). - * This will free all the resources previously allocated to this buffer. - * - * This function will stop the buffer if it is not at the stop state before - * freeing all the resources. - * - * CALL LEVELS: PASSIVE. - * - * @param hHandle - * An opaque identifier obtained from CreateBuffer. - * - * @return - * Returns SEGA_SUCCESS if successful. Otherwise, returns an appropriate - * error code. - */ +typedef void (*HAWOSEGABUFFERCALLBACK)(void *hHandle, HAWOSMESSAGETYPE message); +int SEGAAPI_CreateBuffer(HAWOSEBUFFERCONFIG *pConfig, HAWOSEGABUFFERCALLBACK pCallback, unsigned int dwFlags, void **phHandle); int SEGAAPI_DestroyBuffer(void *hHandle); - -/*********************************************************** - * @section - * API to control effect slots and effects parameters. - * - * Refers to the EAX4 Programmer's Guide for the details of - * controlling FX Slots and controlling Effect parameters. - * - * Only the EAX4 FX Slots and Effect Parameters property controls - * will be implemented for this project. - * - * Need to add property to switch the FX returns for - * FXSlot2 and FXSlot3 when non-reverb is loaded to these slots - * as per SEGA request. - */ - -/** - * Sets global EAX property. - * - * This function sets the EAX4 FX Slots and Effect Parameters property - * controls as defined in EAX4 EAX4 Programmer's Guide. - * - * @param guid - * EAX Object GUID - * - * @param ulProperty - * Property enumeration value of each object - * - * @param pData - * A pointer to a memory address where the data will be accessed - * - * @param ulDataSize - * An unsigned integer indicating the size of the data pointed to by the pData. - * - * @return - * Returns TRUE if successful. Otherwise, returns FALSE. - */ int SEGAAPI_SetGlobalEAXProperty(GUID *guid, unsigned long ulProperty, void *pData, unsigned long ulDataSize); - -/** - * Gets global EAX property. - * - * This function gets the EAX4 FX Slots and Effect Parameters property - * controls as defined in EAX4 EAX4 Programmer's Guide. - * - * @param guid - * EAX Object GUID - * - * @param ulProperty - * Property enumeration value of each object - * - * @param pData - * A pointer to a memory address where the data will be accessed - * - * @param ulDataSize - * An unsigned integer indicating the size of the data pointed to by the pData. - * - * @return - * Returns TRUE if successful. Otherwise, returns FALSE. - */ int SEGAAPI_GetGlobalEAXProperty(GUID *guid, unsigned long ulProperty, void *pData, unsigned long ulDataSize); - -/*********************************************************** - * @section - * API to control SPDIF Output channel status, sampling rate - * and output routing matrix. - * - */ - -/** - * Sets SPDIF Out channel status. - * - * @param dwChannelStatus - * Channel Status - * - * @param dwExtChannelStatus - * Extended Channel Status - * - * @return - * Returns SEGA_SUCCESS if successful. Otherwise, returns an appropriate - * error code. - */ -int SEGAAPI_SetSPDIFOutChannelStatus( - unsigned int dwChannelStatus, - unsigned int dwExtChannelStatus); - -/** - * Gets SPDIF Out channel status. - * - * @param pdwChannelStatus - * Pointer to address where Channel Status is returned to. - * - * @param pdwExtChannelStatus - * Pointer to address where Extended Channel Status is returned to. - * - * @return - * Returns SEGA_SUCCESS if successful. Otherwise, returns an appropriate - * error code. - */ -int SEGAAPI_GetSPDIFOutChannelStatus( - unsigned int *pdwChannelStatus, - unsigned int *pdwExtChannelStatus); - -/** - * Sets the SPDIF Out sampling rate. This function also updates the - * SPDIF-Out channel status to reflect the correct sampling rate. - * The default SPDIF Out sampling rate is 48KHz. - * - * @param dwSamplingRate - * Sampling rate enumeration type - * - * @return - * Returns SEGA_SUCCESS if successful. Otherwise, returns an appropriate - * error code. - */ +int SEGAAPI_SetSPDIFOutChannelStatus(unsigned int dwChannelStatus, unsigned int dwExtChannelStatus); +int SEGAAPI_GetSPDIFOutChannelStatus(unsigned int *pdwChannelStatus, unsigned int *pdwExtChannelStatus); int SEGAAPI_SetSPDIFOutSampleRate(HASPDIFOUTRATE dwSamplingRate); - -/** - * Gets SPDIF Out sampling rate - * - * @return - * Returns sampling rate enum. - * Note that returned value is set to HASPDIFOUT_48KHZ if error invoked this function. - */ HASPDIFOUTRATE SEGAAPI_GetSPDIFOutSampleRate(void); - -/** - * Sets SPDIF Out channel routing. - * - * @param dwChannel - * The channel to route. - * 0 for Left channel, 1 for right channel. - * - * @param dwSource - * The source to which the channel should be received signal from. - * If the channel doesn't need to be connected to anything, - * specify HA_UNUSED_PORT. - * HA_FXSLOTx_PORT is not a valid source. Routes from these ports - * will return failure. - * - * See HAROUTING for the details of the source enumeration list. - * - * @return - * Returns SEGA_SUCCESS if successful. Otherwise, returns an appropriate - * error code. - */ -int SEGAAPI_SetSPDIFOutChannelRouting( - unsigned int dwChannel, - HAROUTING dwSource); - -/** - * Gets SPDIF Out channel routing - * - * @param dwChannel - * The channel to route. - * 0 for Left channel, 1 for right channel. - * - * @return - * The source to which the channel is received signal from. - * Note that returned value is set to HA_UNUSED_PORT if error invoked this function. - * - * See HAROUTING for the details of the source enumeration list. - */ +int SEGAAPI_SetSPDIFOutChannelRouting( unsigned int dwChannel, HAROUTING dwSource); HAROUTING SEGAAPI_GetSPDIFOutChannelRouting(unsigned int dwChannel); - -/*********************************************************** - * @section - * API to control global inputs and outputs volume. - * For outputs, these volume controls are post-routing. - */ - -/** - * Sets the volume to a specific linear value. Volumes are specified - * as fractional fixed-point linear values between HAWOSEVOL_MAX (0xFFFFFFFF) - * and 0x0. Note that only the upper word is effective. - * - * @param dwPhysIO - * The Physical IO being addressed. - * - * @param dwVolume - * The new volume level. - * - * @return - * Returns SEGA_SUCCESS if successful. Otherwise, returns an appropriate - * error code. - */ int SEGAAPI_SetIOVolume(HAPHYSICALIO dwPhysIO, unsigned int dwVolume); - -/** - * Returns the current volume level for the requested physical IO. - * - * @param dwPhysIO - * The Physical IO being addressed. - * - * @return - * The current volume. - * Note that returned value is set to 0xffffffff if error invoked this function. - */ unsigned int SEGAAPI_GetIOVolume(HAPHYSICALIO dwPhysIO); - -/** - * Sets the last status code manually. - * - * Typically, this is use to reset the last status code. - * Note that the last status code will be reset whenever a function is invoked. - * - * @param LastStatus - * The last status code to change to. - * - * @return - * None. - */ void SEGAAPI_SetLastStatus(int LastStatus); - -/** - * Returns the last status code for the function that just invoked. - * The last status code will be reset whenever a function is invoked. - * Therefore, The last status code should be checked immediately after a function - * is invoked. - * - * For functions that return int, caller can check the return code - * immediately without needing to call GetLastStatus function. - * - * @return - * The int code. - */ int SEGAAPI_GetLastStatus(void); - -/** - * Resets the driver to its default states. - * - * This includes but not limited to the followings: - * - Stop and destroy all the currently playing buffers. All previous buffer - * handles are no longer valid after returning from this call. - * - Resets all volume levels to its default. - * - Resets EAX property values to their defaults. - * - Resets SPDIF Out sampling rate and routing to its default. - * - * - * @return - * The int code. - */ int SEGAAPI_Reset(void); - -/** - * Initializes the SEGAAPI Library. - * - * This must be the first function to call before using any of the SEGAAPI functions. - * - * - * @return - * The int code. - */ int SEGAAPI_Init(void); - -/** - * Exits from the SEGAAPI Library. - * - * This function performs cleanup on the SEGAAPI Library. - * It must be the last function to call. - * - * - * @return - * The int code. - */ int SEGAAPI_Exit(void); #endif /* __SEGAAPI_H */ diff --git a/src/lindbergh/graphics.c b/src/lindbergh/graphics.c index 8905d63..ebd4e36 100644 --- a/src/lindbergh/graphics.c +++ b/src/lindbergh/graphics.c @@ -76,6 +76,9 @@ Window XCreateWindow(Display *display, Window parent, int x, int y, unsigned int width = getConfig()->width; height = getConfig()->height; + width = 10; + height = 10; + // Ensure that the windows will respond with keyboard and mouse events attributes->event_mask = attributes->event_mask | KeyPressMask | KeyReleaseMask | PointerMotionMask; attributes->override_redirect = 0;