From 6eccd043f22d9ddfa6418c4342e0a9fd5476a7dd Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Mon, 2 Mar 2009 20:59:13 +0000 Subject: [PATCH] ICS (image compositor socket) patches from robin gareus, to keep ICS alive in 2.X; variations on giso's proposed fix for #1731 (x-fade clicking) git-svn-id: svn://localhost/ardour2/branches/2.0-ongoing@4720 d708f5d6-7413-0410-9779-e7cbd77b26cf --- gtk2_ardour/ardour_image_compositor_socket.h | 2 + gtk2_ardour/editor_imageframe.cc | 15 ++++- gtk2_ardour/imageframe.cc | 2 +- gtk2_ardour/imageframe_socket_handler.cc | 61 +++++++++++--------- gtk2_ardour/imageframe_socket_handler.h | 7 +++ gtk2_ardour/imageframe_time_axis.cc | 5 +- gtk2_ardour/imageframe_view.cc | 13 ++++- gtk2_ardour/marker_time_axis.cc | 3 + gtk2_ardour/visual_time_axis.cc | 22 +++++-- libs/ardour/ardour/session.h | 8 ++- libs/ardour/crossfade.cc | 10 +++- libs/ardour/route.cc | 1 + libs/ardour/session.cc | 19 ++++++ libs/ardour/session_state.cc | 5 ++ 14 files changed, 131 insertions(+), 42 deletions(-) diff --git a/gtk2_ardour/ardour_image_compositor_socket.h b/gtk2_ardour/ardour_image_compositor_socket.h index 6ed92ef8ac..03f008669d 100644 --- a/gtk2_ardour/ardour_image_compositor_socket.h +++ b/gtk2_ardour/ardour_image_compositor_socket.h @@ -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 diff --git a/gtk2_ardour/editor_imageframe.cc b/gtk2_ardour/editor_imageframe.cc index d2defd40c0..1cb17481e9 100644 --- a/gtk2_ardour/editor_imageframe.cc +++ b/gtk2_ardour/editor_imageframe.cc @@ -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 diff --git a/gtk2_ardour/imageframe.cc b/gtk2_ardour/imageframe.cc index 7ff05ee9e9..8758819c8a 100644 --- a/gtk2_ardour/imageframe.cc +++ b/gtk2_ardour/imageframe.cc @@ -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) diff --git a/gtk2_ardour/imageframe_socket_handler.cc b/gtk2_ardour/imageframe_socket_handler.cc index 96b61cafdd..9279a177ee 100644 --- a/gtk2_ardour/imageframe_socket_handler.cc +++ b/gtk2_ardour/imageframe_socket_handler.cc @@ -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 diff --git a/gtk2_ardour/imageframe_socket_handler.h b/gtk2_ardour/imageframe_socket_handler.h index 3a87f5bf71..0835f18d3a 100644 --- a/gtk2_ardour/imageframe_socket_handler.h +++ b/gtk2_ardour/imageframe_socket_handler.h @@ -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 diff --git a/gtk2_ardour/imageframe_time_axis.cc b/gtk2_ardour/imageframe_time_axis.cc index f3630e7152..700a160dcd 100644 --- a/gtk2_ardour/imageframe_time_axis.cc +++ b/gtk2_ardour/imageframe_time_axis.cc @@ -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 */ + } } /** diff --git a/gtk2_ardour/imageframe_view.cc b/gtk2_ardour/imageframe_view.cc index f35381301e..d1291472a4 100644 --- a/gtk2_ardour/imageframe_view.cc +++ b/gtk2_ardour/imageframe_view.cc @@ -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 diff --git a/gtk2_ardour/marker_time_axis.cc b/gtk2_ardour/marker_time_axis.cc index df041f8f76..f5c80be288 100644 --- a/gtk2_ardour/marker_time_axis.cc +++ b/gtk2_ardour/marker_time_axis.cc @@ -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 */ + } } /** diff --git a/gtk2_ardour/visual_time_axis.cc b/gtk2_ardour/visual_time_axis.cc index 2035293cf8..468b967186 100644 --- a/gtk2_ardour/visual_time_axis.cc +++ b/gtk2_ardour/visual_time_axis.cc @@ -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 (); } } diff --git a/libs/ardour/ardour/session.h b/libs/ardour/ardour/session.h index b8b0c92512..6c97349c50 100644 --- a/libs/ardour/ardour/session.h +++ b/libs/ardour/ardour/session.h @@ -504,7 +504,13 @@ class Session : public PBD::StatefulDestructible std::list > 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 new_video_track (string name); + void remove_route (boost::shared_ptr); void resort_routes (); diff --git a/libs/ardour/crossfade.cc b/libs/ardour/crossfade.cc index f0cfb9eeda..7a24404721 100644 --- a/libs/ardour/crossfade.cc +++ b/libs/ardour/crossfade.cc @@ -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 newin, boost::shared_ptr 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; diff --git a/libs/ardour/route.cc b/libs/ardour/route.cc index 50f03854fb..47b94432e4 100644 --- a/libs/ardour/route.cc +++ b/libs/ardour/route.cc @@ -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())); diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc index bad699b12a..7019910381 100644 --- a/libs/ardour/session.cc +++ b/libs/ardour/session.cc @@ -2115,6 +2115,25 @@ Session::new_route_from_template (uint32_t how_many, const std::string& template return ret; } +boost::shared_ptr +Session::new_video_track (string name) +{ + uint32_t control_id = ntracks() + nbusses() + 1; + shared_ptr 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 writer (routes); + shared_ptr 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) { diff --git a/libs/ardour/session_state.cc b/libs/ardour/session_state.cc index f206d18644..73d8ba2921 100644 --- a/libs/ardour/session_state.cc +++ b/libs/ardour/session_state.cc @@ -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 (XMLRouteFactory (**niter));