Hello community, here is the log from the commit of package aseqview checked in at Thu Mar 29 18:16:34 CEST 2007. -------- --- aseqview/aseqview.changes 2007-03-26 16:31:43.000000000 +0200 +++ /mounts/work_src_done/STABLE/aseqview/aseqview.changes 2007-03-29 16:49:24.000000000 +0200 @@ -1,0 +2,5 @@ +Thu Mar 29 16:49:16 CEST 2007 - tiwai@suse.de + +- fix races in thread mode + +------------------------------------------------------------------- Old: ---- aseqview-0.2.4.tar.bz2 New: ---- aseqview-0.2.5.tar.bz2 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ aseqview.spec ++++++ --- /var/tmp/diff_new_pack.S28417/_old 2007-03-29 18:16:11.000000000 +0200 +++ /var/tmp/diff_new_pack.S28417/_new 2007-03-29 18:16:11.000000000 +0200 @@ -1,5 +1,5 @@ # -# spec file for package aseqview (Version 0.2.4) +# spec file for package aseqview (Version 0.2.5) # # Copyright (c) 2007 SUSE LINUX Products GmbH, Nuernberg, Germany. # This file and all modifications and additions to the pristine @@ -13,7 +13,7 @@ Name: aseqview BuildRequires: alsa-devel gtk2-devel update-desktop-files Summary: ALSA Sequencer Event Viewer -Version: 0.2.4 +Version: 0.2.5 Release: 1 License: GNU General Public License (GPL) Group: Productivity/Multimedia/Sound/Midi @@ -68,6 +68,8 @@ %{_datadir}/pixmaps/*.png %changelog +* Thu Mar 29 2007 - tiwai@suse.de +- fix races in thread mode * Mon Mar 26 2007 - tiwai@suse.de - updated to version 0.2.4: * Added MIDI Tunig Standard (MTS) feature ++++++ aseqview-0.2.4.tar.bz2 -> aseqview-0.2.5.tar.bz2 ++++++ diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/aseqview-0.2.4/aseqview.c new/aseqview-0.2.5/aseqview.c --- old/aseqview-0.2.4/aseqview.c 2007-03-26 14:42:40.000000000 +0200 +++ new/aseqview-0.2.5/aseqview.c 2007-03-29 16:28:20.000000000 +0200 @@ -115,6 +115,7 @@ UPDATE_STATUS, NOTE_ON, NOTE_OFF, + PIANO_RESET, UPDATE_PGM, UPDATE_MODE, UPDATE_TEMPER_KEYSIG, @@ -167,12 +168,13 @@ static void parse_sysex(port_status_t *, int, unsigned char *, int); static int get_channel(unsigned char); static void visualize_temper_type(midi_status_t *, int); -static void reset_all(midi_status_t *); +static void reset_all(midi_status_t *, int); static void send_resets(channel_status_t *); static int is_redirect(port_status_t *); static void set_vel_bar_color(GtkWidget *, int, int); static void av_channel_update(GtkWidget *, int, int); static void av_note_update(GtkWidget *, int, int, int); +static void av_piano_reset(GtkWidget *, int); static void av_program_update(GtkWidget *, char *, int); static void display_midi_mode(GtkWidget *, int); static void display_temper_keysig(GtkWidget *, int); @@ -277,22 +279,23 @@ port_add_callback(port->port, PORT_MIDI_EVENT_CB, (port_callback_t) process_event, port); } - if (use_thread) { + if (use_thread) av_ringbuf_init(); - pthread_create(&midi_thread, NULL, midi_loop, st); - gtk_idle_add(idle_cb, st); - } else { - gdk_input_add(get_file_desc(st), GDK_INPUT_READ, handle_input, st); - if (rt_prio) - set_realtime_priority(SCHED_FIFO); - } /* explicit subscription to ports */ if (src_client >= 0 && src_client != SND_SEQ_ADDRESS_SUBSCRIBERS) port_connect_from(st->ports[0].port, src_client, src_port); if (do_output && dest_client >= 0 && dest_client != SND_SEQ_ADDRESS_SUBSCRIBERS) { port_connect_to(st->ports[0].port, dest_client, dest_port); - reset_all(st); + reset_all(st, 0); + } + if (use_thread) { + pthread_create(&midi_thread, NULL, midi_loop, st); + gtk_idle_add(idle_cb, st); + } else { + gdk_input_add(get_file_desc(st), GDK_INPUT_READ, handle_input, st); + if (rt_prio) + set_realtime_priority(SCHED_FIFO); } gtk_main(); if (use_thread) { @@ -361,7 +364,7 @@ #else mode = (do_output) ? SND_SEQ_OPEN : SND_SEQ_OPEN_IN; #endif - st->client = port_client_new("MIDI Viewer", mode); + st->client = port_client_new("MIDI Viewer", mode, use_thread); caps = SND_SEQ_PORT_CAP_WRITE | SND_SEQ_PORT_CAP_SUBS_WRITE; if (do_output) caps |= SND_SEQ_PORT_CAP_READ | SND_SEQ_PORT_CAP_SUBS_READ; @@ -920,7 +923,7 @@ int type, snd_seq_event_t *ev, port_status_t *port) { if (port_num_subscription(p, SND_SEQ_QUERY_SUBS_READ) == 1) - reset_all(port->main); + reset_all(port->main, use_thread); return 0; } @@ -932,7 +935,7 @@ int type, snd_seq_event_t *ev, port_status_t *port) { if (port_num_subscription(p, SND_SEQ_QUERY_SUBS_WRITE) == 0) - reset_all(port->main); + reset_all(port->main, use_thread); return 0; } @@ -1271,7 +1274,7 @@ /* * reset all stuff */ -static void reset_all(midi_status_t *st) +static void reset_all(midi_status_t *st, int in_buf) { int p, i, j; port_status_t *port; @@ -1284,15 +1287,14 @@ chst = &port->ch[i]; all_sounds_off(chst, 0); chst->is_drum = (i == 9) ? 1 : 0; - set_vel_bar_color(chst->w_vel, chst->is_drum, 0); - change_program(port, i, 0, 0); - reset_controllers(chst, 0); - change_pitch(port, i, 0, 0); + set_vel_bar_color(chst->w_vel, chst->is_drum, in_buf); + change_program(port, i, 0, in_buf); + reset_controllers(chst, in_buf); + change_pitch(port, i, 0, in_buf); chst->temper_type = 0; - display_temper_type(chst->w_temper_type, 0); - if (chst->w_piano) - for (j = 0; j < NUM_KEYS; j++) - piano_note_off(PIANO(chst->w_piano), j); + display_temper_type(chst->w_temper_type, in_buf); + if (show_piano) + av_piano_reset(chst->w_piano, in_buf); if (is_redirect(port)) send_resets(chst); } @@ -1379,6 +1381,19 @@ /* */ +static void av_piano_reset(GtkWidget *w, int in_buf) +{ + if (in_buf) + av_ringbuf_write(PIANO_RESET, w, 0); + else { + int i; + for (i = 0; i < NUM_KEYS; i++) + av_note_update(w, i, 0, 0); + } +} + +/* + */ static void av_program_update(GtkWidget *w, char *progname, int in_buf) { if (in_buf) @@ -1495,7 +1510,7 @@ */ static gboolean idle_cb(gpointer data) { - int type; + int type, i; GtkWidget *w; long val; @@ -1513,6 +1528,9 @@ case NOTE_OFF: av_note_update(w, val, 0, 0); break; + case PIANO_RESET: + av_piano_reset(w, 0); + break; case UPDATE_PGM: av_program_update(w, (char *) val, 0); break; diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/aseqview-0.2.4/ChangeLog new/aseqview-0.2.5/ChangeLog --- old/aseqview-0.2.4/ChangeLog 2007-03-26 16:23:20.000000000 +0200 +++ new/aseqview-0.2.5/ChangeLog 2007-03-29 15:55:21.000000000 +0200 @@ -1,3 +1,5 @@ +0.2.5 - Fix possible segfaults due to races in thread mode + 0.2.4 - Added MIDI Tunig Standard (MTS) feature by TAMUKI Shoichi <tamuki@linet.gr.jp> diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/aseqview-0.2.4/configure new/aseqview-0.2.5/configure --- old/aseqview-0.2.4/configure 2007-03-26 16:23:52.000000000 +0200 +++ new/aseqview-0.2.5/configure 2007-03-29 15:57:06.000000000 +0200 @@ -2075,7 +2075,7 @@ # Define the identity of the package. PACKAGE=aseqview - VERSION=0.2.4 + VERSION=0.2.5 cat >>confdefs.h <<_ACEOF diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/aseqview-0.2.4/configure.in new/aseqview-0.2.5/configure.in --- old/aseqview-0.2.4/configure.in 2007-03-26 16:23:29.000000000 +0200 +++ new/aseqview-0.2.5/configure.in 2007-03-29 15:55:41.000000000 +0200 @@ -1,7 +1,7 @@ dnl Process this file with autoconf to produce a configure script. AC_INIT(configure.in) -AM_INIT_AUTOMAKE(aseqview, 0.2.4) +AM_INIT_AUTOMAKE(aseqview, 0.2.5) AM_CONFIG_HEADER(config.h) AC_PROG_CC diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/aseqview-0.2.4/portlib.c new/aseqview-0.2.5/portlib.c --- old/aseqview-0.2.4/portlib.c 2005-08-23 14:45:44.000000000 +0200 +++ new/aseqview-0.2.5/portlib.c 2007-03-29 14:56:48.000000000 +0200 @@ -45,6 +45,8 @@ int num_ports; port_t *ports; int running; + int use_pthread; + pthread_mutex_t *lock; }; struct port_t { @@ -84,9 +86,36 @@ /* + */ +static void MUTEX_INIT(port_client_t *client, int use_pthread) +{ + client->use_pthread = use_pthread; + if (use_pthread) + pthread_mutex_init(&client->lock, NULL); +} + +static void MUTEX_DESTROY(port_client_t *client) +{ + if (client->use_pthread) + pthread_mutex_destroy(&client->lock); +} + +static void MUTEX_LOCK(port_client_t *client) +{ + if (client->use_pthread) + pthread_mutex_lock(&client->lock); +} + +static void MUTEX_UNLOCK(port_client_t *client) +{ + if (client->use_pthread) + pthread_mutex_unlock(&client->lock); +} + +/* * create a client by non-blocking mode */ -port_client_t *port_client_new(char *name, int mode) +port_client_t *port_client_new(char *name, int mode, int use_pthread) { port_client_t *client; @@ -106,6 +135,7 @@ client->mode = mode; client->num_ports = 0; client->ports = NULL; + MUTEX_INIT(client, use_pthread); if (snd_seq_set_client_name(client->seq, name) < 0) error("set client info"); @@ -125,6 +155,7 @@ next = p->next; free(p); } + MUTEX_DESTROY(client); free(client); } } @@ -202,7 +233,7 @@ client->running = 1; while (client->running) { if (poll(pfd, npfds, timeout) < 0) - error("poll"); + continue; if (port_client_do_event(client)) break; } @@ -244,7 +275,9 @@ if (rc < 0) return rc; } + MUTEX_LOCK(client); snd_seq_flush_output(client->seq); + MUTEX_UNLOCK(client); return 0; } @@ -364,10 +397,15 @@ int rc; snd_seq_ev_set_source(ev, p->port); - if ((rc = snd_seq_event_output(p->client->seq, ev)) < 0) + MUTEX_LOCK(p->client); + rc = snd_seq_event_output(p->client->seq, ev); + if (rc < 0) { + MUTEX_UNLOCK(p->client); return rc; + } if (flush) snd_seq_flush_output(p->client->seq); + MUTEX_UNLOCK(p->client); return rc; } @@ -376,7 +414,11 @@ */ int port_flush_event(port_t *p) { - return snd_seq_flush_output(p->client->seq); + int err; + MUTEX_LOCK(p->client); + err = snd_seq_flush_output(p->client->seq); + MUTEX_UNLOCK(p->client); + return err; } /* diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/aseqview-0.2.4/portlib.h new/aseqview-0.2.5/portlib.h --- old/aseqview-0.2.4/portlib.h 2005-08-23 14:45:51.000000000 +0200 +++ new/aseqview-0.2.5/portlib.h 2007-03-29 14:56:48.000000000 +0200 @@ -58,7 +58,7 @@ #define PORT_CAP_WR (SND_SEQ_PORT_CAP_WRITE|SND_SEQ_PORT_CAP_SUBS_WRITE) #define PORT_CAP_ALL (PORT_CAP_RD|PORT_CAP_WR) -port_client_t *port_client_new(char *name, int mode); +port_client_t *port_client_new(char *name, int mode, int use_pthread); void port_client_delete(port_client_t *p); port_t *port_attach(port_client_t *p, char *name, unsigned int cap, unsigned int type); int port_detach(port_t *p); ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Remember to have fun... --------------------------------------------------------------------- To unsubscribe, e-mail: opensuse-commit+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-commit+help@opensuse.org