2020-02-20 07:12:36 -05:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2009-2012 Carl Hetherington <carl@carlh.net>
|
|
|
|
* Copyright (C) 2009-2014 David Robillard <d@drobilla.net>
|
|
|
|
* Copyright (C) 2009-2017 Paul Davis <paul@linuxaudiosystems.com>
|
|
|
|
* Copyright (C) 2012-2016 Tim Mayberry <mojofunk@gmail.com>
|
|
|
|
* Copyright (C) 2013-2019 Robin Gareus <robin@gareus.org>
|
|
|
|
* Copyright (C) 2015-2016 Ben Loftis <ben@harrisonconsoles.com>
|
|
|
|
* Copyright (C) 2015-2018 John Emmas <john@creativepost.co.uk>
|
|
|
|
* Copyright (C) 2015 Johannes Mueller <github@johannes-mueller.org>
|
|
|
|
* Copyright (C) 2016-2018 Len Ovens <len@ovenwerks.net>
|
2021-06-13 10:32:18 -04:00
|
|
|
* Copyright (C) 2020 Luciano Iam <oss@lucianoiam.com>
|
2020-02-20 07:12:36 -05:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "ardour/session.h"
|
|
|
|
|
|
|
|
#include "ardour_websockets.h"
|
|
|
|
|
|
|
|
using namespace ARDOUR;
|
|
|
|
using namespace ArdourSurface;
|
|
|
|
|
2024-10-19 18:16:01 -04:00
|
|
|
#include "pbd/abstract_ui.inc.cc" // instantiate template
|
2020-02-20 07:12:36 -05:00
|
|
|
|
|
|
|
ArdourWebsockets::ArdourWebsockets (Session& s)
|
2020-04-09 09:57:09 -04:00
|
|
|
: ControlProtocol (s, X_ (surface_name))
|
2020-02-20 07:12:36 -05:00
|
|
|
, AbstractUI<ArdourWebsocketsUIRequest> (name ())
|
2020-05-30 13:08:27 -04:00
|
|
|
, _mixer (*this)
|
|
|
|
, _transport (*this)
|
2020-02-20 07:12:36 -05:00
|
|
|
, _server (*this)
|
2021-06-13 14:54:43 -04:00
|
|
|
, _feedback (*this)
|
2020-02-20 07:12:36 -05:00
|
|
|
, _dispatcher (*this)
|
|
|
|
{
|
2020-05-30 13:08:27 -04:00
|
|
|
_components.push_back (&_mixer);
|
|
|
|
_components.push_back (&_transport);
|
2020-02-23 10:03:59 -05:00
|
|
|
_components.push_back (&_server);
|
|
|
|
_components.push_back (&_feedback);
|
|
|
|
_components.push_back (&_dispatcher);
|
2020-02-20 07:12:36 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
ArdourWebsockets::~ArdourWebsockets ()
|
|
|
|
{
|
2020-02-23 10:03:59 -05:00
|
|
|
stop ();
|
2020-02-20 07:12:36 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
ArdourWebsockets::set_active (bool yn)
|
|
|
|
{
|
2020-02-23 10:03:59 -05:00
|
|
|
if (yn != active ()) {
|
|
|
|
if (yn) {
|
|
|
|
if (start ()) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (stop ()) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return ControlProtocol::set_active (yn);
|
2020-02-20 07:12:36 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ArdourWebsockets::thread_init ()
|
|
|
|
{
|
2020-02-23 10:03:59 -05:00
|
|
|
PBD::notify_event_loops_about_thread_creation (pthread_self (), event_loop_name (), 2048);
|
|
|
|
SessionEvent::create_per_thread_pool (event_loop_name (), 128);
|
2020-02-20 07:12:36 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ArdourWebsockets::do_request (ArdourWebsocketsUIRequest* req)
|
|
|
|
{
|
2020-02-23 10:03:59 -05:00
|
|
|
if (req->type == CallSlot) {
|
|
|
|
call_slot (MISSING_INVALIDATOR, req->the_slot);
|
|
|
|
} else if (req->type == Quit) {
|
|
|
|
stop ();
|
|
|
|
}
|
2020-02-20 07:12:36 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
ArdourWebsockets::start ()
|
|
|
|
{
|
2020-02-23 10:03:59 -05:00
|
|
|
/* startup the event loop thread */
|
|
|
|
BaseUI::run ();
|
2020-02-20 07:12:36 -05:00
|
|
|
|
2020-02-23 10:03:59 -05:00
|
|
|
for (std::vector<SurfaceComponent*>::iterator it = _components.begin ();
|
|
|
|
it != _components.end (); ++it) {
|
|
|
|
int rc = (*it)->start ();
|
|
|
|
if (rc != 0) {
|
2020-04-09 17:35:46 -04:00
|
|
|
BaseUI::quit ();
|
2020-02-23 10:03:59 -05:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
2020-02-20 07:12:36 -05:00
|
|
|
|
2020-02-23 10:03:59 -05:00
|
|
|
PBD::info << "ArdourWebsockets: started" << endmsg;
|
2020-02-20 07:12:36 -05:00
|
|
|
|
2020-02-23 10:03:59 -05:00
|
|
|
return 0;
|
2020-02-20 07:12:36 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2020-02-23 10:03:59 -05:00
|
|
|
ArdourWebsockets::stop ()
|
|
|
|
{
|
|
|
|
for (std::vector<SurfaceComponent*>::iterator it = _components.begin ();
|
|
|
|
it != _components.end (); ++it) {
|
|
|
|
(*it)->stop ();
|
|
|
|
}
|
|
|
|
|
|
|
|
BaseUI::quit ();
|
2020-02-20 07:12:36 -05:00
|
|
|
|
2020-02-23 10:03:59 -05:00
|
|
|
PBD::info << "ArdourWebsockets: stopped" << endmsg;
|
2020-02-20 07:12:36 -05:00
|
|
|
|
2020-02-23 10:03:59 -05:00
|
|
|
return 0;
|
2020-02-20 07:12:36 -05:00
|
|
|
}
|