mirror of
https://github.com/Ardour/ardour.git
synced 2026-01-30 08:53:08 +01:00
tighten up error handling a little bit during various setup functions for Mackie Control
This commit is contained in:
parent
018465f739
commit
79fed95c1b
4 changed files with 41 additions and 14 deletions
|
|
@ -393,7 +393,9 @@ MackieControlProtocol::set_active (bool yn)
|
|||
|
||||
BaseUI::run ();
|
||||
|
||||
create_surfaces ();
|
||||
if (create_surfaces ()) {
|
||||
return -1;
|
||||
}
|
||||
connect_session_signals ();
|
||||
_active = true;
|
||||
update_surfaces ();
|
||||
|
|
@ -606,7 +608,7 @@ MackieControlProtocol::set_profile (const string& profile_name)
|
|||
_device_profile = d->second;
|
||||
}
|
||||
|
||||
void
|
||||
int
|
||||
MackieControlProtocol::set_device (const string& device_name, bool allow_activation)
|
||||
{
|
||||
map<string,DeviceInfo>::iterator d = DeviceInfo::device_info.find (device_name);
|
||||
|
|
@ -615,7 +617,7 @@ MackieControlProtocol::set_device (const string& device_name, bool allow_activat
|
|||
device_name, allow_activation));
|
||||
|
||||
if (d == DeviceInfo::device_info.end()) {
|
||||
return;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (_active) {
|
||||
|
|
@ -629,13 +631,16 @@ MackieControlProtocol::set_device (const string& device_name, bool allow_activat
|
|||
set_active (true);
|
||||
} else {
|
||||
if (_active) {
|
||||
create_surfaces ();
|
||||
if (create_surfaces ()) {
|
||||
return -1;
|
||||
}
|
||||
switch_banks (0, true);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
int
|
||||
MackieControlProtocol::create_surfaces ()
|
||||
{
|
||||
string device_name;
|
||||
|
|
@ -652,7 +657,13 @@ MackieControlProtocol::create_surfaces ()
|
|||
|
||||
for (uint32_t n = 0; n < 1 + _device_info.extenders(); ++n) {
|
||||
|
||||
boost::shared_ptr<Surface> surface (new Surface (*this, device_name, n, stype));
|
||||
boost::shared_ptr<Surface> surface;
|
||||
|
||||
try {
|
||||
surface.reset (new Surface (*this, device_name, n, stype));
|
||||
} catch (...) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
{
|
||||
Glib::Threads::Mutex::Lock lm (surfaces_lock);
|
||||
|
|
@ -698,6 +709,8 @@ MackieControlProtocol::create_surfaces ()
|
|||
g_source_ref (psrc->gobj());
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -1573,14 +1586,17 @@ MackieControlProtocol::set_ipmidi_base (int16_t portnum)
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
int
|
||||
MackieControlProtocol::ipmidi_restart ()
|
||||
{
|
||||
clear_ports ();
|
||||
clear_surfaces ();
|
||||
create_surfaces ();
|
||||
if (create_surfaces ()) {
|
||||
return -1;
|
||||
}
|
||||
switch_banks (_current_initial_bank, true);
|
||||
needs_ipmidi_restart = false;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
|||
|
|
@ -120,8 +120,8 @@ class MackieControlProtocol
|
|||
Mackie::DeviceProfile& device_profile() { return _device_profile; }
|
||||
|
||||
int set_active (bool yn);
|
||||
void set_device (const std::string&, bool allow_activation = true);
|
||||
void set_profile (const std::string&);
|
||||
int set_device (const std::string&, bool allow_activation = true);
|
||||
void set_profile (const std::string&);
|
||||
|
||||
FlipMode flip_mode () const { return _flip_mode; }
|
||||
ViewMode view_mode () const { return _view_mode; }
|
||||
|
|
@ -291,7 +291,7 @@ class MackieControlProtocol
|
|||
|
||||
ARDOUR::RouteNotificationList _last_selected_routes;
|
||||
|
||||
void create_surfaces ();
|
||||
int create_surfaces ();
|
||||
bool periodic();
|
||||
void build_gui ();
|
||||
bool midi_input_handler (Glib::IOCondition ioc, MIDI::Port* port);
|
||||
|
|
@ -301,8 +301,8 @@ class MackieControlProtocol
|
|||
void build_button_map ();
|
||||
void gui_track_selection_changed (ARDOUR::RouteNotificationListPtr, bool save_list);
|
||||
void _gui_track_selection_changed (ARDOUR::RouteNotificationList*, bool save_list);
|
||||
void ipmidi_restart ();
|
||||
void initialize ();
|
||||
int ipmidi_restart ();
|
||||
void initialize ();
|
||||
|
||||
/* BUTTON HANDLING */
|
||||
|
||||
|
|
|
|||
|
|
@ -86,7 +86,11 @@ Surface::Surface (MackieControlProtocol& mcp, const std::string& device_name, ui
|
|||
{
|
||||
DEBUG_TRACE (DEBUG::MackieControl, "Surface::Surface init\n");
|
||||
|
||||
_port = new SurfacePort (*this);
|
||||
try {
|
||||
_port = new SurfacePort (*this);
|
||||
} catch (...) {
|
||||
throw failed_constructor ();
|
||||
}
|
||||
|
||||
/* only the first Surface object has global controls */
|
||||
|
||||
|
|
|
|||
|
|
@ -23,6 +23,8 @@
|
|||
#include <sigc++/sigc++.h>
|
||||
#include <boost/shared_array.hpp>
|
||||
|
||||
#include "pbd/failed_constructor.h"
|
||||
|
||||
#include "midi++/types.h"
|
||||
#include "midi++/ipmidi_port.h"
|
||||
|
||||
|
|
@ -49,6 +51,7 @@ using namespace ARDOUR;
|
|||
SurfacePort::SurfacePort (Surface& s)
|
||||
: _surface (&s)
|
||||
{
|
||||
|
||||
if (_surface->mcp().device_info().uses_ipmidi()) {
|
||||
_input_port = new MIDI::IPMIDIPort (_surface->mcp().ipmidi_base() +_surface->number());
|
||||
_output_port = _input_port;
|
||||
|
|
@ -56,6 +59,10 @@ SurfacePort::SurfacePort (Surface& s)
|
|||
_async_in = AudioEngine::instance()->register_input_port (DataType::MIDI, string_compose (_("%1 in"), _surface->name()), true);
|
||||
_async_out = AudioEngine::instance()->register_output_port (DataType::MIDI, string_compose (_("%1 out"), _surface->name()), true);
|
||||
|
||||
if (_async_in == 0 || _async_out == 0) {
|
||||
throw failed_constructor();
|
||||
}
|
||||
|
||||
_input_port = boost::dynamic_pointer_cast<AsyncMIDIPort>(_async_in).get();
|
||||
_output_port = boost::dynamic_pointer_cast<AsyncMIDIPort>(_async_out).get();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue