ICS (image compositor socket) patches from robin gareus, to keep ICS alive in 2.X...
authorPaul Davis <paul@linuxaudiosystems.com>
Mon, 2 Mar 2009 20:59:13 +0000 (20:59 +0000)
committerPaul Davis <paul@linuxaudiosystems.com>
Mon, 2 Mar 2009 20:59:13 +0000 (20:59 +0000)
git-svn-id: svn://localhost/ardour2/branches/2.0-ongoing@4720 d708f5d6-7413-0410-9779-e7cbd77b26cf

14 files changed:
gtk2_ardour/ardour_image_compositor_socket.h
gtk2_ardour/editor_imageframe.cc
gtk2_ardour/imageframe.cc
gtk2_ardour/imageframe_socket_handler.cc
gtk2_ardour/imageframe_socket_handler.h
gtk2_ardour/imageframe_time_axis.cc
gtk2_ardour/imageframe_view.cc
gtk2_ardour/marker_time_axis.cc
gtk2_ardour/visual_time_axis.cc
libs/ardour/ardour/session.h
libs/ardour/crossfade.cc
libs/ardour/route.cc
libs/ardour/session.cc
libs/ardour/session_state.cc

index 6ed92ef8ac8c66e5d05c3622c179fd050d4be0ff..03f008669d9c414e6f0a8bd4ee64ae9aa17ab643 100644 (file)
@@ -46,6 +46,8 @@ namespace ardourvis
        /** the number of characters used to for the size of the image data message */
        const int32_t IMAGE_DATA_MESSAGE_SIZE_CHARS = 32 ;
 
+       /** the number of characters in a return/reply message */
+       const int32_t RETURN_MSG_SIZE = 3 ;
        // ------------------------------------------------------------------------- //
        // Main Actions
        // we join the action chars with items to create the message
