fix build

Change-Id: I8d89a2c85594c2975963ad9904c878ea8ea904b0
diff --git a/shared/OpenglCodecCommon/goldfish_address_space.cpp b/shared/OpenglCodecCommon/goldfish_address_space.cpp
index 133c75a..3b39399 100644
--- a/shared/OpenglCodecCommon/goldfish_address_space.cpp
+++ b/shared/OpenglCodecCommon/goldfish_address_space.cpp
@@ -73,7 +73,7 @@
 }
 
 GoldfishAddressSpaceBlock::GoldfishAddressSpaceBlock() :
-    m_alloced(false), m_guest_ptr(NULL), m_phys_addr(0), m_provider(NULL) {}
+    m_offset(0), m_alloced(false), m_guest_ptr(NULL), m_phys_addr(0), m_provider(NULL) {}
 GoldfishAddressSpaceBlock::~GoldfishAddressSpaceBlock() { destroy(); }
 
 GoldfishAddressSpaceBlock &GoldfishAddressSpaceBlock::operator=(const GoldfishAddressSpaceBlock &rhs)
@@ -114,6 +114,11 @@
     return m_guest_ptr;
 }
 
+uint64_t GoldfishAddressSpaceBlock::offset() const
+{
+    return m_offset;
+}
+
 void GoldfishAddressSpaceBlock::destroy()
 {
     if (m_alloced) {
diff --git a/shared/OpenglCodecCommon/goldfish_address_space.h b/shared/OpenglCodecCommon/goldfish_address_space.h
index 31ac2c8..e0720d5 100644
--- a/shared/OpenglCodecCommon/goldfish_address_space.h
+++ b/shared/OpenglCodecCommon/goldfish_address_space.h
@@ -82,6 +82,7 @@
     void destroy();
     GoldfishAddressSpaceBlock &operator=(const GoldfishAddressSpaceBlock &);
 
+    uint64_t  m_offset;
 #ifdef HOST_BUILD
     bool        m_alloced;
     void     *m_guest_ptr;
@@ -97,7 +98,6 @@
     void     *m_mmaped_ptr;
     uint64_t  m_phys_addr;
     uint64_t  m_host_addr;
-    uint64_t  m_offset;
     size_t    m_size;
 #endif
 };
diff --git a/system/gralloc/gralloc.cpp b/system/gralloc/gralloc.cpp
index 54435ac..7af8938 100644
--- a/system/gralloc/gralloc.cpp
+++ b/system/gralloc/gralloc.cpp
@@ -129,12 +129,20 @@
       : sz(0), refcount(0), bigbufCount(0) {
         pthread_mutex_init(&lock, NULL);
 
+#ifdef HOST_BUILD
+        if (rcEnc->getDmaVersion() > 0) {
+            sz = INITIAL_DMA_REGION_SIZE;
+            goldfish_dma_create_region(sz, &goldfish_dma);
+        }
+#else
         if (rcEnc->hasDirectMem()) {
             // do nothing here
         } else if (rcEnc->getDmaVersion() > 0) {
             sz = INITIAL_DMA_REGION_SIZE;
             goldfish_dma_create_region(sz, &goldfish_dma);
         }
+#endif
+
     }
 
     goldfish_dma_context goldfish_dma;
@@ -158,7 +166,11 @@
 }
 
 static bool has_DMA_support(const ExtendedRCEncoderContext *rcEnc) {
+#ifdef HOST_BUILD
+    return rcEnc->getDmaVersion() > 0;
+#else
     return rcEnc->getDmaVersion() > 0 || rcEnc->hasDirectMem();
+#endif
 }
 
 static gralloc_dmaregion_t* init_gralloc_dmaregion(ExtendedRCEncoderContext *rcEnc) {
@@ -227,6 +239,13 @@
 
     gralloc_dmaregion_t* grdma = init_gralloc_dmaregion(rcEnc);
     pthread_mutex_lock(&grdma->lock);
+#ifdef HOST_BUILD
+    if (rcEnc->getDmaVersion() > 0) {
+        shouldDelete = put_gralloc_region_dma_locked(grdma, sz);
+    } else {
+        shouldDelete = false;
+    }
+#else
     if (rcEnc->hasDirectMem()) {
         shouldDelete = put_gralloc_region_direct_mem_locked(grdma, sz);
     } else if (rcEnc->getDmaVersion() > 0) {
@@ -234,6 +253,7 @@
     } else {
         shouldDelete = false;
     }
+#endif
     pthread_mutex_unlock(&grdma->lock);
 
     return shouldDelete;
@@ -283,6 +303,13 @@
     D("%s: for sz %u, refcount %u", __func__, sz, grdma->refcount);
     const uint32_t new_sz = std::max(grdma->sz, sz);
 
+#ifdef HOST_BUILD
+    if (rcEnc->getDmaVersion() > 0) {
+        gralloc_dmaregion_register_ashmem_dma_locked(grdma, new_sz);
+    } else {
+        ALOGE("%s: unexpected DMA type", __func__);
+    }
+#else
     if (rcEnc->hasDirectMem()) {
         gralloc_dmaregion_register_ashmem_direct_mem_locked(grdma, new_sz);
     } else if (rcEnc->getDmaVersion() > 0) {
@@ -290,6 +317,7 @@
     } else {
         ALOGE("%s: unexpected DMA type", __func__);
     }
+#endif
 
     pthread_mutex_unlock(&grdma->lock);
 }