Merge pull request #1 from dnet/master

small improvements
pull/2/head
Oona Räisänen 2012-12-25 04:49:34 -08:00
commit e7f58dc03b
4 zmienionych plików z 36 dodań i 10 usunięć

3
.gitignore vendored 100644
Wyświetl plik

@ -0,0 +1,3 @@
slowrx
rx
rx-lum

Wyświetl plik

@ -11,4 +11,4 @@ slowrx: common.h common.c slowrx.c gui.c video.c sync.c vis.c modespec.c pcm.c f
$(CC) $(CFLAGS) $(OFLAGS) common.c modespec.c gui.c video.c vis.c sync.c pcm.c fsk.c slowrx.c -o slowrx -lfftw3 -lm `pkg-config --cflags --libs gtk+-3.0` -lgthread-2.0 -lpnglite -lasound
clean:
rm -f *.o
rm -f slowrx

26
pcm.c
Wyświetl plik

@ -84,17 +84,25 @@ void initPcmDevice() {
gtk_combo_box_set_active(GTK_COMBO_BOX(cardcombo), 0);
if (cardnum == 0) {
sprintf(pcm_name,"default");
} else {
sprintf(pcm_name,"hw:%d",cardnum-1);
}
snd_pcm_hw_params_alloca(&hwparams);
if (snd_pcm_open(&pcm_handle, pcm_name, PcmInStream, 0) < 0) {
fprintf(stderr, "ALSA: Error opening PCM device %s\n", pcm_name);
exit(EXIT_FAILURE);
while (true) {
if (cardnum == 0) {
sprintf(pcm_name,"default");
} else {
sprintf(pcm_name,"hw:%d",cardnum-1);
}
if (snd_pcm_open(&pcm_handle, pcm_name, PcmInStream, 0) < 0) {
fprintf(stderr, "ALSA: Error opening PCM device %s\n", pcm_name);
if (cardnum == 0) {
exit(EXIT_FAILURE);
} else {
cardnum--;
}
} else {
break;
}
}
/* Init hwparams with full configuration space */

Wyświetl plik

@ -9,6 +9,8 @@
#include <stdbool.h>
#include <math.h>
#include <time.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <gtk/gtk.h>
#include <pnglite.h>
@ -19,6 +21,17 @@
#include "common.h"
void ensure_dir_exists(const char *dir) {
struct stat buf;
int i = stat(dir, &buf);
if (i != 0) {
if (mkdir(dir, 0777) != 0) {
perror("Unable to create directory for output file");
exit(EXIT_FAILURE);
}
}
}
void *Listen() {
@ -168,6 +181,7 @@ void *Listen() {
setVU(0,-100);
ensure_dir_exists("rx-lum");
LumFile = fopen(lumfilename,"w");
if (LumFile == NULL) {
perror("Unable to open luma file for writing");
@ -184,6 +198,7 @@ void *Listen() {
scaledpb = gdk_pixbuf_scale_simple (RxPixbuf, ModeSpec[Mode].ImgWidth, ModeSpec[Mode].ImgHeight * ModeSpec[Mode].YScale, GDK_INTERP_HYPER);
pixels = gdk_pixbuf_get_pixels(scaledpb);
ensure_dir_exists("rx");
png_open_file_write(&png, pngfilename);
png_set_data(&png, ModeSpec[Mode].ImgWidth, ModeSpec[Mode].ImgHeight * ModeSpec[Mode].YScale, 8, PNG_TRUECOLOR, pixels);
png_close_file(&png);