X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=plugins%2Fradio%2Fradio-rtlsdr.c;h=7d7e498ad86ac4bc3fb5ef1ce2fde9e5bb09d1ca;hb=e6298876fdbf457b6dd61556472060a9fa652c82;hp=e90bda08f75b09582921c45f778e08123751d5d8;hpb=915d25a0c2fcff8a8bb189963f490e0894d05733;p=src%2Fapp-framework-binder.git
diff --git a/plugins/radio/radio-rtlsdr.c b/plugins/radio/radio-rtlsdr.c
index e90bda08..7d7e498a 100644
--- a/plugins/radio/radio-rtlsdr.c
+++ b/plugins/radio/radio-rtlsdr.c
@@ -16,6 +16,9 @@
* along with this program. If not, see .
*/
+#include
+#include
+
#include "radio-api.h"
#include "radio-rtlsdr.h"
@@ -45,7 +48,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);
-
+
return 1;
}
@@ -58,6 +61,7 @@ PUBLIC void _radio_off (unsigned int num) {
_radio_dev_free(dev_ctx[num]);
free(dev_ctx[num]);
}
+
/* free(dev_ctx); */
}
@@ -69,11 +73,11 @@ PUBLIC void _radio_set_mode (unsigned int num, Mode mode) {
_radio_apply_params(dev_ctx[num]);
}
-PUBLIC void _radio_set_freq (unsigned int num, float freq) {
+PUBLIC void _radio_set_freq (unsigned int num, double freq) {
if (!dev_ctx || !dev_ctx[num])
return;
- dev_ctx[num]->freq = freq;
+ dev_ctx[num]->freq = (float)freq;
_radio_apply_params(dev_ctx[num]);
}
@@ -394,14 +398,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)
- // mRadio->PlayAlsa((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;