#include #include #include #include #include #include #include "common.h" /* * Stuff related to sound card capture * */ // Capture fresh PCM data to buffer void readPcm(gint numsamples) { int samplesread, i; gint32 tmp[BUFLEN]; // Holds one or two 16-bit channels, will be ANDed to single channel samplesread = snd_pcm_readi(pcm.handle, tmp, (pcm.WindowPtr == 0 ? BUFLEN : numsamples)); if (samplesread < numsamples) { if (samplesread == -EPIPE) printf("ALSA: buffer overrun\n"); else if (samplesread < 0) { printf("ALSA error %d (%s)\n", samplesread, snd_strerror(samplesread)); gtk_widget_set_tooltip_text(gui.image_devstatus, "ALSA error"); Abort = TRUE; pthread_exit(NULL); } else printf("Can't read %d samples\n", numsamples); // On first appearance of error, update the status icon if (!pcm.BufferDrop) { gdk_threads_enter(); gtk_image_set_from_stock(GTK_IMAGE(gui.image_devstatus),GTK_STOCK_DIALOG_WARNING,GTK_ICON_SIZE_SMALL_TOOLBAR); gtk_widget_set_tooltip_text(gui.image_devstatus, "Device is dropping samples"); gdk_threads_leave(); pcm.BufferDrop = TRUE; } } if (pcm.WindowPtr == 0) { // Fill buffer on first run for (i=0; i