Exemple #1
0
 int Shm::getShmInit(void * &pstShm, int iFlag) {
     volatile char *sShm = NULL;
     sShm = getShm(iFlag & (~IPC_CREAT));
     if (NULL == sShm) {
         if (!(iFlag & IPC_CREAT)) {
             return -__LINE__;
         }
         sShm = getShm(iFlag);
         if (!sShm) {
             return -__LINE__;
         }
         memset((char*) sShm, 0, iSize);
         
         pstShm = (void*) sShm;
         return -__LINE__;
     }
     pstShm = (void*) sShm;
     return 0;
 }
Exemple #2
0
/////////////////////////////////////////////////////////
// Constructor
//
/////////////////////////////////////////////////////////
pix_share_write :: pix_share_write(int argc, t_atom*argv) :
#if USE_SHM
  shm_id(0), shm_addr(NULL),
#endif
  m_size(0),
  m_outlet(0)
{
#if USE_SHM
  memset(&shm_desc, 0, sizeof(shm_desc));
#elif defined _WIN32
#else
  error("Gem has been compiled without shared memory support!")
#endif
  if(argc<1) {
    //~ throw(GemException("no ID given"));
  } else {
    int err  = getShm(argc, argv);

    switch(err) {
    case 0:
      break;
    case 1:
      throw(GemException("no valid size given"));
      break;
    case 2:
      throw(GemException("given size < 0"));
      break;
    case 3:
      throw(GemException("no valid dimensions given"));
      break;
    case 4:
      throw(GemException("<color> must be one of: 4,2,1,RGBA,YUV,Grey"));
      break;
    case 5:
      throw(GemException("arguments: <id> <width> <height> <color>"));
      break;
    case 6:
      throw(GemException("couldn't get shared memory"));
      break;
    case 7:
      throw(GemException("no ID given"));
      break;
    case 8:
      throw(GemException("invalid ID..."));
      break;
    default:
      throw(GemException("unknown error"));
      break;
    }
  }
  m_outlet = outlet_new(this->x_obj,0);
}
/////////////////////////////////////////////////////////
// Constructor
//
/////////////////////////////////////////////////////////
pix_share_write :: pix_share_write(int argc, t_atom*argv)
#ifdef _WIN32
#else
  : shm_id(0), shm_addr(NULL)
#endif
{
  if(argc<1){
    throw(GemException("no ID given"));
  }
  int err  = getShm(argc, argv);

  switch(err){
  case 0:
    break;
  case 1:
    throw(GemException("no valid size given"));
    break;
  case 2:
    throw(GemException("given size < 0"));
    break;
  case 3:
    throw(GemException("no valid dimensions given"));
    break;
  case 4:
    throw(GemException("<color> must be one of: 4,2,1,RGBA,YUV,Grey"));
    break;
  case 5:
    throw(GemException("arguments: <id> <width> <height> <color>"));
    break;
  case 6:
    throw(GemException("couldn't get shared memory"));
    break;
  case 7:
    throw(GemException("no ID given"));
    break;
  case 8:
    throw(GemException("invalid ID..."));
    break;
   default:
    throw(GemException("unknown error"));
    break;
  }
}