X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=plugins%2Fradio%2Fradio-rtlsdr.c;h=b99cf9b76bdfcbb3f38a256f4cc07388beef7623;hb=e3320f303c4eb8f7fe0fac69bfa9ce36d9916930;hp=bba0d89aac67781b59b2b8a27256c8c5f7f4f53a;hpb=0d170147150b90678225b55548215d09d8273e6d;p=src%2Fapp-framework-binder.git diff --git a/plugins/radio/radio-rtlsdr.c b/plugins/radio/radio-rtlsdr.c index bba0d89a..b99cf9b7 100644 --- a/plugins/radio/radio-rtlsdr.c +++ b/plugins/radio/radio-rtlsdr.c @@ -17,9 +17,6 @@ */ #include "radio-api.h" -#include "radio-rtlsdr.h" - -static audioCtxHandleT *actx = NULL; /* ------------- RADIO RTLSDR IMPLEMENTATION ---------------- */ @@ -47,14 +44,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 +59,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 +394,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;