Fixing the master volume slider - sequencer slider and avoiding
authorterminatorX <>
Wed, 16 Apr 2003 19:45:56 +0000 (19:45 +0000)
committerterminatorX <>
Wed, 16 Apr 2003 19:45:56 +0000 (19:45 +0000)
ALSA closure of non-open device - Alex

AUTHORS
src/tX_audiodevice.cc
src/tX_audiodevice.h
src/tX_engine.cc
src/tX_global.c
src/tX_mastergui.cc
src/tX_seqpar.cc
src/tX_vtt.cc

diff --git a/AUTHORS b/AUTHORS
index e4ba9e4015d4e9122c281e6af5fa971eebba6d17..9b4c18e78c70e79ccae4a36df19a73d37bc6dd4d 100644 (file)
--- a/AUTHORS
+++ b/AUTHORS
@@ -10,6 +10,7 @@ new startup switches: Josh Steiner <joschi@eds.org>
 misc fixes and enhancements:
                        Adrian Reber <adrian@lisas.de>
 Ogg Vorbis support:    Matthew Evans <activesx@hotmail.com>
-                       
+MIDI interface:  Arthur Peters <amp@singingwizard.org>
+
 The lowpass filter is based on a description:
 reso_lop.txt:          Paul Kellett <paul.kellett@maxim.abel.co.uk>
index 9ccf74d6b71b0cee1e6f775422c5d8aa0dad4c60..7e435c656d4cba52ae4b335b011dbf0c06a430aa 100644 (file)
@@ -49,7 +49,7 @@
 #include "tX_engine.h"
 
 tX_audiodevice :: tX_audiodevice() : samples_per_buffer(0),
-current_buffer(0), buffer_pos(0)
+current_buffer(0), buffer_pos(0), is_open(false)
 {
        sample_buffer[0]=NULL;
        sample_buffer[1]=NULL;
@@ -113,11 +113,18 @@ int tX_audiodevice_oss :: open()
        if (fd) return (1);
        fd=::open(globals.oss_device, O_WRONLY, 0);
        
+       if (fd==-1) {
+               tX_error("tX_audiodevice_oss::open() can't open device: %s", strerror(errno));
+               return -1;
+       }
+       
+       is_open=true;
+       
        /* setting buffer size */       
        buff_cfg=(globals.oss_buff_no<<16) | globals.oss_buff_size;
        p=buff_cfg;
 
-       tX_debug("tX_adudiodevice_oss::open() - buff_no: %i, buff_size: %i, buff_cfg: %08x", globals.oss_buff_no, globals.oss_buff_size, buff_cfg);
+       tX_debug("tX_audiodevice_oss::open() - buff_no: %i, buff_size: %i, buff_cfg: %08x", globals.oss_buff_no, globals.oss_buff_size, buff_cfg);
                
        i = ioctl(fd, SNDCTL_DSP_SETFRAGMENT, &p);
        ioctl(fd, SNDCTL_DSP_RESET, 0);         
@@ -158,6 +165,7 @@ int tX_audiodevice_oss :: close()
        {       
                return(1);              
        }
+       is_open=false;
        ::close(fd);
        fd=0;
        blocksize=0;
@@ -207,6 +215,8 @@ int tX_audiodevice_alsa :: open()
                tX_error("ALSA: Failed to access PCM device \"%s\"", pcm_name);
                return -1;
        }
+       
+       is_open=true;
 
        snd_pcm_hw_params_alloca(&hw_params);   
        
@@ -294,12 +304,15 @@ int tX_audiodevice_alsa :: open()
        }
        
        snd_pcm_hw_params_free (hw_params);
-       return snd_pcm_prepare(pcm_handle);
+       return 0; //snd_pcm_prepare(pcm_handle);
 }
 
 int tX_audiodevice_alsa :: close()
 {
-       snd_pcm_close(pcm_handle);
+       if (is_open) {
+               snd_pcm_close(pcm_handle);
+       }
+       is_open=false;
        
        return 0;
 }
@@ -309,7 +322,6 @@ double tX_audiodevice_alsa :: get_latency()
        return 0;
 }
 
-
 tX_audiodevice_alsa :: tX_audiodevice_alsa() : tX_audiodevice(),
 pcm_handle(NULL) {}
 
index de15a733e7a2c99c229330939c9250d53d09171d..04abd6df9764df6fe56da2d09201aa260f08e65c 100644 (file)
@@ -48,6 +48,7 @@ class tX_audiodevice
        int buffer_pos;
        int vtt_buffer_size;
        tX_engine *engine;
+       bool is_open;
        
        int sample_rate;
        tX_audiodevice();
@@ -62,6 +63,7 @@ class tX_audiodevice
        
        void fill_buffer(int16_t *target_buffer, int16_t *next_target_buffer);
 
