돌고래 홈페이지
ID:
PW:


  운영자(2015-05-20 15:56:47, Hit : 594, Vote : 108
 유니티 메모리 맵 코드

c++ 의 포인터 데이터를 c# 으로 전달하기
http://yamecoder.tistory.com/301


안드로이드

package com.neo.mmfplugin;

import java.io.IOException;
import android.os.MemoryFile;
import android.util.Log;

public class MMF {
        
        private static MemoryFile _mf = null;
        
        public static boolean Create( String name, int size)
        {
                if(_mf != null)
                        return false;
                
                boolean res = true;
                try
                {
                        _mf = new MemoryFile( name, size);
                }
                catch (IOException e)
                {
                        Log.i("MMF", "MMF FAILED");
                        Log.i("MMF", e.toString());
                        res = false;
                }                
                        
                Log.i("MMF", "MMF OK");
                return res;
        }
        
        public static void Release()
        {
                if(_mf != null)
                {
                        Log.i("MMF", "MMF Release ");
                        _mf.close();
                }
        }
        
        public static byte [] ReadBytes( int count)
        {
                if( _mf == null)
                        return null;
                
                boolean res = true;                
                byte [] byteArray = new byte [count];
                                
                try
                {
                        _mf.readBytes(byteArray, 0, 0, count);
                }
                catch (IOException e)
                {
                        //Log.i("MMF", e.toString());
                        res = false;
                }
                
                if(res == true)
                {
                        //Log.i("MMF", "MMF Read OK");
                }
                else
                {
                        //Log.i("MMF", "MMF Read FAILED");                        
                }
                        
                return byteArray;
        }        
        
        
        private static  int byteArrayToInt(byte [] bytes, int n)
        {
                return ((((int)bytes[n + 0] & 0xff) << 24) |
                                (((int)bytes[n + 1] & 0xff) << 16) |
                                (((int)bytes[n + 2] & 0xff) << 8) |
                                (((int)bytes[n + 3] & 0xff)));
        }         
        
        public static boolean WriteBytes( byte [] byteArray, int count)
        {
                if( _mf == null)
                        return false;
                
                boolean res = true;
                
                try
                {
                        _mf.writeBytes(byteArray, 0, 0, count);
                }
                catch (IOException e)
                {
                        //Log.i("MMF", e.toString());
                        res = false;
                }
                
                return res;
        }
        
}

========================================================================

IOS

http://www.gnu.org/software/libc/manual/html_node/Memory_002dmapped-I_002fO.html
mmap        munmap


https://github.com/Appboy/appboy-unity-sdk/blob/master/unity-samples/iOS/Roll-A-Ball-Ios/Libraries/libil2cpp/include/os/MemoryMappedFile.h

http://beej.us/guide/bgipc/output/html/multipage/mmap.html


"MAP_SHARED PROT_WRITE mmap" 검색

http://www.avrfreaks.net/forum/adding-memory-mapped-io?page=all
http://blog.daum.net/ehclub/681
http://blog.daum.net/ehclub/681



"shm_open" 검색
https://gist.github.com/jverkoey/2985830
http://egloos.zum.com/purewell/v/3078937
http://tip.daum.net/openknow/13056111?q=shm_open
http://iphonedevwiki.net/index.php/GSCapability
http://www.qnx.com/developers/docs/6.3.0SP3/neutrino/lib_ref/s/shm_open.html




유니티 아이폰 코드
모바일 서버

Copyright 1999-2018 Zeroboard / skin by zero