From 1653b37ce931a02f0b89b23f369e1233d9705bab Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Mon, 29 Oct 2012 15:45:49 +0000 Subject: [PATCH] multichannel tweaks and a bit more debugging git-svn-id: svn://localhost/ardour2/branches/3.0-SG@13358 d708f5d6-7413-0410-9779-e7cbd77b26cf --- libs/ardour/ardour/soundgrid.h | 4 ++-- libs/ardour/sg_rack.cc | 17 ++++++++++++----- libs/ardour/soundgrid.mm | 33 ++++++++++++++++++++++++++------- 3 files changed, 40 insertions(+), 14 deletions(-) diff --git a/libs/ardour/ardour/soundgrid.h b/libs/ardour/ardour/soundgrid.h index af1697ef2d..be0feeb01e 100644 --- a/libs/ardour/ardour/soundgrid.h +++ b/libs/ardour/ardour/soundgrid.h @@ -86,8 +86,8 @@ class SoundGrid : public boost::noncopyable static PBD::Signal0 Shutdown; - bool add_rack_synchronous (uint32_t clusterType, int32_t process_group, uint32_t &trackHandle); - bool add_rack_asynchronous (uint32_t clusterType, int32_t process_group); + bool add_rack_synchronous (uint32_t clusterType, int32_t process_group, uint32_t channels, uint32_t& trackHandle); + bool add_rack_asynchronous (uint32_t clusterType, int32_t process_group, uint32_t channels); bool remove_rack_synchronous (uint32_t clusterType, uint32_t trackHandle); bool remove_all_racks_synchronous (); diff --git a/libs/ardour/sg_rack.cc b/libs/ardour/sg_rack.cc index de1b096797..a9a5318cb6 100644 --- a/libs/ardour/sg_rack.cc +++ b/libs/ardour/sg_rack.cc @@ -17,6 +17,8 @@ */ +#include + #include "pbd/compose.h" #include "pbd/failed_constructor.h" @@ -37,13 +39,14 @@ using std::string; SoundGridRack::SoundGridRack (Session& s, Route& r, const std::string& name) : SessionObject (s, name) , _route (r) + , _rack_id (UINT32_MAX) { - DEBUG_TRACE (DEBUG::SoundGrid, string_compose ("Creating SG Chainer for %1\n", r.name())); - if (r.is_hidden()) { return; } + DEBUG_TRACE (DEBUG::SoundGrid, string_compose ("Creating SG Chainer for %1\n", r.name())); + if (dynamic_cast (&r) != 0) { _cluster_type = eClusterType_InputTrack; } else { @@ -57,7 +60,9 @@ SoundGridRack::SoundGridRack (Session& s, Route& r, const std::string& name) } } - if (SoundGrid::instance().add_rack_synchronous (_cluster_type, 0, _rack_id)) { + const int32_t process_group = 0; + + if (SoundGrid::instance().add_rack_synchronous (_cluster_type, process_group, r.n_outputs().n_audio(), _rack_id)) { throw failed_constructor(); } @@ -70,8 +75,10 @@ SoundGridRack::SoundGridRack (Session& s, Route& r, const std::string& name) SoundGridRack::~SoundGridRack () { - DEBUG_TRACE (DEBUG::SoundGrid, string_compose ("Destroying SG Chainer for %1\n", _route.name())); - (void) SoundGrid::instance().remove_rack_synchronous (_cluster_type, _rack_id); + if (_rack_id != UINT32_MAX) { + DEBUG_TRACE (DEBUG::SoundGrid, string_compose ("Destroying SG Chainer for %1\n", _route.name())); + (void) SoundGrid::instance().remove_rack_synchronous (_cluster_type, _rack_id); + } } int diff --git a/libs/ardour/soundgrid.mm b/libs/ardour/soundgrid.mm index b50225b497..c90406e2a1 100644 --- a/libs/ardour/soundgrid.mm +++ b/libs/ardour/soundgrid.mm @@ -313,9 +313,11 @@ SoundGrid::set (WSEvent* ev, const std::string& /*what*/) ev->sourceController = (WSDControllerHandle) this; if (_callback_table.setEventProc (_host_handle, this, ev) != eNoErr) { + DEBUG_TRACE (DEBUG::SoundGrid, "Set failure\n"); return -1; } + DEBUG_TRACE (DEBUG::SoundGrid, "Set success\n"); return 0; } @@ -657,11 +659,13 @@ SoundGrid::assignment_complete (WSCommand* cmd) /* Actually do stuff */ bool -SoundGrid::add_rack_synchronous (uint32_t clusterType, int32_t process_group, uint32_t &trackHandle) +SoundGrid::add_rack_synchronous (uint32_t clusterType, int32_t process_group, uint32_t channels, uint32_t &trackHandle) { WSAddTrackCommand myCommand; - command (Init_WSAddTrackCommand (&myCommand, clusterType, 1, process_group, (WSDControllerHandle)this, 0)); + channels = 1; + + command (Init_WSAddTrackCommand (&myCommand, clusterType, channels, process_group, (WSDControllerHandle)this, 0)); if (0 == myCommand.m_command.out_status) { trackHandle = myCommand.out_trackID.clusterHandle; @@ -672,12 +676,13 @@ SoundGrid::add_rack_synchronous (uint32_t clusterType, int32_t process_group, ui } bool -SoundGrid::add_rack_asynchronous (uint32_t clusterType, int32_t process_group) +SoundGrid::add_rack_asynchronous (uint32_t clusterType, int32_t process_group, uint32_t channels) { WSAddTrackCommand *pMyCommand = new WSAddTrackCommand; - WMSDErr errCode = command (Init_WSAddTrackCommand (pMyCommand, clusterType, 1, process_group, (WSDControllerHandle)this, pMyCommand)); - - printf ("AddRack Command result = %d, command status = %d\n", errCode, pMyCommand->m_command.out_status); + + channels = 1; + + WMSDErr errCode = command (Init_WSAddTrackCommand (pMyCommand, clusterType, channels, process_group, (WSDControllerHandle)this, pMyCommand)); return (WMSD_Pending == errCode); } @@ -718,7 +723,7 @@ SoundGrid::set_gain (uint32_t in_clusterType, uint32_t in_trackHandle, double in faderEvent.controlID.sectionControlID.sectionType = eControlType_Output; faderEvent.controlID.sectionControlID.sectionIndex = eControlType_Output_Local; - faderEvent.controlID.sectionControlID.channelIndex = 0; + faderEvent.controlID.sectionControlID.channelIndex = wvEnum_Unknown; faderEvent.controlID.sectionControlID.controlID = eControlID_Output_Gain; return set (&faderEvent, "fader level"); @@ -866,6 +871,20 @@ SoundGrid::sg_port_as_jack_port (const Port& sgport) return jack_port; } +#if 0 +void +SoundGrid::drop_sg_jack_mapping (const string& jack_port) +{ + jack_soundgrid_map.remove (jack_port); + + for (SG_JACKMap::iterator i = soundgrid_jack_map.begin(); i != soundgrid_jack_map.end(); ++i) { + if (i->second == jack_port) { + soundgrid_jack_map.erase (i); + } + } +} +#endif + int SoundGrid::connect (const Port& src, const Port& dst) {