jack2 codebase
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

52 lines
1.8KB

  1. #ifndef ANDROIDSHM
  2. #define ANDROIDSHM
  3. #include <binder/Parcel.h>
  4. #include "BnAndroidShm.h"
  5. #include <utils/Log.h>
  6. #include <binder/MemoryHeapBase.h>
  7. #include "shm.h"
  8. #include "android/Shm.h" //android extension of shm.h
  9. namespace android {
  10. class AndroidShm : public BnAndroidShm
  11. {
  12. #define MAX_SHARED_MEMORY_COUNT 257
  13. private:
  14. int MemAlloc(unsigned int size);
  15. public:
  16. virtual ~AndroidShm();
  17. static int instantiate();
  18. virtual int sendCommand(const char* command);
  19. virtual int allocShm(const int size); // if negative return value is error
  20. virtual int removeShm(const unsigned int index); // shared memory Á¦°Å
  21. virtual int isAllocated(const unsigned int index); // allocated ¿©ºÎ È®ÀÎ
  22. virtual int setRegistryIndex(const unsigned int index);
  23. virtual int getRegistryIndex();
  24. virtual sp<IMemoryHeap> InitSemaphore(const char* name);
  25. virtual sp<IMemoryHeap> getBuffer(int index);
  26. //virtual status_t onTransact(
  27. // uint32_t code,
  28. // const Parcel& data,
  29. // Parcel* reply,
  30. // uint32_t flags);
  31. private:
  32. int testGetBuffer();
  33. int testGetBufferByNewProcess();
  34. AndroidShm();
  35. sp<MemoryHeapBase> mMemHeap[MAX_SHARED_MEMORY_COUNT];
  36. unsigned int mRegistryIndex;
  37. // for named semaphore simulation
  38. #define MAX_SEMAPHORE_MEMORY_COUNT 300
  39. #define MAX_SEMAPHORE_NAME_LENGTH 300
  40. sp<MemoryHeapBase> mSemaphore[MAX_SEMAPHORE_MEMORY_COUNT];
  41. char mSemaphoreName[MAX_SEMAPHORE_MEMORY_COUNT][MAX_SEMAPHORE_NAME_LENGTH];
  42. };
  43. };
  44. #endif