fix mmap-related functions' bugs

1. sync hw ptr before calculating the avail
2. return zero when reading or writing successfully
diff --git a/src/pcm.c b/src/pcm.c
index 17775d5..169d982 100644
--- a/src/pcm.c
+++ b/src/pcm.c
@@ -1242,6 +1242,7 @@
 
 int pcm_mmap_avail(struct pcm *pcm)
 {
+    pcm_sync_ptr(pcm, SNDRV_PCM_SYNC_PTR_HWSYNC);
     if (pcm->flags & PCM_IN)
         return pcm_mmap_capture_avail(pcm);
     else
@@ -1552,8 +1553,14 @@
     if ((~pcm->flags) & (PCM_OUT | PCM_MMAP))
         return -ENOSYS;
 
-    return pcm_mmap_transfer(pcm, (void *)data,
-                             pcm_bytes_to_frames(pcm, count));
+    unsigned int frames = pcm_bytes_to_frames(pcm, count);
+    int res = pcm_mmap_transfer(pcm, (void *) data, frames);
+
+    if (res < 0) {
+        return res;
+    }
+
+    return (unsigned int) res == frames ? 0 : -EIO;
 }
 
 int pcm_mmap_read(struct pcm *pcm, void *data, unsigned int count)
@@ -1561,7 +1568,14 @@
     if ((~pcm->flags) & (PCM_IN | PCM_MMAP))
         return -ENOSYS;
 
-    return pcm_mmap_transfer(pcm, data, pcm_bytes_to_frames(pcm, count));
+    unsigned int frames = pcm_bytes_to_frames(pcm, count);
+    int res = pcm_mmap_transfer(pcm, data, frames);
+
+    if (res < 0) {
+        return res;
+    }
+
+    return (unsigned int) res == frames ? 0 : -EIO;
 }
 
 /* Returns current read/write position in the mmap buffer with associated time stamp. */