Code Review
/
src
/
app-framework-binder.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
http-svc: handle alises more efficiently
[src/app-framework-binder.git]
/
plugins
/
radio
/
radio-rtlsdr.c
diff --git
a/plugins/radio/radio-rtlsdr.c
b/plugins/radio/radio-rtlsdr.c
index
bf4fcea
..
b99cf9b
100644
(file)
--- a/
plugins/radio/radio-rtlsdr.c
+++ b/
plugins/radio/radio-rtlsdr.c
@@
-1,5
+1,6
@@
/*
* Copyright (C) 2015 "IoT.bzh"
/*
* 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
*
* 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
@@
-16,7
+17,6
@@
*/
#include "radio-api.h"
*/
#include "radio-api.h"
-#include "radio-rtlsdr.h"
/* ------------- RADIO RTLSDR IMPLEMENTATION ---------------- */
/* ------------- RADIO RTLSDR IMPLEMENTATION ---------------- */
@@
-44,7
+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);
dev_ctx[num]->demod = NULL;
dev_ctx[num]->output = NULL;
_radio_dev_init(dev_ctx[num], num);
-
+
return 1;
}
return 1;
}
@@
-57,6
+57,7
@@
PUBLIC void _radio_off (unsigned int num) {
_radio_dev_free(dev_ctx[num]);
free(dev_ctx[num]);
}
_radio_dev_free(dev_ctx[num]);
free(dev_ctx[num]);
}
+
/* free(dev_ctx); */
}
/* free(dev_ctx); */
}
@@
-68,11
+69,11
@@
PUBLIC void _radio_set_mode (unsigned int num, Mode mode) {
_radio_apply_params(dev_ctx[num]);
}
_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;
if (!dev_ctx || !dev_ctx[num])
return;
- dev_ctx[num]->freq = freq;
+ dev_ctx[num]->freq =
(float)
freq;
_radio_apply_params(dev_ctx[num]);
}
_radio_apply_params(dev_ctx[num]);
}
@@
-393,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;
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);
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);
}
pthread_rwlock_unlock(&output->lck);
}
+ if (file) fclose(file);
+ unlink (AUDIO_BUFFER);
output->thr_finished = 1;
return 0;
output->thr_finished = 1;
return 0;