Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Remove dependencies on TLSF and libkern.

  • Loading branch information...
commit bfa23b108a009d015632d2d87ac9bfbd4a05f50f 1 parent cd9215e
@jvoorhis authored
Showing with 6 additions and 48 deletions.
  1. +3 −14 ext/Rakefile
  2. +3 −23 ext/siren.c
  3. +0 −11 ext/siren.h
View
17 ext/Rakefile
@@ -14,32 +14,21 @@ LIBS = %w[
/usr/local/lib/libportaudio.a
]
-TLSF_DIR = 'vendor/TLSF-2.4.6/src'
-TLSF = File.join(TLSF_DIR, 'tlsf.o')
-
SRC = %w[
siren.h
siren.c
]
-file TLSF do
- Dir.chdir(TLSF_DIR) do
- sh 'make'
- end
-end
-
-file SIREN => [TLSF, *SRC] do |t|
- includes = "-I #{TLSF_DIR}"
+file SIREN => [*SRC] do |t|
frameworks = FRAMEWORKS.map { |f| "-framework #{f}" } * " "
libs = LIBS * " "
- sh "gcc -Wall #{includes} -c -fPIC -O3 siren.c"
- sh "gcc -dynamiclib #{frameworks} #{libs} siren.o #{TLSF} -o #{t.name}"
+ sh "gcc -Wall -c -fPIC -O3 siren.c"
+ sh "gcc -dynamiclib #{frameworks} #{libs} siren.o -o #{t.name}"
end
task :test => SIREN
task :clean do
- FileUtils.rm_f TLSF
FileUtils.rm_f '*.o'
FileUtils.rm_f '*.dylib'
end
View
26 ext/siren.c
@@ -11,8 +11,6 @@ static inline Sample32 clip(Sample32 samp)
int InitDSPSystem()
{
- init_memory_pool(POOL_SIZE, pool);
-
if (Pa_Initialize()) {
fprintf(stderr, "Error initializing PortAudio");
return 1;
@@ -55,7 +53,6 @@ int NewDSPKernel(int deviceID, int channels, double fs, DSPKernel **outKernel)
kernel->frame = 0;
kernel->channels = channels;
kernel->voiceList = NULL;
- kernel->lock = OS_SPINLOCK_INIT;
*outKernel = kernel;
return 0;
}
@@ -66,16 +63,6 @@ int DisposeDSPKernel(DSPKernel *kernel)
return 0;
}
-static inline void DSPKernelLock(DSPKernel *kernel)
-{
- OSSpinLockLock(&kernel->lock);
-}
-
-static inline void DSPKernelUnlock(DSPKernel *kernel)
-{
- OSSpinLockUnlock(&kernel->lock);
-}
-
int DSPKernelCallback(const void *bufferIn, void *bufferOut,
unsigned long frameCount,
const PaStreamCallbackTimeInfo *timeInfo,
@@ -88,7 +75,6 @@ int DSPKernelCallback(const void *bufferIn, void *bufferOut,
Sample32 sampleOut;
Voice *voice;
- DSPKernelLock(kernel);
for (frame = 0; frame < frameCount; frame++) {
for (channel = 0; channel < kernel->channels; channel++) {
sampleOut = 0.0;
@@ -104,7 +90,6 @@ int DSPKernelCallback(const void *bufferIn, void *bufferOut,
}
kernel->frame++;
}
- DSPKernelUnlock(kernel);
return paContinue;
}
@@ -131,26 +116,22 @@ int DSPKernelStop(DSPKernel *kernel)
VoiceID NewVoice(DSPKernel *kernel, RenderFunc render, void *state)
{
- Voice *voice = malloc_ex(sizeof(Voice), pool);
+ Voice *voice = malloc(sizeof(Voice));
voice->render = render;
voice->frame = 0;
voice->state = state;
voice->next = kernel->voiceList;
- DSPKernelLock(kernel);
kernel->voiceList = voice;
- DSPKernelUnlock(kernel);
return (VoiceID)voice;
}
int RemoveVoice(DSPKernel *kernel, Voice *remove)
{
Voice *voice = kernel->voiceList;
- DSPKernelLock(kernel);
if (kernel->voiceList == remove) {
kernel->voiceList = remove->next;
- free_ex(remove, pool);
- DSPKernelUnlock(kernel);
+ free(remove);
return 0;
}
@@ -161,13 +142,12 @@ int RemoveVoice(DSPKernel *kernel, Voice *remove)
int result;
if (voice->next) {
voice->next = remove->next;
- free_ex(remove, pool);
+ free(remove);
result = 0;
} else {
result = -1;
}
- DSPKernelUnlock(kernel);
return result;
}
View
11 ext/siren.h
@@ -2,12 +2,6 @@
#define __SIREN_H
#include <portaudio.h>
-#include <tlsf.h>
-#include <libkern/OSAtomic.h>
-
-#define POOL_SIZE 1024 * 1024
-
-static char pool[POOL_SIZE];
int InitDSPSystem();
@@ -31,7 +25,6 @@ typedef struct _DSPKernel {
int channels;
int frame;
Voice *voiceList;
- OSSpinLock lock;
} DSPKernel;
int DSPKernelDeviceCount();
@@ -42,10 +35,6 @@ int NewDSPKernel(int deviceID, int channels, double fs, DSPKernel **outKernel);
int DisposeDSPKernel(DSPKernel *kernel);
-static inline void DSPKernelLock(DSPKernel *kernel);
-
-static inline void DSPKernelUnlock(DSPKernel *kernel);
-
int DSPKernelCallback(const void *input, void *output,
unsigned long frameCount,
const PaStreamCallbackTimeInfo *timeInfo,
Please sign in to comment.
Something went wrong with that request. Please try again.