index d2defd40c04f98a06bfec843121a6de1f28664f4..1cb17481e985b9aa34bc3db27e0e46f649f2734a 100644 (file)
@@ -1081,19 +1081,32 @@ Editor::markerview_end_handle_end_trim (ArdourCanvas::Item* item, GdkEvent* even
 void
 Editor::handle_new_imageframe_time_axis_view(const string & track_name, void* src)
 {
+       route_redisplay_does_not_sync_order_keys = true;
+       no_route_list_redisplay = true;
+
        ImageFrameTimeAxis* iftav ;
        iftav = new ImageFrameTimeAxis(track_name, *this, *session, *track_canvas) ;
        iftav->set_time_axis_name(track_name, this) ;
        track_views.push_back(iftav) ;
 
-       TreeModel::Row row = *(route_display_model->append());
 
+       TreeModel::Row row = *(route_display_model->append());
+#if 1 // fake Route workaround
+       row[route_display_columns.route] = 
+               session->new_video_track(iftav->name());
+#endif
        row[route_display_columns.text] = iftav->name();
        row[route_display_columns.tv] = iftav;
+       row[route_display_columns.visible] = true;
        route_list_display.get_selection()->select (row);
 
        iftav->GoingAway.connect(bind(mem_fun(*this, &Editor::remove_route), (TimeAxisView*)iftav)) ;
+       iftav->set_old_order_key (route_display_model->children().size() - 1);
        iftav->gui_changed.connect(mem_fun(*this, &Editor::handle_gui_changes)) ;
+
+       no_route_list_redisplay = false;
+       redisplay_route_list ();
+       route_redisplay_does_not_sync_order_keys = false;
 }
 
 void
index 7ff05ee9e94b693986d7f991d728a309ac0d333b..8758819c8a962212ae4d3c66d20bdde76b4b4497 100644 (file)
@@ -35,7 +35,7 @@ ImageFrame::ImageFrame(Group& parentx, ArtPixBuf* pbuf, double x, double y, Gtk:
 : Item(GNOME_CANVAS_ITEM(g_object_new(get_type(),0)))
 {
   item_construct(parentx);
-  set("pixbuf", pbuf, "x", x,"y", y,"width", w,"height", h, 0);
+  set("pixbuf", pbuf, "x", x,"y", y,"width", w,"height", h, "anchor", anchor, 0);
 }
 
 ImageFrame::ImageFrame(Group& parentx)
index 96b61cafdd301bedc783b692fa32013c31680e6e..9279a177eeb750d4b70ae51531f3e3d58d4d0af9 100644 (file)
@@ -316,8 +316,7 @@ ImageFrameSocketHandler::send_imageframe_time_axis_removed(const string & track_
        send_message(msgBuffer.str()) ;
 
        // XXX should do something with the return
-       std::string retmsg ;
-       read_message(retmsg) ;
+       read_result();
 }
                
 /**
@@ -357,8 +356,7 @@ ImageFrameSocketHandler::send_imageframe_time_axis_renamed(const string & new_id
        send_message(msgBuffer.str()) ;
 
        // XXX should do something with the return
-       std::string retmsg ;
-       read_message(retmsg) ;
+       read_result();
 }
 
 //------------------------
@@ -393,8 +391,7 @@ ImageFrameSocketHandler::send_marker_time_axis_removed(const string & track_id,
        send_message(msgBuffer.str()) ;
 
        // XXX should do something with the return
-       std::string retmsg ;
-       read_message(retmsg) ;
+       read_result();
 }
                
 /**
@@ -434,8 +431,7 @@ ImageFrameSocketHandler::send_marker_time_axis_renamed(const string & new_id, co
        send_message(msgBuffer.str()) ;
        
        // XXX should do something with the return
-       std::string retmsg ;
-       read_message(retmsg) ;
+       read_result();
 }
 
 //---------------------------------
@@ -476,8 +472,7 @@ ImageFrameSocketHandler::send_imageframe_time_axis_group_removed(const string &
        send_message(msgBuffer.str()) ;
 
        // XXX should do something with the return
-       std::string retmsg ;
-       read_message(retmsg) ;
+       read_result();
 }
 
 /**
@@ -521,8 +516,7 @@ ImageFrameSocketHandler::send_imageframe_time_axis_group_renamed(const string &
        send_message(msgBuffer.str()) ;
        
        // XXX should do something with the return
-       std::string retmsg ;
-       read_message(retmsg) ;
+       read_result();
 }
 
 
@@ -561,8 +555,7 @@ ImageFrameSocketHandler::send_imageframe_view_position_change(nframes_t pos, voi
        send_message(msgBuffer.str()) ;
        
        // XXX should do something with the return
-       std::string retmsg ;
-       read_message(retmsg) ;
+       read_result();
 }
                
 /**
@@ -596,8 +589,7 @@ ImageFrameSocketHandler::send_imageframe_view_duration_change(nframes_t dur, voi
        send_message(msgBuffer.str()) ;
        
        // XXX should do something with the return
-       std::string retmsg ;
-       read_message(retmsg) ;
+       read_result();
 }
                
 /**
@@ -632,8 +624,7 @@ ImageFrameSocketHandler::send_imageframe_view_renamed(const string & new_id, con
        send_message(msgBuffer.str()) ;
        
        // XXX should do something with the return
-       std::string retmsg ;
-       read_message(retmsg) ;
+       read_result();
 }
                
 /**
@@ -669,8 +660,7 @@ ImageFrameSocketHandler::send_imageframe_view_removed(const string & item_id, vo
        send_message(msgBuffer.str()) ;
 
        // XXX should do something with the return
-       std::string retmsg ;
-       read_message(retmsg) ;
+       read_result();
 }
 
 
@@ -709,8 +699,7 @@ ImageFrameSocketHandler::send_marker_view_position_change(nframes_t pos, void* s
        send_message(msgBuffer.str()) ;
 
        // XXX should do something with the return
-       std::string retmsg ;
-       read_message(retmsg) ;
+       read_result();
 }
                
 /**
@@ -742,8 +731,7 @@ ImageFrameSocketHandler::send_marker_view_duration_change(nframes_t dur, void* s
        send_message(msgBuffer.str()) ;
 
        // XXX should do something with the return
-       std::string retmsg ;
-       read_message(retmsg) ;
+       read_result();
 }      
 
                
@@ -780,8 +768,7 @@ ImageFrameSocketHandler::send_marker_view_renamed(const string & new_id, const s
        send_message(msgBuffer.str()) ;
        
        // XXX should do something with the return
-       std::string retmsg ;
-       read_message(retmsg) ;
+       read_result();
 }
                
 /**
@@ -815,8 +802,7 @@ ImageFrameSocketHandler::send_marker_view_removed(const string & item_id, void*
        send_message(msgBuffer.str()) ;
 
        // XXX should do something with the return
-       std::string retmsg ;
-       read_message(retmsg) ;
+       read_result();
 }
 
 
@@ -2323,6 +2309,25 @@ ImageFrameSocketHandler::read_message(std::string& msg)
        return(retcode) ;
 }
 
+/**
+ * Reads a reply message ("RT0"/"RT1") from the Socket
+ *
+ * @return true if "RT0" was received,, otherwise false
+ */
+bool
+ImageFrameSocketHandler::read_result()
+{
+       char buf[(ardourvis::RETURN_MSG_SIZE)+1] ;
+       int retcode = ::recv(theArdourToCompositorSocket, buf, ardourvis::RETURN_MSG_SIZE, 0) ;
+       buf[ardourvis::RETURN_MSG_SIZE]='\0';
+       if (retcode > 0) {
+         std::cout << "Received Result [" << buf << "]\n" ;
+         if (retcode == ardourvis::RETURN_MSG_SIZE && buf == ardourvis::RETURN_TRUE) {
+           return (true);
+         }
+       }
+       return(false) ;
+}
 
 /**
  * Convenience method to string_compose and send a success messasge back to the Image Compositor
index 3a87f5bf718e446a2267e37fa9bbe0acc4e97c55..0835f18d3aecf9d23dbcc86497b329b14cd7dc28 100644 (file)
@@ -669,6 +669,13 @@ class ImageFrameSocketHandler : public sigc::trackable
                 * @return the return value from the socket call
                 */
                int read_message(std::string& msg) ;
+
+               /**
+                * Reads a return message ("RT0"/"RT1") from the Socket
+                *
+                * @return true if "RT0" was received,, otherwise false
+                */
+               bool read_result();
                
                /**
                 * Convenience method to compose and send a success messasge back to the Image Compositor
index f3630e715262830ff877b0fc2e8a1cee2a0164c0..700a160dcd99ca87b722e7ccf0b9329fab996152 100644 (file)
@@ -138,6 +138,7 @@ ImageFrameTimeAxis::~ImageFrameTimeAxis ()
 void
 ImageFrameTimeAxis::set_height (uint32_t h)
 {
+       bool changed = (height == 0) || (h != height);
        VisualTimeAxis::set_height(h) ;
        
        // tell out view helper of the change too
@@ -146,8 +147,10 @@ ImageFrameTimeAxis::set_height (uint32_t h)
                view->set_height((double) height) ;
        }
        
+       if (changed) {
        // tell those interested that we have had our height changed
-        gui_changed("track_height",(void*)0); /* EMIT_SIGNAL */
+               gui_changed("track_height",(void*)0); /* EMIT_SIGNAL */
+       }
 }
 
 /**
index f35381301e238d4bf43228ff5fd935581b285fcd..d1291472a4b98b062f53db6d4529a3599f7b5991 100644 (file)
@@ -67,7 +67,7 @@ ImageFrameView::ImageFrameView(const string & item_id,
        uint32_t width,
        uint32_t height,
        uint32_t num_channels)
-  : TimeAxisViewItem(item_id, *parent, *tv, spu, basic_color, start, duration,
+  : TimeAxisViewItem(item_id, *parent, *tv, spu, basic_color, start, duration, false,
                     TimeAxisViewItem::Visibility (TimeAxisViewItem::ShowNameText|
                                                   TimeAxisViewItem::ShowNameHighlight|
                                                   TimeAxisViewItem::ShowFrame|
@@ -86,7 +86,16 @@ ImageFrameView::ImageFrameView(const string & item_id,
        memcpy(the_rgb_data, rgb_data, (width*height*num_channels)) ;
 
        ArtPixBuf* pbuf ;
-       pbuf = art_pixbuf_new_rgba(the_rgb_data, width, height, (num_channels * width));
+       if (num_channels==3)
+         pbuf = art_pixbuf_new_rgb(the_rgb_data, width, height, (num_channels * width));
+       else if (num_channels==4)
+         pbuf = art_pixbuf_new_rgba(the_rgb_data, width, height, (num_channels * width));
+       else  {
+         ; // error unsupported image data format
+         art_free(the_rgb_data);
+         std::cerr << "imageframe_view: unsupported image data format" << std::endl;
+         return;
+       }
        imageframe = 0 ;
        
        //calculate our image width based on the track height
index df041f8f765373e4af48f9057c486f160859a503..f5c80be288c3c729dd34fe6fed291d28b73f18a7 100644 (file)
@@ -109,6 +109,7 @@ MarkerTimeAxis::~MarkerTimeAxis()
 void
 MarkerTimeAxis::set_height (uint32_t h)
 {
+       bool changed = (height == 0) || (h != height);
        VisualTimeAxis::set_height(h) ;
        
        // tell out view helper of the change too
@@ -117,8 +118,10 @@ MarkerTimeAxis::set_height (uint32_t h)
                view->set_height((double) height) ;
        }
        
+       if (changed) {
        // tell those interested that we have had our height changed
         gui_changed("track_height",(void*)0) ; /* EMIT_SIGNAL */
