Fixed VoE data reading in userspace.
authorFlorian Pose <fp@igh-essen.com>
Wed, 15 Oct 2008 16:08:29 +0000
changeset 1271 19f9e9b6cf2c
parent 1270 11f4b6e10d74
child 1272 288c982acd23
Fixed VoE data reading in userspace.
lib/voe_handler.c
--- a/lib/voe_handler.c	Wed Oct 15 10:32:54 2008 +0000
+++ b/lib/voe_handler.c	Wed Oct 15 16:08:29 2008 +0000
@@ -36,7 +36,11 @@
 
 /*****************************************************************************/
 
+#include <stdlib.h>
+#include <sys/ioctl.h>
 #include <stdio.h>
+#include <errno.h>
+#include <string.h>
 
 #include "voe_handler.h"
 #include "slave_config.h"
@@ -55,9 +59,9 @@
     data.vendor_id = &vendor_id;
     data.vendor_type = &vendor_type;
 
-    if (ioctl(voe->config->master->fd, EC_IOCTL_VOE_SEND_HEADER, &data) == -1) {
-        fprintf(stderr, "Failed to set VoE send header.\n");
-    }
+    if (ioctl(voe->config->master->fd, EC_IOCTL_VOE_SEND_HEADER, &data) == -1)
+        fprintf(stderr, "Failed to set VoE send header: %s\n",
+                strerror(errno));
 }
 
 /*****************************************************************************/
@@ -72,9 +76,9 @@
     data.vendor_id = vendor_id;
     data.vendor_type = vendor_type;
 
-    if (ioctl(voe->config->master->fd, EC_IOCTL_VOE_REC_HEADER, &data) == -1) {
-        fprintf(stderr, "Failed to get received VoE header.\n");
-    }
+    if (ioctl(voe->config->master->fd, EC_IOCTL_VOE_REC_HEADER, &data) == -1)
+        fprintf(stderr, "Failed to get received VoE header: %s\n",
+                strerror(errno));
 }
 
 /*****************************************************************************/
@@ -100,9 +104,9 @@
     data.config_index = voe->config->index;
     data.voe_index = voe->index;
 
-    if (ioctl(voe->config->master->fd, EC_IOCTL_VOE_READ, &data) == -1) {
-        fprintf(stderr, "Failed to initiate VoE reading.\n");
-    }
+    if (ioctl(voe->config->master->fd, EC_IOCTL_VOE_READ, &data) == -1)
+        fprintf(stderr, "Failed to initiate VoE reading: %s\n",
+                strerror(errno));
 }
 
 /*****************************************************************************/
@@ -116,9 +120,9 @@
     data.size = size;
     data.data = voe->data;
 
-    if (ioctl(voe->config->master->fd, EC_IOCTL_VOE_WRITE, &data) == -1) {
-        fprintf(stderr, "Failed to initiate VoE reading.\n");
-    }
+    if (ioctl(voe->config->master->fd, EC_IOCTL_VOE_WRITE, &data) == -1)
+        fprintf(stderr, "Failed to initiate VoE writing: %s\n",
+                strerror(errno));
 }
 
 /*****************************************************************************/
@@ -132,7 +136,8 @@
     data.size = 0;
 
     if (ioctl(voe->config->master->fd, EC_IOCTL_VOE_EXEC, &data) == -1) {
-        fprintf(stderr, "Failed to initiate VoE reading.\n");
+        fprintf(stderr, "Failed to execute VoE handler: %s\n",
+                strerror(errno));
         return EC_REQUEST_ERROR;
     }
 
@@ -149,8 +154,10 @@
             voe->mem_size = data.size;
         }
 
+        data.data = voe->data;
+
         if (ioctl(voe->config->master->fd, EC_IOCTL_VOE_DATA, &data) == -1) {
-            fprintf(stderr, "Failed to get VoE data!\n");
+            fprintf(stderr, "Failed to get VoE data: %s\n", strerror(errno));
             return EC_REQUEST_ERROR;
         }
         voe->data_size = data.size;