audio_hal: Add more IpcBuffer C API. [1/1]

PD#TV-31284

Problem:
For RDK rmfAudioCapture API implementation, C
style of buffer pointer functions are needed.

Solution:
Add C style functions for buffer pointers.

Verify:
Verified with RDK platco build.

Change-Id: I55e659af64bd0b1ce9ad9381b0a79ea47543c2d0
Signed-off-by: Tim Yao <tim.yao@amlogic.com>
diff --git a/include/IpcBuffer/IpcBuffer_c.h b/include/IpcBuffer/IpcBuffer_c.h
index 809ea5e..5a7cea3 100644
--- a/include/IpcBuffer/IpcBuffer_c.h
+++ b/include/IpcBuffer/IpcBuffer_c.h
@@ -1,6 +1,8 @@
 #ifndef IpcBuffer_c_
 #define IpcBuffer_c_
 
+#include <stdint.h>
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -11,6 +13,10 @@
 
 extern void IpcBuffer_write(void *cb, const unsigned char *buf, int size);
 
+extern uint8_t *IpcBuffer_get_ptr(const char *name);
+
+extern uint64_t IpcBuffer_get_wr_pos(const char *name);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/src/IpcBuffer/IpcBuffer.cpp b/src/IpcBuffer/IpcBuffer.cpp
index 2a23866..311f086 100644
--- a/src/IpcBuffer/IpcBuffer.cpp
+++ b/src/IpcBuffer/IpcBuffer.cpp
@@ -152,5 +152,27 @@
   ((IpcBuffer *)(cb))->write_nb(buf, size);
 }
 
+uint8_t *IpcBuffer_get_ptr(const char *name)
+{
+  managed_shared_memory *shm = audio_server_shmem::getInstance();
+  IpcBuffer * cb = shm->find<IpcBuffer>(name).first;
+  if (cb) {
+    return cb->start_ptr();
+  }
+  return NULL;
+}
+
+uint64_t IpcBuffer_get_wr_pos(const char *name)
+{
+  managed_shared_memory *shm = audio_server_shmem::getInstance();
+  IpcBuffer * cb = shm->find<IpcBuffer>(name).first;
+  if (cb) {
+    uint64_t time, position;
+    cb->get_write_position(time, position);
+    return position;
+  }
+  return 0;
+}
+
 }