aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/radio
diff options
context:
space:
mode:
authorManuel Bachmann <manuel.bachmann@iot.bzh>2015-12-21 04:21:51 +0100
committerManuel Bachmann <manuel.bachmann@iot.bzh>2015-12-21 04:25:23 +0100
commit03bebc12f0fd5006a72e430084146a36d2db7c8d (patch)
treec9dc5d4e03099c802bf3cc4bf08a4658665b5408 /plugins/radio
parent6f22e88cd3e6d502efa7100ad2b129641305fb53 (diff)
Untie Radio and Audio APIs
Radio and Audio API functions do not cross-call themselves directly anymore ; this is necessary to have independent plugin binaries (.so) in the near future. (PS : audio buffer securization is WIP) Signed-off-by: Manuel Bachmann <manuel.bachmann@iot.bzh>
Diffstat (limited to 'plugins/radio')
-rw-r--r--plugins/radio/radio-api.h3
-rw-r--r--plugins/radio/radio-rtlsdr.c26
2 files changed, 11 insertions, 18 deletions
diff --git a/plugins/radio/radio-api.h b/plugins/radio/radio-api.h
index 0dbd3422..4ea41b1c 100644
--- a/plugins/radio/radio-api.h
+++ b/plugins/radio/radio-api.h
@@ -21,9 +21,6 @@
#include "radio-rtlsdr.h"
-#include "../audio/audio-api.h"
-#include "../audio/audio-alsa.h"
-
/* -------------- PLUGIN DEFINITIONS ----------------- */
#define MAX_RADIO 10
diff --git a/plugins/radio/radio-rtlsdr.c b/plugins/radio/radio-rtlsdr.c
index bba0d89a..a8c15faa 100644
--- a/plugins/radio/radio-rtlsdr.c
+++ b/plugins/radio/radio-rtlsdr.c
@@ -19,8 +19,6 @@
#include "radio-api.h"
#include "radio-rtlsdr.h"
-static audioCtxHandleT *actx = NULL;
-
/* ------------- RADIO RTLSDR IMPLEMENTATION ---------------- */
/* --- PUBLIC FUNCTIONS --- */
@@ -47,14 +45,7 @@ PUBLIC unsigned char _radio_on (unsigned int num, radioCtxHandleT *ctx) {
dev_ctx[num]->demod = NULL;
dev_ctx[num]->output = NULL;
_radio_dev_init(dev_ctx[num], num);
-
- actx = malloc (sizeof(audioCtxHandleT));
- actx->idx = -1;
- actx->volume = 25;
- actx->channels = 2;
- actx->mute = 0;
- _alsa_init ("default", actx);
-
+
return 1;
}
@@ -69,9 +60,6 @@ PUBLIC void _radio_off (unsigned int num) {
}
/* free(dev_ctx); */
-
- _alsa_free ("default");
- free (actx);
}
PUBLIC void _radio_set_mode (unsigned int num, Mode mode) {
@@ -407,14 +395,22 @@ STATIC void* _demod_thread_fn (void *ctx) {
STATIC void* _output_thread_fn (void *ctx) {
dev_ctx_T *dev_ctx = (dev_ctx_T *)ctx;
output_ctx *output = dev_ctx->output;
+ FILE *file;
+
+ file = fopen (AUDIO_BUFFER, "wb");
while (dev_ctx->should_run) {
pthread_wait(&output->ok, &output->ok_m);
pthread_rwlock_rdlock(&output->lck);
- if (!dev_ctx->mute)
- _alsa_play(actx->idx, (void*)&output->buf, output->buf_len);
+ if (!dev_ctx->mute && file) {
+ fwrite (output->buf, 2, output->buf_len, file);
+ fflush (file);
+ fseek (file, 0, SEEK_SET);
+ }
pthread_rwlock_unlock(&output->lck);
}
+ if (file) fclose(file);
+ unlink (AUDIO_BUFFER);
output->thr_finished = 1;
return 0;