rtsp: Write as much as possible in gst_rtsp_source_dispatch().
authorPeter Kjellerstedt <pkj@axis.com>
Tue, 16 Jun 2009 17:04:54 +0000 (19:04 +0200)
committerPeter Kjellerstedt <pkj@axis.com>
Mon, 24 Aug 2009 11:19:45 +0000 (13:19 +0200)
Try to write as much as possible if there are multiple messages queued.

gst-libs/gst/rtsp/gstrtspconnection.c

index 44f65c5..eee292d 100644 (file)
@@ -3060,7 +3060,7 @@ gst_rtsp_source_dispatch (GSource * source, GSourceFunc callback G_GNUC_UNUSED,
       res = write_bytes (watch->writefd.fd, watch->write_data,
           &watch->write_off, watch->write_size);
       if (res == GST_RTSP_EINTR)
-        break;
+        goto write_blocked;
       else if (G_LIKELY (res == GST_RTSP_OK)) {
         if (watch->funcs.message_sent)
           watch->funcs.message_sent (watch, watch->write_id, watch->user_data);
@@ -3072,17 +3072,19 @@ gst_rtsp_source_dispatch (GSource * source, GSourceFunc callback G_GNUC_UNUSED,
           goto error;
       }
 
-    done:
-      if (g_async_queue_length (watch->messages) == 0 && watch->write_added) {
-        g_source_remove_poll ((GSource *) watch, &watch->writefd);
-        watch->write_added = FALSE;
-        watch->writefd.revents = 0;
-      }
       g_free (watch->write_data);
       watch->write_data = NULL;
-    } while (FALSE);
+    } while (TRUE);
+
+  done:
+    if (watch->write_added) {
+      g_source_remove_poll ((GSource *) watch, &watch->writefd);
+      watch->write_added = FALSE;
+      watch->writefd.revents = 0;
+    }
   }
 
+write_blocked:
   return TRUE;
 
   /* ERRORS */