+       }
 }
 
 /**
index 2035293cf821ba83b3830b4c50477a890e84349b..468b9671866c38f5c2f1b4e118d947d4bf854e84 100644 (file)
@@ -84,18 +84,22 @@ VisualTimeAxis::VisualTimeAxis(const string & name, PublicEditor& ed, ARDOUR::Se
        size_button.set_name("TrackSizeButton") ;
        visual_button.set_name("TrackVisualButton") ;
        hide_button.set_name("TrackRemoveButton") ;
-       hide_button.add(*(Gtk::manage(new Gtk::Image(get_xpm("small_x.xpm")))));
+       hide_button.add (*(manage (new Image (::get_icon("hide")))));
+       hide_button.show_all ();
+
        size_button.signal_button_release_event().connect (mem_fun (*this, &VisualTimeAxis::size_click)) ;
        visual_button.signal_clicked().connect (mem_fun (*this, &VisualTimeAxis::visual_click)) ;
        hide_button.signal_clicked().connect (mem_fun (*this, &VisualTimeAxis::hide_click)) ;
        ARDOUR_UI::instance()->tooltips().set_tip(size_button,_("Display Height")) ;
        ARDOUR_UI::instance()->tooltips().set_tip(visual_button, _("Visual options")) ;
        ARDOUR_UI::instance()->tooltips().set_tip(hide_button, _("Hide this track")) ;
-               
+
+if (0) {               
+               /* old school - when we used to put an extra row of buttons in place */
        controls_table.attach (hide_button, 0, 1, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
        controls_table.attach (visual_button, 1, 2, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
        controls_table.attach (size_button, 2, 3, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
-
+}
        /* remove focus from the buttons */
        size_button.unset_flags(Gtk::CAN_FOCUS) ;
        hide_button.unset_flags(Gtk::CAN_FOCUS) ;
@@ -154,15 +158,21 @@ VisualTimeAxis::set_height(uint32_t h)
        if (h >= hNormal) {
                hide_name_label ();
                show_name_entry ();
-               other_button_hbox.show_all() ;
+               visual_button.show();
+               size_button.show();
+               hide_button.show();
        } else if (h >= hSmaller) {
                hide_name_label ();
                show_name_entry ();
-               other_button_hbox.hide_all() ;
+               visual_button.hide ();
+               size_button.hide ();
+               hide_button.hide();
        } else if (h >= hSmall) {
                hide_name_entry ();
                show_name_label ();
-               other_button_hbox.hide_all() ;
+               visual_button.hide ();
+               size_button.hide ();
+               hide_button.hide ();
        }
 }
 
index b8b0c92512c5d5292a87f61dc9e74b818ded245f..6c97349c509a52dc7afb53ee427c92e2793c39c0 100644 (file)
@@ -504,7 +504,13 @@ class Session : public PBD::StatefulDestructible
        std::list<boost::shared_ptr<AudioTrack> > new_audio_track (int input_channels, int output_channels, TrackMode mode = Normal, uint32_t how_many = 1);
        RouteList new_audio_route (int input_channels, int output_channels, uint32_t how_many);
        RouteList new_route_from_template (uint32_t how_many, const std::string& template_path);
-       
+
+       /* this is a hack put in to support work on video tracks by Robin Gareus. Nobody 
+          should assume that this works yet (February 2009)
+       */
+
+       boost::shared_ptr<Route> new_video_track (string name);
+
        void   remove_route (boost::shared_ptr<Route>);
 
        void   resort_routes ();
index f0cfb9eeda78441eaa261213f958b77b9267bb7a..7a244047214920477b3db7a4df2c02923647a8a6 100644 (file)
@@ -162,6 +162,12 @@ Crossfade::Crossfade (const Playlist& playlist, XMLNode& node)
        if (set_state (node)) {
                throw failed_constructor();
        }
+
+       /* we should not need to do this here, since all values were set via XML. however
+          some older sessions may have bugs and this allows us to fix them.
+       */
+       
+       update ();
 }
 
 Crossfade::Crossfade (const Crossfade &orig, boost::shared_ptr<AudioRegion> newin, boost::shared_ptr<AudioRegion> newout)
