aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/radio
diff options
context:
space:
mode:
authorManuel Bachmann <manuel.bachmann@iot.bzh>2015-12-17 10:54:24 +0100
committerManuel Bachmann <manuel.bachmann@iot.bzh>2015-12-17 12:09:22 +0100
commit3bce4a6a8648c91b6ddea478116b3b0679ef4648 (patch)
tree752ddb7f13ba774998fefd052f6dd1c387e4e882 /plugins/radio
parent07fb99ec63d034983b768e8b8bd3d2b30ae37f6f (diff)
Final modifications for Radio-Audio API communication
Signed-off-by: Manuel Bachmann <manuel.bachmann@iot.bzh>
Diffstat (limited to 'plugins/radio')
-rw-r--r--plugins/radio/radio-api.c2
-rw-r--r--plugins/radio/radio-api.h3
-rw-r--r--plugins/radio/radio-rtlsdr.c17
3 files changed, 19 insertions, 3 deletions
diff --git a/plugins/radio/radio-api.c b/plugins/radio/radio-api.c
index f065a8ad..8754b63c 100644
--- a/plugins/radio/radio-api.c
+++ b/plugins/radio/radio-api.c
@@ -298,7 +298,7 @@ STATIC json_object* play (AFB_request *request) { /* AFB_SESSION_CHECK */
/* radio stop */
ctx->is_playing = 0;
_radio_stop (ctx->idx);
- json_object_object_add (jresp, "play-on", json_object_new_string ("off"));
+ json_object_object_add (jresp, "play", json_object_new_string ("off"));
}
return jresp;
diff --git a/plugins/radio/radio-api.h b/plugins/radio/radio-api.h
index 4ea41b1c..0dbd3422 100644
--- a/plugins/radio/radio-api.h
+++ b/plugins/radio/radio-api.h
@@ -21,6 +21,9 @@
#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 e90bda08..e5a609e3 100644
--- a/plugins/radio/radio-rtlsdr.c
+++ b/plugins/radio/radio-rtlsdr.c
@@ -19,6 +19,8 @@
#include "radio-api.h"
#include "radio-rtlsdr.h"
+static audioCtxHandleT *actx = NULL;
+
/* ------------- RADIO RTLSDR IMPLEMENTATION ---------------- */
/* --- PUBLIC FUNCTIONS --- */
@@ -46,6 +48,13 @@ PUBLIC unsigned char _radio_on (unsigned int num, radioCtxHandleT *ctx) {
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;
}
@@ -58,7 +67,11 @@ PUBLIC void _radio_off (unsigned int num) {
_radio_dev_free(dev_ctx[num]);
free(dev_ctx[num]);
}
+
/* free(dev_ctx); */
+
+ _alsa_free ("default");
+ free (actx);
}
PUBLIC void _radio_set_mode (unsigned int num, Mode mode) {
@@ -398,8 +411,8 @@ STATIC void* _output_thread_fn (void *ctx) {
while (dev_ctx->should_run) {
pthread_wait(&output->ok, &output->ok_m);
pthread_rwlock_rdlock(&output->lck);
- //if (!dev_ctx->mute)
- // mRadio->PlayAlsa((void*)&output->buf, output->buf_len);
+ if (!dev_ctx->mute)
+ _alsa_play(actx->idx, (void*)&output->buf, output->buf_len);
pthread_rwlock_unlock(&output->lck);
}