Split JackWaitThreadedDriver's Execute method
[jack2.git] / android / Shm.cpp
blob1149616fe8f7e4eee2aca610b0adbf013db36b64
1 /*
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"
24 #include <stddef.h>
25 #include <stdio.h>
26 #include <stdlib.h>
27 #include <string.h>
28 #include <unistd.h>
30 #include <binder/MemoryHeapBase.h>
31 #include <binder/IServiceManager.h>
32 #include <binder/IPCThreadState.h>
33 #include <utils/Log.h>
34 #include <sys/stat.h>
35 #include <sys/socket.h>
36 #include <sys/types.h>
37 #include <sys/un.h>
38 #include <sys/wait.h>
39 #include "BnAndroidShm.h"
40 #include "AndroidShm.h"
42 #include "JackConstants.h"
44 #include <fcntl.h>
45 #include <signal.h>
46 #include <limits.h>
47 #include <errno.h>
48 #include <dirent.h>
49 #include <sys/mman.h>
50 #include <linux/ashmem.h>
51 #include <cutils/ashmem.h>
53 #include "JackError.h"
55 // remove ALOGI log
56 #define jack_d
57 //#define jack_d ALOGI
58 #define jack_error ALOGE
59 #define MEMORY_SIZE 10*1024
62 namespace android {
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"
105 int Shm::semid = -1;
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");
116 Shm::ref = new Shm;
117 //AndroidShm::instantiate();
119 return ref;
122 Shm::Shm() { }
124 Shm::~Shm() { }
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;
134 // do {
135 // binder = sm->getService(String16("com.samsung.android.jam.IAndroidShm"));
136 // if (binder != 0)
137 // break;
138 // ALOGW("CameraService not published, waiting...");
139 // usleep(500000); // 0.5 s
140 // } while(true);
141 // mShmService = interface_cast<IAndroidShm>(binder);
142 // }
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 ) {
148 // not used
150 void Shm::shm_copy_to_registry (jack_shm_info_t* /*si*/, jack_shm_registry_index_t*) {
151 // not used
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...");
168 return -1;
170 jack_release_shm_entry (index);
171 jack_shm_unlock_registry ();
172 jack_d ("release_shm_info: success!");
174 else
175 jack_error ("release_shm_info: error!");
177 return 0;
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);
182 return NULL;
185 sp<IAndroidShm> service = Shm::getShmService();
186 if(service == NULL){
187 jack_error("shm service is null");
188 return NULL;
190 mShmMemBase[fd] = service->getBuffer(fd);
191 if(mShmMemBase[fd] == NULL) {
192 jack_error("fail to get memory buffer");
193 return NULL;
196 return ((char *) mShmMemBase[fd]->getBase());
199 int Shm::shm_lock_registry (void) {
200 pthread_mutex_lock (&mutex);
201 return 0;
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) {
217 int shm_fd = -1;
218 jack_d("remove_id [%s]",(char*)id);
219 if(!strcmp((const char*)id, JACK_REGISTRY_NAME)) {
220 shm_fd = registry_fd;
221 } else {
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;
225 break;
230 if (shm_fd >= 0) {
231 sp<IAndroidShm> service = getShmService();
232 if(service != NULL) {
233 service->removeShm(shm_fd);
234 } else {
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();
245 if(service == NULL){
246 jack_error("shm service is null");
247 return EINVAL;
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");
258 //close (shm_fd);
259 ri->ptr.attached_at = NULL;
260 registry_fd = JACK_SHM_REGISTRY_FD;
261 return EINVAL;
264 ri->fd = shm_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;
272 return 0;
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
282 return 0;
285 int Shm::GetUID() {
286 return getuid();
289 int Shm::GetPID() {
290 return getpid();
293 int Shm::jack_shm_lock_registry (void) {
294 // TODO: replace semaphore to mutex
295 pthread_mutex_lock (&mutex);
296 return 0;
299 void Shm::jack_shm_unlock_registry (void) {
300 // TODO: replace semaphore to mutex
301 pthread_mutex_unlock (&mutex);
302 return;
305 void Shm::shm_init_registry () {
306 if(jack_shm_header == NULL)
307 return;
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 */
340 int shm_fd = 0;
342 strncpy (registry_id, JACK_REGISTRY_NAME, sizeof (registry_id) - 1);
343 registry_id[sizeof (registry_id) - 1] = '\0';
345 sp<IAndroidShm> service = getShmService();
346 if(service == NULL){
347 jack_error("shm service is null");
348 return EINVAL;
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;
354 return EINVAL;
357 service->setRegistryIndex(shm_fd);
359 /* set up global pointers */
360 ri->fd = shm_fd;
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
375 return 0;
378 int Shm::shm_validate_registry () {
379 /* registry must be locked */
380 if(jack_shm_header == NULL) {
381 return -1;
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 */
394 return -1;
397 int Shm::server_initialize_shm (int new_registry) {
398 int rc;
400 jack_d("server_initialize_shm\n");
402 if (jack_shm_header)
403 return 0; /* already initialized */
405 if (shm_lock_registry () < 0) {
406 jack_error ("jack_shm_lock_registry fails...");
407 return -1;
410 rc = access_registry (&registry_info);
412 if (new_registry) {
413 remove_shm (&registry_id);
414 rc = ENOENT;
417 switch (rc) {
418 case ENOENT: /* registry does not exist */
419 rc = create_registry (&registry_info);
420 break;
421 case 0: /* existing registry */
422 if (shm_validate_registry () == 0)
423 break;
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 (&registry_info);
429 remove_shm (&registry_id);
430 if ((rc = create_registry (&registry_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);
436 //#endif
438 break;
439 default: /* failure return code */
440 break;
443 shm_unlock_registry ();
444 return rc;
447 // here begin the API
448 int Shm::register_server (const char *server_name, int new_registry) {
449 int i, res = 0;
451 jack_d("register_server new_registry[%d]\n", new_registry);
453 set_server_prefix (server_name);
455 if (server_initialize_shm (new_registry))
456 return ENOMEM;
458 if (shm_lock_registry () < 0) {
459 jack_error ("jack_shm_lock_registry fails...");
460 return -1;
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 */
475 goto unlock;
478 /* see if server still exists */
479 if (kill (jack_shm_header->server[i].pid, 0) == 0) {
480 res = EEXIST; /* other server running */
481 goto unlock;
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)
492 break;
495 if (i >= MAX_SERVERS) {
496 res = ENOSPC; /* out of space */
497 goto unlock;
500 /* claim it */
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';
507 unlock:
508 shm_unlock_registry ();
509 return res;
512 int Shm::unregister_server (const char * /* server_name */) {
513 int i;
514 if (shm_lock_registry () < 0) {
515 jack_error ("jack_shm_lock_registry fails...");
516 return -1;
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 ();
527 return 0;
530 int Shm::initialize_shm (const char *server_name) {
531 int rc;
533 if (jack_shm_header)
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...");
540 return -1;
543 if ((rc = access_registry (&registry_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 ();
551 return rc;
554 int Shm::initialize_shm_server (void) {
555 // not used
556 return 0;
559 int Shm::initialize_shm_client (void) {
560 // not used
561 return 0;
564 int Shm::cleanup_shm (void) {
565 int i;
566 int destroy;
567 jack_shm_info_t copy;
569 if (shm_lock_registry () < 0) {
570 jack_error ("jack_shm_lock_registry fails...");
571 return -1;
574 for (i = 0; i < MAX_SHM_ID; i++) {
575 jack_shm_registry_t* r;
577 r = &jack_shm_registry[i];
578 memcpy (&copy, r, sizeof (jack_shm_info_t));
579 destroy = FALSE;
581 /* ignore unused entries */
582 if (r->allocator == 0)
583 continue;
585 /* is this my shm segment? */
586 if (r->allocator == GetPID()) {
588 /* allocated by this process, so unattach
589 and destroy. */
590 release_shm (&copy);
591 destroy = TRUE;
593 } else {
595 /* see if allocator still exists */
596 if (kill (r->allocator, 0)) {
597 if (errno == ESRCH) {
598 /* allocator no longer exists,
599 * so destroy */
600 destroy = TRUE;
605 if (destroy) {
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);
613 r->size = 0;
614 r->allocator = 0;
618 shm_unlock_registry ();
619 return TRUE;
623 jack_shm_registry_t * Shm::get_free_shm_info () {
624 /* registry must be locked */
625 jack_shm_registry_t* si = NULL;
626 int i;
628 for (i = 0; i < MAX_SHM_ID; ++i) {
629 if (jack_shm_registry[i].size == 0) {
630 break;
634 if (i < MAX_SHM_ID) {
635 si = &jack_shm_registry[i];
638 return si;
641 int Shm::shmalloc (const char * /*shm_name*/, jack_shmsize_t size, jack_shm_info_t* si) {
642 jack_shm_registry_t* registry;
643 int shm_fd;
644 int rc = -1;
645 char name[SHM_NAME_MAX+1];
647 if (shm_lock_registry () < 0) {
648 jack_error ("jack_shm_lock_registry fails...");
649 return -1;
652 sp<IAndroidShm> service = getShmService();
653 if(service == NULL){
654 rc = errno;
655 jack_error("shm service is null");
656 goto unlock;
659 if ((registry = get_free_shm_info ()) == NULL) {
660 jack_error ("shm registry full");
661 goto unlock;
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);
667 goto unlock;
670 if((shm_fd = service->allocShm(size)) < 0) {
671 rc = errno;
672 jack_error ("Cannot create shm segment %s", name);
673 goto unlock;
676 //close (shm_fd);
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;
682 si->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 ");
689 unlock:
690 shm_unlock_registry ();
691 return rc;
694 void Shm::release_shm (jack_shm_info_t* /*si*/) {
695 // do nothing
698 void Shm::release_lib_shm (jack_shm_info_t* /*si*/) {
699 // do nothing
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);
716 close (si->fd);
717 return -1;
719 return 0;
722 int Shm::attach_lib_shm (jack_shm_info_t* si) {
723 int res = attach_shm(si);
724 if (res == 0)
725 si->size = jack_shm_registry[si->index].size; // Keep size in si struct
726 return res;
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);
734 close (si->fd);
735 return -1;
737 return 0;
740 int Shm::attach_lib_shm_read (jack_shm_info_t* si) {
741 int res = attach_shm_read(si);
742 if (res == 0)
743 si->size = jack_shm_registry[si->index].size; // Keep size in si struct
744 return res;
747 int Shm::resize_shm (jack_shm_info_t* si, jack_shmsize_t size) {
748 jack_shm_id_t id;
750 /* The underlying type of `id' differs for SYSV and POSIX */
751 memcpy (&id, &jack_shm_registry[si->index].id, sizeof (id));
753 release_shm (si);
754 destroy_shm (si);
756 if (shmalloc ((char *) id, size, si)) {
757 return -1;
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) {
772 if(si != NULL) {
773 return (char*)si->ptr.attached_at;
774 } else {
775 jack_error ("jack_shm_addr : jack_shm_info_t is NULL!");
776 return 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();