[xiph-commits] r12355 - trunk/fusd/examples

xiphmont at svn.xiph.org xiphmont at svn.xiph.org
Fri Jan 19 09:44:19 PST 2007


Author: xiphmont
Date: 2007-01-19 09:44:17 -0800 (Fri, 19 Jan 2007)
New Revision: 12355

Modified:
   trunk/fusd/examples/drums.c
   trunk/fusd/examples/drums2.c
   trunk/fusd/examples/pager.c
Log:
Update the fusd examples now that multiple registration is no longer bitrotted.



Modified: trunk/fusd/examples/drums.c
===================================================================
--- trunk/fusd/examples/drums.c	2007-01-19 17:26:14 UTC (rev 12354)
+++ trunk/fusd/examples/drums.c	2007-01-19 17:44:17 UTC (rev 12355)
@@ -59,7 +59,7 @@
 static char *drums_strings[] = {"bam", "bum", "beat", "boom",
 				"bang", "crash", NULL};
 
-int drums_read(struct fusd_file_info *file, char *user_buffer,
+ssize_t drums_read(struct fusd_file_info *file, char *user_buffer,
 	       size_t user_length, loff_t *offset)
 {
   int len;

Modified: trunk/fusd/examples/drums2.c
===================================================================
--- trunk/fusd/examples/drums2.c	2007-01-19 17:26:14 UTC (rev 12354)
+++ trunk/fusd/examples/drums2.c	2007-01-19 17:44:17 UTC (rev 12355)
@@ -82,14 +82,16 @@
   /* file->device_info is what we passed to fusd_register when we
    * registered the device.  It's a pointer into the "drums" struct. */
   struct drum_info *d = (struct drum_info *) file->device_info;
+  int *user_num = calloc(1, sizeof(*user_num));
 
   /* Store this user's unique user number in their private_data */
-  file->private_data = (void *) ++(d->num_users);
+  *user_num = ++(d->num_users);
+  file->private_data = (void *) user_num; 
 
   return 0; /* return success */
 }
 
-int drums_read(struct fusd_file_info *file, char *user_buffer,
+ssize_t drums_read(struct fusd_file_info *file, char *user_buffer,
 	       size_t user_length, loff_t *offset)
 {
   struct drum_info *d = (struct drum_info *) file->device_info;
@@ -97,10 +99,11 @@
   char sound[128];
 
   sprintf(sound, "You are user %d to hear a drum go '%s'!\n",
-	  (int) file->private_data, d->name);
+	  *(int *) file->private_data, d->name);
 
   len = MIN(user_length, strlen(sound));
   memcpy(user_buffer, sound, len);
+  *offset += len;
   return len;
 }
 /* EXAMPLE STOP */

Modified: trunk/fusd/examples/pager.c
===================================================================
--- trunk/fusd/examples/pager.c	2007-01-19 17:26:14 UTC (rev 12354)
+++ trunk/fusd/examples/pager.c	2007-01-19 17:44:17 UTC (rev 12355)
@@ -247,7 +247,7 @@
  * one; if this happens, use fusd_destroy() to get rid of the older one.
  */
 /* EXAMPLE START pager-polldiff.c */
-ssize_t pager_notify_polldiff(struct fusd_file_info *file,
+int pager_notify_polldiff(struct fusd_file_info *file,
 			      unsigned int cached_state)
 {
   struct pager_client *c = (struct pager_client *) file->private_data;



More information about the commits mailing list