Style fixes; no functional changes.

git-svn-id: svn://svn.code.sf.net/p/jack-keyboard/code/trunk@9 1fa2bf75-7d80-4145-9e94-f9b4e25a1cb2
This commit is contained in:
trasz 2008-10-12 16:49:40 +00:00
parent 0f3cb64475
commit fdf976ab39

View File

@ -168,7 +168,7 @@ get_time(void)
seconds = tv.tv_sec + tv.tv_usec / 1000000.0; seconds = tv.tv_sec + tv.tv_usec / 1000000.0;
return seconds; return (seconds);
} }
double double
@ -183,7 +183,7 @@ get_delta_time(void)
if (previously == -1.0) { if (previously == -1.0) {
previously = now; previously = now;
return 0; return (0);
} }
delta = now - previously; delta = now - previously;
@ -191,7 +191,7 @@ get_delta_time(void)
assert(delta >= 0.0); assert(delta >= 0.0);
return delta; return (delta);
} }
gboolean gboolean
@ -218,7 +218,7 @@ process_received_message_async(gpointer evp)
queue_message(ev); queue_message(ev);
return FALSE; return (FALSE);
} }
struct MidiMessage * struct MidiMessage *
@ -228,7 +228,7 @@ midi_message_from_midi_event(jack_midi_event_t event)
if (ev == NULL) { if (ev == NULL) {
perror("malloc"); perror("malloc");
return NULL; return (NULL);
} }
assert(event.size >= 1 && event.size <= 3); assert(event.size >= 1 && event.size <= 3);
@ -238,7 +238,7 @@ midi_message_from_midi_event(jack_midi_event_t event)
memcpy(ev->data, event.buffer, ev->len); memcpy(ev->data, event.buffer, ev->len);
return ev; return (ev);
} }
gboolean gboolean
@ -248,7 +248,7 @@ warning_async(gpointer s)
g_warning(str); g_warning(str);
return FALSE; return (FALSE);
} }
void void
@ -313,7 +313,7 @@ nframes_to_ms(jack_nframes_t nframes)
assert(sr > 0); assert(sr > 0);
return (nframes * 1000.0) / (double)sr; return ((nframes * 1000.0) / (double)sr);
} }
void void
@ -393,9 +393,8 @@ int
process_callback(jack_nframes_t nframes, void *notused) process_callback(jack_nframes_t nframes, void *notused)
{ {
#ifdef MEASURE_TIME #ifdef MEASURE_TIME
if (get_delta_time() > MAX_TIME_BETWEEN_CALLBACKS) { if (get_delta_time() > MAX_TIME_BETWEEN_CALLBACKS)
warn_from_jack_thread_context("Had to wait too long for JACK callback; scheduling problem?"); warn_from_jack_thread_context("Had to wait too long for JACK callback; scheduling problem?");
}
#endif #endif
/* Check for impossible condition that actually happened to me, caused by some problem between jackd and OSS4. */ /* Check for impossible condition that actually happened to me, caused by some problem between jackd and OSS4. */
@ -408,12 +407,11 @@ process_callback(jack_nframes_t nframes, void *notused)
process_midi_output(nframes); process_midi_output(nframes);
#ifdef MEASURE_TIME #ifdef MEASURE_TIME
if (get_delta_time() > MAX_PROCESSING_TIME) { if (get_delta_time() > MAX_PROCESSING_TIME)
warn_from_jack_thread_context("Processing took too long; scheduling problem?"); warn_from_jack_thread_context("Processing took too long; scheduling problem?");
}
#endif #endif
return 0; return (0);
} }
void void
@ -473,7 +471,7 @@ update_connected_to_combo_async(gpointer notused)
GtkTreeIter iter; GtkTreeIter iter;
if (jack_client == NULL || output_port == NULL) if (jack_client == NULL || output_port == NULL)
return FALSE; return (FALSE);
connected = jack_port_get_connections(output_port); connected = jack_port_get_connections(output_port);
available = jack_get_ports(jack_client, NULL, JACK_DEFAULT_MIDI_TYPE, JackPortIsInput); available = jack_get_ports(jack_client, NULL, JACK_DEFAULT_MIDI_TYPE, JackPortIsInput);
@ -513,7 +511,7 @@ update_connected_to_combo_async(gpointer notused)
free(available); free(available);
return FALSE; return (FALSE);
} }
void void
@ -566,7 +564,7 @@ update_window_title_async(gpointer notused)
if (window != NULL) if (window != NULL)
draw_window_title(); draw_window_title();
return FALSE; return (FALSE);
} }
int int
@ -575,7 +573,7 @@ graph_order_callback(void *notused)
g_idle_add(update_window_title_async, NULL); g_idle_add(update_window_title_async, NULL);
g_idle_add(update_connected_to_combo_async, NULL); g_idle_add(update_connected_to_combo_async, NULL);
return 0; return (0);
} }
void void
@ -598,25 +596,25 @@ connect_to_input_port(const char *port)
int ret; int ret;
if (!strcmp(port, jack_port_name(input_port))) if (!strcmp(port, jack_port_name(input_port)))
return -1; return (-1);
if (!allow_connecting_to_own_kind) { if (!allow_connecting_to_own_kind) {
if (!strncmp(port, jack_port_name(input_port), strlen(PACKAGE_NAME))) if (!strncmp(port, jack_port_name(input_port), strlen(PACKAGE_NAME)))
return -2; return (-2);
} }
ret = jack_port_disconnect(jack_client, output_port); ret = jack_port_disconnect(jack_client, output_port);
if (ret) { if (ret) {
g_warning("Cannot disconnect MIDI port."); g_warning("Cannot disconnect MIDI port.");
return -3; return (-3);
} }
ret = jack_connect(jack_client, jack_port_name(output_port), port); ret = jack_connect(jack_client, jack_port_name(output_port), port);
if (ret) { if (ret) {
g_warning("Cannot connect to %s.", port); g_warning("Cannot connect to %s.", port);
return -4; return (-4);
} }
g_warning("Connected to %s.", port); g_warning("Connected to %s.", port);
@ -630,7 +628,7 @@ connect_to_input_port(const char *port)
send_program_change_once = 0; send_program_change_once = 0;
return 0; return (0);
} }
void void
@ -911,19 +909,16 @@ lash_callback(gpointer notused)
case LASH_Restore_Data_Set: case LASH_Restore_Data_Set:
load_config_from_lash(); load_config_from_lash();
lash_send_event(lash_client, event); lash_send_event(lash_client, event);
break; break;
case LASH_Save_Data_Set: case LASH_Save_Data_Set:
save_config_into_lash(); save_config_into_lash();
lash_send_event(lash_client, event); lash_send_event(lash_client, event);
break; break;
case LASH_Quit: case LASH_Quit:
g_warning("Exiting due to LASH request."); g_warning("Exiting due to LASH request.");
exit(EX_OK); exit(EX_OK);
break; break;
default: default:
@ -932,7 +927,7 @@ lash_callback(gpointer notused)
} }
} }
return TRUE; return (TRUE);
} }
void void
@ -965,7 +960,7 @@ sustain_event_handler(GtkToggleButton *widget, gpointer pressed)
piano_keyboard_sustain_release(keyboard); piano_keyboard_sustain_release(keyboard);
} }
return FALSE; return (FALSE);
} }
void void
@ -1031,7 +1026,7 @@ int grab_x_error_handler(Display *dpy, XErrorEvent *notused)
{ {
keyboard_grabbed = 0; keyboard_grabbed = 0;
return 42; /* Returned value is ignored. */ return (42); /* Returned value is ignored. */
} }
GdkFilterReturn GdkFilterReturn
@ -1043,7 +1038,7 @@ keyboard_grab_filter(GdkXEvent *xevent, GdkEvent *event, gpointer notused)
xe = (XEvent *)xevent; xe = (XEvent *)xevent;
if (xe->type != KeyPress && xe->type != KeyRelease) if (xe->type != KeyPress && xe->type != KeyRelease)
return GDK_FILTER_CONTINUE; return (GDK_FILTER_CONTINUE);
xke = (XKeyEvent *)xevent; xke = (XKeyEvent *)xevent;
@ -1051,7 +1046,7 @@ keyboard_grab_filter(GdkXEvent *xevent, GdkEvent *event, gpointer notused)
GDK would discard it. */ GDK would discard it. */
xke->window = GDK_WINDOW_XWINDOW(window->window); xke->window = GDK_WINDOW_XWINDOW(window->window);
return GDK_FILTER_CONTINUE; return (GDK_FILTER_CONTINUE);
} }
void void
@ -1216,73 +1211,73 @@ maybe_add_digit(GdkEventKey *event)
if (event->type == GDK_KEY_PRESS) if (event->type == GDK_KEY_PRESS)
add_digit(0); add_digit(0);
return TRUE; return (TRUE);
} }
if (event->keyval == GDK_KP_1 || event->keyval == GDK_KP_End) { if (event->keyval == GDK_KP_1 || event->keyval == GDK_KP_End) {
if (event->type == GDK_KEY_PRESS) if (event->type == GDK_KEY_PRESS)
add_digit(1); add_digit(1);
return TRUE; return (TRUE);
} }
if (event->keyval == GDK_KP_2 || event->keyval == GDK_KP_Down) { if (event->keyval == GDK_KP_2 || event->keyval == GDK_KP_Down) {
if (event->type == GDK_KEY_PRESS) if (event->type == GDK_KEY_PRESS)
add_digit(2); add_digit(2);
return TRUE; return (TRUE);
} }
if (event->keyval == GDK_KP_3 || event->keyval == GDK_KP_Page_Down) { if (event->keyval == GDK_KP_3 || event->keyval == GDK_KP_Page_Down) {
if (event->type == GDK_KEY_PRESS) if (event->type == GDK_KEY_PRESS)
add_digit(3); add_digit(3);
return TRUE; return (TRUE);
} }
if (event->keyval == GDK_KP_4 || event->keyval == GDK_KP_Left) { if (event->keyval == GDK_KP_4 || event->keyval == GDK_KP_Left) {
if (event->type == GDK_KEY_PRESS) if (event->type == GDK_KEY_PRESS)
add_digit(4); add_digit(4);
return TRUE; return (TRUE);
} }
if (event->keyval == GDK_KP_5 || event->keyval == GDK_KP_Begin) { if (event->keyval == GDK_KP_5 || event->keyval == GDK_KP_Begin) {
if (event->type == GDK_KEY_PRESS) if (event->type == GDK_KEY_PRESS)
add_digit(5); add_digit(5);
return TRUE; return (TRUE);
} }
if (event->keyval == GDK_KP_6 || event->keyval == GDK_KP_Right) { if (event->keyval == GDK_KP_6 || event->keyval == GDK_KP_Right) {
if (event->type == GDK_KEY_PRESS) if (event->type == GDK_KEY_PRESS)
add_digit(6); add_digit(6);
return TRUE; return (TRUE);
} }
if (event->keyval == GDK_KP_7 || event->keyval == GDK_KP_Home) { if (event->keyval == GDK_KP_7 || event->keyval == GDK_KP_Home) {
if (event->type == GDK_KEY_PRESS) if (event->type == GDK_KEY_PRESS)
add_digit(7); add_digit(7);
return TRUE; return (TRUE);
} }
if (event->keyval == GDK_KP_8 || event->keyval == GDK_KP_Up) { if (event->keyval == GDK_KP_8 || event->keyval == GDK_KP_Up) {
if (event->type == GDK_KEY_PRESS) if (event->type == GDK_KEY_PRESS)
add_digit(8); add_digit(8);
return TRUE; return (TRUE);
} }
if (event->keyval == GDK_KP_9 || event->keyval == GDK_KP_Page_Up) { if (event->keyval == GDK_KP_9 || event->keyval == GDK_KP_Page_Up) {
if (event->type == GDK_KEY_PRESS) if (event->type == GDK_KEY_PRESS)
add_digit(9); add_digit(9);
return TRUE; return (TRUE);
} }
return FALSE; return (FALSE);
} }
int int
@ -1294,7 +1289,7 @@ get_entered_number(void)
entered_number = -1; entered_number = -1;
return tmp; return (tmp);
} }
int int
@ -1306,7 +1301,7 @@ clip(int val, int lo, int hi)
if (val > hi) if (val > hi)
val = hi; val = hi;
return val; return (val);
} }
gint gint
@ -1322,11 +1317,11 @@ keyboard_event_handler(GtkWidget *widget, GdkEventKey *event, gpointer notused)
g_signal_emit_by_name(keyboard, "key-release-event", event, &retval); g_signal_emit_by_name(keyboard, "key-release-event", event, &retval);
if (retval) if (retval)
return TRUE; return (TRUE);
if (maybe_add_digit(event)) if (maybe_add_digit(event))
return TRUE; return (TRUE);
/* /*
* '+' key shifts octave up. '-' key shifts octave down. * '+' key shifts octave up. '-' key shifts octave down.
@ -1335,14 +1330,14 @@ keyboard_event_handler(GtkWidget *widget, GdkEventKey *event, gpointer notused)
if (event->type == GDK_KEY_PRESS && octave < OCTAVE_MAX) if (event->type == GDK_KEY_PRESS && octave < OCTAVE_MAX)
gtk_spin_button_set_value(GTK_SPIN_BUTTON(octave_spin), octave + 1); gtk_spin_button_set_value(GTK_SPIN_BUTTON(octave_spin), octave + 1);
return TRUE; return (TRUE);
} }
if (event->keyval == GDK_KP_Subtract || event->keyval == GDK_minus) { if (event->keyval == GDK_KP_Subtract || event->keyval == GDK_minus) {
if (event->type == GDK_KEY_PRESS && octave > OCTAVE_MIN) if (event->type == GDK_KEY_PRESS && octave > OCTAVE_MIN)
gtk_spin_button_set_value(GTK_SPIN_BUTTON(octave_spin), octave - 1); gtk_spin_button_set_value(GTK_SPIN_BUTTON(octave_spin), octave - 1);
return TRUE; return (TRUE);
} }
/* /*
@ -1359,7 +1354,7 @@ keyboard_event_handler(GtkWidget *widget, GdkEventKey *event, gpointer notused)
gtk_spin_button_set_value(GTK_SPIN_BUTTON(program_spin), clip(tmp, PROGRAM_MIN, PROGRAM_MAX)); gtk_spin_button_set_value(GTK_SPIN_BUTTON(program_spin), clip(tmp, PROGRAM_MIN, PROGRAM_MAX));
} }
return TRUE; return (TRUE);
} }
if (event->keyval == GDK_KP_Divide) { if (event->keyval == GDK_KP_Divide) {
@ -1373,7 +1368,7 @@ keyboard_event_handler(GtkWidget *widget, GdkEventKey *event, gpointer notused)
gtk_spin_button_set_value(GTK_SPIN_BUTTON(program_spin), clip(tmp, PROGRAM_MIN, PROGRAM_MAX)); gtk_spin_button_set_value(GTK_SPIN_BUTTON(program_spin), clip(tmp, PROGRAM_MIN, PROGRAM_MAX));
} }
return TRUE; return (TRUE);
} }
/* /*
@ -1390,7 +1385,7 @@ keyboard_event_handler(GtkWidget *widget, GdkEventKey *event, gpointer notused)
gtk_spin_button_set_value(GTK_SPIN_BUTTON(bank_spin), clip(tmp, BANK_MIN, BANK_MAX)); gtk_spin_button_set_value(GTK_SPIN_BUTTON(bank_spin), clip(tmp, BANK_MIN, BANK_MAX));
} }
return TRUE; return (TRUE);
} }
if (event->keyval == GDK_Page_Down) { if (event->keyval == GDK_Page_Down) {
@ -1404,7 +1399,7 @@ keyboard_event_handler(GtkWidget *widget, GdkEventKey *event, gpointer notused)
gtk_spin_button_set_value(GTK_SPIN_BUTTON(bank_spin), clip(tmp, BANK_MIN, BANK_MAX)); gtk_spin_button_set_value(GTK_SPIN_BUTTON(bank_spin), clip(tmp, BANK_MIN, BANK_MAX));
} }
return TRUE; return (TRUE);
} }
/* /*
@ -1421,7 +1416,7 @@ keyboard_event_handler(GtkWidget *widget, GdkEventKey *event, gpointer notused)
gtk_spin_button_set_value(GTK_SPIN_BUTTON(channel_spin), clip(tmp, CHANNEL_MIN, CHANNEL_MAX)); gtk_spin_button_set_value(GTK_SPIN_BUTTON(channel_spin), clip(tmp, CHANNEL_MIN, CHANNEL_MAX));
} }
return TRUE; return (TRUE);
} }
if (event->keyval == GDK_End) { if (event->keyval == GDK_End) {
@ -1435,7 +1430,7 @@ keyboard_event_handler(GtkWidget *widget, GdkEventKey *event, gpointer notused)
gtk_spin_button_set_value(GTK_SPIN_BUTTON(channel_spin), clip(tmp, CHANNEL_MIN, CHANNEL_MAX)); gtk_spin_button_set_value(GTK_SPIN_BUTTON(channel_spin), clip(tmp, CHANNEL_MIN, CHANNEL_MAX));
} }
return TRUE; return (TRUE);
} }
/* /*
@ -1445,21 +1440,21 @@ keyboard_event_handler(GtkWidget *widget, GdkEventKey *event, gpointer notused)
if (event->type == GDK_KEY_PRESS) if (event->type == GDK_KEY_PRESS)
connect_to_next_input_port(); connect_to_next_input_port();
return TRUE; return (TRUE);
} }
if (event->keyval == GDK_Delete) { if (event->keyval == GDK_Delete) {
if (event->type == GDK_KEY_PRESS) if (event->type == GDK_KEY_PRESS)
connect_to_prev_input_port(); connect_to_prev_input_port();
return TRUE; return (TRUE);
} }
if (event->keyval == GDK_Escape) { if (event->keyval == GDK_Escape) {
if (event->type == GDK_KEY_PRESS) if (event->type == GDK_KEY_PRESS)
panic(); panic();
return TRUE; return (TRUE);
} }
/* /*
@ -1475,7 +1470,7 @@ keyboard_event_handler(GtkWidget *widget, GdkEventKey *event, gpointer notused)
else else
gtk_button_released(GTK_BUTTON(sustain_button)); gtk_button_released(GTK_BUTTON(sustain_button));
return TRUE; return (TRUE);
} }
/* /*
@ -1490,7 +1485,7 @@ keyboard_event_handler(GtkWidget *widget, GdkEventKey *event, gpointer notused)
gtk_range_set_value(GTK_RANGE(velocity_hscale), *current_velocity); gtk_range_set_value(GTK_RANGE(velocity_hscale), *current_velocity);
return TRUE; return (TRUE);
} }
@ -1502,10 +1497,10 @@ keyboard_event_handler(GtkWidget *widget, GdkEventKey *event, gpointer notused)
gtk_range_set_value(GTK_RANGE(velocity_hscale), *current_velocity); gtk_range_set_value(GTK_RANGE(velocity_hscale), *current_velocity);
return TRUE; return (TRUE);
} }
return FALSE; return (FALSE);
} }
void void
@ -1544,7 +1539,7 @@ init_gtk_1(int *argc, char ***argv)
/* Window. */ /* Window. */
window = gtk_window_new(GTK_WINDOW_TOPLEVEL); window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_container_set_border_width (GTK_CONTAINER (window), 2); gtk_container_set_border_width(GTK_CONTAINER(window), 2);
} }
void void
@ -1860,6 +1855,6 @@ main(int argc, char *argv[])
gtk_main(); gtk_main();
return 0; return (0);
} }