diff --git a/alsa_in.c b/alsa_in.c index 8dd13c6..84a29f8 100644 --- a/alsa_in.c +++ b/alsa_in.c @@ -256,12 +256,6 @@ static int set_swparams(snd_pcm_t *handle, snd_pcm_sw_params_t *swparams, int pe printf("Unable to set avail min for capture: %s\n", snd_strerror(err)); return err; } - /* align all transfers to 1 sample */ - err = snd_pcm_sw_params_set_xfer_align(handle, swparams, 1); - if (err < 0) { - printf("Unable to set transfer align for capture: %s\n", snd_strerror(err)); - return err; - } /* write the parameters to the playback device */ err = snd_pcm_sw_params(handle, swparams); if (err < 0) { @@ -312,7 +306,7 @@ void freewheel (int freewheel_starting, void *ignored_arg) if( freewheel_starting ) { snd_pcm_close( alsa_handle ); alsa_handle = 0; - // reset resampling parameters + // reset resampling parameters resample_mean = 1.0; static_resample_factor = 1.0; resample_lower_limit = 0.25; @@ -342,7 +336,7 @@ int process (jack_nframes_t nframes, void *arg) { /* freewheeling, or some other error */ return 0; } - + delay = snd_pcm_avail( alsa_handle ); delay -= jack_frames_since_cycle_start( client ); @@ -363,7 +357,7 @@ int process (jack_nframes_t nframes, void *arg) { // Set the resample_rate... we need to adjust the offset integral, to do this. // first look at the PI controller, this code is just a special case, which should never execute once - // everything is swung in. + // everything is swung in. offset_integral = - (resample_mean - static_resample_factor) * catch_factor * catch_factor2; // Also clear the array. we are beginning a new control cycle. for( i=0; i target_delay ) { fprintf( stderr, "target_delay (%d) cant be smaller than max_diff(%d)\n", target_delay, max_diff ); diff --git a/alsa_out.c b/alsa_out.c index 47779d1..71aceef 100644 --- a/alsa_out.c +++ b/alsa_out.c @@ -255,12 +255,6 @@ static int set_swparams(snd_pcm_t *handle, snd_pcm_sw_params_t *swparams, int pe printf("Unable to set avail min for capture: %s\n", snd_strerror(err)); return err; } - /* align all transfers to 1 sample */ - err = snd_pcm_sw_params_set_xfer_align(handle, swparams, 1); - if (err < 0) { - printf("Unable to set transfer align for capture: %s\n", snd_strerror(err)); - return err; - } /* write the parameters to the playback device */ err = snd_pcm_sw_params(handle, swparams); if (err < 0) { @@ -298,10 +292,10 @@ static snd_pcm_t *open_audiofd( char *device_name, int capture, int rate, int ch //snd_pcm_start( handle ); //snd_pcm_wait( handle, 200 ); int num_null_samples = nperiods * period * channels; - char *tmp = alloca( num_null_samples * formats[format].sample_size ); + char *tmp = alloca( num_null_samples * formats[format].sample_size ); memset( tmp, 0, num_null_samples * formats[format].sample_size ); snd_pcm_writei( handle, tmp, num_null_samples ); - + return handle; } @@ -336,7 +330,7 @@ int process (jack_nframes_t nframes, void *arg) { // Set the resample_rate... we need to adjust the offset integral, to do this. // first look at the PI controller, this code is just a special case, which should never execute once - // everything is swung in. + // everything is swung in. offset_integral = - (resample_mean - static_resample_factor) * catch_factor * catch_factor2; // Also clear the array. we are beginning a new control cycle. for( i=0; i target_delay ) { fprintf( stderr, "target_delay (%d) cant be smaller than max_diff(%d)\n", target_delay, max_diff ); diff --git a/evmon.c b/evmon.c index 7f7b647..01b2e3a 100644 --- a/evmon.c +++ b/evmon.c @@ -1,6 +1,6 @@ /* Copyright (C) 2007 Paul Davis - + This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or @@ -27,7 +27,7 @@ #include void -port_rename_callback (jack_port_id_t port, const char* old_name, const char* new_name) +port_rename_callback (jack_port_id_t port, const char* old_name, const char* new_name, void * ptr) { printf ("Port %d renamed from %s to %s\n", port, old_name, new_name); } @@ -82,7 +82,7 @@ propchange (jack_uuid_t subject, const char* key, jack_property_change_t change) printf ("All properties changed!\n"); } else { jack_uuid_unparse (subject, buf); - + if (key) { printf ("key [%s] for %s %s\n", key, buf, action); } else { @@ -106,7 +106,7 @@ main (int argc, char *argv[]) } return 1; } - + if (jack_set_port_registration_callback (client, port_callback, NULL)) { fprintf (stderr, "cannot set port registration callback\n"); return 1; diff --git a/property.c b/property.c index 26245e2..b8b941c 100644 --- a/property.c +++ b/property.c @@ -24,8 +24,8 @@ show_usage (void) fprintf (stderr, " -d, --delete Remove/delete property \"key\" for \"UUID\"\n"); fprintf (stderr, " -d, --delete UUID Remove/delete all properties for \"UUID\"\n"); fprintf (stderr, " -D, --delete-all Remove/delete all properties\n"); - fprintf (stderr, " --client Interpret UUID as a client name, not a UUID\n"); - fprintf (stderr, " --port \tInterpret UUID as a port name, not a UUID\n"); + fprintf (stderr, " --client Interpret UUID as a client name, not a UUID\n"); + fprintf (stderr, " --port \tInterpret UUID as a port name, not a UUID\n"); fprintf (stderr, "\nDisplay options:\n"); fprintf (stderr, " -l Show all properties\n"); fprintf (stderr, " -l, --list UUID \tShow value all properties of UUID\n"); @@ -44,7 +44,7 @@ get_subject (jack_client_t* client, char* argv[], int* optind) fprintf (stderr, "cannot get UUID for client named %s\n", cstr); return -1; } - + if (jack_uuid_parse (ustr, &uuid)) { fprintf (stderr, "cannot parse client UUID as UUID\n"); return -1; @@ -61,13 +61,13 @@ get_subject (jack_client_t* client, char* argv[], int* optind) fprintf (stderr, "cannot find port name %s\n", pstr); return -1; } - + uuid = jack_port_uuid (port); subject = pstr; } else { char* str = argv[(*optind)++]; - + if (jack_uuid_parse (str, &uuid)) { fprintf (stderr, "cannot parse subject as UUID\n"); return -1; @@ -81,7 +81,7 @@ get_subject (jack_client_t* client, char* argv[], int* optind) int main (int argc, char* argv[]) { - jack_client_t* client = NULL; + jack_client_t* client = NULL; jack_options_t options = JackNoStartServer; char* key = NULL; char* value = NULL; @@ -89,7 +89,6 @@ int main (int argc, char* argv[]) int set = 1; int delete = 0; int delete_all = 0; - int list_all = 0; int c; int option_index; extern int optind; @@ -99,238 +98,237 @@ int main (int argc, char* argv[]) { "delete-all", 0, 0, 'D' }, { "list", 0, 0, 'l' }, { "all", 0, 0, 'a' }, - { "client", 0, 0, 'c' }, - { "port", 0, 0, 'p' }, + { "client", 0, 0, 'c' }, + { "port", 0, 0, 'p' }, { 0, 0, 0, 0 } }; - if (argc < 2) { - show_usage (); - exit (1); - } + if (argc < 2) { + show_usage (); + exit (1); + } while ((c = getopt_long (argc, argv, "sdDlaApc", long_options, &option_index)) >= 0) { switch (c) { case 's': - if (argc < 5) { - show_usage (); - exit (1); - } + if (argc < 5) { + show_usage (); + exit (1); + } set = 1; break; - case 'd': - if (argc < 3) { - show_usage (); - return 1; - } - set = 0; - delete = 1; - break; - - case 'D': - delete = 0; - set = 0; - delete_all = 1; - break; - - case 'l': - set = 0; - delete = 0; - delete_all = 0; - break; - - case 'a': - list_all = 1; - set = 0; - delete = 0; - delete_all = 0; - break; - - case 'p': - subject_is_port = 1; - break; - - case 'c': - subject_is_client = 1; - break; - - case '?': - default: - show_usage (); - exit (1); - } - } + case 'd': + if (argc < 3) { + show_usage (); + return 1; + } + set = 0; + delete = 1; + break; - if ((client = jack_client_open ("jack-property", options, NULL)) == 0) { - fprintf (stderr, "Cannot connect to JACK server\n"); - exit (1); - } + case 'D': + delete = 0; + set = 0; + delete_all = 1; + break; - if (delete_all) { + case 'l': + set = 0; + delete = 0; + delete_all = 0; + break; - if (jack_remove_all_properties (client) == 0) { - printf ("JACK metadata successfully delete\n"); - exit (0); - } - exit (1); - } + case 'a': + set = 0; + delete = 0; + delete_all = 0; + break; - if (delete) { + case 'p': + subject_is_port = 1; + break; - int args_left = argc - optind; + case 'c': + subject_is_client = 1; + break; - if (args_left < 1) { - show_usage (); - exit (1); - } + case '?': + default: + show_usage (); + exit (1); + } + } - /* argc == 3: delete all properties for a subject - argc == 4: delete value of key for subject - */ - - if (args_left >= 2) { - - if (get_subject (client, argv, &optind)) { - return 1; - } - - key = argv[optind++]; - - if (jack_remove_property (client, uuid, key)) { - fprintf (stderr, "\"%s\" property not removed for %s\n", key, subject); - exit (1); - } - - } else { - - if (get_subject (client, argv, &optind)) { - return 1; - } - - if (jack_remove_properties (client, uuid) < 0) { - fprintf (stderr, "cannot remove properties for UUID %s\n", subject); - exit (1); - } - } + if ((client = jack_client_open ("jack-property", options, NULL)) == 0) { + fprintf (stderr, "Cannot connect to JACK server\n"); + exit (1); + } - } else if (set) { + if (delete_all) { - int args_left = argc - optind; + if (jack_remove_all_properties (client) == 0) { + printf ("JACK metadata successfully delete\n"); + exit (0); + } + exit (1); + } - if (get_subject (client, argv, &optind)) { - return -1; - } + if (delete) { - key = argv[optind++]; - value = argv[optind++]; + int args_left = argc - optind; - if (args_left >= 3) { - type = argv[optind++]; - } else { - type = ""; - } + if (args_left < 1) { + show_usage (); + exit (1); + } - if (jack_set_property (client, uuid, key, value, type)) { - fprintf (stderr, "cannot set value for key %s of %s\n", value, subject); - exit (1); - } - - } else { + /* argc == 3: delete all properties for a subject + argc == 4: delete value of key for subject + */ - /* list properties */ - - int args_left = argc - optind; - - if (args_left >= 2) { - - /* list properties for a UUID/key pair */ - - if (get_subject (client, argv, &optind)) { - return -1; - } - - key = argv[optind++]; - - if (jack_get_property (uuid, key, &value, &type) == 0) { - printf ("%s\n", value); - free (value); - if (type) { - free (type); - } - } else { - fprintf (stderr, "Value not found for %s of %s\n", key, subject); - exit (1); - } - - } else if (args_left == 1) { - - /* list all properties for a given UUID */ - - jack_description_t description; - size_t cnt, n; - - if (get_subject (client, argv, &optind)) { - return -1; - } - - if ((cnt = jack_get_properties (uuid, &description)) < 0) { - fprintf (stderr, "could not retrieve properties for %s\n", subject); - exit (1); - } - - for (n = 0; n < cnt; ++n) { - if (description.properties[n].type) { - printf ("key: %s value: %s type: %s\n", - description.properties[n].key, - description.properties[n].data, - description.properties[n].type); - } else { - printf ("key: %s value: %s\n", - description.properties[n].key, - description.properties[n].data); - } - } - - jack_free_description (&description, 0); - - } else { - - /* list all properties */ - - jack_description_t* description; - size_t cnt; - size_t p; - size_t n; - char buf[JACK_UUID_STRING_SIZE]; - - if ((cnt = jack_get_all_properties (&description)) < 0) { - fprintf (stderr, "could not retrieve properties for %s\n", subject); - exit (1); - } - - for (n = 0; n < cnt; ++n) { - jack_uuid_unparse (description[n].subject, buf); - printf ("%s\n", buf); - for (p = 0; p < description[n].property_cnt; ++p) { - if (description[n].properties[p].type) { - printf ("key: %s value: %s type: %s\n", - description[n].properties[p].key, - description[n].properties[p].data, - description[n].properties[p].type); - } else { - printf ("key: %s value: %s\n", - description[n].properties[p].key, - description[n].properties[p].data); - } - } - jack_free_description (&description[n], 0); - } - - free (description); - } - } + if (args_left >= 2) { + if (get_subject (client, argv, &optind)) { + return 1; + } - (void) jack_client_close (client); - return 0; + key = argv[optind++]; + + if (jack_remove_property (client, uuid, key)) { + fprintf (stderr, "\"%s\" property not removed for %s\n", key, subject); + exit (1); + } + + } else { + + if (get_subject (client, argv, &optind)) { + return 1; + } + + if (jack_remove_properties (client, uuid) < 0) { + fprintf (stderr, "cannot remove properties for UUID %s\n", subject); + exit (1); + } + } + + } else if (set) { + + int args_left = argc - optind; + + if (get_subject (client, argv, &optind)) { + return -1; + } + + key = argv[optind++]; + value = argv[optind++]; + + if (args_left >= 3) { + type = argv[optind++]; + } else { + type = ""; + } + + if (jack_set_property (client, uuid, key, value, type)) { + fprintf (stderr, "cannot set value for key %s of %s\n", value, subject); + exit (1); + } + + } else { + + /* list properties */ + + int args_left = argc - optind; + + if (args_left >= 2) { + + /* list properties for a UUID/key pair */ + + if (get_subject (client, argv, &optind)) { + return -1; + } + + key = argv[optind++]; + + if (jack_get_property (uuid, key, &value, &type) == 0) { + printf ("%s\n", value); + free (value); + if (type) { + free (type); + } + } else { + fprintf (stderr, "Value not found for %s of %s\n", key, subject); + exit (1); + } + + } else if (args_left == 1) { + + /* list all properties for a given UUID */ + + jack_description_t description; + size_t cnt, n; + + if (get_subject (client, argv, &optind)) { + return -1; + } + + if ((cnt = jack_get_properties (uuid, &description)) < 0) { + fprintf (stderr, "could not retrieve properties for %s\n", subject); + exit (1); + } + + for (n = 0; n < cnt; ++n) { + if (description.properties[n].type) { + printf ("key: %s value: %s type: %s\n", + description.properties[n].key, + description.properties[n].data, + description.properties[n].type); + } else { + printf ("key: %s value: %s\n", + description.properties[n].key, + description.properties[n].data); + } + } + + jack_free_description (&description, 0); + + } else { + + /* list all properties */ + + jack_description_t* description; + size_t cnt; + size_t p; + size_t n; + char buf[JACK_UUID_STRING_SIZE]; + + if ((cnt = jack_get_all_properties (&description)) < 0) { + fprintf (stderr, "could not retrieve properties for %s\n", subject); + exit (1); + } + + for (n = 0; n < cnt; ++n) { + jack_uuid_unparse (description[n].subject, buf); + printf ("%s\n", buf); + for (p = 0; p < description[n].property_cnt; ++p) { + if (description[n].properties[p].type) { + printf ("key: %s value: %s type: %s\n", + description[n].properties[p].key, + description[n].properties[p].data, + description[n].properties[p].type); + } else { + printf ("key: %s value: %s\n", + description[n].properties[p].key, + description[n].properties[p].data); + } + } + jack_free_description (&description[n], 0); + } + + free (description); + } + } + + + (void) jack_client_close (client); + return 0; }