2 Copyright (C) 2001-2003 Paul Davis
3 Copyright (C) 2005-2012 Grame
4 Copyright (C) 2013 Samsung Electronics
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU Lesser General Public License as published by
8 the Free Software Foundation; either version 2.1 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU Lesser General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 #define LOG_TAG "JAMSHMSERVICE"
30 #include <binder/MemoryHeapBase.h>
31 #include <binder/IServiceManager.h>
32 #include <binder/IPCThreadState.h>
33 #include <utils/Log.h>
35 #include <sys/socket.h>
36 #include <sys/types.h>
39 #include "BnAndroidShm.h"
40 #include "AndroidShm.h"
42 #include "JackConstants.h"
50 #include <linux/ashmem.h>
51 #include <cutils/ashmem.h>
53 #include "JackError.h"
57 //#define jack_d ALOGI
58 #define jack_error ALOGE
59 #define MEMORY_SIZE 10*1024
64 jack_shmtype_t
Shm::jack_shmtype
= shm_ANDROID
;
66 /* The JACK SHM registry is a chunk of memory for keeping track of the
67 * shared memory used by each active JACK server. This allows the
68 * server to clean up shared memory when it exits. To avoid memory
69 * leakage due to kill -9, crashes or debugger-driven exits, this
70 * cleanup is also done when a new instance of that server starts.
73 /* per-process global data for the SHM interfaces */
74 jack_shm_id_t
Shm::registry_id
; /* SHM id for the registry */
75 jack_shm_fd_t
Shm::registry_fd
= JACK_SHM_REGISTRY_FD
;
77 jack_shm_info_t
Shm::registry_info
= {
78 JACK_SHM_NULL_INDEX
, 0, 0, { MAP_FAILED
}
81 /* pointers to registry header and array */
82 jack_shm_header_t
*Shm::jack_shm_header
= NULL
;
83 jack_shm_registry_t
*Shm::jack_shm_registry
= NULL
;
84 char Shm::jack_shm_server_prefix
[JACK_SERVER_NAME_SIZE
] = "";
86 /* jack_shm_lock_registry() serializes updates to the shared memory
87 * segment JACK uses to keep track of the SHM segments allocated to
88 * all its processes, including multiple servers.
90 * This is not a high-contention lock, but it does need to work across
91 * multiple processes. High transaction rates and realtime safety are
92 * not required. Any solution needs to at least be portable to POSIX
93 * and POSIX-like systems.
95 * We must be particularly careful to ensure that the lock be released
96 * if the owning process terminates abnormally. Otherwise, a segfault
97 * or kill -9 at the wrong moment could prevent JACK from ever running
98 * again on that machine until after a reboot.
101 #define JACK_SEMAPHORE_KEY 0x282929
102 #define JACK_SHM_REGISTRY_KEY JACK_SEMAPHORE_KEY
103 #define JACK_REGISTRY_NAME "/jack-shm-registry"
106 pthread_mutex_t
Shm::mutex
= PTHREAD_MUTEX_INITIALIZER
;
108 //sp<IAndroidShm> Shm::mShmService;
109 sp
<IMemoryHeap
> Shm::mShmMemBase
[JACK_SHM_HEAP_ENOUGH_COUNT
] = {0,};
111 Shm
* Shm::ref
= NULL
;
113 Shm
* Shm::Instantiate() {
114 if(Shm::ref
== NULL
) {
115 jack_d("shm::Instantiate is called");
117 //AndroidShm::instantiate();
126 sp
<IAndroidShm
> Shm::getShmService(){
127 return interface_cast
<IAndroidShm
>(defaultServiceManager()->getService(String16("com.samsung.android.jam.IAndroidShm")));
130 //sp<IAndroidShm>& Shm::getShmService() {
131 // if (mShmService.get() == 0) {
132 // sp<IServiceManager> sm = defaultServiceManager();
133 // sp<IBinder> binder;
135 // binder = sm->getService(String16("com.samsung.android.jam.IAndroidShm"));
138 // ALOGW("CameraService not published, waiting...");
139 // usleep(500000); // 0.5 s
141 // mShmService = interface_cast<IAndroidShm>(binder);
143 // ALOGE_IF(mShmService==0, "no CameraService!?");
144 // return mShmService;
147 void Shm::shm_copy_from_registry (jack_shm_info_t
* /*si*/, jack_shm_registry_index_t
) {
150 void Shm::shm_copy_to_registry (jack_shm_info_t
* /*si*/, jack_shm_registry_index_t
*) {
154 void Shm::jack_release_shm_entry (jack_shm_registry_index_t index
) {
155 /* the registry must be locked */
156 jack_shm_registry
[index
].size
= 0;
157 jack_shm_registry
[index
].allocator
= 0;
158 memset (&jack_shm_registry
[index
].id
, 0,
159 sizeof (jack_shm_registry
[index
].id
));
160 jack_shm_registry
[index
].fd
= 0;
163 int Shm::release_shm_info (jack_shm_registry_index_t index
) {
164 /* must NOT have the registry locked */
165 if (jack_shm_registry
[index
].allocator
== GetPID()) {
166 if (jack_shm_lock_registry () < 0) {
167 jack_error ("jack_shm_lock_registry fails...");
170 jack_release_shm_entry (index
);
171 jack_shm_unlock_registry ();
172 jack_d ("release_shm_info: success!");
175 jack_error ("release_shm_info: error!");
179 char* Shm::shm_addr (unsigned int fd
) {
180 if(fd
>= JACK_SHM_HEAP_ENOUGH_COUNT
) {
181 jack_error("ignore to get memory buffer : index[%d] is too big", fd
);
185 sp
<IAndroidShm
> service
= Shm::getShmService();
187 jack_error("shm service is null");
190 mShmMemBase
[fd
] = service
->getBuffer(fd
);
191 if(mShmMemBase
[fd
] == NULL
) {
192 jack_error("fail to get memory buffer");
196 return ((char *) mShmMemBase
[fd
]->getBase());
199 int Shm::shm_lock_registry (void) {
200 pthread_mutex_lock (&mutex
);
204 void Shm::shm_unlock_registry (void) {
205 pthread_mutex_unlock (&mutex
);
208 void Shm::release_shm_entry (jack_shm_registry_index_t index
) {
209 /* the registry must be locked */
210 jack_shm_registry
[index
].size
= 0;
211 jack_shm_registry
[index
].allocator
= 0;
212 memset (&jack_shm_registry
[index
].id
, 0,
213 sizeof (jack_shm_registry
[index
].id
));
216 void Shm::remove_shm (jack_shm_id_t
*id
) {
218 jack_d("remove_id [%s]",(char*)id
);
219 if(!strcmp((const char*)id
, JACK_REGISTRY_NAME
)) {
220 shm_fd
= registry_fd
;
222 for (int i
= 0; i
< MAX_SHM_ID
; i
++) {
223 if(!strcmp((const char*)id
, jack_shm_registry
[i
].id
)) {
224 shm_fd
= jack_shm_registry
[i
].fd
;
231 sp
<IAndroidShm
> service
= getShmService();
232 if(service
!= NULL
) {
233 service
->removeShm(shm_fd
);
235 jack_error("shm service is null");
238 jack_d ("[APA] jack_remove_shm : ok ");
241 int Shm::access_registry (jack_shm_info_t
* ri
) {
242 jack_d("access_registry\n");
243 /* registry must be locked */
244 sp
<IAndroidShm
> service
= getShmService();
246 jack_error("shm service is null");
249 int shm_fd
= service
->getRegistryIndex();
251 strncpy (registry_id
, JACK_REGISTRY_NAME
, sizeof (registry_id
) - 1);
252 registry_id
[sizeof (registry_id
) - 1] = '\0';
254 if(service
->isAllocated(shm_fd
) == FALSE
) {
255 //jack_error ("Cannot mmap shm registry segment (%s)",
256 // strerror (errno));
257 jack_error ("Cannot mmap shm registry segment");
259 ri
->ptr
.attached_at
= NULL
;
260 registry_fd
= JACK_SHM_REGISTRY_FD
;
265 registry_fd
= shm_fd
;
266 ri
->ptr
.attached_at
= shm_addr(shm_fd
);
268 if(ri
->ptr
.attached_at
== NULL
) {
269 ALOGE("attached pointer is null !");
270 jack_shm_header
= NULL
;
271 jack_shm_registry
= NULL
;
275 /* set up global pointers */
276 ri
->index
= JACK_SHM_REGISTRY_INDEX
;
277 jack_shm_header
= (jack_shm_header_t
*)(ri
->ptr
.attached_at
);
278 jack_shm_registry
= (jack_shm_registry_t
*) (jack_shm_header
+ 1);
280 jack_d("jack_shm_header[%p],jack_shm_registry[%p]", jack_shm_header
, jack_shm_registry
);
281 //close (shm_fd); // steph
293 int Shm::jack_shm_lock_registry (void) {
294 // TODO: replace semaphore to mutex
295 pthread_mutex_lock (&mutex
);
299 void Shm::jack_shm_unlock_registry (void) {
300 // TODO: replace semaphore to mutex
301 pthread_mutex_unlock (&mutex
);
305 void Shm::shm_init_registry () {
306 if(jack_shm_header
== NULL
)
309 /* registry must be locked */
311 memset (jack_shm_header
, 0, JACK_SHM_REGISTRY_SIZE
);
313 jack_shm_header
->magic
= JACK_SHM_MAGIC
;
314 //jack_shm_header->protocol = JACK_PROTOCOL_VERSION;
315 jack_shm_header
->type
= jack_shmtype
;
316 jack_shm_header
->size
= JACK_SHM_REGISTRY_SIZE
;
317 jack_shm_header
->hdr_len
= sizeof (jack_shm_header_t
);
318 jack_shm_header
->entry_len
= sizeof (jack_shm_registry_t
);
320 for (int i
= 0; i
< MAX_SHM_ID
; ++i
) {
321 jack_shm_registry
[i
].index
= i
;
325 void Shm::set_server_prefix (const char *server_name
) {
326 snprintf (jack_shm_server_prefix
, sizeof (jack_shm_server_prefix
),
327 "jack-%d:%s:", GetUID(), server_name
);
330 /* create a new SHM registry segment
332 * sets up global registry pointers, if successful
334 * returns: 0 if registry created successfully
335 * nonzero error code if unable to allocate a new registry
337 int Shm::create_registry (jack_shm_info_t
* ri
) {
338 jack_d("create_registry\n");
339 /* registry must be locked */
342 strncpy (registry_id
, JACK_REGISTRY_NAME
, sizeof (registry_id
) - 1);
343 registry_id
[sizeof (registry_id
) - 1] = '\0';
345 sp
<IAndroidShm
> service
= getShmService();
347 jack_error("shm service is null");
351 if((shm_fd
= service
->allocShm(JACK_SHM_REGISTRY_SIZE
)) < 0) {
352 jack_error("Cannot create shm registry segment");
353 registry_fd
= JACK_SHM_REGISTRY_FD
;
357 service
->setRegistryIndex(shm_fd
);
359 /* set up global pointers */
361 ri
->index
= JACK_SHM_REGISTRY_INDEX
;
362 registry_fd
= shm_fd
;
363 ri
->ptr
.attached_at
= shm_addr(shm_fd
);
364 ri
->size
= JACK_SHM_REGISTRY_SIZE
;
366 jack_shm_header
= (jack_shm_header_t
*)(ri
->ptr
.attached_at
);
367 jack_shm_registry
= (jack_shm_registry_t
*) (jack_shm_header
+ 1);
369 jack_d("create_registry jack_shm_header[%p], jack_shm_registry[%p]", jack_shm_header
, jack_shm_registry
);
371 /* initialize registry contents */
372 shm_init_registry ();
373 //close (shm_fd); // steph
378 int Shm::shm_validate_registry () {
379 /* registry must be locked */
380 if(jack_shm_header
== NULL
) {
384 if ((jack_shm_header
->magic
== JACK_SHM_MAGIC
)
385 //&& (jack_shm_header->protocol == JACK_PROTOCOL_VERSION)
386 && (jack_shm_header
->type
== jack_shmtype
)
387 && (jack_shm_header
->size
== JACK_SHM_REGISTRY_SIZE
)
388 && (jack_shm_header
->hdr_len
== sizeof (jack_shm_header_t
))
389 && (jack_shm_header
->entry_len
== sizeof (jack_shm_registry_t
))) {
391 return 0; /* registry OK */
397 int Shm::server_initialize_shm (int new_registry
) {
400 jack_d("server_initialize_shm\n");
403 return 0; /* already initialized */
405 if (shm_lock_registry () < 0) {
406 jack_error ("jack_shm_lock_registry fails...");
410 rc
= access_registry (®istry_info
);
413 remove_shm (®istry_id
);
418 case ENOENT
: /* registry does not exist */
419 rc
= create_registry (®istry_info
);
421 case 0: /* existing registry */
422 if (shm_validate_registry () == 0)
424 /* else it was invalid, so fall through */
425 case EINVAL
: /* bad registry */
426 /* Apparently, this registry was created by an older
427 * JACK version. Delete it so we can try again. */
428 release_shm (®istry_info
);
429 remove_shm (®istry_id
);
430 if ((rc
= create_registry (®istry_info
)) != 0) {
431 //jack_error ("incompatible shm registry (%s)",
432 // strerror (errno));
433 jack_error ("incompatible shm registry");
434 //#ifndef USE_POSIX_SHM
435 // jack_error ("to delete, use `ipcrm -M 0x%0.8x'", JACK_SHM_REGISTRY_KEY);
439 default: /* failure return code */
443 shm_unlock_registry ();
447 // here begin the API
448 int Shm::register_server (const char *server_name
, int new_registry
) {
451 jack_d("register_server new_registry[%d]\n", new_registry
);
453 set_server_prefix (server_name
);
455 if (server_initialize_shm (new_registry
))
458 if (shm_lock_registry () < 0) {
459 jack_error ("jack_shm_lock_registry fails...");
463 /* See if server_name already registered. Since server names
464 * are per-user, we register the unique server prefix string.
466 for (i
= 0; i
< MAX_SERVERS
; i
++) {
468 if (strncmp (jack_shm_header
->server
[i
].name
,
469 jack_shm_server_prefix
,
470 JACK_SERVER_NAME_SIZE
) != 0)
471 continue; /* no match */
473 if (jack_shm_header
->server
[i
].pid
== GetPID()) {
474 res
= 0; /* it's me */
478 /* see if server still exists */
479 if (kill (jack_shm_header
->server
[i
].pid
, 0) == 0) {
480 res
= EEXIST
; /* other server running */
484 /* it's gone, reclaim this entry */
485 memset (&jack_shm_header
->server
[i
], 0,
486 sizeof (jack_shm_server_t
));
489 /* find a free entry */
490 for (i
= 0; i
< MAX_SERVERS
; i
++) {
491 if (jack_shm_header
->server
[i
].pid
== 0)
495 if (i
>= MAX_SERVERS
) {
496 res
= ENOSPC
; /* out of space */
501 jack_shm_header
->server
[i
].pid
= GetPID();
502 strncpy (jack_shm_header
->server
[i
].name
,
503 jack_shm_server_prefix
,
504 JACK_SERVER_NAME_SIZE
- 1);
505 jack_shm_header
->server
[i
].name
[JACK_SERVER_NAME_SIZE
- 1] = '\0';
508 shm_unlock_registry ();
512 int Shm::unregister_server (const char * /* server_name */) {
514 if (shm_lock_registry () < 0) {
515 jack_error ("jack_shm_lock_registry fails...");
519 for (i
= 0; i
< MAX_SERVERS
; i
++) {
520 if (jack_shm_header
->server
[i
].pid
== GetPID()) {
521 memset (&jack_shm_header
->server
[i
], 0,
522 sizeof (jack_shm_server_t
));
526 shm_unlock_registry ();
530 int Shm::initialize_shm (const char *server_name
) {
534 return 0; /* already initialized */
536 set_server_prefix (server_name
);
538 if (shm_lock_registry () < 0) {
539 jack_error ("jack_shm_lock_registry fails...");
543 if ((rc
= access_registry (®istry_info
)) == 0) {
544 if ((rc
= shm_validate_registry ()) != 0) {
545 jack_error ("Incompatible shm registry, "
546 "are jackd and libjack in sync?");
549 shm_unlock_registry ();
554 int Shm::initialize_shm_server (void) {
559 int Shm::initialize_shm_client (void) {
564 int Shm::cleanup_shm (void) {
567 jack_shm_info_t copy
;
569 if (shm_lock_registry () < 0) {
570 jack_error ("jack_shm_lock_registry fails...");
574 for (i
= 0; i
< MAX_SHM_ID
; i
++) {
575 jack_shm_registry_t
* r
;
577 r
= &jack_shm_registry
[i
];
578 memcpy (©
, r
, sizeof (jack_shm_info_t
));
581 /* ignore unused entries */
582 if (r
->allocator
== 0)
585 /* is this my shm segment? */
586 if (r
->allocator
== GetPID()) {
588 /* allocated by this process, so unattach
595 /* see if allocator still exists */
596 if (kill (r
->allocator
, 0)) {
597 if (errno
== ESRCH
) {
598 /* allocator no longer exists,
607 int index
= copy
.index
;
609 if ((index
>= 0) && (index
< MAX_SHM_ID
)) {
610 remove_shm (&jack_shm_registry
[index
].id
);
611 release_shm_entry (index
);
618 shm_unlock_registry ();
623 jack_shm_registry_t
* Shm::get_free_shm_info () {
624 /* registry must be locked */
625 jack_shm_registry_t
* si
= NULL
;
628 for (i
= 0; i
< MAX_SHM_ID
; ++i
) {
629 if (jack_shm_registry
[i
].size
== 0) {
634 if (i
< MAX_SHM_ID
) {
635 si
= &jack_shm_registry
[i
];
641 int Shm::shmalloc (const char * /*shm_name*/, jack_shmsize_t size
, jack_shm_info_t
* si
) {
642 jack_shm_registry_t
* registry
;
645 char name
[SHM_NAME_MAX
+1];
647 if (shm_lock_registry () < 0) {
648 jack_error ("jack_shm_lock_registry fails...");
652 sp
<IAndroidShm
> service
= getShmService();
655 jack_error("shm service is null");
659 if ((registry
= get_free_shm_info ()) == NULL
) {
660 jack_error ("shm registry full");
664 snprintf (name
, sizeof (name
), "/jack-%d-%d", GetUID(), registry
->index
);
665 if (strlen (name
) >= sizeof (registry
->id
)) {
666 jack_error ("shm segment name too long %s", name
);
670 if((shm_fd
= service
->allocShm(size
)) < 0) {
672 jack_error ("Cannot create shm segment %s", name
);
677 registry
->size
= size
;
678 strncpy (registry
->id
, name
, sizeof (registry
->id
) - 1);
679 registry
->id
[sizeof (registry
->id
) - 1] = '\0';
680 registry
->allocator
= GetPID();
681 registry
->fd
= shm_fd
;
683 si
->index
= registry
->index
;
684 si
->ptr
.attached_at
= MAP_FAILED
; /* not attached */
685 rc
= 0; /* success */
687 jack_d ("[APA] jack_shmalloc : ok ");
690 shm_unlock_registry ();
694 void Shm::release_shm (jack_shm_info_t
* /*si*/) {
698 void Shm::release_lib_shm (jack_shm_info_t
* /*si*/) {
702 void Shm::destroy_shm (jack_shm_info_t
* si
) {
703 /* must NOT have the registry locked */
704 if (si
->index
== JACK_SHM_NULL_INDEX
)
705 return; /* segment not allocated */
707 remove_shm (&jack_shm_registry
[si
->index
].id
);
708 release_shm_info (si
->index
);
711 int Shm::attach_shm (jack_shm_info_t
* si
) {
712 jack_shm_registry_t
*registry
= &jack_shm_registry
[si
->index
];
714 if((si
->ptr
.attached_at
= shm_addr(registry
->fd
)) == NULL
) {
715 jack_error ("Cannot mmap shm segment %s", registry
->id
);
722 int Shm::attach_lib_shm (jack_shm_info_t
* si
) {
723 int res
= attach_shm(si
);
725 si
->size
= jack_shm_registry
[si
->index
].size
; // Keep size in si struct
729 int Shm::attach_shm_read (jack_shm_info_t
* si
) {
730 jack_shm_registry_t
*registry
= &jack_shm_registry
[si
->index
];
732 if((si
->ptr
.attached_at
= shm_addr(registry
->fd
)) == NULL
) {
733 jack_error ("Cannot mmap shm segment %s", registry
->id
);
740 int Shm::attach_lib_shm_read (jack_shm_info_t
* si
) {
741 int res
= attach_shm_read(si
);
743 si
->size
= jack_shm_registry
[si
->index
].size
; // Keep size in si struct
747 int Shm::resize_shm (jack_shm_info_t
* si
, jack_shmsize_t size
) {
750 /* The underlying type of `id' differs for SYSV and POSIX */
751 memcpy (&id
, &jack_shm_registry
[si
->index
].id
, sizeof (id
));
756 if (shmalloc ((char *) id
, size
, si
)) {
759 return attach_shm (si
);
762 void Shm::jack_shm_copy_from_registry (jack_shm_info_t
* si
, jack_shm_registry_index_t t
) {
763 Shm::Instantiate()->shm_copy_from_registry(si
,t
);
765 void Shm::jack_shm_copy_to_registry (jack_shm_info_t
* si
, jack_shm_registry_index_t
* t
) {
766 Shm::Instantiate()->shm_copy_to_registry(si
,t
);
768 int Shm::jack_release_shm_info (jack_shm_registry_index_t t
) {
769 return Shm::Instantiate()->release_shm_info(t
);
771 char* Shm::jack_shm_addr (jack_shm_info_t
* si
) {
773 return (char*)si
->ptr
.attached_at
;
775 jack_error ("jack_shm_addr : jack_shm_info_t is NULL!");
779 int Shm::jack_register_server (const char *server_name
, int new_registry
) {
780 return Shm::Instantiate()->register_server(server_name
, new_registry
);
782 int Shm::jack_unregister_server (const char *server_name
) {
783 return Shm::Instantiate()->unregister_server(server_name
);
785 int Shm::jack_initialize_shm (const char *server_name
) {
786 return Shm::Instantiate()->initialize_shm(server_name
);
788 int Shm::jack_initialize_shm_server (void) {
789 return Shm::Instantiate()->initialize_shm_server();
791 int Shm::jack_initialize_shm_client () {
792 return Shm::Instantiate()->initialize_shm_client();
794 int Shm::jack_cleanup_shm (void) {
795 return Shm::Instantiate()->cleanup_shm();
797 int Shm::jack_shmalloc (const char *shm_name
, jack_shmsize_t size
, jack_shm_info_t
* result
) {
798 return Shm::Instantiate()->shmalloc(shm_name
, size
, result
);
800 void Shm::jack_release_shm (jack_shm_info_t
* si
) {
801 Shm::Instantiate()->release_shm(si
);
803 void Shm::jack_release_lib_shm (jack_shm_info_t
* si
) {
804 Shm::Instantiate()->release_lib_shm(si
);
806 void Shm::jack_destroy_shm (jack_shm_info_t
* si
) {
807 Shm::Instantiate()->destroy_shm(si
);
809 int Shm::jack_attach_shm (jack_shm_info_t
* si
) {
810 return Shm::Instantiate()->attach_shm(si
);
812 int Shm::jack_attach_lib_shm (jack_shm_info_t
* si
) {
813 return Shm::Instantiate()->attach_lib_shm(si
);
815 int Shm::jack_attach_shm_read (jack_shm_info_t
* si
) {
816 return Shm::Instantiate()->attach_shm_read(si
);
818 int Shm::jack_attach_lib_shm_read (jack_shm_info_t
* si
) {
819 return Shm::Instantiate()->attach_lib_shm_read(si
);
821 int Shm::jack_resize_shm (jack_shm_info_t
* si
, jack_shmsize_t size
) {
822 return Shm::Instantiate()->resize_shm(si
, size
);
826 void jack_shm_copy_from_registry (jack_shm_info_t
* si
, jack_shm_registry_index_t t
) {
827 android::Shm::jack_shm_copy_from_registry(si
, t
);
829 void jack_shm_copy_to_registry (jack_shm_info_t
* si
, jack_shm_registry_index_t
* t
) {
830 android::Shm::jack_shm_copy_to_registry(si
, t
);
832 int jack_release_shm_info (jack_shm_registry_index_t t
) {
833 return android::Shm::jack_release_shm_info(t
);
835 char* jack_shm_addr (jack_shm_info_t
* si
) {
836 return android::Shm::jack_shm_addr(si
);
838 int jack_register_server (const char *server_name
, int new_registry
) {
839 return android::Shm::jack_register_server(server_name
, new_registry
);
841 int jack_unregister_server (const char *server_name
) {
842 return android::Shm::jack_unregister_server(server_name
);
844 int jack_initialize_shm (const char *server_name
) {
845 return android::Shm::jack_initialize_shm(server_name
);
847 int jack_initialize_shm_server (void) {
848 return android::Shm::jack_initialize_shm_server();
850 int jack_initialize_shm_client (void) {
851 return android::Shm::jack_initialize_shm_client();
853 int jack_cleanup_shm (void) {
854 return android::Shm::jack_cleanup_shm();
856 int jack_shmalloc (const char *shm_name
, jack_shmsize_t size
, jack_shm_info_t
* result
) {
857 return android::Shm::jack_shmalloc(shm_name
, size
, result
);
859 void jack_release_shm (jack_shm_info_t
* si
) {
860 android::Shm::jack_release_shm(si
);
862 void jack_release_lib_shm (jack_shm_info_t
* si
) {
863 android::Shm::jack_release_lib_shm(si
);
865 void jack_destroy_shm (jack_shm_info_t
* si
) {
866 android::Shm::jack_destroy_shm(si
);
868 int jack_attach_shm (jack_shm_info_t
* si
) {
869 return android::Shm::jack_attach_shm(si
);
871 int jack_attach_lib_shm (jack_shm_info_t
* si
) {
872 return android::Shm::jack_attach_lib_shm(si
);
874 int jack_attach_shm_read (jack_shm_info_t
* si
) {
875 return android::Shm::jack_attach_shm_read(si
);
877 int jack_attach_lib_shm_read (jack_shm_info_t
* si
) {
878 return android::Shm::jack_attach_lib_shm_read(si
);
880 int jack_resize_shm (jack_shm_info_t
* si
, jack_shmsize_t size
) {
881 return android::Shm::jack_resize_shm(si
, size
);
883 void jack_instantiate() {
884 android::AndroidShm::instantiate();