diff --git a/common.c b/common.c index 527bea1..96eb10e 100644 --- a/common.c +++ b/common.c @@ -23,6 +23,7 @@ int SNRdBthresh[10] = {30, 15, 10, 5, 3, 0, -3, -5, -10, -15}; bool Adaptive = true; bool ManualActivated = false; bool Abort = false; +bool BufferDrop = false; pthread_t thread1; @@ -84,6 +85,7 @@ void changeDevices() { int status; + BufferDrop = false; Abort = true; pthread_join(thread1, NULL); diff --git a/common.h b/common.h index 5e79e21..49b981a 100644 --- a/common.h +++ b/common.h @@ -18,6 +18,7 @@ extern gshort HedrShift; extern bool Adaptive; extern bool ManualActivated; extern bool Abort; +extern bool BufferDrop; extern bool *HasSync; extern pthread_t thread1; diff --git a/pcm.c b/pcm.c index 890e3c1..434ce02 100644 --- a/pcm.c +++ b/pcm.c @@ -25,12 +25,22 @@ void readPcm(gint numsamples) { samplesread = snd_pcm_readi(pcm_handle, tmp, (PcmPointer == 0 ? BUFLEN : numsamples)); if (samplesread < numsamples) { + if (samplesread == -EPIPE) printf("ALSA: buffer overrun\n"); else if (samplesread == -EBADFD) printf("ALSA: PCM is not in the right state\n"); else if (samplesread == -ESTRPIPE) printf("ALSA: a suspend event occurred\n"); else if (samplesread < 0) printf("ALSA error %d\n", samplesread); else printf("Can't read %d samples\n", numsamples); - exit(EXIT_FAILURE); + + // On first appearance of error, update the status icon + if (!BufferDrop) { + gdk_threads_enter(); + gtk_image_set_from_stock(GTK_IMAGE(gui.devstatusicon),GTK_STOCK_DIALOG_WARNING,GTK_ICON_SIZE_SMALL_TOOLBAR); + gtk_widget_set_tooltip_text(gui.devstatusicon, "Device is dropping samples"); + gdk_threads_leave(); + BufferDrop = true; + } + } if (PcmPointer == 0) { @@ -99,6 +109,8 @@ int initPcmDevice(char *wanteddevname) { bool found; char *cardname; + BufferDrop = false; + snd_pcm_hw_params_alloca(&hwparams); card = -1; diff --git a/vis.c b/vis.c index 980cd7d..949941b 100644 --- a/vis.c +++ b/vis.c @@ -92,8 +92,6 @@ guchar GetVIS () { (tone[14*3+i] > tone[0+j] - 725 && tone[14*3+i] < tone[0+j] - 675) // 1200 Hz stop bit ) { - printf("Possible header @ %+.0f Hz\n",tone[0+j]-1900); - // Attempt to read VIS gotvis = true;