From fa417b373e93903c8c41cdfd800a0311bc495e15 Mon Sep 17 00:00:00 2001
From: Timo Dritschler <timo.dritschler@kit.edu>
Date: Tue, 16 Jun 2015 17:25:08 +0200
Subject: Pushed to version 1.3.0

Highlights:
- KiroSb: Added kiro_sb_get_dma_pointer interface
---
 src/kiro-sb.c | 24 +++++++++++++++---------
 src/kiro-sb.h | 25 +++++++++++++++++++++++++
 2 files changed, 40 insertions(+), 9 deletions(-)

(limited to 'src')

diff --git a/src/kiro-sb.c b/src/kiro-sb.c
index 6ec671c..3d6173f 100644
--- a/src/kiro-sb.c
+++ b/src/kiro-sb.c
@@ -274,15 +274,10 @@ kiro_sb_get_data (KiroSb *self)
     KiroSbPrivate *priv = KIRO_SB_GET_PRIVATE (self);
 
     struct KiroTrbInfo *header = kiro_trb_get_raw_buffer (priv->trb);
-    switch (header->offset) {
-        case 0:
-            return kiro_trb_get_element (priv->trb, 0);
-            break;
-        case 1:
-            return kiro_trb_get_element (priv->trb, 1);
-            break;
-        default:
-            return kiro_trb_get_element (priv->trb, -1);
+    if (header->offset > 0) {
+        return kiro_trb_get_element (priv->trb, 1);
+    } else {
+        return kiro_trb_get_element (priv->trb, 0);
     }
 }
 
@@ -310,6 +305,17 @@ kiro_sb_push_dma (KiroSb *self)
     return kiro_trb_dma_push (priv->trb);
 }
 
+void *
+kiro_sb_get_dma_pointer (KiroSb *self)
+{
+    g_return_val_if_fail (self != NULL, NULL);
+
+    KiroSbPrivate *priv = KIRO_SB_GET_PRIVATE (self);
+    g_return_val_if_fail (priv->initialized == 1, NULL);
+
+    return kiro_trb_get_element (priv->trb, -1);
+}
+
 
 gboolean
 kiro_sb_clone (KiroSb *self, const gchar* address, const gchar* port)
diff --git a/src/kiro-sb.h b/src/kiro-sb.h
index a2b8604..32f1a48 100644
--- a/src/kiro-sb.h
+++ b/src/kiro-sb.h
@@ -340,6 +340,31 @@ gboolean kiro_sb_push       (KiroSb *sb, void *data);
  */
 void* kiro_sb_push_dma      (KiroSb *sb);
 
+/**
+ * kiro_sb_get_dma_pointer:
+ * @sb: (transfer none) The #KiroSb to get the data from
+ *
+ *   Returns a pointer where the next element will be stored.
+ *   This operation is only valid for a 'serving' #KiroSb. Calling this
+ *   function on a 'cloning' #KiroSb will allways return a %NULL pointer.
+ *
+ * Returns: (transfer none) (type gulong):
+ *   A pointer to the memory where the next element will be stored
+ * Note:
+ *   This function can be used to preemtively write data to the @sb without
+ *   advancing the internal buffer (no remote sync will occur).  It is the users
+ *   responsibility to ensure no more data is written to the pointed memory then
+ *   was specified with the initial call to kiro_sb_serve or returned by
+ *   kiro_sb_get_size.  Under no circumstances might the returned pointer be
+ *   freed by the user.  Once the element has been written, you can use
+ *   kiro_sb_push_dma() to advance the buffer, making the remote side aware of
+ *   the new element.
+ * See also:
+ *   kiro_sb_get_size, kiro_sb_serve
+ *
+ * Since: 1.3
+ */
+void* kiro_sb_get_dma_pointer     (KiroSb *sb);
 
 G_END_DECLS
 
-- 
cgit v1.2.3