From 3bd2adba9acd4b5cb772ca893ef2b0e2863e5342 Mon Sep 17 00:00:00 2001 From: terminatorX <> Date: Mon, 12 Aug 2002 22:12:31 +0000 Subject: [PATCH] Removed lots of old code - fixed a record-to-wav error with the new tX_engine code - Alex --- ChangeLog | 11 ++++++++- src/main.cc | 2 ++ src/tX_audiodevice.cc | 8 ++----- src/tX_audiofile.cc | 13 ++++------- src/tX_engine.cc | 31 +++++++++++++++++-------- src/tX_mastergui.cc | 22 +----------------- src/tX_vtt.cc | 54 +++++-------------------------------------- src/tX_vtt.h | 12 ---------- src/tX_vttgui.cc | 5 ---- src/tX_widget.c | 2 -- 10 files changed, 48 insertions(+), 112 deletions(-) diff --git a/ChangeLog b/ChangeLog index 09ee9dc..3774fbf 100644 --- a/ChangeLog +++ b/ChangeLog @@ -31,7 +31,16 @@ changed. - Pre-listen support for mpg321 - Added a new auto-hiding "panel-bar" to which turntable control and audio panels can be minimized to. -- Cleaning up the audio panel +- Cleaned up the turntables' audio panel for better looks and easier usage +- Rewrote the engine thread completely - unlike before the engine thread + is created on startup and kept alive until termination. +- terminatorX can now be run suid root - and it might even be safe. After + creating the engine thread both terminatorX threads drop root privileges + before evaluating any parameters or reading/writing files, etc. The problem + is the pthread "manager thread" is out of control of terminatorX code - so + I cannot tell that thread to drop privileges. +- Fixed Drag'n'Drop for GNOME 2 +- Deleted tons of old outdated code in tX_engine.cc and tX_mastergui.cc [v3.72] - Applied a patch from Matthew Evans that introduces diff --git a/src/main.cc b/src/main.cc index c8e6b39..11f11cf 100644 --- a/src/main.cc +++ b/src/main.cc @@ -423,6 +423,8 @@ int main(int argc, char **argv) store_globals(); + delete engine; + fprintf(stderr, "Have a nice life.\n"); #else gtk_widget_hide(main_window); diff --git a/src/tX_audiodevice.cc b/src/tX_audiodevice.cc index 24b34e2..c4f8bdb 100644 --- a/src/tX_audiodevice.cc +++ b/src/tX_audiodevice.cc @@ -99,9 +99,7 @@ int tX_audiodevice_oss :: open() /* setting buffer size */ buff_cfg=(globals.buff_no<<16) | globals.buff_size; -#ifdef ENABLE_DEBUG_OUTPUT - fprintf(stderr, "[tX_adudiodevice_oss::open()] buff_no: %i, buff_size: %i, buff_cfg: %08x\n", globals.buff_no, globals.buff_size, buff_cfg); -#endif + tX_debug("tX_adudiodevice_oss::open() - buff_no: %i, buff_size: %i, buff_cfg: %08x", globals.buff_no, globals.buff_size, buff_cfg); p=buff_cfg; @@ -127,9 +125,7 @@ int tX_audiodevice_oss :: open() i += ioctl(fd, SNDCTL_DSP_GETBLKSIZE, &blocksize); -#ifdef ENABLE_DEBUG_OUTPUT - fprintf(stderr, "[tX_adudiodevice_oss::open()] blocksize: %i\n", blocksize); -#endif + tX_debug("tX_adudiodevice_oss::open() - blocksize: %i", blocksize); samples_per_buffer=blocksize/sizeof(int16_t); globals.true_block_size=samples_per_buffer/2; diff --git a/src/tX_audiofile.cc b/src/tX_audiofile.cc index 12e9159..a553406 100644 --- a/src/tX_audiofile.cc +++ b/src/tX_audiofile.cc @@ -347,15 +347,14 @@ int tx_audiofile :: load_wav() { bytes = fread(p, 1, min(1024, wav_in.len-allbytes), wav_in.handle); + if (bytes<=0) { + free(data); + return (TX_AUDIO_ERR_WAV_READ); + } + #ifdef BIG_ENDIAN_MACHINE swapbuffer(p, bytes/sizeof(int16_t)); #endif - if (bytes<=0) - { - free(data); - //wav_progress_update(0); - return (TX_AUDIO_ERR_WAV_READ); - } allbytes+=bytes; ld_set_progress((float) allbytes/(float)wav_in.len); @@ -368,8 +367,6 @@ int tx_audiofile :: load_wav() mem=data; no_samples=memsize/sizeof(int16_t); -// printf("WAV: data: %08x, size %i, len: %i\n", data, memsize, no_samples); - return (TX_AUDIO_SUCCESS); } #endif diff --git a/src/tX_engine.cc b/src/tX_engine.cc index f409df6..4441d0c 100644 --- a/src/tX_engine.cc +++ b/src/tX_engine.cc @@ -29,6 +29,9 @@ mouse-speed (should be changed to maybe) but now depends on sample size -> you can warp through all samples with the same mouse-distance. + + 12 Aug 2002: Complete rewrite - tX_engine is now a class and the thread + is created on startup and kept alive until termination */ #include "tX_types.h" @@ -52,10 +55,6 @@ tX_engine *engine=NULL; -tx_mouse *mouse=new tx_mouse(); -tX_audiodevice *device=NULL; -tx_tapedeck *tape=new tx_tapedeck(); - void tX_engine :: set_grab_request() { grab_request=true; } @@ -71,8 +70,10 @@ void tX_engine :: loop() { pthread_mutex_unlock(&start); /* Render first block */ - sequencer.step(); - temp=vtt_class::render_all_turntables(); + if (!stop_flag) { + sequencer.step(); + temp=vtt_class::render_all_turntables(); + } while (!stop_flag) { /* Checking whether to grab or not */ @@ -85,7 +86,8 @@ void tX_engine :: loop() { grab_active=false; /* Reseting grab_request, too - doesn't help keeping it, does it ? ;) */ grab_request=false; - // mouse->ungrab() // do we need this? + mouse->ungrab(); + grab_off(); } else { grab_active=true; } @@ -141,6 +143,10 @@ void *engine_thread_entry(void *engine_void) { } engine->loop(); + + tX_debug("engine_thread_entry() - Engine thread terminating."); + + pthread_exit(NULL); } tX_engine :: tX_engine() { @@ -239,12 +245,13 @@ tX_engine_error tX_engine :: run() { if (recording_request) { if (tape->start_record(globals.record_filename, device->get_buffersize()*sizeof(int16_t))) { - recording=true; device->close(); delete device; device=NULL; return ERROR_TAPE; - } + } else { + recording=true; + } } for (vtt=vtt_class::main_list.begin(); vtt!=vtt_class::main_list.end(); vtt++) { @@ -289,5 +296,11 @@ void tX_engine :: stop() { } tX_engine :: ~tX_engine() { + void *dummy; + thread_terminate=true; + stop_flag=true; + pthread_mutex_unlock(&start); + tX_debug("~tX_engine() - Waiting for engine thread to terminate."); + pthread_join(thread, &dummy); } diff --git a/src/tX_mastergui.cc b/src/tX_mastergui.cc index 7f5e02d..7fb7aab 100644 --- a/src/tX_mastergui.cc +++ b/src/tX_mastergui.cc @@ -103,7 +103,6 @@ Window xwindow; #define WID_DYN TRUE, TRUE, 0 #define WID_FIX FALSE, FALSE, 0 extern void add_vtt(GtkWidget *ctrl, GtkWidget *audio, char *fn); -extern void recreate_gui(vtt_class *vtt, GtkWidget *daddy); extern void destroy_gui(vtt_class *vtt); extern void gui_show_frame(vtt_class *vtt, int show); @@ -121,7 +120,6 @@ GtkWidget *used_mem=NULL; int stop_update=0; int update_delay; -int mg_hide_gui=0; vtt_class *old_focus=NULL; int grab_status=0; @@ -522,10 +520,6 @@ void mg_enable_critical_buttons(int enable) } -#ifdef USE_SCHEDULER -int mg_oldprio; -#endif - GtkSignalFunc seq_stop(GtkWidget *w, void *); GtkSignalFunc audio_on(GtkWidget *w, void *d) @@ -667,18 +661,6 @@ void grab_off() grab_status=0; } -void hide_clicked(GtkWidget *w, void *d) -{ - if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(w))) - { - mg_hide_gui=1; - } - else - { - mg_hide_gui=0; - } -} - void quit() { turn_audio_off(); @@ -927,7 +909,7 @@ void create_mastergui(int x, int y) dummy=gtk_entry_new_with_max_length(12); seq_entry=dummy; - gtk_widget_set_usize(dummy, 55, 20); + gtk_widget_set_usize(dummy, 65, 20); gtk_entry_set_text(GTK_ENTRY(dummy), "00:00.00"); gtk_box_pack_start(GTK_BOX(sequencer_box), dummy, WID_FIX); gtk_widget_show(dummy); @@ -952,7 +934,6 @@ void create_mastergui(int x, int y) panel_bar=gtk_hbox_new(TRUE,2); gtk_box_pack_start(GTK_BOX(left_hbox), panel_bar, WID_FIX); - //gtk_widget_show(panel_bar); control_parent=gtk_hbox_new(FALSE,0); gtk_box_pack_start(GTK_BOX(tt_parent), control_parent, WID_FIX); @@ -1240,4 +1221,3 @@ void remove_from_panel_bar(GtkWidget *button) { gtk_container_remove(GTK_CONTAINER(panel_bar), button); if (buttons_on_panel_bar==0) gtk_widget_hide(panel_bar); } - diff --git a/src/tX_vtt.cc b/src/tX_vtt.cc index 308b130..ef7187d 100644 --- a/src/tX_vtt.cc +++ b/src/tX_vtt.cc @@ -117,9 +117,6 @@ vtt_class :: vtt_class (int do_create_gui) sync_cycles=0, sync_countdown=0; - x_control=CONTROL_SCRATCH; - y_control=CONTROL_CUTOFF; - lp_enable=0; lp_reso=0.8; lp_freq=0.3; @@ -359,12 +356,6 @@ void vtt_class :: set_loop(int newstate) loop=newstate; } -void vtt_class :: set_controls (int x, int y) -{ - x_control=x; - y_control=y; -} - void vtt_class :: set_mute(int newstate) { mute=newstate; @@ -1530,41 +1521,6 @@ void vtt_class :: set_scratch(int newstate) } } -#define MAGIC 0.05 - -void vtt_class :: handle_input(int control, f_prec value) -{ - f_prec temp; - - switch (control) - { - case CONTROL_SCRATCH: - if (do_scratch) sp_speed.receive_input_value(value*globals.mouse_speed); - sense_cycles=globals.sense_cycles; - break; - - case CONTROL_VOLUME: - temp=rel_volume+MAGIC*value*globals.mouse_speed; - if (temp>2.0) temp=2.0; - else if (temp<0) temp=0; - sp_volume.receive_input_value(temp); - break; - - case CONTROL_CUTOFF: - temp=lp_freq+MAGIC*value*globals.mouse_speed; - if (temp>0.99) temp=0.99; - else if (temp<0) temp=0; - sp_lp_freq.receive_input_value(temp); - break; - - case CONTROL_FEEDBACK: - temp=ec_feedback+MAGIC*value*globals.mouse_speed; - if (temp>1.0) temp=1.0; - else if (temp<0) temp=0; - sp_ec_feedback.receive_input_value(temp); - break; - } -} void vtt_class :: unfocus() { @@ -1719,6 +1675,7 @@ int vtt_class :: save(FILE * output) int vtt_class :: load_10(FILE * input) { int res=0; + int obsolete_int; atload(name); atload(filename); @@ -1734,8 +1691,8 @@ int vtt_class :: load_10(FILE * input) atload(loop); atload(mute); - atload(x_control); - atload(y_control); + atload(obsolete_int); //x_control + atload(obsolete_int); //y_control atload(lp_enable); atload(lp_gain); @@ -1758,6 +1715,7 @@ int vtt_class :: load_11(FILE * input) int res=0; guint32 pid; int32_t gui_page; + int obsolete_int; atload(name); atload(filename); @@ -1773,8 +1731,8 @@ int vtt_class :: load_11(FILE * input) atload(loop); atload(mute); - atload(x_control); - atload(y_control); + atload(obsolete_int); //x_control + atload(obsolete_int); //y_control atload(lp_enable); atload(lp_gain); diff --git a/src/tX_vtt.h b/src/tX_vtt.h index 6a1870a..5d4a01b 100644 --- a/src/tX_vtt.h +++ b/src/tX_vtt.h @@ -51,12 +51,6 @@ #define EC_MAX_BUFFER 256000 -#define CONTROL_NOTHING 0 -#define CONTROL_SCRATCH 1 -#define CONTROL_VOLUME 2 -#define CONTROL_CUTOFF 3 -#define CONTROL_FEEDBACK 4 - #define NEED_FADE_OUT 0 #define NEED_FADE_IN 1 @@ -168,10 +162,6 @@ class vtt_class int mix_solo; int fade; - /* input control vars */ - int x_control; - int y_control; - /* seq par mapping for x/y axis */ tX_seqpar *x_par; tX_seqpar *y_par; @@ -251,7 +241,6 @@ class vtt_class void set_mute(int); - void set_controls(int, int); void set_y_input_parameter(tX_seqpar *); void set_x_input_parameter(tX_seqpar *); @@ -275,7 +264,6 @@ class vtt_class void set_scratch(int); void xy_input(f_prec, f_prec); - void handle_input(int, f_prec); vtt_fx_ladspa * add_effect(LADSPA_Plugin *); diff --git a/src/tX_vttgui.cc b/src/tX_vttgui.cc index ff69239..3fd6993 100644 --- a/src/tX_vttgui.cc +++ b/src/tX_vttgui.cc @@ -127,8 +127,6 @@ void cancel_load_file(GtkWidget *wid, vtt_class *vtt) int quit_load_file(GtkWidget *wid, vtt_class *vtt) { - //vtt->gui.file_dialog=NULL; - //prelis_stop(); return 1; } @@ -834,9 +832,6 @@ void build_vtt_gui(vtt_class *vtt) gui_set_tooltip(g->del, "Click here to annihilate this turntable. All events recorded for this turntable will be erased, too."); p->add_client_widget(g->del); -// g->show_audio=gtk_toggle_button_new_with_label("Show Audio"); -// p->add_client_widget(g->show_audio); - gtk_box_pack_start(GTK_BOX(g->control_subbox), p->get_widget(), WID_FIX); p=new tX_panel("Trigger", g->control_subbox); diff --git a/src/tX_widget.c b/src/tX_widget.c index e3240f2..b35fb3a 100644 --- a/src/tX_widget.c +++ b/src/tX_widget.c @@ -349,8 +349,6 @@ extern "C" { GtkWidget *widget; GdkWindow *window; GdkGC *gc; -// GdkColor *fg; -// GdkColor *bg; int current_x, x, y, yc, ymax; -- 2.25.4