Update mojoAL
This commit is contained in:
parent
bd3fd0957a
commit
6d763a1e26
@ -7,10 +7,11 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h> /* needed for alloca */
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <float.h>
|
#include <float.h>
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _WIN32
|
||||||
#define AL_API __declspec(dllexport)
|
#define AL_API __declspec(dllexport)
|
||||||
#define ALC_API __declspec(dllexport)
|
#define ALC_API __declspec(dllexport)
|
||||||
#endif
|
#endif
|
||||||
@ -532,7 +533,7 @@ struct ALCcontext_struct
|
|||||||
};
|
};
|
||||||
|
|
||||||
/* forward declarations */
|
/* forward declarations */
|
||||||
static int source_get_offset(ALsource *src, ALenum param);
|
static float source_get_offset(ALsource *src, ALenum param);
|
||||||
static void source_set_offset(ALsource *src, ALenum param, ALfloat value);
|
static void source_set_offset(ALsource *src, ALenum param, ALfloat value);
|
||||||
|
|
||||||
/* the just_queued list is backwards. Add it to the queue in the correct order. */
|
/* the just_queued list is backwards. Add it to the queue in the correct order. */
|
||||||
@ -3959,31 +3960,33 @@ static void source_pause(ALCcontext *ctx, const ALuint name)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int source_get_offset(ALsource *src, ALenum param)
|
static float source_get_offset(ALsource *src, ALenum param)
|
||||||
{
|
{
|
||||||
int offset = 0;
|
int offset = 0;
|
||||||
int framesize = sizeof(float);
|
int framesize = sizeof (float);
|
||||||
int freq = 1;
|
int freq = 1;
|
||||||
if (src->type == AL_STREAMING) {
|
if (src->type == AL_STREAMING) {
|
||||||
/* streaming: the offset counts from the first processed buffer in the queue. */
|
/* streaming: the offset counts from the first processed buffer in the queue. */
|
||||||
BufferQueueItem *item = src->buffer_queue.head;
|
BufferQueueItem *item = src->buffer_queue.head;
|
||||||
if (item) {
|
if (item) {
|
||||||
framesize = (int)(item->buffer->channels * sizeof(float));
|
framesize = (int) (item->buffer->channels * sizeof (float));
|
||||||
freq = (int)(item->buffer->frequency);
|
freq = (int) (item->buffer->frequency);
|
||||||
int proc_buf = SDL_AtomicGet(&src->buffer_queue_processed.num_items);
|
int proc_buf = SDL_AtomicGet(&src->buffer_queue_processed.num_items);
|
||||||
offset = (proc_buf * item->buffer->len + src->offset);
|
offset = (proc_buf * item->buffer->len + src->offset);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
framesize = (int)(src->buffer->channels * sizeof(float));
|
framesize = (int) (src->buffer->channels * sizeof (float));
|
||||||
freq = (int)src->buffer->frequency;
|
freq = (int) src->buffer->frequency;
|
||||||
offset = src->offset;
|
offset = src->offset;
|
||||||
}
|
}
|
||||||
switch(param) {
|
switch(param) {
|
||||||
case AL_SAMPLE_OFFSET: return offset / framesize; break;
|
case AL_SAMPLE_OFFSET: return (float) (offset / framesize); break;
|
||||||
case AL_SEC_OFFSET: return (offset / framesize) / freq; break;
|
case AL_SEC_OFFSET: return ((float) (offset / framesize)) / ((float) freq); break;
|
||||||
case AL_BYTE_OFFSET: return offset; break;
|
case AL_BYTE_OFFSET: return (float) offset; break;
|
||||||
default: return 0; break;
|
default: break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return 0.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void source_set_offset(ALsource *src, ALenum param, ALfloat value)
|
static void source_set_offset(ALsource *src, ALenum param, ALfloat value)
|
||||||
@ -3994,21 +3997,17 @@ static void source_set_offset(ALsource *src, ALenum param, ALfloat value)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int bufflen = 0;
|
|
||||||
int framesize = sizeof(float);
|
|
||||||
int freq = 1;
|
|
||||||
|
|
||||||
if (src->type == AL_STREAMING) {
|
if (src->type == AL_STREAMING) {
|
||||||
FIXME("set_offset for streaming sources not implemented");
|
FIXME("set_offset for streaming sources not implemented");
|
||||||
return;
|
return;
|
||||||
} else {
|
|
||||||
bufflen = (int)src->buffer->len;
|
|
||||||
framesize = (int)(src->buffer->channels * sizeof(float));
|
|
||||||
freq = (int)src->buffer->frequency;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const int bufflen = (int) src->buffer->len;
|
||||||
|
const int framesize = (int) (src->buffer->channels * sizeof (float));
|
||||||
|
const int freq = (int) src->buffer->frequency;
|
||||||
int offset = -1;
|
int offset = -1;
|
||||||
switch(param) {
|
|
||||||
|
switch (param) {
|
||||||
case AL_SAMPLE_OFFSET:
|
case AL_SAMPLE_OFFSET:
|
||||||
offset = value * framesize;
|
offset = value * framesize;
|
||||||
break;
|
break;
|
||||||
@ -4019,11 +4018,15 @@ static void source_set_offset(ALsource *src, ALenum param, ALfloat value)
|
|||||||
offset = ((int)value / framesize) * framesize;
|
offset = ((int)value / framesize) * framesize;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (offset < 0 || offset > bufflen) {
|
|
||||||
|
if ((offset < 0) || (offset > bufflen)) {
|
||||||
set_al_error(ctx, AL_INVALID_VALUE);
|
set_al_error(ctx, AL_INVALID_VALUE);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* make sure the offset lands on a sample frame boundary. */
|
||||||
|
offset -= offset % framesize;
|
||||||
|
|
||||||
if (!SDL_AtomicGet(&src->mixer_accessible)) {
|
if (!SDL_AtomicGet(&src->mixer_accessible)) {
|
||||||
src->offset = offset;
|
src->offset = offset;
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user