Beispiel #1
0
static      vmResult
alsa_enable(void)
{
	int         err;

	if ((err = snd_pcm_open(&pcm_handle, pcm_name,
							SND_PCM_STREAM_PLAYBACK, 0)) < 0) {
		module_logger(&alsaSound, _L|LOG_ERROR | LOG_USER,
					  _("Could not open ALSA PCM device (%s): %s\n"), pcm_name,
					  snd_strerror(err));
		return vmNotAvailable;
	}

	if (!setup_playback())
		return vmInternalError;

	// allow this to fail
//	if (direction == SND_PCM_OPEN_DUPLEX && !setup_recording())
//	direction = SND_PCM_OPEN_PLAYBACK;

	pthread_mixer_init(pcm_hz, pcm_samplesize,
					   (pcm_format == SND_PCM_FORMAT_S8 ||
						pcm_format == SND_PCM_FORMAT_S16_BE ||
						pcm_format == SND_PCM_FORMAT_S16_LE),
					   (pcm_format == SND_PCM_FORMAT_S8 ||
						pcm_format == SND_PCM_FORMAT_U8),
					   (pcm_format == SND_PCM_FORMAT_S16_BE ||
						pcm_format == SND_PCM_FORMAT_U16_BE));

	return pthread_mixer_enable();
}
Beispiel #2
0
/**
 * Main fake event test program. Setup, teardown and report errors.
 * @param argc: arg count.
 * @param argv: array of commandline arguments.
 * @return program failure if test fails.
 */
int
main(int argc, char* argv[])
{
    int c, res;
    int pass_argc = 0;
    char* pass_argv[MAXARG];
    char* playback_file = NULL;
    int init_optind = optind;
    char* init_optarg = optarg;
    struct replay_scenario* scen = NULL;

    /* we do not want the test to depend on the timezone */
    (void)putenv("TZ=UTC");

    log_init(NULL, 0, NULL);
    /* determine commandline options for the daemon */
    pass_argc = 1;
    pass_argv[0] = "unbound";
    add_opts("-d", &pass_argc, pass_argv);
    while( (c=getopt(argc, argv, "2egho:p:s")) != -1) {
        switch(c) {
        case 's':
            free(pass_argv[1]);
            testbound_selftest();
            printf("selftest successful\n");
            exit(0);
        case '2':
#if (defined(HAVE_EVP_SHA256) || defined(HAVE_NSS)) && defined(USE_SHA2)
            printf("SHA256 supported\n");
            exit(0);
#else
            printf("SHA256 not supported\n");
            exit(1);
#endif
            break;
        case 'e':
#if defined(USE_ECDSA)
            printf("ECDSA supported\n");
            exit(0);
#else
            printf("ECDSA not supported\n");
            exit(1);
#endif
            break;
        case 'g':
#ifdef USE_GOST
            if(ldns_key_EVP_load_gost_id()) {
                printf("GOST supported\n");
                exit(0);
            } else {
                printf("GOST not supported\n");
                exit(1);
            }
#else
            printf("GOST not supported\n");
            exit(1);
#endif
            break;
        case 'p':
            playback_file = optarg;
            break;
        case 'o':
            add_opts(optarg, &pass_argc, pass_argv);
            break;
        case '?':
        case 'h':
        default:
            testbound_usage();
            return 1;
        }
    }
    argc -= optind;
    argv += optind;
    if(argc != 0) {
        testbound_usage();
        return 1;
    }
    log_info("Start of %s testbound program.", PACKAGE_STRING);
    if(atexit(&remove_configfile) != 0)
        fatal_exit("atexit() failed: %s", strerror(errno));

    /* setup test environment */
    scen = setup_playback(playback_file, &pass_argc, pass_argv);
    /* init fake event backend */
    fake_event_init(scen);

    pass_argv[pass_argc] = NULL;
    echo_cmdline(pass_argc, pass_argv);

    /* reset getopt processing */
    optind = init_optind;
    optarg = init_optarg;

    /* run the normal daemon */
    res = daemon_main(pass_argc, pass_argv);

    fake_event_cleanup();
    for(c=1; c<pass_argc; c++)
        free(pass_argv[c]);
    if(res == 0) {
        log_info("Testbound Exit Success");
#ifdef HAVE_PTHREAD
        /* dlopen frees its thread state (dlopen of gost engine) */
        pthread_exit(NULL);
#endif
    }
    return res;
}
Beispiel #3
0
int main(int argc, char *argv[])
{
	struct termios tp;
	struct timeval tv;
	int fds;
	fd_set watchset;
	char ch = 0;
	int song;

	MAGENTA();
	printf("NDS Music Player, libao edition\n");
	printf("Version 4.0\n");
	printf("Using vio2sf 0.15\n");
	NORMAL();
	// check if an argument was given
	if (argc < 2)
	{
		RED();
		printf("Error: must specify a filename or names!\n");
		NORMAL();
		return -1;
	}

	GREEN();
	printf("Press ESC or Q to stop. p = previous song, n = next song\n\n", argv[1]);
	NORMAL();

	if (setup_playback(argv[1]) < 0)
	{
		return -1;
	}

	tcgetattr(STDIN_FILENO, &tp);
	tp.c_lflag &= ~ICANON;
	tp.c_lflag &= ~(ECHO | ECHOCTL | ECHONL);
	tcsetattr(STDIN_FILENO, TCSANOW, &tp);

	ch = 0;
	song = 1;
	while ((ch != 27) && (ch != 'q') && (ch != 'Q'))
	{
		fds = STDIN_FILENO;
		FD_ZERO(&watchset);
		FD_SET(fds, &watchset);
		tv.tv_sec = 0;
		tv.tv_usec = 16666/2;	// timeout every 1/120th of a second
		if (select(fds+1, &watchset, NULL, NULL, &tv))
		{
			ch = getchar();	// (blocks until something is pressed)
		}
		else
		{
			ch = 0;
		}

		m1sdr_TimeCheck();

		// Added the ability to press the n key to goto the next song
		if ((ch == 'n') && ((song+1) < argc))
		{
			xsf_term();
			m1sdr_Exit();
			if (c)
			{
				free(c);
				c = NULL;
			}
			free(buffer);
			song++;

			if (setup_playback(argv[song]) < 0)
			{
				ch = 27;
			}
		}

		if ((ch == 'p') && (song > 1))
		{
			xsf_term();
			m1sdr_Exit();
			if (c)
			{
				free(c);
				c = NULL;
			}
			free(buffer);
			song--;

			if (setup_playback(argv[song]) < 0)
			{
				ch = 27;
			}
		}
	}

	xsf_term();

	tcgetattr(STDIN_FILENO, &tp);
	tp.c_lflag |= ICANON;
	tp.c_lflag |= (ECHO | ECHOCTL | ECHONL);
	tcsetattr(STDIN_FILENO, TCSANOW, &tp);

	free(buffer);

	return 1;
}