]> git.tuebingen.mpg.de Git - paraslash.git/blobdiff - alsa_write.c
Make writers remove btr node on errors.
[paraslash.git] / alsa_write.c
index 27a8db3dcdf5daec5c4e4baedaaa7eb3a1833e4f..75fe6fae90bb6282b199ef3a659576ad152f0c42 100644 (file)
@@ -332,17 +332,13 @@ again:
                pad->channels = conf->channels_arg;
                if (!conf->samplerate_given) { /* config option trumps btr_exec */
                        int32_t rate;
-                       ret = get_btr_samplerate(btrn, &rate);
-                       if (ret < 0)
-                               goto err;
-                       pad->samplerate = rate;
+                       if (get_btr_samplerate(btrn, &rate) >= 0)
+                               pad->samplerate = rate;
                }
                if (!conf->channels_given) {
                        int32_t ch;
-                       ret = get_btr_channels(btrn, &ch);
-                       if (ret < 0)
-                               goto err;
-                       pad->channels = ch;
+                       if (get_btr_channels(btrn, &ch) >= 0)
+                               pad->channels = ch;
                }
                PARA_INFO_LOG("%d channel(s), %dHz\n", pad->channels, pad->samplerate);
                ret = 1;
@@ -352,11 +348,6 @@ again:
                wn->min_iqs = pad->bytes_per_frame;
        }
        frames = bytes / pad->bytes_per_frame;
-       avail = snd_pcm_avail_update(pad->handle);
-       if (avail <= 0)
-               return;
-       frames = PARA_MIN(frames, avail);
-       //PARA_CRIT_LOG("writing %ld frames\n", frames);
        frames = snd_pcm_writei(pad->handle, data, frames);
        if (frames >= 0) {
                btr_consume(btrn, frames * pad->bytes_per_frame);
@@ -367,12 +358,13 @@ again:
                snd_pcm_prepare(pad->handle);
                return;
        }
-       PARA_WARNING_LOG("%s\n", snd_strerror(-frames));
        if (frames == -EAGAIN)
                return;
+       PARA_WARNING_LOG("%s\n", snd_strerror(-frames));
        ret = -E_ALSA_WRITE;
 err:
        assert(ret < 0);
+       btr_remove_node(btrn);
        t->error = ret;
 }