+       bool get_is_open() { return is_open; }
        virtual void start();   
        virtual void play(int16_t*)=0; /* play blocked */
 };
index 2fb822137faf6113297d0b5da3ed86b7b7b521cf..2f6a2b8697546a4d0a1ec5f94f63620f0c17a578 100644 (file)
@@ -245,7 +245,7 @@ tX_engine_error tX_engine :: run() {
        }
        
        if (device->open()) {
-               device->close();
+               if (device->get_is_open()) device->close();
                delete device;
                device=NULL;            
                return ERROR_AUDIO;
@@ -299,7 +299,7 @@ void tX_engine :: stop() {
        
        tX_debug("tX_engine::stop() - loop has stopped.");
 
-       device->close();
+       if (device->get_is_open()) device->close();
        delete device;
        device=NULL;
        
index d0e6c477f11b89f333435a06fc70cb34d8ffd80d..df47ea062102ac97519c583d9dd8ee9e425da1a6 100644 (file)
@@ -228,8 +228,8 @@ void store_globals() {
        char rc_name[PATH_MAX]="";
        char device_type[16];
        char indent[]="\t";
-       FILE *rc;
-       gzFile rz;
+       FILE *rc=NULL;
+       gzFile rz=NULL;
        _store_compress_xml=0;
        char tmp_xml_buffer[4096];
        
index 90df18ba50c49c4dfdfb224b81d6893122fe4b6d..98cfc1a77d7d67e49df6aaf8d4be45e724a8863f 100644 (file)
@@ -370,7 +370,7 @@ void load_tt_part(char * buffer)
        tX_seqpar :: init_all_graphics();
        vg_init_all_non_seqpars();
                
-       gtk_adjustment_set_value(volume_adj, 2.0-globals.volume);
+       gtk_adjustment_set_value(volume_adj, globals.volume);
        gtk_adjustment_set_value(pitch_adj, globals.pitch);
        sprintf(wbuf,"terminatorX - %s", strip_path(buffer));
        gtk_window_set_title(GTK_WINDOW(main_window), wbuf);            
@@ -857,13 +857,15 @@ void seq_update()
        gtk_adjustment_set_value(seq_adj, sequencer.get_timestamp_as_float());
        
 }
-void seq_slider_released(GtkWidget *wid, void *d)
+gboolean seq_slider_released(GtkWidget *wid, void *d)
 {
        seq_adj_care=0;
        gtk_widget_set_sensitive(seq_slider, 0);        
        sequencer.forward_to_start_timestamp(0);
        gtk_widget_set_sensitive(seq_slider, 1);        
        seq_adj_care=1;
+       
+       return FALSE;
 }
 void sequencer_move(GtkWidget *wid, void *d)
 {
@@ -1198,11 +1200,12 @@ void create_mastergui(int x, int y)
        gtk_box_pack_start(GTK_BOX(right_hbox), master_vol_box, WID_DYN);
        gtk_widget_show(master_vol_box);        
        
-       dumadj=(GtkAdjustment*) gtk_adjustment_new(2.0-globals.volume, 0, 2, 0.01, 0.05, 0.005);
+       dumadj=(GtkAdjustment*) gtk_adjustment_new(globals.volume, 0, 2, 0.01, 0.05, 0.005);
        volume_adj=dumadj;
 
        connect_adj(dumadj, master_volume_changed, NULL);       
        dummy=gtk_vscale_new(dumadj);
+       //gtk_range_set_inverted(GTK_RANGE(dummy), TRUE);
        gtk_scale_set_draw_value(GTK_SCALE(dummy), False);
        gtk_box_pack_end(GTK_BOX(master_vol_box), dummy, WID_FIX);
        gtk_widget_show(dummy); 
index 9e5f26c445da17e37a4793b28434e1c22316e4bd..a0bd0218adfd266d9c6d2d3d765d0bb62bd828e5 100644 (file)
@@ -393,7 +393,7 @@ void tX_seqpar_master_volume :: do_exec(const float value)
 
 void tX_seqpar_master_volume :: do_update_graphics ()
 {
-       gtk_adjustment_set_value(volume_adj, vtt_class::master_volume);
+       gtk_adjustment_set_value(volume_adj, 2.0-vtt_class::master_volume);
 }
 
 const char * tX_seqpar_master_volume :: get_name()
index a8861476c0f12e5b9cdcd6fa4fa73a66831dc371..d16221011d1e0b7b248d559165c0bf09a47bc5e9 100644 (file)
@@ -360,7 +360,6 @@ void vtt_class :: recalc_pitch()
        res_pitch*=audiofile_pitch_correction;
        speed=res_pitch;
        ec_set_length(ec_length);
-       tX_debug("setting pitch: rel: %lf -> res: %lf", rel_pitch, res_pitch);
 }
 
 void vtt_class :: set_autotrigger(int newstate)