More logging changes.

This commit is contained in:
Tim LaBerge
2012-03-31 18:48:22 -07:00
parent 5c42cad5e7
commit 122bbcd823
6 changed files with 193 additions and 69 deletions

View File

@@ -709,8 +709,8 @@ static EffectValues values_rp_mix = {
};
static EffectSettings usb_settings[] = {
{"USB/RP Mix", USB_AUDIO_PLAYBACK_MIX, USB_POSITION, &values_rp_mix},
{"USB Level", USB_AUDIO_LEVEL, USB_POSITION, &values_m12_to_24},
{"USB/RP Mix", USB_AUDIO_PLAYBACK_MIX, GLOBAL_POSITION, &values_rp_mix},
{"USB Level", USB_AUDIO_LEVEL, GLOBAL_POSITION, &values_m12_to_24},
};
static EffectSettings misc_settings[] = {
@@ -4119,7 +4119,10 @@ ModifierGroup *modifier_linkable_list()
modifier_group->type = EXP_TYPE;
modifier_group->position = EXP_POSITION;
g_message("Group %d count %d", group_id, count);
debug_msg(DEBUG_MSG2HOST|DEBUG_GROUP,
"RECEIVE_MODIFIER_LINKABLE_LIST: Group %d count %d",
group_id, count);
EffectGroup *group = g_slice_alloc(count * sizeof(EffectGroup));
for (i=0; i<count; i++) {
@@ -4141,7 +4144,9 @@ ModifierGroup *modifier_linkable_list()
if (group[i].settings == NULL)
group[i].settings_amt = 0;
g_message("ID: %4d Position: %2d Label: %s", id, position, modifier ? modifier->label : NULL);
debug_msg(DEBUG_MSG2HOST|DEBUG_GROUP,
"ID: %4d Position: %2d Label: %s",
id, position, modifier ? modifier->label : NULL);
}
modifier_group->group = group;

130
gdigi.c
View File

@@ -35,6 +35,63 @@ static GQueue *message_queue = NULL;
static GMutex *message_queue_mutex = NULL;
static GCond *message_queue_cond = NULL;
static guint DebugFlags;
gboolean
debug_flag_is_set (debug_flags_t flags)
{
if (DebugFlags & flags) {
return TRUE;
}
return FALSE;
}
gboolean set_debug_flags (const gchar *option_name, const gchar *value,
gpointer data, GError **error)
{
if (strchr(value, 'd')) {
DebugFlags |= DEBUG_MSG2DEV;
}
if (strchr(value, 'h')) {
DebugFlags |= DEBUG_MSG2HOST;
}
if (strchr(value, 's')) {
DebugFlags |= DEBUG_STARTUP;
}
if (strchr(value, 'H')) {
DebugFlags |= DEBUG_HEX;
}
if (strchr(value, 'g')) {
DebugFlags |= DEBUG_GROUP;
}
if (strchr(value, 'x')) {
DebugFlags |= DEBUG_XML;
}
if (strchr(value, 'v')) {
DebugFlags |= DEBUG_VERBOSE;
}
if (strchr(value, 'a')) {
DebugFlags = -1;
}
return TRUE;
}
void
debug_msg (debug_flags_t flags, char *fmt, ...)
{
char buf[1024];
if (flags & DebugFlags) {
va_list ap;
va_start(ap, fmt);
vsnprintf(buf, 1024, fmt, ap);
va_end(ap);
g_message("%s", buf);
}
}
/**
* Registers an error quark for gdigi if necessary.
*
@@ -225,11 +282,12 @@ void push_message(GString *msg)
{
MessageID msgid = get_message_id(msg);
if (((unsigned char)msg->str[0] == 0xF0) && ((unsigned char)msg->str[msg->len-1] == 0xF7))
g_message("Pushing correct message!");
debug_msg(DEBUG_VERBOSE, "Pushing correct message!");
else
g_warning("Pushing incorrect message!");
int x;
if (debug_flag_is_set(DEBUG_HEX)) {
for (x = 0; x<msg->len; x++) {
if (x && (x % 26) == 0) {
printf("\n");
@@ -239,7 +297,8 @@ void push_message(GString *msg)
if (x % 26) {
printf("\n");
}
g_message("Received %s", get_message_name(msgid));
}
debug_msg(DEBUG_VERBOSE, "Received %s", get_message_name(msgid));
SettingParam *param;
switch (msgid) {
@@ -248,6 +307,7 @@ void push_message(GString *msg)
return;
case NACK:
g_warning("Received NACK!");
g_string_free(msg, TRUE);
return;
@@ -257,7 +317,11 @@ void push_message(GString *msg)
param = setting_param_new_from_data(&msg->str[8], NULL);
XmlSettings *xml = get_xml_settings(param->id, param->position);
char *label = xml ? xml->label : "NULL";
g_message("ID: %5d Position: %2d Value: %.1d: %s", param->id, param->position, param->value, label);
debug_msg(DEBUG_MSG2HOST,
"RECEIVE_PARAMETER_VALUE: ID: %5d Position: %2d "
"Value: %6.1d: %s",
param->id, param->position,
param->value, label);
GDK_THREADS_ENTER();
apply_setting_param_to_gui(param);
@@ -274,28 +338,40 @@ void push_message(GString *msg)
switch (str[8]) {
case NOTIFY_PRESET_MOVED:
if (str[11] == PRESETS_EDIT_BUFFER && str[12] == 0) {
g_message("Loaded preset %d from bank %d", str[10], str[9]);
GDK_THREADS_ENTER();
g_timeout_add(0, apply_current_preset_to_gui, NULL);
GDK_THREADS_LEAVE();
debug_msg(DEBUG_MSG2HOST,
"RECEIVE_DEVICE_NOTIFICATION: Loaded preset "
"%d from bank %d",
str[10], str[9]);
} else {
g_message("%d %d moved to %d %d", str[9], str[10], str[11], str[12]);
debug_msg(DEBUG_MSG2HOST,
"RECEIVE_DEVICE_NOTIFICATION: %d %d moved to "
"%d %d",
str[9], str[10],
str[11], str[12]);
}
case NOTIFY_MODIFIER_GROUP_CHANGED:
{
int i;
if (debug_flag_is_set(DEBUG_HEX)) {
printf("\n");
for (i = 0; i < msg->len; i++) {
printf(" %02x", (unsigned char) str[i]);
}
printf("\n");
g_message("Modifier group id %d changed",
}
debug_msg(DEBUG_MSG2HOST,
"NOTIFY_MODIFIER_GROUP_CHANGED: Modifier group "
"id %d changed",
(str[9] << 8) | (str[10]));
break;
}
default:
g_message("Received unhandled device notification 0x%x", str[11]);
g_warning("Received unhandled device notification 0x%x",
str[11]);
}
g_string_free(msg, TRUE);
return;
@@ -303,17 +379,22 @@ void push_message(GString *msg)
unpack_message(msg);
gint tot, n, x;
tot = (unsigned char)msg->str[9];
if (debug_flag_is_set(DEBUG_HEX)) {
for (n = 0; n < msg->len; n++) {
printf("%02x ",(unsigned char) msg->str[n]);
}
printf("\n");
}
n = 0;
x = 10;
do {
param = setting_param_new_from_data(&msg->str[x], &x);
g_message("Received global param ID: %5d Position: %2.1d Value: %6.1d: %s",
param->id, param->position, param->value);
debug_msg(DEBUG_MSG2HOST,
"RECEIVE_GLOBAL_PARAMETERS ID: %5d "
"Position: %2.1d Value: %6.1d: %s",
param->id,
param->position, param->value, "XXX");
setting_param_free(param);
} while ( (x < msg->len) && n < tot);
@@ -324,10 +405,13 @@ void push_message(GString *msg)
case RECEIVE_MODIFIER_LINKABLE_LIST:
unpack_message(msg);
tot = (unsigned char)msg->str[9];
if (debug_flag_is_set(DEBUG_HEX)) {
for (n = 0; n < msg->len; n++) {
printf("%02x ",(unsigned char) msg->str[n]);
}
printf("\n");
}
modifier_linkable_list(msg);
@@ -461,7 +545,8 @@ void send_message(gint procedure, gchar *data, gint len)
g_string_append_printf(msg, "%c\xF7",
calculate_checksum(&msg->str[1], msg->len - 1));
g_message("Sending message %s len %d", get_message_name(procedure), len);
debug_msg(DEBUG_VERBOSE, "Sending message %s len %d",
get_message_name(procedure), len);
send_data(msg->str, msg->len);
g_string_free(msg, TRUE);
@@ -682,7 +767,7 @@ SectionID get_genetx_section_id(gint version, gint type)
}
}
g_message("This version of gdigi don't know what to do with this "
g_warning("This version of gdigi don't know what to do with this "
"GeNetX version (%d) and type (%d)", version, type);
return -1;
@@ -698,7 +783,8 @@ SectionID get_genetx_section_id(gint version, gint type)
void get_option(guint id, guint position)
{
GString *msg = g_string_sized_new(9);
g_message("Requesting parameter id %d position %d", id, position);
debug_msg(DEBUG_MSG2DEV, "REQUEST_PARAMETER_VALUE: id %d position %d",
id, position);
g_string_append_printf(msg, "%c%c%c",
((id & 0xFF00) >> 8), (id & 0xFF),
position);
@@ -719,7 +805,8 @@ void set_option(guint id, guint position, guint value)
((id & 0xFF00) >> 8), (id & 0xFF),
position);
append_value(msg, value);
g_message("Sending id %d position %d value %d", id, position, value);
debug_msg(DEBUG_MSG2DEV, "Sending id %d position %d value %d",
id, position, value);
send_message(RECEIVE_PARAMETER_VALUE, msg->str, msg->len);
g_string_free(msg, TRUE);
}
@@ -930,7 +1017,7 @@ GList *get_message_list(MessageID id)
}
while (amt) {
g_message("%d messages left", amt);
debug_msg(DEBUG_VERBOSE, "%d messages left", amt);
data = g_queue_pop_nth(message_queue, x);
if (data == NULL) {
g_cond_wait(message_queue_cond, message_queue_mutex);
@@ -1185,6 +1272,9 @@ static void request_device_configuration()
static GOptionEntry options[] = {
{"device", 'd', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_STRING, &device_port, "MIDI device port to use", NULL},
{"debug-flags", 'D', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_CALLBACK, set_debug_flags,
"Set debug flags: any combination of a, d, h, s:\n",
NULL},
{NULL}
};
@@ -1229,7 +1319,7 @@ int main(int argc, char *argv[]) {
g_option_context_add_group(context, gtk_get_option_group(TRUE));
if (!g_option_context_parse(context, &argc, &argv, &error)) {
g_message("option parsing failed: %s\n", error->message);
g_warning("option parsing failed: %s\n", error->message);
g_error_free(error);
g_option_context_free(context);
exit(EXIT_FAILURE);
@@ -1256,9 +1346,9 @@ int main(int argc, char *argv[]) {
device_port = g_strdup_printf("hw:%d,0,0",
GPOINTER_TO_INT(device->data));
g_list_free(devices);
g_message("Found device %s", device_port);
debug_msg(DEBUG_STARTUP, "Found device %s\n", device_port);
} else {
g_message("Using device %s", device_port);
debug_msg(DEBUG_STARTUP, "Using device %s\n", device_port);
}
g_option_context_free(context);
@@ -1286,14 +1376,14 @@ int main(int argc, char *argv[]) {
if (device != NULL) {
/* enable GUI mode */
set_option(GUI_MODE_ON_OFF, USB_POSITION, 1);
set_option(GUI_MODE_ON_OFF, GLOBAL_POSITION, 1);
gui_create(device);
gtk_main();
gui_free();
/* disable GUI mode */
set_option(GUI_MODE_ON_OFF, USB_POSITION, 0);
set_option(GUI_MODE_ON_OFF, GLOBAL_POSITION, 0);
}
}
}
@@ -1308,7 +1398,7 @@ int main(int argc, char *argv[]) {
}
if (message_queue != NULL) {
g_message("%d unread messages in queue",
g_warning("%d unread messages in queue",
g_queue_get_length(message_queue));
g_queue_foreach(message_queue, (GFunc) message_free_func, NULL);
g_queue_free(message_queue);

26
gdigi.h
View File

@@ -22,6 +22,19 @@
#ifndef DOXYGEN_SHOULD_SKIP_THIS
typedef enum {
DEBUG_MSG2DEV = (1 << 0), // Device bound messages.
DEBUG_MSG2HOST = (1 << 1), // Host bound messages.
DEBUG_STARTUP = (1 << 2),
DEBUG_GROUP = (1 << 3), // Modifier group
DEBUG_HEX = (1 << 4), // Dump message contents in hex.
DEBUG_XML = (1 << 5),
DEBUG_VERBOSE = (1 << 6),
} debug_flags_t;
void debug_msg (debug_flags_t, char *fmt, ...);
gboolean debug_flag_is_set (debug_flags_t flag);
#define GNX_CHANNEL_POSITION 7
#define GNX_CHANNEL_AMP 260
#define GNX_WARP 261
@@ -885,7 +898,10 @@ enum {
#define TONE_LIB_TYPE 8704
#define FX_LIB_TYPE 8705
#define FX_LIB_LEVEL 8706
#define FX_LIB_LEVEL 8706 // This influences pitch shift mix, delay level,
// and reverb level, in proportion, as
// specified by FX_LIB_LEVEL_MAX1,2,3.
//
#define FX_LIB_LEVEL_MAX1 8708
#define FX_LIB_LEVEL_MAX2 8710
#define FX_LIB_LEVEL_MAX3 8712
@@ -962,12 +978,18 @@ enum {
EFFECTS_LIB_CUSTOM = 1856
};
#define USB_POSITION 0
#define GLOBAL_POSITION 0
#define TUNING_REFERENCE 12288
#define USB_AUDIO_PLAYBACK_MIX 12297
#define USB_AUDIO_LEVEL 12307
#define GUI_MODE_ON_OFF 12298
#define EXP_PEDAL_LEVEL 12300
#define STOMP_MODE 12370
#endif /* DOXYGEN_SHOULD_SKIP_THIS */
typedef enum {

12
gui.c
View File

@@ -249,7 +249,7 @@ static gboolean custom_value_output_cb(GtkSpinButton *spin, EffectValues *values
if (values->type & VALUE_TYPE_EXTRA) {
values = values->extra;
} else {
g_message("custom_value_output_cb called with out of bounds value");
g_warning("custom_value_output_cb called with out of bounds value");
return FALSE;
}
}
@@ -993,7 +993,7 @@ static void action_open_preset_cb(GtkAction *action)
for (x=0; x<n_file_types; x++) {
GtkFileFilter *current_filter = gtk_file_filter_new();
if (file_types[x].name == NULL) {
g_message("Skipping NULL array entry");
g_warning("Skipping NULL array entry");
continue;
}
@@ -1255,7 +1255,7 @@ static void add_menubar(GtkWidget *window, GtkWidget *vbox)
gtk_window_add_accel_group(GTK_WINDOW(window), gtk_ui_manager_get_accel_group(ui));
if (!gtk_ui_manager_add_ui_from_string(ui, menu_info, -1, &error)) {
g_message("building menus failed: %s", error->message);
g_warning("building menus failed: %s", error->message);
g_error_free(error);
error = NULL;
}
@@ -1353,9 +1353,6 @@ void gui_create(Device *device)
g_signal_connect(G_OBJECT(window), "delete_event", G_CALLBACK(gtk_main_quit), NULL);
/* Not part of the preset, but update from the device. */
get_option(USB_AUDIO_LEVEL, USB_POSITION);
get_option(USB_AUDIO_PLAYBACK_MIX, USB_POSITION);
}
/**
@@ -1414,7 +1411,8 @@ gboolean unsupported_device_dialog(Device **device)
if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) {
gint number = gtk_combo_box_get_active(GTK_COMBO_BOX(combo_box));
if (number != -1 && number <n_supported_devices) {
g_message("Starting %s compability mode", supported_devices[number]->name);
g_message("Starting %s compability mode",
supported_devices[number]->name);
*device = supported_devices[number];
gtk_widget_destroy(dialog);
return TRUE;

View File

@@ -69,7 +69,7 @@ static void XMLCALL start(void *data, const char *el, const char **attr) {
if (g_strcmp0(el, "Params") == 0) {
ad->section = SECTION_PARAMS;
if (ad->preset->params != NULL)
g_message("Params aleady exists!");
g_warning("Params aleady exists!");
} else if (g_strcmp0(el, "Param") == 0) {
SettingParam *param = setting_param_new();
ad->preset->params = g_list_prepend(ad->preset->params, param);
@@ -84,7 +84,7 @@ static void XMLCALL start(void *data, const char *el, const char **attr) {
} else if (g_strcmp0(el, "Genetx") == 0) {
ad->section = SECTION_GENETX;
if (ad->preset->genetxs != NULL)
g_message("Genetx already exists!");
g_warning("Genetx already exists!");
} else if (g_strcmp0(el, "GenetxModel") == 0) {
SettingGenetx *genetx = setting_genetx_new();
ad->preset->genetxs = g_list_prepend(ad->preset->genetxs, genetx);
@@ -160,7 +160,7 @@ static void XMLCALL text_cb(void *data, const char* text, int len)
} else if (g_strcmp0(value, "Version2") == 0) {
genetx->version = GENETX_VERSION_2;
} else {
g_message("Unknown GeNetX version: %s", value);
g_warning("Unknown GeNetX version: %s", value);
}
break;
case PARSER_TYPE_GENETX_TYPE:
@@ -169,7 +169,7 @@ static void XMLCALL text_cb(void *data, const char* text, int len)
} else if (g_strcmp0(value, "Cabinet") == 0) {
genetx->type = GENETX_TYPE_CABINET;
} else {
g_message("Unknown GeNetX type: %s", value);
g_warning("Unknown GeNetX type: %s", value);
}
break;
case PARSER_TYPE_GENETX_CHANNEL:
@@ -178,7 +178,7 @@ static void XMLCALL text_cb(void *data, const char* text, int len)
} else if (g_strcmp0(value, "Channel2") == 0) {
genetx->channel = GENETX_CHANNEL2;
} else {
g_message("Unknown GeNetX channel: %s", value);
g_warning("Unknown GeNetX channel: %s", value);
}
break;
case PARSER_TYPE_GENETX_NAME:
@@ -219,7 +219,7 @@ Preset *create_preset_from_xml_file(gchar *filename, GError **error)
gchar *contents;
if (g_file_get_contents(filename, &contents, NULL, &err) == FALSE) {
g_message("Failed to get %s contents: %s", filename, err->message);
g_warning("Failed to get %s contents: %s", filename, err->message);
*error = g_error_copy(err);
g_error_free(err);
return NULL;
@@ -308,12 +308,16 @@ Preset *create_preset_from_data(GList *list)
modified = (unsigned char)data->str[11+strlen(name)];
if ((bank == PRESETS_EDIT_BUFFER) && (number == 0)) {
g_message("Received current edit buffer");
debug_msg(DEBUG_MSG2HOST,
"RECEIVE_PRESET_START: current edit buffer");
} else {
g_message("Received preset %d from bank %d", number, bank);
debug_msg(DEBUG_MSG2HOST,
"RECEIVE_PRESET_START: preset %d from bank %d",
number, bank);
}
g_message("Modified flag: %d Name: %s", modified, name);
debug_msg(DEBUG_MSG2HOST, "Name: %s, %sodified",
name, modified ? "M" : "Not m");
preset->name = name;
break;
case RECEIVE_PRESET_PARAMETERS:
@@ -326,16 +330,19 @@ Preset *create_preset_from_data(GList *list)
SettingParam *param = setting_param_new_from_data(&data->str[x], &x);
n++;
preset->params = g_list_prepend(preset->params, param);
g_message("%3d ID %4d Position %2d Value %6.1d",
n, param->id, param->position, param->value);
debug_msg(DEBUG_MSG2HOST, "%3d ID %4d Position %2d "
"Value %6.1d",
n, param->id, param->position,
param->value);
} while ((x < data->len) && n<total);
g_message("TOTAL %d", total);
debug_msg(DEBUG_MSG2HOST, "TOTAL %d", total);
preset->params = g_list_sort(preset->params, params_cmp);
break;
case RECEIVE_PRESET_END:
break;
default:
g_message("Unhandled message in preset messages list");
g_warning("Unhandled message 0x%x in preset messages list",
get_message_id(data));
}
}

View File

@@ -57,11 +57,12 @@ map_xml_value(XmlSettings *xml, gint value)
switch (xml->values->type) {
case VALUE_TYPE_LABEL:
if ((xml->values == &values_on_off) && (value > 1)) {
g_message("Skipping modifier->label %s\n", xml->label);
g_warning("Skipping modifier->label %s\n", xml->label);
return NULL;
}
if (value > xml->values->max || value < xml->values->min) {
g_message("%s value %d out of range %0.1f %0.1f", xml->label, value, xml->values->min, xml->values->max);
g_warning("%s value %d out of range %0.1f %0.1f",
xml->label, value, xml->values->min, xml->values->max);
}
{
XmlLabel *labels = xml->xml_labels;
@@ -144,7 +145,7 @@ write_preset_to_xml(Preset *preset, gchar *filename)
SettingParam *param = (SettingParam *) iter_params->data;
if (param->id == last_id && param->position == last_position) {
g_message("Skipping duplicate parameter id %d position %d",
g_warning("Skipping duplicate parameter id %d position %d",
last_id, last_position);
iter_params = iter_params->next;
continue;
@@ -208,8 +209,9 @@ write_preset_to_xml(Preset *preset, gchar *filename)
{
char *textp = map_xml_value(xml, param->value);
if (!textp) {
g_message("Unable to map %s value %d for id %d position %d",
xml->label, param->value, param->id, param->position);
g_warning("Unable to map %s value %d for id %d position %d",
xml->label, param->value, param->id,
param->position);
textp = "";
}
rc = xmlTextWriterWriteElement(writer, BAD_CAST "Text",
@@ -237,7 +239,7 @@ write_preset_to_xml(Preset *preset, gchar *filename)
break;
default:
g_message("Unhandled value type %d", type);
g_warning("Unhandled value type %d", type);
break;
}
}