Esempio n. 1
0
int ja_initialize(SAMPLE srate, unsigned int input_channels,
                  unsigned int output_channels, unsigned int nframes,
                  const char* client_name)
{
        sigset_t sset;
        (void) srate;
        (void) nframes;

        ja_error_msg[0] = '\0';
        client = jack_client_open(client_name, JackNoStartServer, NULL);
        if (client == NULL) {
                ja_set_error_msg("jack_client_open failure");
                return 1;
        }
        ja_frames = jack_get_buffer_size(client);
        ja_sample_rate = (SAMPLE) jack_get_sample_rate(client);
        ja_in_channels = input_channels;
        ja_out_channels = output_channels;
        ja_buffer_bytes = ja_frames * JA_SAMPLE_SIZE;

        ja_inputs = (jack_default_audio_sample_t **)
                malloc(sizeof(jack_default_audio_sample_t *) * input_channels);
        RETURN_IF_NULLPTR(ja_inputs, "malloc failure");

        ja_outputs = (jack_default_audio_sample_t **)
                malloc(sizeof(jack_default_audio_sample_t *) * output_channels);
        RETURN_IF_NULLPTR(ja_outputs, "malloc failure");

        if (ja_register_ports() != 0)
                return 1;

        jack_set_process_thread(client, ja_process_thread, NULL);
        jack_on_shutdown(client, ja_shutdown, NULL);

        /* Unblock signals */
        sigemptyset(&sset);
        if (sigprocmask(SIG_SETMASK, &sset, NULL) < 0) {
                ja_error("Unblock signals error\n");
                return 1;
        }
        ja_lisp_busy = 1;

        return 0;
}
Esempio n. 2
0
static int ja_register_ports(void)
{
        int i;

        input_ports =
                (jack_port_t **) malloc(sizeof(jack_port_t *) * ja_in_channels);
        RETURN_IF_NULLPTR(input_ports, "malloc failure");

        input_port_names = (char **) malloc(sizeof(char *) * ja_in_channels);
        RETURN_IF_NULLPTR(input_port_names, "malloc failure");

        for (i = 0; i < ja_in_channels; i++) {
                input_port_names[i] =
                        (char *) malloc(sizeof(char) * JA_PORT_NAME_MAX_LENGTH);
                RETURN_IF_NULLPTR(input_port_names[i], "malloc failure");
                sprintf(input_port_names[i], "in_%d", i + 1);
                input_ports[i] = jack_port_register (client,
                                                     input_port_names[i],
                                                     JACK_DEFAULT_AUDIO_TYPE,
                                                     JackPortIsInput, 0);
        }

        output_ports =
                (jack_port_t **) malloc(sizeof(jack_port_t *) * ja_out_channels);
        RETURN_IF_NULLPTR(output_ports, "malloc failure");

        output_port_names = (char **) malloc(sizeof(char *) * ja_out_channels);
        RETURN_IF_NULLPTR(output_port_names, "malloc failure");

        for (i = 0; i < ja_out_channels; i++) {
                output_port_names[i] =
                        (char *) malloc(sizeof(char) * JA_PORT_NAME_MAX_LENGTH);
                RETURN_IF_NULLPTR(output_port_names[i], "malloc failure");
                sprintf(output_port_names[i], "out_%d", i + 1);
                output_ports[i] = jack_port_register (client,
                                                      output_port_names[i],
                                                      JACK_DEFAULT_AUDIO_TYPE,
                                                      JackPortIsOutput, 0);
        }
        return 0;
}
Esempio n. 3
0
void PlayerManager::removePlayer(Player* player)
{
    RETURN_IF_NULLPTR(player, "failed to remove player, nullptr.");
    removePlayer(player->guid());
}