aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2018-01-11 09:16:28 -0800
committerChris Robinson <[email protected]>2018-01-11 09:16:28 -0800
commit3832b25f308279539a3748bafdc5056d16e4b291 (patch)
tree72aad63e0452328ffdf483cf949edc2aa2ce66be
parent15ad5245bfa498dff729d2bb1cd91fad161cc806 (diff)
Move the ringbuffer declarations to a separate header
And rename alcRing.c to ringbuffer.c for consistency.
-rw-r--r--Alc/backends/alsa.c1
-rw-r--r--Alc/backends/coreaudio.c1
-rw-r--r--Alc/backends/dsound.c1
-rw-r--r--Alc/backends/jack.c1
-rw-r--r--Alc/backends/mmdevapi.c1
-rw-r--r--Alc/backends/opensl.c3
-rw-r--r--Alc/backends/oss.c1
-rw-r--r--Alc/backends/portaudio.c1
-rw-r--r--Alc/backends/winmm.c1
-rw-r--r--Alc/ringbuffer.c (renamed from Alc/alcRing.c)25
-rw-r--r--Alc/ringbuffer.h29
-rw-r--r--CMakeLists.txt2
-rw-r--r--OpenAL32/Include/alMain.h20
13 files changed, 43 insertions, 44 deletions
diff --git a/Alc/backends/alsa.c b/Alc/backends/alsa.c
index f941ce4b..fb5a4446 100644
--- a/Alc/backends/alsa.c
+++ b/Alc/backends/alsa.c
@@ -27,6 +27,7 @@
#include "alMain.h"
#include "alu.h"
#include "alconfig.h"
+#include "ringbuffer.h"
#include "threads.h"
#include "compat.h"
diff --git a/Alc/backends/coreaudio.c b/Alc/backends/coreaudio.c
index ec926d3d..ba73ab82 100644
--- a/Alc/backends/coreaudio.c
+++ b/Alc/backends/coreaudio.c
@@ -27,6 +27,7 @@
#include "alMain.h"
#include "alu.h"
+#include "ringbuffer.h"
#include <CoreServices/CoreServices.h>
#include <unistd.h>
diff --git a/Alc/backends/dsound.c b/Alc/backends/dsound.c
index f730dc95..f88a50c1 100644
--- a/Alc/backends/dsound.c
+++ b/Alc/backends/dsound.c
@@ -34,6 +34,7 @@
#include "alMain.h"
#include "alu.h"
+#include "ringbuffer.h"
#include "threads.h"
#include "compat.h"
#include "alstring.h"
diff --git a/Alc/backends/jack.c b/Alc/backends/jack.c
index 4ef9006c..0dc01ae7 100644
--- a/Alc/backends/jack.c
+++ b/Alc/backends/jack.c
@@ -27,6 +27,7 @@
#include "alMain.h"
#include "alu.h"
#include "alconfig.h"
+#include "ringbuffer.h"
#include "threads.h"
#include "compat.h"
diff --git a/Alc/backends/mmdevapi.c b/Alc/backends/mmdevapi.c
index 9afb62f0..ecd7eb5d 100644
--- a/Alc/backends/mmdevapi.c
+++ b/Alc/backends/mmdevapi.c
@@ -41,6 +41,7 @@
#include "alMain.h"
#include "alu.h"
+#include "ringbuffer.h"
#include "threads.h"
#include "compat.h"
#include "alstring.h"
diff --git a/Alc/backends/opensl.c b/Alc/backends/opensl.c
index aa1ff991..4ec003d8 100644
--- a/Alc/backends/opensl.c
+++ b/Alc/backends/opensl.c
@@ -26,8 +26,9 @@
#include "alMain.h"
#include "alu.h"
-#include "compat.h"
+#include "ringbuffer.h"
#include "threads.h"
+#include "compat.h"
#include "backends/base.h"
diff --git a/Alc/backends/oss.c b/Alc/backends/oss.c
index 196432e1..2ff7c72b 100644
--- a/Alc/backends/oss.c
+++ b/Alc/backends/oss.c
@@ -36,6 +36,7 @@
#include "alMain.h"
#include "alu.h"
#include "alconfig.h"
+#include "ringbuffer.h"
#include "threads.h"
#include "compat.h"
diff --git a/Alc/backends/portaudio.c b/Alc/backends/portaudio.c
index 0f4672c4..b793486f 100644
--- a/Alc/backends/portaudio.c
+++ b/Alc/backends/portaudio.c
@@ -27,6 +27,7 @@
#include "alMain.h"
#include "alu.h"
#include "alconfig.h"
+#include "ringbuffer.h"
#include "compat.h"
#include "backends/base.h"
diff --git a/Alc/backends/winmm.c b/Alc/backends/winmm.c
index b5b3cdb6..4e4d0c06 100644
--- a/Alc/backends/winmm.c
+++ b/Alc/backends/winmm.c
@@ -29,6 +29,7 @@
#include "alMain.h"
#include "alu.h"
+#include "ringbuffer.h"
#include "threads.h"
#include "backends/base.h"
diff --git a/Alc/alcRing.c b/Alc/ringbuffer.c
index d72b34f1..63add593 100644
--- a/Alc/alcRing.c
+++ b/Alc/ringbuffer.c
@@ -23,6 +23,7 @@
#include <string.h>
#include <stdlib.h>
+#include "ringbuffer.h"
#include "alMain.h"
#include "threads.h"
#include "almalloc.h"
@@ -39,7 +40,6 @@ struct ll_ringbuffer {
size_t size;
size_t size_mask;
size_t elem_size;
- int mlocked;
alignas(16) char buf[];
};
@@ -49,7 +49,7 @@ struct ll_ringbuffer {
ll_ringbuffer_t *ll_ringbuffer_create(size_t sz, size_t elem_sz)
{
ll_ringbuffer_t *rb;
- ALuint power_of_two;
+ size_t power_of_two;
power_of_two = NextPowerOf2(sz);
if(power_of_two < sz)
@@ -63,32 +63,13 @@ ll_ringbuffer_t *ll_ringbuffer_create(size_t sz, size_t elem_sz)
rb->size = power_of_two;
rb->size_mask = rb->size - 1;
rb->elem_size = elem_sz;
- rb->mlocked = 0;
return rb;
}
/* Free all data associated with the ringbuffer `rb'. */
void ll_ringbuffer_free(ll_ringbuffer_t *rb)
{
- if(rb)
- {
-#ifdef USE_MLOCK
- if(rb->mlocked)
- munlock(rb, sizeof(*rb) + rb->size*rb->elem_size);
-#endif /* USE_MLOCK */
- al_free(rb);
- }
-}
-
-/* Lock the data block of `rb' using the system call 'mlock'. */
-int ll_ringbuffer_mlock(ll_ringbuffer_t *rb)
-{
-#ifdef USE_MLOCK
- if(!rb->mlocked && mlock(rb, sizeof(*rb) + rb->size*rb->elem_size))
- return -1;
-#endif /* USE_MLOCK */
- rb->mlocked = 1;
- return 0;
+ al_free(rb);
}
/* Reset the read and write pointers to zero. This is not thread safe. */
diff --git a/Alc/ringbuffer.h b/Alc/ringbuffer.h
new file mode 100644
index 00000000..f764c20f
--- /dev/null
+++ b/Alc/ringbuffer.h
@@ -0,0 +1,29 @@
+#ifndef RINGBUFFER_H
+#define RINGBUFFER_H
+
+#include <stddef.h>
+
+
+typedef struct ll_ringbuffer ll_ringbuffer_t;
+typedef struct ll_ringbuffer_data {
+ char *buf;
+ size_t len;
+} ll_ringbuffer_data_t;
+
+ll_ringbuffer_t *ll_ringbuffer_create(size_t sz, size_t elem_sz);
+void ll_ringbuffer_free(ll_ringbuffer_t *rb);
+void ll_ringbuffer_reset(ll_ringbuffer_t *rb);
+
+void ll_ringbuffer_get_read_vector(const ll_ringbuffer_t *rb, ll_ringbuffer_data_t *vec);
+void ll_ringbuffer_get_write_vector(const ll_ringbuffer_t *rb, ll_ringbuffer_data_t *vec);
+
+size_t ll_ringbuffer_read(ll_ringbuffer_t *rb, char *dest, size_t cnt);
+size_t ll_ringbuffer_peek(ll_ringbuffer_t *rb, char *dest, size_t cnt);
+void ll_ringbuffer_read_advance(ll_ringbuffer_t *rb, size_t cnt);
+size_t ll_ringbuffer_read_space(const ll_ringbuffer_t *rb);
+
+size_t ll_ringbuffer_write(ll_ringbuffer_t *rb, const char *src, size_t cnt);
+void ll_ringbuffer_write_advance(ll_ringbuffer_t *rb, size_t cnt);
+size_t ll_ringbuffer_write_space(const ll_ringbuffer_t *rb);
+
+#endif /* RINGBUFFER_H */
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 929b5517..0b07f4ea 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -714,10 +714,10 @@ SET(OPENAL_OBJS OpenAL32/alAuxEffectSlot.c
SET(ALC_OBJS Alc/ALc.c
Alc/ALu.c
Alc/alconfig.c
- Alc/alcRing.c
Alc/bs2b.c
Alc/converter.c
Alc/mastering.c
+ Alc/ringbuffer.c
Alc/effects/chorus.c
Alc/effects/compressor.c
Alc/effects/dedicated.c
diff --git a/OpenAL32/Include/alMain.h b/OpenAL32/Include/alMain.h
index 5b4519eb..c11eb6d1 100644
--- a/OpenAL32/Include/alMain.h
+++ b/OpenAL32/Include/alMain.h
@@ -799,26 +799,6 @@ void ALCcontext_DeferUpdates(ALCcontext *context);
void ALCcontext_ProcessUpdates(ALCcontext *context);
-typedef struct ll_ringbuffer ll_ringbuffer_t;
-typedef struct ll_ringbuffer_data {
- char *buf;
- size_t len;
-} ll_ringbuffer_data_t;
-ll_ringbuffer_t *ll_ringbuffer_create(size_t sz, size_t elem_sz);
-void ll_ringbuffer_free(ll_ringbuffer_t *rb);
-void ll_ringbuffer_get_read_vector(const ll_ringbuffer_t *rb, ll_ringbuffer_data_t *vec);
-void ll_ringbuffer_get_write_vector(const ll_ringbuffer_t *rb, ll_ringbuffer_data_t *vec);
-size_t ll_ringbuffer_read(ll_ringbuffer_t *rb, char *dest, size_t cnt);
-size_t ll_ringbuffer_peek(ll_ringbuffer_t *rb, char *dest, size_t cnt);
-void ll_ringbuffer_read_advance(ll_ringbuffer_t *rb, size_t cnt);
-size_t ll_ringbuffer_read_space(const ll_ringbuffer_t *rb);
-int ll_ringbuffer_mlock(ll_ringbuffer_t *rb);
-void ll_ringbuffer_reset(ll_ringbuffer_t *rb);
-size_t ll_ringbuffer_write(ll_ringbuffer_t *rb, const char *src, size_t cnt);
-void ll_ringbuffer_write_advance(ll_ringbuffer_t *rb, size_t cnt);
-size_t ll_ringbuffer_write_space(const ll_ringbuffer_t *rb);
-
-
void SetRTPriority(void);
void SetDefaultChannelOrder(ALCdevice *device);