diff -c -r -P xwave2/Changelog xwave2-1/Changelog *** xwave2/Changelog Thu Aug 13 08:57:07 1998 --- xwave2-1/Changelog Wed Oct 21 21:40:21 1998 *************** *** 1,4 **** --- 1,19 ---- + * Jonathan Woithe (jwoithe@physics.adelaide.edu.au), 21 October 1998 + - integrated the loop patch from xwave 0.6 + - fixed bugs + + infinite loop when zoom window clicked on quickly fixed. + + during play when loop selected, set_playline never returned True to + indicate completion to the XtWorkProc mechanism when the Stop button + was pressed; this caused extra lines to appear in the overview + graphic during subsequent mouse selection operations. Stop_it() now + sets Loop to False so set_playline exits properly. + + in one location in both buttonr_action() and mark_canvas() the marked + length (marklength and playlength respectively) could be set to point + beyond the last sample; this prevented the program from finishing + after playing a selection. A check (which was present in all other + vulnerable locations) was added to prevent this. + * xwave 2 release -cleaned up audio.c to support audio devices of other systems -changed reclevel routines (record_dialog.c,audio.c) -changed from SIGALRM to XtWorkProc in record_dialog.c diff -c -r -P xwave2/src/bitmaps/loop_off.xbm xwave2-1/src/bitmaps/loop_off.xbm *** xwave2/src/bitmaps/loop_off.xbm Thu Jan 1 09:30:00 1970 --- xwave2-1/src/bitmaps/loop_off.xbm Thu Oct 15 19:56:47 1998 *************** *** 0 **** --- 1,6 ---- + #define loop_off_width 15 + #define loop_off_height 15 + static unsigned char loop_off_bits[] = { + 0x08, 0x60, 0xcc, 0x7b, 0xfc, 0x3f, 0xfe, 0x1f, 0xbe, 0x1f, 0xfc, 0x3b, + 0xf0, 0x39, 0x78, 0x38, 0x3e, 0x1c, 0x1f, 0x1e, 0xff, 0x1f, 0xfb, 0x07, + 0xe1, 0x03, 0x00, 0x00, 0x00, 0x00, }; diff -c -r -P xwave2/src/bitmaps/loop_on.xbm xwave2-1/src/bitmaps/loop_on.xbm *** xwave2/src/bitmaps/loop_on.xbm Thu Jan 1 09:30:00 1970 --- xwave2-1/src/bitmaps/loop_on.xbm Thu Oct 15 19:56:47 1998 *************** *** 0 **** --- 1,6 ---- + #define loop_on_width 15 + #define loop_on_height 15 + static unsigned char loop_on_bits[] = { + 0x08, 0x00, 0xcc, 0x03, 0xfc, 0x0f, 0xfe, 0x1f, 0x3e, 0x1c, 0x3c, 0x38, + 0x60, 0x38, 0x00, 0x38, 0x18, 0x1c, 0x1c, 0x1e, 0xf8, 0x1f, 0xf8, 0x07, + 0xe0, 0x03, 0x00, 0x00, 0x00, 0x00, }; diff -c -r -P xwave2/src/button.c xwave2-1/src/button.c *** xwave2/src/button.c Thu Aug 13 08:57:09 1998 --- xwave2-1/src/button.c Wed Oct 21 21:35:15 1998 *************** *** 68,73 **** --- 68,75 ---- #include "bitmaps/begin.xbm" #include "bitmaps/end.xbm" #include "bitmaps/zoom.xbm" + #include "bitmaps/loop_on.xbm" + #include "bitmaps/loop_off.xbm" char begin_text[MAX_NUMLENGTH]="0"; char length_text[MAX_NUMLENGTH]="0"; *************** *** 75,90 **** Pixmap upBitmap = None; Pixmap downBitmap = None; bool button_2=False; extern Main_Data *MD; static void try_record(Widget w, XtPointer client_data, XtPointer call_data); static void button_2_on(); static void button_2_off(); static Boolean set_playline(XtPointer client_data); static int pid=-1; ! static Widget buttons[16]; static int last_pos; static XtWorkProcId p_id; static time_t start_clock; --- 77,97 ---- Pixmap upBitmap = None; Pixmap downBitmap = None; bool button_2=False; + static bool Loop_on=False,Loop=False; + static Pixmap loop_onBitmap = None; + static Pixmap loop_offBitmap = None; extern Main_Data *MD; static void try_record(Widget w, XtPointer client_data, XtPointer call_data); + static void change_bitmap(Widget w, Pixmap bitmap); + static void try_loop(Widget w, XtPointer client_data, XtPointer call_data); static void button_2_on(); static void button_2_off(); static Boolean set_playline(XtPointer client_data); static int pid=-1; ! static Widget buttons[17]; static int last_pos; static XtWorkProcId p_id; static time_t start_clock; *************** *** 137,142 **** --- 144,151 ---- stopBitmap= XCBFD(dpy,win,(char *)stop_bits,stop_width,stop_height); playBitmap= XCBFD(dpy,win,(char *)play_bits,play_width,play_height); recordBitmap= XCBFD(dpy,win,(char *)record_bits,record_width,record_height); + loop_onBitmap= XCBFD(dpy,win,(char *)loop_on_bits,loop_on_width,loop_on_height); + loop_offBitmap= XCBFD(dpy,win,(char *)loop_off_bits,loop_off_width,loop_off_height); upBitmap= XCBFD(dpy,win,(char *)up_bits,up_width,up_height); downBitmap= XCBFD(dpy,win,(char *)down_bits,down_width,down_height); *************** *** 213,218 **** --- 222,238 ---- XtAddCallback (buttons[i], XtNcallback, try_record, (XtPointer) MD); + i++; + buttons[i]= MW ("bb_loop_btn",commandWidgetClass,w, + XtNfromHoriz,buttons[i-1], + XtNtop,XawChainTop,XtNbottom,XawChainTop, + XtNbitmap, loop_offBitmap, + XtNsensitive, MD->mb->canplay, + XtNleft,XawChainLeft,XtNright,XawChainLeft, + NULL); + + XtAddCallback (buttons[i], XtNcallback, try_loop, (XtPointer) MD); + label = MW ("bb_begin_label",labelWidgetClass,w, XtNfromHoriz,buttons[i], XtNborderWidth,0, *************** *** 425,436 **** record_dialog(md); } void play_it_g(Widget w, XtPointer client_data, XtPointer call_data) { void abort_playing(); Main_Data *md=(Main_Data*) client_data; int pid_status; ! signal(SIGUSR1,abort_playing); menu_state(False); if (md->mb->playing) { --- 445,478 ---- record_dialog(md); } + void change_bitmap(Widget w, Pixmap bitmap) + { + Arg wargs[1]; + int n=0; + + XtSetArg(wargs[n],XtNbitmap, bitmap); n++; + XtSetValues(w,wargs,n); + } + + void try_loop(Widget w, XtPointer client_data, XtPointer call_data) + { + Loop_on = !Loop_on; + + if(Loop_on) + change_bitmap(w,loop_onBitmap); + else + change_bitmap(w,loop_offBitmap); + } + void play_it_g(Widget w, XtPointer client_data, XtPointer call_data) { void abort_playing(); Main_Data *md=(Main_Data*) client_data; int pid_status; ! ! if (!MD->wd->ismark && Loop_on) ! change_bitmap(buttons[B_LOOP],loop_offBitmap); ! signal(SIGUSR1,abort_playing); menu_state(False); if (md->mb->playing) { *************** *** 444,455 **** md->mb->playing=True; button_state(False); pid= fork(); if (!pid) { ! XtDestroyApplicationContext(XtWidgetToApplicationContext(w)); ! play_buffer(md); ! exit(0); } else if (pid<=0) { md->mb->playing=FALSE; button_state(True); --- 486,501 ---- md->mb->playing=True; button_state(False); + Loop=Loop_on && MD->wd->ismark; pid= fork(); if (!pid) { ! XtDestroyApplicationContext(XtWidgetToApplicationContext(w)); ! do{ ! play_buffer(md); ! }while(Loop); ! Loop=False; ! exit(0); } else if (pid<=0) { md->mb->playing=FALSE; button_state(True); *************** *** 488,493 **** --- 534,544 ---- signal(SIGUSR1,abort_playing); menu_state(False); + + if (Loop_on) + change_bitmap(buttons[B_LOOP],loop_onBitmap); + Loop=False; + if (md->mb->playing) { button_state(True); kill((pid_t)pid,SIGKILL); *************** *** 536,541 **** --- 587,595 ---- waitpid((pid_t)pid, &pid_status, 0); pid=-1; md->mb->playing=FALSE; + /* Allow set_playline() to return TRUE and thus complete its */ + /* background processing. */ + Loop=False; button_state(True); menu_state(True); if (last_pos>=0 && last_posmg->width) clear_line(last_pos); *************** *** 549,558 **** { int pid_status; ! set_button_state(B_STOP,B_PLAY,False); ! signal(SIGUSR1,SIG_IGN); waitpid((pid_t)pid, &pid_status,0); pid=-1; MD->mb->playing=FALSE; button_state(True); menu_state(True); --- 603,621 ---- { int pid_status; ! if(Loop) ! { ! signal(SIGUSR1,abort_playing); ! start_clock=clock(); ! return; ! } ! if (Loop_on) ! change_bitmap(buttons[B_LOOP],loop_onBitmap); ! waitpid((pid_t)pid, &pid_status,0); pid=-1; + set_button_state(B_STOP,B_PLAY,False); + signal(SIGUSR1,SIG_IGN); MD->mb->playing=FALSE; button_state(True); menu_state(True); *************** *** 596,602 **** if ((!md->mb->playing)||now_pos>=end) { if (md->wd->isplay) set_line(md->wd->playbeg/md->mg->step); ! return(True); } set_line(now_pos); --- 659,673 ---- if ((!md->mb->playing)||now_pos>=end) { if (md->wd->isplay) set_line(md->wd->playbeg/md->mg->step); ! ! if(!Loop) ! return(True); ! else ! { ! last_pos=now_pos=md->wd->markbeg/md->mg->step; ! last_pos--; ! return False; ! } } set_line(now_pos); diff -c -r -P xwave2/src/button.h xwave2-1/src/button.h *** xwave2/src/button.h Thu Aug 13 08:57:09 1998 --- xwave2-1/src/button.h Sat Oct 17 22:48:31 1998 *************** *** 9,25 **** #define B_STOP 4 #define B_PLAY 5 #define B_REC 6 ! #define B_BEG 7 ! #define B_BUP 8 ! #define B_BDOWN 9 ! #define B_LENGTH 10 ! #define B_LUP 11 ! #define B_LDOWN 12 ! #define B_ZOOM 13 ! #define B_ZUP 14 ! #define B_ZDOWN 15 ! ! #define B_LAST 15 void create_button(Widget); void set_button_state(int,int,bool); --- 9,26 ---- #define B_STOP 4 #define B_PLAY 5 #define B_REC 6 ! #define B_LOOP 7 ! #define B_BEG 8 ! #define B_BUP 9 ! #define B_BDOWN 10 ! #define B_LENGTH 11 ! #define B_LUP 12 ! #define B_LDOWN 13 ! #define B_ZOOM 14 ! #define B_ZUP 15 ! #define B_ZDOWN 16 ! ! #define B_LAST 16 void create_button(Widget); void set_button_state(int,int,bool); diff -c -r -P xwave2/src/graphics.c xwave2-1/src/graphics.c *** xwave2/src/graphics.c Thu Aug 13 08:57:09 1998 --- xwave2-1/src/graphics.c Wed Oct 21 21:36:00 1998 *************** *** 1754,1759 **** --- 1754,1763 ---- if (event->x>firstmark) { md->wd->markbeg=ceil(firstmark*md->mg->step); md->wd->marklength=ceil((event->x-firstmark)*md->mg->step); + /* Prevent rounding errors from attempting to set too long */ + /* a length */ + if (md->wd->markbeg+md->wd->marklength>md->wd->tlength) + md->wd->marklength=md->wd->tlength-md->wd->markbeg; } else { md->wd->markbeg=ceil(event->x*md->mg->step); md->wd->marklength=ceil((firstmark-event->x)*md->mg->step); *************** *** 1986,1992 **** md->wd->isplay=False; /* remove all events from queue */ ! XSync(dpy,True); /* pointer outside the points/lines */ pos=md->cg->pos/md->wd->bpspl/md->cg->step; --- 1990,2000 ---- md->wd->isplay=False; /* remove all events from queue */ ! /* This can't be done since it may remove a ButtonRelease event if it */ ! /* follows quickly from the initial ButtonPress event. Instead have */ ! /* the switch() statement in the while() loop remove events not being */ ! /* explicitly handled from the queue. */ ! /* XSync(dpy,True); */ /* pointer outside the points/lines */ pos=md->cg->pos/md->wd->bpspl/md->cg->step; *************** *** 2005,2011 **** md->wd->markbeg=x; set_cursor(md->cw->graph,CURSOR_MARK); ! /* wait for first event arrive after button press */ XPeekEvent(dpy,&pev); --- 2013,2019 ---- md->wd->markbeg=x; set_cursor(md->cw->graph,CURSOR_MARK); ! /* wait for first event arrive after button press */ XPeekEvent(dpy,&pev); *************** *** 2115,2120 **** --- 2123,2131 ---- length+=(firstx-x)*md->cg->step; } md->wd->ismark=True; + /* Make sure we don't try to play past the last sample */ + if (beg+length > md->wd->tlength) + length = md->wd->tlength-beg; md->wd->markbeg=beg; md->wd->marklength=length; if (update_cvmark&&scrolled) *************** *** 2123,2128 **** --- 2134,2146 ---- update_status(md); return; } /* ButtonRelease */ + default: { + /* Remove other events that we are not interested in from */ + /* the queue. This used to be accomplished by an XSync() */ + /* call outside of the while() loop. */ + XNextEvent(dpy,&pev); + break; + } } /* switch */ } /* XPending */ } /* while(True) */ diff -c -r -P xwave2/src/status.c xwave2-1/src/status.c *** xwave2/src/status.c Thu Aug 13 08:57:10 1998 --- xwave2-1/src/status.c Sat Oct 17 22:49:32 1998 *************** *** 147,152 **** --- 147,153 ---- if (md->no==1) { set_button_state(B_BEG,B_ZDOWN,True); set_button_state(B_PLAY,B_REC,md->mb->canplay); + set_button_state(B_LOOP,B_LOOP,md->mb->canplay); set_menu_state(M_SAVEAS,M_CLOSE,True); set_menu_state(M_ECHO,M_PROPS,True); set_cmenu_state(CM_PLAY,CM_PLAY,md->mb->canplay);