tinyalsa: Add PCM_NORESTART flag.

Add a flag which can be passed to pcm_open (called PCM_NORESTART).
When set on a playback stream, calls to pcm_write will not
automatically attempt to restart an ALSA device in the case of an
underflow.  Instead, it will propagate the first EPIPE error up to the
application to allow it to handle the underflow situation.  Subsequent
calls to pcm_write will attempt to start the pipeline.

Change-Id: If17973c6de9079c4227631bac9ff09b218377344
Signed-off-by: John Grossman <johngro@google.com>
diff --git a/pcm.c b/pcm.c
index 9324f38..b4c35b2 100644
--- a/pcm.c
+++ b/pcm.c
@@ -388,8 +388,12 @@
         if (ioctl(pcm->fd, SNDRV_PCM_IOCTL_WRITEI_FRAMES, &x)) {
             pcm->running = 0;
             if (errno == EPIPE) {
-                    /* we failed to make our window -- try to restart */
+                /* we failed to make our window -- try to restart if we are
+                 * allowed to do so.  Otherwise, simply allow the EPIPE error to
+                 * propagate up to the app level */
                 pcm->underruns++;
+                if (pcm->flags & PCM_NORESTART)
+                    return -EPIPE;
                 continue;
             }
             return oops(pcm, errno, "cannot write stream data");