mirror of
https://github.com/Ardour/ardour.git
synced 2026-01-10 23:46:20 +01:00
WIP: Add SessionControllerHandleRef
This can be used to ensure that whenever this has a reference to a session, it also has a session controller set up to use that session. Towards sharing code between ARDOUR_UI and SessionController. WIP: SessionHandleRef|Ptr are not safe abstractions, so this isn't either, since derived types can and do manually mess around with the session pointer. Probably lifetime bugs here, and probably a good idea to statically prevent that, but a /lot/ of existing code uses _session directly.
This commit is contained in:
parent
83626ae637
commit
125f7ea273
4 changed files with 130 additions and 2 deletions
|
|
@ -76,7 +76,7 @@
|
|||
#include "ardour/types.h"
|
||||
#include "ardour/utils.h"
|
||||
#include "ardour/plugin.h"
|
||||
#include "ardour/session_handle.h"
|
||||
#include "ardour/session_controller_handle.h"
|
||||
#include "ardour/system_exec.h"
|
||||
|
||||
#include "video_timeline.h"
|
||||
|
|
@ -187,7 +187,7 @@ namespace ArdourWidgets {
|
|||
#define MAX_LUA_ACTION_SCRIPTS 32
|
||||
#define MAX_LUA_ACTION_BUTTONS 12
|
||||
|
||||
class ARDOUR_UI : public Gtkmm2ext::UI, public ARDOUR::SessionHandlePtr, public TransportControlProvider
|
||||
class ARDOUR_UI : public Gtkmm2ext::UI, public ARDOUR::SessionControllerHandlePtr, public TransportControlProvider
|
||||
{
|
||||
public:
|
||||
ARDOUR_UI (int *argcp, char **argvp[], const char* localedir);
|
||||
|
|
|
|||
58
libs/ardour/ardour/session_controller_handle.h
Normal file
58
libs/ardour/ardour/session_controller_handle.h
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
/*
|
||||
* Copyright (C) 2009-2017 Paul Davis <paul@linuxaudiosystems.com>
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef __libardour_session_controller_handle_h__
|
||||
#define __libardour_session_controller_handle_h__
|
||||
|
||||
#include "ardour/libardour_visibility.h"
|
||||
#include "ardour/session_controller.h"
|
||||
#include "ardour/session_handle.h"
|
||||
|
||||
namespace ARDOUR {
|
||||
|
||||
class Session;
|
||||
class SessionController;
|
||||
|
||||
class LIBARDOUR_API SessionControllerHandleRef : public SessionHandleRef
|
||||
{
|
||||
public:
|
||||
SessionControllerHandleRef (Session& s);
|
||||
|
||||
virtual ~SessionControllerHandleRef ();
|
||||
|
||||
protected:
|
||||
SessionController _controller;
|
||||
};
|
||||
|
||||
class LIBARDOUR_API SessionControllerHandlePtr : public SessionHandlePtr
|
||||
{
|
||||
public:
|
||||
SessionControllerHandlePtr (Session* s);
|
||||
SessionControllerHandlePtr ();
|
||||
|
||||
virtual ~SessionControllerHandlePtr ();
|
||||
|
||||
virtual void set_session (Session *);
|
||||
|
||||
protected:
|
||||
SessionController _controller;
|
||||
};
|
||||
|
||||
} /* namespace */
|
||||
|
||||
#endif /* __libardour_session_controller_handle_h__ */
|
||||
69
libs/ardour/session_controller_handle.cc
Normal file
69
libs/ardour/session_controller_handle.cc
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
/*
|
||||
* Copyright (C) 2009-2016 Paul Davis <paul@linuxaudiosystems.com>
|
||||
*
|
||||
* 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 "pbd/demangle.h"
|
||||
#include "pbd/error.h"
|
||||
|
||||
#include "ardour/boost_debug.h"
|
||||
#include "ardour/session.h"
|
||||
#include "ardour/session_controller.h"
|
||||
#include "ardour/session_controller_handle.h"
|
||||
|
||||
#include "pbd/i18n.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace ARDOUR;
|
||||
using namespace PBD;
|
||||
|
||||
SessionControllerHandleRef::SessionControllerHandleRef (Session& s)
|
||||
: SessionHandleRef (s)
|
||||
, _controller (&s)
|
||||
{
|
||||
_session.DropReferences.connect_same_thread (*this, boost::bind (&SessionControllerHandleRef::session_going_away, this));
|
||||
_session.Destroyed.connect_same_thread (*this, boost::bind (&SessionControllerHandleRef::insanity_check, this));
|
||||
}
|
||||
|
||||
SessionControllerHandleRef::~SessionControllerHandleRef ()
|
||||
{
|
||||
}
|
||||
|
||||
/*-------------------------*/
|
||||
|
||||
SessionControllerHandlePtr::SessionControllerHandlePtr (Session* s)
|
||||
: SessionHandlePtr (s)
|
||||
, _controller (s)
|
||||
{
|
||||
}
|
||||
|
||||
SessionControllerHandlePtr::SessionControllerHandlePtr ()
|
||||
: SessionHandlePtr ()
|
||||
, _controller (NULL)
|
||||
{
|
||||
}
|
||||
|
||||
SessionControllerHandlePtr::~SessionControllerHandlePtr ()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
SessionControllerHandlePtr::set_session (Session* s)
|
||||
{
|
||||
SessionHandlePtr::set_session (s);
|
||||
|
||||
_controller = SessionController (s);
|
||||
}
|
||||
|
|
@ -214,6 +214,7 @@ libardour_sources = [
|
|||
'session_command.cc',
|
||||
'session_configuration.cc',
|
||||
'session_controller.cc',
|
||||
'session_controller_handle.cc',
|
||||
'session_directory.cc',
|
||||
'session_events.cc',
|
||||
'session_export.cc',
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue