void uade_arch_spawn(struct uade_ipc *ipc, pid_t *uadepid, const char *uadename) { #if 0 int fds[2]; char input[32], output[32]; if (socketpair(AF_UNIX, SOCK_STREAM, 0, fds)) { fprintf(stderr, "Can not create socketpair: %s\n", strerror(errno)); abort(); } *uadepid = fork(); if (*uadepid < 0) { fprintf(stderr, "Fork failed: %s\n", strerror(errno)); abort(); } /* The child (*uadepid == 0) will execute uadecore */ if (*uadepid == 0) { int fd; int maxfds; if ((maxfds = sysconf(_SC_OPEN_MAX)) < 0) { maxfds = 1024; fprintf(stderr, "Getting max fds failed. Using %d.\n", maxfds); } /* close everything else but stdin, stdout, stderr, and in/out fds */ for (fd = 3; fd < maxfds; fd++) { if (fd != fds[1]) atomic_close(fd); } /* give in/out fds as command line parameters to the uade process */ snprintf(input, sizeof(input), "fd://%d", fds[1]); snprintf(output, sizeof(output), "fd://%d", fds[1]); execlp(uadename, uadename, "-i", input, "-o", output, (char *) NULL); fprintf(stderr, "uade execlp failed: %s\n", strerror(errno)); abort(); } /* Close fds that the uadecore uses */ if (atomic_close(fds[1]) < 0) { fprintf(stderr, "Could not close uadecore fds: %s\n", strerror(errno)); kill (*uadepid, SIGTERM); abort(); } do { snprintf(output, sizeof output, "fd://%d", fds[0]); snprintf(input, sizeof input, "fd://%d", fds[0]); uade_set_peer(ipc, 1, input, output); } while (0); #endif }
int init() { char temp[256]; //uadeconf_loaded = uade_load_initial_config(uadeconfname, // sizeof uadeconfname, // &state.config, NULL); if(eaglestore == 0) { memset(&state, 0, sizeof state); __android_log_print(ANDROID_LOG_VERBOSE, "UADEPlugin", "baseDir os '%s'", baseDir); uadeconf_loaded = uade_load_initial_config(&state, uadeconfname, sizeof(uadeconfname), baseDir); strcpy(state.permconfig.basedir.name, baseDir); state.config = state.permconfig; // state.config.no_filter = 1; uade_set_peer(&uadeipc, 1, "client", "server"); state.ipc = uadeipc; eaglestore = 1; } if(thread == 0) { __android_log_print(ANDROID_LOG_VERBOSE, "UADEPlugin", "Creating thread"); pthread_create(&thread, NULL, threadProc, NULL); sprintf(temp, "%s/uaerc", baseDir); if(uade_send_string(UADE_COMMAND_CONFIG, temp, &uadeipc)) { __android_log_print(ANDROID_LOG_VERBOSE, "UADE", "Can not send config name\n"); } } if(!soundBuffer) soundBuffer = (short*)malloc(44100 * 8); return 0; }
void uade_option(int argc, char **argv) { int i, j, no_more_opts; char **s_argv; int s_argc; int cfg_loaded = 0; char optionsfile[PATH_MAX]; int ret; char *input = NULL; char *output = NULL; /* network byte order is the big endian order */ uade_big_endian = (htonl(0x1234) == 0x1234); memset(&song, 0, sizeof(song)); no_more_opts = 0; s_argv = malloc(sizeof(argv[0]) * (argc + 1)); if (!s_argv) { fprintf (stderr, "uadecore: Out of memory for command line parsing.\n"); exit(-1); } s_argc = 0; s_argv[s_argc++] = argv[0]; for (i = 1; i < argc;) { j = i; /* if argv[i] begins with '-', see if it is a switch that we should handle here. */ if (argv[i][0] == '-') { if (!strcmp(argv[i], "--help") || !strcmp(argv[i], "-h") || !strcmp(argv[i], "-help")) { uade_print_help(OPTION_HELP, argv[0]); exit(0); } else if (!strcmp(argv[i], "-i")) { if ((i + 1) >= argc) { fprintf(stderr, "uadecore: %s parameter missing\n", argv[i]); uade_print_help(OPTION_ILLEGAL_PARAMETERS, argv[0]); exit(-1); } input = argv[i + 1]; i += 2; } else if (!strcmp(argv[i], "-o")) { if ((i + 1) >= argc) { fprintf(stderr, "uadecore: %s parameter missing\n", argv[i]); uade_print_help(OPTION_ILLEGAL_PARAMETERS, argv[0]); exit(-1); } output = argv[i + 1]; i += 2; } else if (!strcmp(argv[i], "--")) { for (i = i + 1; i < argc ; i++) s_argv[s_argc++] = argv[i]; break; } } if (i == j) { s_argv[s_argc++] = argv[i]; i++; } } s_argv[s_argc] = NULL; uade_set_peer(&uadeipc, 0, input, output); ret = uade_receive_string(optionsfile, UADE_COMMAND_CONFIG, sizeof(optionsfile), &uadeipc); if (ret == 0) { fprintf(stderr, "uadecore: No config file passed as a message.\n"); exit(-1); } else if (ret < 0) { fprintf(stderr, "uadecore: Invalid input. Expected a config file.\n"); exit(-1); } // printf("got config : %s\n",optionsfile); /* use the config file provided with a message, if '-config' option was not given */ if (!cfg_loaded) { if (cfgfile_load (&currprefs, optionsfile) == 0) { fprintf(stderr, "uadecore: Could not load uaerc (%s).\n", optionsfile); exit(-1); } } free(s_argv); uade_portable_initializations(); uade_reboot = 1; }