@@ -468,11 +474,11 @@ Crossfade::update ()
                break;
                
        case EndOfIn:
-               _position = _in->last_frame() - _length;
+               _position = _in->last_frame() - _length + 1;
                break;
                
        case EndOfOut:
-               _position = _out->last_frame() - _length;
+               _position = _out->last_frame() - _length + 1;
        }
 
        return true;
index 50f03854fb5f74dfcd773935eca1d629cc7295bc..47b94432e4981b44c0f8f88d0c83164e27442653 100644 (file)
@@ -1834,6 +1834,7 @@ Route::_set_state (const XMLNode& node, bool call_base)
                        string coutname = _name;
                        coutname += _("[control]");
 
+                       delete _control_outs;
                        _control_outs = new IO (_session, coutname);
                        _control_outs->set_state (**(child->children().begin()));
 
index bad699b12a8f4e43a976c4561ab4686a4117ba7c..7019910381051ba00a28f09aaba36887bbeca658 100644 (file)
@@ -2115,6 +2115,25 @@ Session::new_route_from_template (uint32_t how_many, const std::string& template
        return ret;
 }
 
+boost::shared_ptr<Route>
+Session::new_video_track (string name)
+{
+       uint32_t control_id = ntracks() + nbusses() + 1;
+       shared_ptr<Route> new_route (
+               new Route ( *this, name, -1, -1, -1, -1, Route::Flag(0), ARDOUR::DataType::NIL));
+       new_route->set_remote_control_id (control_id);
+
+       RouteList rl;
+       rl.push_back (new_route);
+        {
+               RCUWriter<RouteList> writer (routes);
+               shared_ptr<RouteList> r = writer.get_copy ();
+                r->insert (r->end(), rl.begin(), rl.end());
+               resort_routes_using (r);
+        }
+       return new_route;
+}
+
 void
 Session::add_routes (RouteList& new_routes, bool save)
 {
index f206d186445cbd63b5acd1a2bdbd4a7ee9e40db4..73d8ba2921146fda7b6336129c79d114bdfbdb70 100644 (file)
@@ -1359,6 +1359,11 @@ Session::load_routes (const XMLNode& node)
        set_dirty();
 
        for (niter = nlist.begin(); niter != nlist.end(); ++niter) {
+               if ((*niter)->property ("default-type")->value() == "unknown" ) {
+                 std::cout << "ignoring route with type unknown. (video-track)" << std::endl;
+                 // Note: this may mess up remote_control IDs or more..
+                 continue;
+               }
 
                boost::shared_ptr<Route> route (XMLRouteFactory (**niter));