fix for erroneous use of a menu group; remove lots of cerr cruft; no playlist ops...
authorPaul Davis <paul@linuxaudiosystems.com>
Wed, 8 Mar 2006 15:37:39 +0000 (15:37 +0000)
committerPaul Davis <paul@linuxaudiosystems.com>
Wed, 8 Mar 2006 15:37:39 +0000 (15:37 +0000)
git-svn-id: svn://localhost/trunk/ardour2@359 d708f5d6-7413-0410-9779-e7cbd77b26cf

gtk2_ardour/audio_time_axis.cc
gtk2_ardour/audio_time_axis.h
gtk2_ardour/editor.cc
gtk2_ardour/mixer_strip.cc
gtk2_ardour/mixer_strip.h
gtk2_ardour/mixer_ui.cc
gtk2_ardour/taperegionview.cc
libs/ardour/ardour/session.h
libs/ardour/audio_track.cc
libs/ardour/diskstream.cc

index 4ec1e3da2a0392aae091b0d9b0a1264f5adad118..819d0fff6351cd211c3286006ff9a1639fd313d9 100644 (file)
@@ -193,9 +193,8 @@ AudioTimeAxisView::AudioTimeAxisView (PublicEditor& ed, Session& sess, Route& rt
        controls_table.attach (size_button, 2, 3, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
        controls_table.attach (automation_button, 3, 4, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
 
-       if (is_audio_track()) {
+       if (is_audio_track() && audio_track()->mode() == ARDOUR::Normal) {
                controls_table.attach (playlist_button, 5, 6, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
-
        }
 
        /* remove focus from the buttons */
@@ -338,29 +337,30 @@ AudioTimeAxisView::edit_click (GdkEventButton *ev)
        using namespace Menu_Helpers;
 
        MenuList& items = edit_group_menu.items ();
+       RadioMenuItem::Group group;
 
        items.clear ();
-       items.push_back (RadioMenuElem (edit_group_menu_radio_group, _("No group"), 
-                                  bind (mem_fun(*this, &AudioTimeAxisView::set_edit_group_from_menu), (RouteGroup *) 0)));
+       items.push_back (RadioMenuElem (group, _("No group"), 
+                                       bind (mem_fun(*this, &AudioTimeAxisView::set_edit_group_from_menu), (RouteGroup *) 0)));
        
        if (_route.edit_group() == 0) {
                static_cast<RadioMenuItem*>(&items.back())->set_active ();
        }
-
-       _session.foreach_edit_group (this, &AudioTimeAxisView::add_edit_group_menu_item);
+       
+       _session.foreach_edit_group (bind (mem_fun (*this, &AudioTimeAxisView::add_edit_group_menu_item), &group));
        edit_group_menu.popup (ev->button, ev->time);
 
        return FALSE;
 }
 
 void
-AudioTimeAxisView::add_edit_group_menu_item (RouteGroup *eg)
+AudioTimeAxisView::add_edit_group_menu_item (RouteGroup *eg, RadioMenuItem::Group* group)
 {
        using namespace Menu_Helpers;
 
        MenuList &items = edit_group_menu.items();
-       items.push_back (RadioMenuElem (edit_group_menu_radio_group,
-                                       eg->name(), bind (mem_fun(*this, &AudioTimeAxisView::set_edit_group_from_menu), eg)));
+
+       items.push_back (RadioMenuElem (*group, eg->name(), bind (mem_fun(*this, &AudioTimeAxisView::set_edit_group_from_menu), eg)));
        if (_route.edit_group() == eg) {
                static_cast<RadioMenuItem*>(&items.back())->set_active ();
        }
@@ -832,12 +832,7 @@ AudioTimeAxisView::rename_current_playlist ()
        AudioPlaylist *pl;
        DiskStream *ds;
 
-       /* neither conditions are supposed to be true at this
-          time, but to leave the design flexible, allow
-          them to be in the future without causing crashes
-       */
-
-       if (((ds = get_diskstream()) == 0) ||((pl = ds->playlist()) == 0)) {
+       if (((ds = get_diskstream()) == 0) || ds->destructive() || ((pl = ds->playlist()) == 0)) {
                return;
        }
 
@@ -864,12 +859,7 @@ AudioTimeAxisView::use_copy_playlist (bool prompt)
        DiskStream *ds;
        string name;
 
-       /* neither conditions are supposed to be true at this
-          time, but to leave the design flexible, allow
-          them to be in the future without causing crashes
-       */
-
-       if (((ds = get_diskstream()) == 0) || ((pl = ds->playlist()) == 0)) {
+       if (((ds = get_diskstream()) == 0) || ds->destructive() || ((pl = ds->playlist()) == 0)) {
                return;
        }
        
@@ -906,13 +896,8 @@ AudioTimeAxisView::use_new_playlist (bool prompt)
        AudioPlaylist *pl;
        DiskStream *ds;
        string name;
-       
-       /* neither conditions are supposed to be true at this
-          time, but to leave the design flexible, allow
-          them to be in the future without causing crashes
-       */
-       
-       if (((ds = get_diskstream()) == 0) || ((pl = ds->playlist()) == 0)) {
+
+       if (((ds = get_diskstream()) == 0) || ds->destructive() || ((pl = ds->playlist()) == 0)) {
                return;
        }
        
index 0272e0fa0e027ef55ae94c609139b9d5fbdc6018..0e2eab66c9a1c8881cc6f84b86a73c0460f477de 100644 (file)
@@ -192,9 +192,8 @@ class AudioTimeAxisView : public RouteUI, public TimeAxisView
        virtual void label_view ();
 
        Gtk::Menu edit_group_menu;
-       Gtk::RadioMenuItem::Group edit_group_menu_radio_group;
 
-       void add_edit_group_menu_item (ARDOUR::RouteGroup *);
+       void add_edit_group_menu_item (ARDOUR::RouteGroup *, Gtk::RadioMenuItem::Group*);
        void set_edit_group_from_menu (ARDOUR::RouteGroup *);
 
        void reset_samples_per_unit ();
index dae80439b189cfda2d6876e3cebb5d77a112b9e7..e3ca52cac23cf7c1f7ebd61fc22be65a7ea75ec4 100644 (file)
@@ -1195,7 +1195,7 @@ Editor::connect_to_session (Session *t)
 
        session_connections.push_back (session->tempo_map().StateChanged.connect (mem_fun(*this, &Editor::tempo_map_changed)));
 
-       session->foreach_edit_group(this, &Editor::add_edit_group);
+       session->foreach_edit_group (mem_fun (*this, &Editor::add_edit_group));
 
        edit_cursor_clock.set_session (session);
        selection_start_clock.set_session (session);
index 64caac4eefaa4321257a59d54c1e23eaf2084d7e..65b0051eaf94c8abba5b6063dace1ef964389f8f 100644 (file)
@@ -1155,12 +1155,12 @@ MixerStrip::set_mix_group (RouteGroup *rg)
 }
 
 void
-MixerStrip::add_mix_group_to_menu (RouteGroup *rg)
+MixerStrip::add_mix_group_to_menu (RouteGroup *rg, RadioMenuItem::Group* group)
 {
        using namespace Menu_Helpers;
 
        MenuList& items = group_menu->items();
-       items.push_back (MenuElem (rg->name(), bind (mem_fun(*this, &MixerStrip::set_mix_group), rg)));
+       items.push_back (RadioMenuElem (*group, rg->name(), bind (mem_fun(*this, &MixerStrip::set_mix_group), rg)));
 }
 
 gint
@@ -1171,9 +1171,11 @@ MixerStrip::select_mix_group (GdkEventButton *ev)
        group_menu = new Menu;
        group_menu->set_name ("ArdourContextMenu");
        MenuList& items = group_menu->items();
+       RadioMenuItem::Group group;
+       
+       items.push_back (RadioMenuElem (group, _("no group"), bind (mem_fun(*this, &MixerStrip::set_mix_group), (RouteGroup *) 0)));
 
-       items.push_back (MenuElem (_("no group"), bind (mem_fun(*this, &MixerStrip::set_mix_group), (RouteGroup *) 0)));
-       _session.foreach_mix_group (this, &MixerStrip::add_mix_group_to_menu);
+       _session.foreach_mix_group (bind (mem_fun (*this, &MixerStrip::add_mix_group_to_menu), &group));
 
        group_menu->popup (ev->button, 0);
        return stop_signal (group_button, "button_press_event");
index f348b96803bcec404411e4e604fc344ec3efb813..8945de21bbe48b81a7feabb8efbacb5fce2c34a3 100644 (file)
@@ -231,7 +231,7 @@ class MixerStrip : public RouteUI, public Gtk::EventBox
        bool ignore_comment_edit;
 
        void set_mix_group (ARDOUR::RouteGroup *);
-       void add_mix_group_to_menu (ARDOUR::RouteGroup *);
+       void add_mix_group_to_menu (ARDOUR::RouteGroup *, Gtk::RadioMenuItem::Group*);
        gint select_mix_group (GdkEventButton *);
        void mix_group_changed (void *);
 
index 5d1c9251161499b35b502c6e735ebc0842692d4a..0fd6b07a62ff91d482cdb2f2fbac0eec79666bcc 100644 (file)
@@ -313,7 +313,7 @@ Mixer_UI::connect_to_session (Session* sess)
        session->RouteAdded.connect (mem_fun(*this, &Mixer_UI::add_strip));
        session->mix_group_added.connect (mem_fun(*this, &Mixer_UI::add_mix_group));
 
-       session->foreach_mix_group(this, &Mixer_UI::add_mix_group);
+       session->foreach_mix_group (mem_fun (*this, &Mixer_UI::add_mix_group));
        
        _plugin_selector->set_session (session);
 
index 4fd40bcc86627d5c042c27f78c3cda7c12e7108e..d4b75191eca218cea833d73e68b64fa4b68a25c3 100644 (file)
@@ -125,18 +125,6 @@ TapeAudioRegionView::update (uint32_t n)
 
        ENSURE_GUI_THREAD (bind (mem_fun(*this, &TapeAudioRegionView::update), n));
 
-       cerr << "peaks ready for channel " << n << endl;
-
-       cerr << "tmp waves size = " << tmp_waves.size() << " waves size = " << waves.size() << endl;
-
-       for (uint32_t x = 0; x < waves.size(); ++x) {
-               cerr << "waves[" << x << "] = " << waves[x] << endl;
-       }
-
-       for (vector<WaveView*>::iterator i = waves.begin(); i != waves.end(); ++i) {
-               cerr << "iterator[" << distance (i, waves.begin()) << "] = " << (*i) << endl;
-       }
-
        /* this triggers a cache invalidation and redraw in the waveview */
 
        waves[n]->property_data_src() = &region;
index b6009731f21474631b6d963934e908e24adb2f49..a47e070766742af0e37890b460a7f1b5b16792de 100644 (file)
@@ -511,17 +511,15 @@ class Session : public sigc::trackable, public Stateful
        sigc::signal<void,RouteGroup*> edit_group_added;
        sigc::signal<void,RouteGroup*> mix_group_added;
 
-       template<class T> void foreach_edit_group (T *obj, void (T::*func)(RouteGroup *)) {
-               list<RouteGroup *>::iterator i;
-               for (i = edit_groups.begin(); i != edit_groups.end(); i++) {
-                       (obj->*func)(*i);
+       void foreach_edit_group (sigc::slot<void,RouteGroup*> sl) {
+               for (list<RouteGroup *>::iterator i = edit_groups.begin(); i != edit_groups.end(); i++) {
+                       sl (*i);
                }
        }
 
-       template<class T> void foreach_mix_group (T *obj, void (T::*func)(RouteGroup *)) {
-               list<RouteGroup *>::iterator i;
-               for (i = mix_groups.begin(); i != mix_groups.end(); i++) {
-                       (obj->*func)(*i);
+       void foreach_mix_group (sigc::slot<void,RouteGroup*> sl) {
+               for (list<RouteGroup *>::iterator i = mix_groups.begin(); i != mix_groups.end(); i++) {
+                       sl (*i);
                }
        }
 
index 7bf8d5732f6ae9b6118bc48f0e3c47a59be60264..85cd86632c6340424741210244df5635a2bce5fd 100644 (file)
@@ -53,9 +53,6 @@ AudioTrack::AudioTrack (Session& sess, string name, Route::Flag flag, TrackMode
 
        if (mode == Destructive) {
                dflags = DiskStream::Flag (dflags | DiskStream::Destructive);
-               cerr << "Creating a new audio track, destructive mode\n";
-       } else {
-               cerr << "Creating a new audio track, NOT destructive mode\n";
        }
 
        DiskStream* ds = new DiskStream (_session, name, dflags);
index c40094dde08b17e4776a4af24ebdc4a840f185c3..80a562ab21681c847e196e50814bf4f1a81fd1ee 100644 (file)
@@ -406,6 +406,10 @@ DiskStream::use_new_playlist ()
        string newname;
        AudioPlaylist* playlist;
 
+       if (!in_set_state && destructive()) {
+               return 0;
+       }
+
        if (_playlist) {
                newname = Playlist::bump_name (_playlist->name(), _session);
        } else {
@@ -423,6 +427,10 @@ DiskStream::use_new_playlist ()
 int
 DiskStream::use_copy_playlist ()
 {
+       if (destructive()) {
+               return 0;
+       }
+
        if (_playlist == 0) {
                error << string_compose(_("DiskStream %1: there is no existing playlist to make a copy of!"), _name) << endmsg;
                return -1;
@@ -663,8 +671,6 @@ DiskStream::check_record_status (jack_nframes_t transport_frame, jack_nframes_t
                }
 
                if (_flags & Recordable) {
-                       cerr << "START RECORD @ " << capture_start_frame << endl;
-
                        for (ChannelList::iterator chan = channels.begin(); chan != channels.end(); ++chan) {
                                
                                RingBufferNPT<CaptureTransition>::rw_vector transvec;
@@ -677,7 +683,8 @@ DiskStream::check_record_status (jack_nframes_t transport_frame, jack_nframes_t
                                }
                                else {
                                        // bad!
-                                       cerr << "capture_transition_buf is full on rec start!  inconceivable!" << endl;
+                                       fatal << X_("programming error: capture_transition_buf is full on rec start!  inconceivable!") 
+                                             << endmsg;
                                }
                        }
                }
@@ -1562,10 +1569,8 @@ DiskStream::do_flush (char * workbuf, bool force_flush)
                                
                                if (captrans.type == CaptureStart) {
                                        // by definition, the first data we got above represents the given capture pos
-                                       cerr << "DS " << name() << "  got CaptureStart at " << captrans.capture_val << endl;
 
                                        (*chan).write_source->mark_capture_start (captrans.capture_val);
-                                       
                                        (*chan).curr_capture_cnt = 0;
 
                                        have_start = true;
@@ -1576,18 +1581,8 @@ DiskStream::do_flush (char * workbuf, bool force_flush)
 
                                        if (captrans.capture_val <= (*chan).curr_capture_cnt + to_write) {
 
-                                               cerr << "DS " << name() << "  got CaptureEnd with " << captrans.capture_val << endl;
                                                // shorten to make the write a perfect fit
                                                uint32_t nto_write = (captrans.capture_val - (*chan).curr_capture_cnt); 
-                                               if (have_start) {
-                                                       // starts and ends within same chunk we're processing
-                                                       cerr << "Starts and ends within same chunk: adjusting to_write from: "
-                                                            << to_write << " to: " << nto_write << endl;
-                                               }
-                                               else {
-                                                       cerr << "Ends within chunk: adjusting to_write to: "
-                                                            << to_write << " to: " << nto_write << endl;
-                                               }
 
                                                if (nto_write < to_write) {
                                                        ret = 1; // should we?
@@ -1602,8 +1597,6 @@ DiskStream::do_flush (char * workbuf, bool force_flush)
                                        }
                                        else {
                                                // actually ends just beyond this chunk, so force more work
-                                               cerr << "DS " << name() << " got CaptureEnd beyond our chunk, cnt of: "
-                                                    << captrans.capture_val << "  leaving on queue" << endl;
                                                ret = 1;
                                                break;
                                        }
@@ -1856,8 +1849,7 @@ DiskStream::finish_capture (bool rec_monitors_input)
                return;
        }
 
-       if ((_flags & Recordable) && destructive()) {
-               cerr << "RECORD END @ " << capture_start_frame + capture_captured << endl;
+       if (recordable() && destructive()) {
                for (ChannelList::iterator chan = channels.begin(); chan != channels.end(); ++chan) {
                        
                        RingBufferNPT<CaptureTransition>::rw_vector transvec;
@@ -1971,10 +1963,6 @@ DiskStream::get_state ()
        char buf[64];
        LocaleGuard lg (X_("POSIX"));
 
-       if (destructive()) {
-               node->add_property ("destructive", "true");
-       }
-
        snprintf (buf, sizeof(buf), "%zd", channels.size());
        node->add_property ("channels", buf);
 
@@ -2049,12 +2037,6 @@ DiskStream::set_state (const XMLNode& node)
                _name = prop->value();
        } 
 
-       if ((prop = node.property ("destructive")) != 0) {
-               if (prop->value() == "true") {
-                       _flags |= Destructive;
-               }
-       } 
-
        if (deprecated_io_node) {
                if ((prop = deprecated_io_node->property ("id")) != 0) {
                        sscanf (prop->value().c_str(), "%" PRIu64, &_id);
@@ -2129,17 +2111,14 @@ DiskStream::set_state (const XMLNode& node)
 
        in_set_state = false;
 
-       /* now that we're all done with playlist+channel set up,
-          go ahead and create write sources.
-       */
-
+       /* make sure this is clear before we do anything else */
 
        capturing_sources.clear ();
 
-       if (recordable() && !destructive()) {
-               /* destructive diskstreams get their sources set up elsewhere */
-               reset_write_sources (false);
-       }
+       /* write sources are handled elsewhere; 
+             for destructive tracks: in {setup,use}_destructive_playlist()
+             for non-destructive: when we handle the input set up of the IO that owns this DS
+       */
                
        in_set_state = false;
 
@@ -2184,8 +2163,6 @@ DiskStream::use_new_write_source (uint32_t n)
                return -1;
        }
 
-       cerr << _name << " using a new source " << chan.write_source << " for channel " << n << endl;
-
        chan.write_source->use ();
 
        return 0;