[maemo-commits] [maemo-commits] r9417 - in projects/haf/trunk/osso-af-utils: debian src

From: subversion at stage.maemo.org subversion at stage.maemo.org
Date: Mon Jan 29 15:45:45 EET 2007
Author: kihamala
Date: 2007-01-29 15:45:44 +0200 (Mon, 29 Jan 2007)
New Revision: 9417

Modified:
   projects/haf/trunk/osso-af-utils/debian/changelog
   projects/haf/trunk/osso-af-utils/src/play-sound.c
Log:
added waiting back to play-sound


Modified: projects/haf/trunk/osso-af-utils/debian/changelog
===================================================================
--- projects/haf/trunk/osso-af-utils/debian/changelog	2007-01-29 13:37:31 UTC (rev 9416)
+++ projects/haf/trunk/osso-af-utils/debian/changelog	2007-01-29 13:45:44 UTC (rev 9417)
@@ -1,3 +1,10 @@
+osso-af-utils (1.14-1) unstable; urgency=low
+
+  * UNRELEASED
+  * Added waiting back to play-sound. Fixes: NB#50967
+
+ -- Kimmo Hämäläinen <kimmo.hamalainen at nokia.com>  Mon, 29 Jan 2007 15:44:48 +0200
+
 osso-af-utils (1.13-2) unstable; urgency=low
 
   * Forgot this: Fixes: NB#50699

Modified: projects/haf/trunk/osso-af-utils/src/play-sound.c
===================================================================
--- projects/haf/trunk/osso-af-utils/src/play-sound.c	2007-01-29 13:37:31 UTC (rev 9416)
+++ projects/haf/trunk/osso-af-utils/src/play-sound.c	2007-01-29 13:45:44 UTC (rev 9417)
@@ -138,6 +138,55 @@
     return 1;
 }
 
+
+static void
+wait_for_esd_server_to_quiesce (int esd_fd)
+{
+    char *buf = NULL ;
+    esd_server_info_t *esd_server_info = NULL ;
+    int monitor_fd = -1, read_return = -1, available_bytes = 0, max_avail = 0;
+    int first_time = 1;
+
+    if (NULL != (esd_server_info = esd_get_server_info (esd_fd)))
+    {
+        if ((monitor_fd = esd_monitor_stream (esd_server_info->format, esd_server_info->rate, NULL, NULL)) > 0)
+        {
+            while (TRUE)
+            {
+                struct timeval tv;
+		
+                ioctl (monitor_fd, FIONREAD, &available_bytes) ;
+                if (available_bytes > max_avail)
+                {
+                    buf = realloc (buf, available_bytes) ;
+                    max_avail = available_bytes ;
+                }
+		
+                if (available_bytes)
+		{
+                    read_return = read(monitor_fd, buf, available_bytes);
+                    if (read_return < 0)
+                        break ;
+		}
+                else if ( !first_time )
+                {
+                    break ;
+                }
+
+                tv.tv_sec = 0;
+                tv.tv_usec = 200000;
+                select (0, NULL, NULL, NULL, &tv); /* avoid tight loop */
+                first_time = 0;
+            }
+
+            if (buf)
+                free (buf) ;
+            close (monitor_fd) ;
+        }
+        esd_free_server_info (esd_server_info) ;
+    }
+}
+
 static int 
 play_sound(gchar *sound_filename,
            gchar *data) 
@@ -172,6 +221,7 @@
     esd_play_file_with_pan(sock, data,
 		  sound_filename, pan, pan);
 
+    wait_for_esd_server_to_quiesce (sock) ;
     esd_close(sock);
 
     return 0;


More information about the maemo-commits mailing list