X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=plugins%2Fradio%2Fradio-rtlsdr.c;h=45db7f7bbed29a5d85e369a3a07d43cfe9cbc776;hb=3d28e7d00cd8641bf600d47ed0e3e7e57cb5b439;hp=e5a609e38f139544b9f8926530394fbed0e1613f;hpb=3bce4a6a8648c91b6ddea478116b3b0679ef4648;p=src%2Fapp-framework-binder.git
diff --git a/plugins/radio/radio-rtlsdr.c b/plugins/radio/radio-rtlsdr.c
index e5a609e3..45db7f7b 100644
--- a/plugins/radio/radio-rtlsdr.c
+++ b/plugins/radio/radio-rtlsdr.c
@@ -2,25 +2,25 @@
* Copyright (C) 2015 "IoT.bzh"
* Author "Manuel Bachmann"
*
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
*
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
+#include
+#include
+
#include "radio-api.h"
#include "radio-rtlsdr.h"
-static audioCtxHandleT *actx = NULL;
-
/* ------------- RADIO RTLSDR IMPLEMENTATION ---------------- */
/* --- PUBLIC FUNCTIONS --- */
@@ -47,14 +47,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 +62,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) {
@@ -82,11 +72,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]);
}
@@ -407,14 +397,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;