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