diff --git a/include/SDL_config_kolibri.h b/include/SDL_config_kolibri.h index 123e1b6..cd885b6 100644 --- a/include/SDL_config_kolibri.h +++ b/include/SDL_config_kolibri.h @@ -47,63 +47,63 @@ #define HAVE_MALLOC 1 #define LACKS_SYS_MMAN_H 1 -#define HAVE_MALLOC 1 -#define HAVE_CALLOC 1 -#define HAVE_REALLOC 1 -#define HAVE_FREE 1 -#define HAVE_ALLOCA 1 -#define HAVE_QSORT 1 -#define HAVE_BSEARCH 1 -#define HAVE_ABS 1 -#define HAVE_BCOPY 1 -#define HAVE_MEMCPY 1 -#define HAVE_STRTOL 1 -#define HAVE_STRTOUL 1 -#define HAVE_STRTOLL 1 -#define HAVE_STRTOULL 1 -#define HAVE_ATOI 1 -#define HAVE_ATOF 1 -#define HAVE_VSSCANF 1 +#define HAVE_MALLOC 1 +#define HAVE_CALLOC 1 +#define HAVE_REALLOC 1 +#define HAVE_FREE 1 +#define HAVE_ALLOCA 1 +#define HAVE_QSORT 1 +#define HAVE_BSEARCH 1 +#define HAVE_ABS 1 +#define HAVE_BCOPY 1 +#define HAVE_MEMCPY 1 +#define HAVE_STRTOL 1 +#define HAVE_STRTOUL 1 +#define HAVE_STRTOLL 1 +#define HAVE_STRTOULL 1 +#define HAVE_ATOI 1 +#define HAVE_ATOF 1 +#define HAVE_VSSCANF 1 #define HAVE_VSNPRINTF 1 -#define HAVE_M_PI 1 -#define HAVE_CEIL 1 -#define HAVE_COPYSIGN 1 -#define HAVE_COS 1 -#define HAVE_COSF 1 -#define HAVE_EXP 1 -#define HAVE_FABS 1 -#define HAVE_FLOOR 1 -#define HAVE_LOG 1 -#define HAVE_LOG10 1 -#define HAVE_LROUND 1 -#define HAVE_LROUNDF 1 -#define HAVE_ROUND 1 -#define HAVE_ROUNDF 1 -#define HAVE_SCALBN 1 -#define HAVE_SIN 1 -#define HAVE_SINF 1 -#define HAVE_SQRT 1 -#define HAVE_SQRTF 1 -#define HAVE_TAN 1 -#define HAVE_TANF 1 -#define HAVE_TRUNC 1 -#define HAVE_TRUNCF 1 -#define HAVE_SETJMP 1 +#define HAVE_M_PI 1 +#define HAVE_CEIL 1 +#define HAVE_COPYSIGN 1 +#define HAVE_COS 1 +#define HAVE_COSF 1 +#define HAVE_EXP 1 +#define HAVE_FABS 1 +#define HAVE_FLOOR 1 +#define HAVE_LOG 1 +#define HAVE_LOG10 1 +#define HAVE_LROUND 1 +#define HAVE_LROUNDF 1 +#define HAVE_ROUND 1 +#define HAVE_ROUNDF 1 +#define HAVE_SCALBN 1 +#define HAVE_SIN 1 +#define HAVE_SINF 1 +#define HAVE_SQRT 1 +#define HAVE_SQRTF 1 +#define HAVE_TAN 1 +#define HAVE_TANF 1 +#define HAVE_TRUNC 1 +#define HAVE_TRUNCF 1 +#define HAVE_SETJMP 1 -/* Enable the N-Gage thread support (src/thread/ngage/\*.c) */ +/* Enable the dummy thread support (src/thread/dummy/\*.c) */ #define SDL_THREADS_DISABLED 1 -/* Enable the N-Gage timer support (src/timer/ngage/\*.c) */ -#define SDL_TIMER_DUMMY 1 +/* Enable the dummy timer support (src/timer/dummy/\*.c) */ +#define SDL_TIMER_DUMMY 1 -/* Enable the N-Gage video driver (src/video/ngage/\*.c) */ +/* Enable the dummy video driver (src/video/dummy/\*.c) */ #define SDL_VIDEO_DRIVER_DUMMY 1 -/* Enable the dummy audio driver (src/audio/dummy/\*.c) */ -#define SDL_AUDIO_DRIVER_KOLIBRI 1 +/* Enable the Kolibri audio driver (src/audio/kolibri/\*.c) */ +#define SDL_AUDIO_DRIVER_KOLIBRI 1 /* Enable the stub joystick driver (src/joystick/dummy/\*.c) */ -#define SDL_JOYSTICK_DISABLED 1 +#define SDL_JOYSTICK_DISABLED 1 /* Enable the stub haptic driver (src/haptic/dummy/\*.c) */ #define SDL_HAPTIC_DISABLED 1 diff --git a/src/audio/kolibri/SDL_kolibriaudio.c b/src/audio/kolibri/SDL_kolibriaudio.c index bf0e62d..607b13e 100644 --- a/src/audio/kolibri/SDL_kolibriaudio.c +++ b/src/audio/kolibri/SDL_kolibriaudio.c @@ -26,35 +26,35 @@ static SDL_AudioDevice *global_device; static void kolibri_audio_callback(void) { ksys_signal_info_t snd_signal; - SDL_AudioDevice *this; + SDL_AudioDevice *_this; SDL_AudioCallback callback; int bPaused; char str[100]; // initialize - this = global_device; - callback = this->spec.callback; + _this = global_device; + callback = _this->spec.callback; if (CreateBuffer(private->used_format | PCM_RING, 0, &private->hBuff)) { private->audio_response = 1; exit(0); } - GetBufferSize(private->hBuff, &this->spec.size); - sprintf(str, "buffer created, size is %d\n", this->spec.size); + GetBufferSize(private->hBuff, &_this->spec.size); + sprintf(str, "buffer created, size is %d\n", _this->spec.size); _ksys_debug_puts(str); - this->spec.size >>= 1; - this->work_buffer = SDL_calloc(1, this->spec.size); + _this->spec.size >>= 1; + _this->work_buffer = SDL_malloc(_this->spec.size); private->audio_response = 1; - if (!this->work_buffer) { + if (!_this->work_buffer) { DestroyBuffer(private->hBuff); exit(0); } // wait for resume - while (SDL_AtomicGet(&this->paused)) + while (SDL_AtomicGet(&_this->paused)) _ksys_thread_yield(); _ksys_debug_puts("audio_thread created\n"); @@ -64,15 +64,15 @@ static void kolibri_audio_callback(void) // main loop while (1) { - if (!SDL_AtomicGet(&this->paused)) { + if (!SDL_AtomicGet(&_this->paused)) { PlayBuffer(private->hBuff, 0); bPaused = 0; private->audio_response = 1; - } else if (SDL_AtomicGet(&this->paused)) { + } else if (SDL_AtomicGet(&_this->paused)) { StopBuffer(private->hBuff); bPaused = 1; private->audio_response = 1; - } else if (SDL_AtomicGet(&this->shutdown)) { + } else if (SDL_AtomicGet(&_this->shutdown)) { private->audio_response = 1; StopBuffer(private->hBuff); DestroyBuffer(private->hBuff); @@ -80,7 +80,7 @@ static void kolibri_audio_callback(void) } else { _ksys_thread_info(&thread_info, main_slot); if (thread_info.slot_state == KSYS_SLOT_STATE_FREE || thread_info.pid != main_tid) { - SDL_AtomicSet(&this->shutdown, 1); + SDL_AtomicSet(&_this->shutdown, 1); continue; } } @@ -90,8 +90,8 @@ static void kolibri_audio_callback(void) _ksys_wait_signal(&snd_signal); if (snd_signal.id != 0xFF000001) continue; - callback(this->spec.userdata, this->work_buffer, this->spec.size); - SetBuffer(private->hBuff, this->work_buffer, ((int *)snd_signal.data)[2], this->spec.size); + callback(_this->spec.userdata, _this->work_buffer, _this->spec.size); + SetBuffer(private->hBuff, _this->work_buffer, ((int *)snd_signal.data)[2], _this->spec.size); } } } @@ -115,7 +115,7 @@ static int KOLIBRIAUDIO_OpenDevice(_THIS, const char *devname) char buff[100]; if (InitSound(&ver)) { - _ksys_debug_puts("Error: cannot load drivers!\n"); + SDL_SetError("Error: cannot load drivers!\n"); return -1; } @@ -124,32 +124,36 @@ static int KOLIBRIAUDIO_OpenDevice(_THIS, const char *devname) return SDL_OutOfMemory(); } - switch (this->spec.freq) { + switch (_this->spec.freq) { #define HANDLE_FREQ(freq, symb) \ case freq: \ - switch (this->spec.channels) { \ + switch (_this->spec.channels) { \ case 1: \ - switch (this->spec.format) { \ + switch (_this->spec.format) { \ case AUDIO_U8: \ case AUDIO_S8: \ - private->used_format = PCM_1_8_##symb; \ + private \ + ->used_format = PCM_1_8_##symb; \ break; \ case AUDIO_U16SYS: \ case AUDIO_S16SYS: \ - private->used_format = PCM_1_16_##symb; \ + private \ + ->used_format = PCM_1_16_##symb; \ break; \ } \ break; \ case 2: \ - switch (this->spec.format) { \ + switch (_this->spec.format) { \ case AUDIO_U8: \ case AUDIO_S8: \ - private->used_format = PCM_2_8_##symb; \ + private \ + ->used_format = PCM_2_8_##symb; \ break; \ case AUDIO_U16SYS: \ case AUDIO_S16SYS: \ - private->used_format = PCM_2_16_##symb; \ + private \ + ->used_format = PCM_2_16_##symb; \ break; \ } \ break; \ @@ -168,7 +172,7 @@ static int KOLIBRIAUDIO_OpenDevice(_THIS, const char *devname) } if (!private->used_format) { - _ksys_debug_puts("Unknown audio format"); + SDL_SetError("Unknown audio format"); return -1; } @@ -180,10 +184,10 @@ static int KOLIBRIAUDIO_OpenDevice(_THIS, const char *devname) break; } - global_device = this; + global_device = _this; private->audio_tid = _ksys_create_thread(kolibri_audio_callback, thread_stack + AUDIO_THREAD_STACK_SIZE); if (private->audio_tid < 0) { - _ksys_debug_puts("Cannot create audio thread"); + SDL_SetError("Cannot create audio thread"); return -1; } @@ -192,20 +196,20 @@ static int KOLIBRIAUDIO_OpenDevice(_THIS, const char *devname) _ksys_thread_yield(); if (!private->hBuff) { - _ksys_debug_puts("Cannot create audio buffer"); + SDL_SetError("Cannot create audio buffer"); return -1; } - if (!this->work_buffer) { - _ksys_debug_puts("Cannot allocate audio buffer"); + if (!_this->work_buffer) { + SDL_SetError("Cannot allocate audio buffer"); return -1; } - this->spec.silence = (this->spec.format == AUDIO_U8 ? 0x80 : 0); - this->spec.samples = this->spec.size / this->spec.channels; - if (this->spec.format == AUDIO_U16SYS || this->spec.format == AUDIO_S16SYS) - this->spec.samples /= 2; + _this->spec.silence = (_this->spec.format == AUDIO_U8 ? 0x80 : 0); + _this->spec.samples = _this->spec.size / _this->spec.channels; + if (_this->spec.format == AUDIO_U16SYS || _this->spec.format == AUDIO_S16SYS) + _this->spec.samples /= 2; - sprintf(buff, "obtained size is %d, samples %d\n", this->spec.size, this->spec.samples); + sprintf(buff, "obtained size is %d, samples %d\n", _this->spec.size, _this->spec.samples); _ksys_debug_puts(buff); return 0; diff --git a/src/audio/kolibri/SDL_kolibriaudio.h b/src/audio/kolibri/SDL_kolibriaudio.h index d835166..a8f2a53 100644 --- a/src/audio/kolibri/SDL_kolibriaudio.h +++ b/src/audio/kolibri/SDL_kolibriaudio.h @@ -2,8 +2,8 @@ #ifndef SDL_kolibriaudio_h_ #define SDL_kolibriaudio_h_ -#define _THIS SDL_AudioDevice *this -#define private this->hidden +#define _THIS SDL_AudioDevice *_this +#define private _this->hidden typedef struct SDL_PrivateAudioData {