X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=plugins%2Fradio%2Fradio-rtlsdr.c;h=bba0d89aac67781b59b2b8a27256c8c5f7f4f53a;hb=0d170147150b90678225b55548215d09d8273e6d;hp=bf4fcea5dc9526c2e4b39896ca02088216897985;hpb=41c462374fb25fae29f3b4a28eb99fdb639e8547;p=src%2Fapp-framework-binder.git diff --git a/plugins/radio/radio-rtlsdr.c b/plugins/radio/radio-rtlsdr.c index bf4fcea5..bba0d89a 100644 --- a/plugins/radio/radio-rtlsdr.c +++ b/plugins/radio/radio-rtlsdr.c @@ -1,5 +1,6 @@ /* * 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 @@ -18,6 +19,8 @@ #include "radio-api.h" #include "radio-rtlsdr.h" +static audioCtxHandleT *actx = NULL; + /* ------------- RADIO RTLSDR IMPLEMENTATION ---------------- */ /* --- PUBLIC FUNCTIONS --- */ @@ -45,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; } @@ -57,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) { @@ -68,11 +82,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]); } @@ -397,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); }