aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFreeArtMan <dos21h@gmail.com>2015-10-07 19:36:19 +0100
committerFreeArtMan <dos21h@gmail.com>2015-10-07 19:36:19 +0100
commite1fd164e62c2dfbd08d0d4699a723cace40d0e8c (patch)
tree2e845ca8f7512e53cec1cc636578f000ffbd00e6
parent21c34937937f27a89290f4377b4ff1801079e6ec (diff)
downloadradiola-e1fd164e62c2dfbd08d0d4699a723cace40d0e8c.tar.gz
radiola-e1fd164e62c2dfbd08d0d4699a723cace40d0e8c.zip
Primitive audio device detection added
-rw-r--r--TODO11
-rw-r--r--hw/aud.c75
-rw-r--r--hw/aud.h11
-rw-r--r--hw/hw_eeprom.c0
-rw-r--r--hw/hw_eeprom.h0
-rw-r--r--hw/make.mk4
-rw-r--r--test/.gitignore1
-rw-r--r--test/Makefile2
-rw-r--r--test/get_audo_list.c11
9 files changed, 110 insertions, 5 deletions
diff --git a/TODO b/TODO
index 872aab1..acc380e 100644
--- a/TODO
+++ b/TODO
@@ -7,20 +7,27 @@
[FILTER]
basic bandpass filter
[DRAW]
- draw in SDL/OpenGL waterfall
+ #draw in SDLchinese simple reader/OpenGL waterfall
+ # make ajustable screen size
output data to web
+ add more options for waterfall
[CORE]
multi threaded
read IQ thread
processing thread
config thread?
log utilities
+ add alsa audio preprocessing
[MOD]
- fm demod
+ #fm demod
wbfn demod
am demod
[AUDIO]
play sound
stream sound to web
+ rewrite play/record sound just primitive version added
+[TEST]
+ stream waterfall post/pre filtered
+ stream waterfall post/pre fm demodulated
rtlsdr? no dithering? in with brain it is? \ No newline at end of file
diff --git a/hw/aud.c b/hw/aud.c
new file mode 100644
index 0000000..a1379c6
--- /dev/null
+++ b/hw/aud.c
@@ -0,0 +1,75 @@
+#include "aud.h"
+
+//harc-copy from aplay.c static void device_list(void)
+int audio_get_devices()
+{
+ snd_pcm_stream_t stream = SND_PCM_STREAM_PLAYBACK;
+
+ snd_ctl_t *handle;
+ int card, err, dev, idx;
+ snd_ctl_card_info_t *info;
+ snd_pcm_info_t *pcminfo;
+ snd_ctl_card_info_alloca(&info);
+ snd_pcm_info_alloca(&pcminfo);
+
+ card = -1;
+ if (snd_card_next(&card) < 0 || card < 0) {
+ printf("no soundcards found...\n");
+ return -1;
+ }
+ printf("**** List of %s Hardware Devices ****\n",
+ snd_pcm_stream_name(stream));
+ while (card >= 0) {
+ char name[32];
+ sprintf(name, "hw:%d", card);
+ if ((err = snd_ctl_open(&handle, name, 0)) < 0) {
+ printf("control open (%i): %s\n", card, snd_strerror(err));
+ goto next_card;
+ }
+ if ((err = snd_ctl_card_info(handle, info)) < 0) {
+ printf("control hardware info (%i): %s\n", card, snd_strerror(err));
+ snd_ctl_close(handle);
+ goto next_card;
+ }
+ dev = -1;
+ while (1) {
+ unsigned int count;
+ if (snd_ctl_pcm_next_device(handle, &dev)<0)
+ printf("snd_ctl_pcm_next_device\n");
+ if (dev < 0)
+ break;
+ snd_pcm_info_set_device(pcminfo, dev);
+ snd_pcm_info_set_subdevice(pcminfo, 0);
+ snd_pcm_info_set_stream(pcminfo, stream);
+ if ((err = snd_ctl_pcm_info(handle, pcminfo)) < 0) {
+ if (err != -ENOENT)
+ printf("control digital audio info (%i): %s\n", card, snd_strerror(err));
+ continue;
+ }
+ printf("card %i: %s [%s], device %i: %s [%s]\n",
+ card, snd_ctl_card_info_get_id(info), snd_ctl_card_info_get_name(info),
+ dev,
+ snd_pcm_info_get_id(pcminfo),
+ snd_pcm_info_get_name(pcminfo));
+ count = snd_pcm_info_get_subdevices_count(pcminfo);
+ printf( " Subdevices: %i/%i\n",
+ snd_pcm_info_get_subdevices_avail(pcminfo), count);
+ for (idx = 0; idx < (int)count; idx++) {
+ snd_pcm_info_set_subdevice(pcminfo, idx);
+ if ((err = snd_ctl_pcm_info(handle, pcminfo)) < 0) {
+ printf("control digital audio playback info (%i): %s\n", card, snd_strerror(err));
+ } else {
+ printf(" Subdevice #%d: %s\n",
+ idx, snd_pcm_info_get_subdevice_name(pcminfo));
+ }
+ }
+ }
+ snd_ctl_close(handle);
+ next_card:
+ if (snd_card_next(&card) < 0) {
+ printf("snd_card_next\n");
+ break;
+ }
+ }
+ return 0;
+}
diff --git a/hw/aud.h b/hw/aud.h
new file mode 100644
index 0000000..500fe18
--- /dev/null
+++ b/hw/aud.h
@@ -0,0 +1,11 @@
+#ifndef __RADIOLA_AUD_H
+#define __RADIOLA_AUD_H
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdint.h>
+#include <alsa/asoundlib.h>
+
+int audio_get_devices();
+
+#endif \ No newline at end of file
diff --git a/hw/hw_eeprom.c b/hw/hw_eeprom.c
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/hw/hw_eeprom.c
diff --git a/hw/hw_eeprom.h b/hw/hw_eeprom.h
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/hw/hw_eeprom.h
diff --git a/hw/make.mk b/hw/make.mk
index 534a7f5..a6b55e3 100644
--- a/hw/make.mk
+++ b/hw/make.mk
@@ -1,7 +1,7 @@
DIR_HW = hw/
-SOURCES_HW += hw/hw.c
+SOURCES_HW += hw/aud.c hw/hw.c hw/hw_eeprom.c
OBJECTS_HW += $(SOURCES_HW:.c=.o)
-LDFLAGS += -lrtlsdr
+LDFLAGS += -lrtlsdr -lasound
OBJECTS_DIR_HW += $(subst $(DIR_HW),$(BUILD_DIR)$(DIR_HW),$(OBJECTS_HW))
diff --git a/test/.gitignore b/test/.gitignore
index c096546..b4557b8 100644
--- a/test/.gitignore
+++ b/test/.gitignore
@@ -2,4 +2,5 @@ get_device_list
read_samples
ui_tui_waterfall
ui_gl_waterfall
+get_audo_list
*.o
diff --git a/test/Makefile b/test/Makefile
index d14f27d..a8160e8 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -1,7 +1,7 @@
CC=gcc
CFLAGS=-I../
#LDFLAGS= `pkg-config --libs libusb` -L../../../r820t -lr820t -Wl,-rpath=../../../r820t
-LDFLAGS=`pkg-config --libs libusb` `sdl2-config --cflags --libs` -lrtlsdr -lm ../radiola.o
+LDFLAGS=`pkg-config --libs libusb` `sdl2-config --cflags --libs` -lrtlsdr -lm ../radiola.o -lasound
SOURCE = $(wildcard *.c)
OBJECTS =
BIN = $(SOURCE:.c=)
diff --git a/test/get_audo_list.c b/test/get_audo_list.c
new file mode 100644
index 0000000..65a6193
--- /dev/null
+++ b/test/get_audo_list.c
@@ -0,0 +1,11 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "hw/aud.h"
+
+int main()
+{
+ audio_get_devices();
+
+ return 0;
+} \ No newline at end of file