[PD] share-mem lib

Cyrille Henry ch at chnry.net
Mon Feb 25 15:54:30 CET 2013


hello

looking at the thread, i was assuming that the question was about shmem, but it look more like a question about pix_share_write.

in shmem, the shmid is the id provide by the user so anyone can acces to the mem.
but shmem did share table, so you have to put the pix in a table before sharing it.

on the other hand, pix_share_read / pix_share_write are dedicated to share pix data.
but the id provide is not the shmid.
looking at the source, i think the shmid is computed with this code :

int hash_str2us(std::string s) {
  
   int result=0;
   int a=63689;
   int b=378551;


   if(s.length()<1)return -1;

   unsigned int i=0;
   for(i=0; i<s.length(); i++) {
     result=result*a+s[i];
     a *= b;
   }

   return ((unsigned short)(result) & 0x7FFFFFFF);
}

is that what you where looking for?

cheers
cyrille


Le 25/02/2013 15:13, Charles Goyard a écrit :
> Hi,
>
> Cyrille Henry wrote:
>> i just did a initial commit of share-mem, a lib dedicated to deal with
>> shared memory.
>
> Wow, great !
>
> I'd like to use this to share pixes with veejay (a vjing tool that runs
> on linux). Veejay wants YUV and can read/write from/to shm. So it looks
> like communication can be done pretty easily. (note there's also an OGRE
> plugin that uses shm).
>
> My question is: how can I map the shm id of pix_share_write to the
> output of ipcs ? Reading the source code left me clueless.
>
> For example:
> [ set 400 256 256 RGBA (
> creates this:
> ~$ ipcs
> key        shmid                            size
> 0x0000798c 229379     charles    666        262164     1
>
> veejay want the shm id as shown in the second field.
>
> How course I can grep the pid and look for pd. But it won't work for
> several shms.
>
> Thanks for any hints,
>



More information about the Pd-list mailing list