void CEXIMic::StreamStart() { // Open stream with current parameters stream_size = buff_size_samples * 500; stream_buffer = new s16[stream_size]; pa_error = Pa_OpenDefaultStream(&pa_stream, 1, 0, paInt16, sample_rate, buff_size_samples, Pa_Callback, this); StreamLog("Pa_OpenDefaultStream"); pa_error = Pa_StartStream(pa_stream); StreamLog("Pa_StartStream"); }
void CEXIMic::StreamTerminate() { StreamStop(); if ((pa_error = Pa_Terminate()) != paNoError) StreamLog("Pa_Terminate"); }
void CEXIMic::StreamInit() { // Setup the wonderful c-interfaced lib... pa_stream = nullptr; if ((pa_error = Pa_Initialize()) != paNoError) StreamLog("Pa_Initialize"); stream_buffer = nullptr; samples_avail = stream_wpos = stream_rpos = 0; }
int main(int argc, char **argv) { static struct option long_options[] = { {"help", no_argument, NULL, '?'}, {"version", no_argument, NULL, 'V'}, {"directory", required_argument, NULL, 'D'}, {"host", required_argument, NULL, 'h'}, {"port", required_argument, NULL, 'p'}, {"username", required_argument, NULL, 'U'}, {"no-loop", no_argument, NULL, 'n'}, {"no-password", no_argument, NULL, 'w'}, {"password", no_argument, NULL, 'W'}, {"status-interval", required_argument, NULL, 's'}, {"verbose", no_argument, NULL, 'v'}, {NULL, 0, NULL, 0} }; int c; int option_index; progname = get_progname(argv[0]); set_pglocale_pgservice(argv[0], PG_TEXTDOMAIN("pg_receivexlog")); if (argc > 1) { if (strcmp(argv[1], "--help") == 0 || strcmp(argv[1], "-?") == 0) { usage(); exit(0); } else if (strcmp(argv[1], "-V") == 0 || strcmp(argv[1], "--version") == 0) { puts("pg_receivexlog (PostgreSQL) " PG_VERSION); exit(0); } } while ((c = getopt_long(argc, argv, "D:h:p:U:s:nwWv", long_options, &option_index)) != -1) { switch (c) { case 'D': basedir = xstrdup(optarg); break; case 'h': dbhost = xstrdup(optarg); break; case 'p': if (atoi(optarg) <= 0) { fprintf(stderr, _("%s: invalid port number \"%s\"\n"), progname, optarg); exit(1); } dbport = xstrdup(optarg); break; case 'U': dbuser = xstrdup(optarg); break; case 'w': dbgetpassword = -1; break; case 'W': dbgetpassword = 1; break; case 's': standby_message_timeout = atoi(optarg) * 1000; if (standby_message_timeout < 0) { fprintf(stderr, _("%s: invalid status interval \"%s\"\n"), progname, optarg); exit(1); } break; case 'n': noloop = 1; break; case 'v': verbose++; break; default: /* * getopt_long already emitted a complaint */ fprintf(stderr, _("Try \"%s --help\" for more information.\n"), progname); exit(1); } } /* * Any non-option arguments? */ if (optind < argc) { fprintf(stderr, _("%s: too many command-line arguments (first is \"%s\")\n"), progname, argv[optind]); fprintf(stderr, _("Try \"%s --help\" for more information.\n"), progname); exit(1); } /* * Required arguments */ if (basedir == NULL) { fprintf(stderr, _("%s: no target directory specified\n"), progname); fprintf(stderr, _("Try \"%s --help\" for more information.\n"), progname); exit(1); } #ifndef WIN32 pqsignal(SIGINT, sigint_handler); #endif while (true) { StreamLog(); if (time_to_abort) { /* * We've been Ctrl-C'ed. That's not an error, so exit without an * errorcode. */ exit(0); } else if (noloop) { fprintf(stderr, _("%s: disconnected.\n"), progname); exit(1); } else { fprintf(stderr, /* translator: check source for value for %d */ _("%s: disconnected. Waiting %d seconds to try again.\n"), progname, RECONNECT_SLEEP_TIME); pg_usleep(RECONNECT_SLEEP_TIME * 1000000); } } /* Never get here */ exit(2); }
int main(int argc, char **argv) { static struct option long_options[] = { {"help", no_argument, NULL, '?'}, {"version", no_argument, NULL, 'V'}, {"dir", required_argument, NULL, 'D'}, {"host", required_argument, NULL, 'h'}, {"port", required_argument, NULL, 'p'}, {"username", required_argument, NULL, 'U'}, {"no-password", no_argument, NULL, 'w'}, {"password", no_argument, NULL, 'W'}, {"statusint", required_argument, NULL, 's'}, {"verbose", no_argument, NULL, 'v'}, {NULL, 0, NULL, 0} }; int c; int option_index; progname = get_progname(argv[0]); set_pglocale_pgservice(argv[0], PG_TEXTDOMAIN("pg_receivexlog")); if (argc > 1) { if (strcmp(argv[1], "--help") == 0 || strcmp(argv[1], "-?") == 0) { usage(); exit(0); } else if (strcmp(argv[1], "-V") == 0 || strcmp(argv[1], "--version") == 0) { puts("pg_receivexlog (PostgreSQL) " PG_VERSION); exit(0); } } while ((c = getopt_long(argc, argv, "D:h:p:U:s:wWv", long_options, &option_index)) != -1) { switch (c) { case 'D': basedir = xstrdup(optarg); break; case 'h': dbhost = xstrdup(optarg); break; case 'p': if (atoi(optarg) <= 0) { fprintf(stderr, _("%s: invalid port number \"%s\"\n"), progname, optarg); exit(1); } dbport = xstrdup(optarg); break; case 'U': dbuser = xstrdup(optarg); break; case 'w': dbgetpassword = -1; break; case 'W': dbgetpassword = 1; break; case 's': standby_message_timeout = atoi(optarg); if (standby_message_timeout < 0) { fprintf(stderr, _("%s: invalid status interval \"%s\"\n"), progname, optarg); exit(1); } break; case 'v': verbose++; break; default: /* * getopt_long already emitted a complaint */ fprintf(stderr, _("Try \"%s --help\" for more information.\n"), progname); exit(1); } } /* * Any non-option arguments? */ if (optind < argc) { fprintf(stderr, _("%s: too many command-line arguments (first is \"%s\")\n"), progname, argv[optind]); fprintf(stderr, _("Try \"%s --help\" for more information.\n"), progname); exit(1); } /* * Required arguments */ if (basedir == NULL) { fprintf(stderr, _("%s: no target directory specified\n"), progname); fprintf(stderr, _("Try \"%s --help\" for more information.\n"), progname); exit(1); } #ifndef WIN32 pqsignal(SIGINT, sigint_handler); #endif StreamLog(); exit(0); }