add a raw CoreMidi data debug mode
[ardour.git] / libs / backends / alsa / zita-alsa-pcmi.cc
index 5aba08c786c203001870ed05d8b6922be1da5c13..3c271b69073806f997e5dc4176ef28199dcf0ef3 100644 (file)
@@ -170,7 +170,11 @@ snd_pcm_sframes_t Alsa_pcmi::pcm_wait (void)
                }
                for (i = 0; i < n2; i++) _poll_fd [i].events |= POLLERR;
 
-               r = poll (_poll_fd, n2, 1000);
+               timespec timeout;
+               timeout.tv_sec = 1;
+               timeout.tv_nsec = 0;
+               r = ppoll (_poll_fd, n2, &timeout, NULL);
+
                if (r < 0)
                {
                        if (errno == EINTR) return 0;
@@ -266,6 +270,9 @@ int Alsa_pcmi::play_init (snd_pcm_uframes_t len)
        const snd_pcm_channel_area_t   *a;
        int                            err;
 
+       if (!_play_handle) {
+               return 0;
+       }
        if ((err = snd_pcm_mmap_begin (_play_handle, &a, &_play_offs, &len)) < 0)
        {
                if (_debug & DEBUG_DATA) fprintf (stderr, "Alsa_pcmi: snd_pcm_mmap_begin(play): %s.\n", snd_strerror (err));
@@ -287,6 +294,10 @@ int Alsa_pcmi::capt_init (snd_pcm_uframes_t len)
        const snd_pcm_channel_area_t  *a;
        int                           err;
 
+       if (!_capt_handle) {
+               return 0;
+       }
+
        if ((err = snd_pcm_mmap_begin (_capt_handle, &a, &_capt_offs, &len)) < 0)
        {
                if (_debug & DEBUG_DATA) fprintf (stderr, "Alsa_pcmi: snd_pcm_mmap_begin(capt): %s.\n", snd_strerror (err));
@@ -322,12 +333,14 @@ void Alsa_pcmi::capt_chan  (int chan, float *dst, int len, int step)
 
 int Alsa_pcmi::play_done (int len)
 {
+       if (!_play_handle) return 0;
        return snd_pcm_mmap_commit (_play_handle, _play_offs, len);
 }
 
 
 int Alsa_pcmi::capt_done (int len)
 {
+       if (!_capt_handle) return 0;
        return snd_pcm_mmap_commit (_capt_handle, _capt_offs, len);
 }
 
@@ -390,7 +403,7 @@ void Alsa_pcmi::initialise (const char *play_name, const char *capt_name, const
                }
        }
 
-       if (! _play_handle || ! _capt_handle) return;
+       if (! _play_handle && ! _capt_handle) return;
 
        if (ctrl_name)
        {