![]() |
Audacity 3.2.0
|
#include <RealtimeEffectList.h>
Public Types | |
using | Lock = spinlock |
using | States = std::vector< std::shared_ptr< RealtimeEffectState > > |
![]() | |
using | Base = Cloneable |
using | PointerType = Owner< Base > |
![]() | |
using | message_type = RealtimeEffectListMessage |
using | CallbackReturn = std::conditional_t< true, void, bool > |
using | Callback = std::function< CallbackReturn(const RealtimeEffectListMessage &) > |
Type of functions that can be connected to the Publisher. More... | |
Public Member Functions | |
RealtimeEffectList () | |
virtual | ~RealtimeEffectList () |
Lock & | GetLock () const |
std::unique_ptr< ClientData::Cloneable<> > | Clone () const override |
template<typename StateVisitor > | |
void | Visit (const StateVisitor &func) |
Apply the function to all states sequentially. More... | |
template<typename StateVisitor > | |
void | Visit (const StateVisitor &func) const |
Apply the function to all states sequentially. More... | |
bool | AddState (std::shared_ptr< RealtimeEffectState > pState) |
bool | ReplaceState (size_t index, std::shared_ptr< RealtimeEffectState > pState) |
void | RemoveState (std::shared_ptr< RealtimeEffectState > pState) |
void | Clear () |
Use only in the main thread. Sends Remove messages. More... | |
std::optional< size_t > | FindState (const std::shared_ptr< RealtimeEffectState > &pState) const |
Report the position of a state in the list. More... | |
size_t | GetStatesCount () const noexcept |
std::shared_ptr< RealtimeEffectState > | GetStateAt (size_t index) noexcept |
std::shared_ptr< const RealtimeEffectState > | GetStateAt (size_t index) const noexcept |
void | MoveEffect (size_t fromIndex, size_t toIndex) |
Use only in the main thread. Changes effect order in the stack. Does nothing if fromIndex equals toIndex. Otherwise effects between fromIndex (exclusive) and toIndex are shifted towards fromIndex. Sends Move event. More... | |
bool | HandleXMLTag (const std::string_view &tag, const AttributesList &attrs) override |
XMLTagHandler * | HandleXMLChild (const std::string_view &tag) override |
Use only in the main thread. May add a state while deserializing. More... | |
void | WriteXML (XMLWriter &xmlFile) const |
Use only in the main thread, to avoid races. More... | |
void | RestoreUndoRedoState (AudacityProject &project) noexcept override |
Modify the project when undoing or redoing to some state in history. More... | |
bool | IsActive () const |
Non-blocking atomic boolean load. More... | |
void | SetActive (bool value) |
Done by main thread only, under a lock guard. More... | |
![]() | |
virtual | ~Base () |
![]() | |
virtual | ~Cloneable () |
virtual PointerType | Clone () const =0 |
![]() | |
virtual | ~UndoStateExtension () |
virtual void | RestoreUndoRedoState (AudacityProject &project)=0 |
Modify the project when undoing or redoing to some state in history. More... | |
virtual bool | CanUndoOrRedo (const AudacityProject &project) |
Whether undo or redo is now permitted; default returns true. More... | |
![]() | |
XMLTagHandler () | |
virtual | ~XMLTagHandler () |
virtual bool | HandleXMLTag (const std::string_view &tag, const AttributesList &attrs)=0 |
virtual void | HandleXMLEndTag (const std::string_view &WXUNUSED(tag)) |
virtual void | HandleXMLContent (const std::string_view &WXUNUSED(content)) |
virtual XMLTagHandler * | HandleXMLChild (const std::string_view &tag)=0 |
void | ReadXMLEndTag (const char *tag) |
void | ReadXMLContent (const char *s, int len) |
XMLTagHandler * | ReadXMLChild (const char *tag) |
![]() | |
Publisher (ExceptionPolicy *pPolicy=nullptr, Alloc a={}) | |
Constructor supporting type-erased custom allocation/deletion. More... | |
Publisher (Publisher &&)=default | |
Publisher & | operator= (Publisher &&)=default |
Subscription | Subscribe (Callback callback) |
Connect a callback to the Publisher; later-connected are called earlier. More... | |
Subscription | Subscribe (Object &obj, Return(Object::*callback)(Args...)) |
Overload of Subscribe takes an object and pointer-to-member-function. More... | |
Static Public Member Functions | |
static RealtimeEffectList & | Get (AudacityProject &project) |
static const RealtimeEffectList & | Get (const AudacityProject &project) |
static RealtimeEffectList & | Set (AudacityProject &project, const std::shared_ptr< RealtimeEffectList > &list) |
static RealtimeEffectList & | Get (Track &track) |
static const RealtimeEffectList & | Get (const Track &track) |
static const std::string & | XMLTag () |
Private Types | |
using | LockGuard = std::lock_guard< Lock > |
Private Member Functions | |
RealtimeEffectList (const RealtimeEffectList &)=delete | |
RealtimeEffectList & | operator= (const RealtimeEffectList &)=delete |
Private Attributes | |
States | mStates |
Lock | mLock |
std::atomic< bool > | mActive { true } |
Additional Inherited Members | |
![]() | |
static constexpr bool | notifies_all |
![]() | |
CallbackReturn | Publish (const RealtimeEffectListMessage &message) |
Send a message to connected callbacks. More... | |
Definition at line 44 of file RealtimeEffectList.h.
using RealtimeEffectList::Lock = spinlock |
Definition at line 58 of file RealtimeEffectList.h.
|
private |
Definition at line 169 of file RealtimeEffectList.h.
using RealtimeEffectList::States = std::vector<std::shared_ptr<RealtimeEffectState> > |
Definition at line 59 of file RealtimeEffectList.h.
|
privatedelete |
RealtimeEffectList::RealtimeEffectList | ( | ) |
Definition at line 15 of file RealtimeEffectList.cpp.
|
virtual |
Definition at line 19 of file RealtimeEffectList.cpp.
bool RealtimeEffectList::AddState | ( | std::shared_ptr< RealtimeEffectState > | pState | ) |
Use only in the main thread Returns true for success. Sends Insert message on success.
!result || pState->GetEffect() != nullptr
Definition at line 81 of file RealtimeEffectList.cpp.
References RealtimeEffectListMessage::Insert, mLock, mStates, Observer::Publisher< RealtimeEffectListMessage >::Publish(), and anonymous_namespace{NoteTrack.cpp}::swap().
void RealtimeEffectList::Clear | ( | ) |
Use only in the main thread. Sends Remove messages.
Definition at line 162 of file RealtimeEffectList.cpp.
References mLock, mStates, Observer::Publisher< RealtimeEffectListMessage >::Publish(), RealtimeEffectListMessage::Remove, and anonymous_namespace{NoteTrack.cpp}::swap().
Referenced by MixAndRender(), and EffectStereoToMono::ProcessOne().
|
overridevirtual |
Should be called (for pushing undo states) only from main thread, to avoid races
Implements ClientData::Cloneable< Owner >.
Definition at line 24 of file RealtimeEffectList.cpp.
References IsActive(), and mStates.
std::optional< size_t > RealtimeEffectList::FindState | ( | const std::shared_ptr< RealtimeEffectState > & | pState | ) | const |
Report the position of a state in the list.
Definition at line 175 of file RealtimeEffectList.cpp.
References PackedArray::begin(), PackedArray::end(), and mStates.
|
static |
Definition at line 42 of file RealtimeEffectList.cpp.
References masterEffects.
Referenced by RealtimeEffectManager::AllListsLock::AllListsLock(), RealtimeEffectListWindow::EnableEffects(), anonymous_namespace{RealtimeEffectManager.cpp}::FindStates(), Get(), GetEffectStages(), MixAndRender(), RealtimeEffectListWindow::OnEffectListItemChange(), anonymous_namespace{FileMenus.cpp}::OnOpen(), EffectStereoToMono::ProcessOne(), RealtimeEffectListWindow::RealtimeEffectListWindow(), RealtimeEffectListWindow::ReloadEffectsList(), RealtimeEffectManager::AllListsLock::Reset(), RealtimeEffectListWindow::SetTrack(), RealtimeEffectPanel::SetTrack(), RealtimeEffectManager::VisitAll(), RealtimeEffectManager::VisitGroup(), and anonymous_namespace{RealtimeEffectPanel.cpp}::VisitRealtimeEffectStateUIs().
|
static |
Definition at line 55 of file RealtimeEffectList.cpp.
References Get().
|
static |
Definition at line 75 of file RealtimeEffectList.cpp.
References Get().
Referenced by Get().
|
static |
Definition at line 69 of file RealtimeEffectList.cpp.
References Track::GetGroupData(), and trackEffects.
|
inline |
Definition at line 64 of file RealtimeEffectList.h.
Referenced by RealtimeEffectManager::AllListsLock::AllListsLock(), and RealtimeEffectManager::AllListsLock::Reset().
|
noexcept |
Returns effect state at given position Use only in the main thread, to avoid races
Definition at line 200 of file RealtimeEffectList.cpp.
|
noexcept |
Returns effect state at given position Use only in the main thread, to avoid races
Definition at line 192 of file RealtimeEffectList.cpp.
|
noexcept |
Use only in the main thread, to avoid races Returns total number of effects in this list
Definition at line 186 of file RealtimeEffectList.cpp.
References mStates.
Referenced by RealtimeEffectListWindow::ReloadEffectsList().
|
overridevirtual |
Use only in the main thread. May add a state while deserializing.
Implements XMLTagHandler.
Definition at line 257 of file RealtimeEffectList.cpp.
References SharedNonInterfering< RealtimeEffectState >::make_shared(), mStates, and RealtimeEffectState::XMLTag().
|
overridevirtual |
Implements XMLTagHandler.
Definition at line 244 of file RealtimeEffectList.cpp.
References activeAttribute, SetActive(), and XMLTag().
bool RealtimeEffectList::IsActive | ( | ) | const |
Non-blocking atomic boolean load.
Definition at line 281 of file RealtimeEffectList.cpp.
References mActive.
Referenced by Clone(), RealtimeEffectPanel::SetTrack(), and WriteXML().
void RealtimeEffectList::MoveEffect | ( | size_t | fromIndex, |
size_t | toIndex | ||
) |
Use only in the main thread. Changes effect order in the stack. Does nothing if fromIndex equals toIndex. Otherwise effects between fromIndex (exclusive) and toIndex are shifted towards fromIndex. Sends Move event.
fromIndex | Index of the moved effect |
toIndex | Final position of the moved effect |
Definition at line 205 of file RealtimeEffectList.cpp.
References mLock, RealtimeEffectListMessage::Move, mStates, Observer::Publisher< RealtimeEffectListMessage >::Publish(), and anonymous_namespace{NoteTrack.cpp}::swap().
|
privatedelete |
void RealtimeEffectList::RemoveState | ( | std::shared_ptr< RealtimeEffectState > | pState | ) |
Use only in the main thread On success sends Remove message.
Definition at line 139 of file RealtimeEffectList.cpp.
References PackedArray::end(), mLock, mStates, Observer::Publisher< RealtimeEffectListMessage >::Publish(), RealtimeEffectListMessage::Remove, and anonymous_namespace{NoteTrack.cpp}::swap().
bool RealtimeEffectList::ReplaceState | ( | size_t | index, |
std::shared_ptr< RealtimeEffectState > | pState | ||
) |
Use only in the main thread Returns true for success. Sends Insert message on success.
!result || pState->GetEffect() != nullptr
Definition at line 105 of file RealtimeEffectList.cpp.
References RealtimeEffectListMessage::DidReplace, mLock, mStates, Observer::Publisher< RealtimeEffectListMessage >::Publish(), anonymous_namespace{NoteTrack.cpp}::swap(), and RealtimeEffectListMessage::WillReplace.
|
overridevirtualnoexcept |
Modify the project when undoing or redoing to some state in history.
Implements UndoStateExtension.
Definition at line 275 of file RealtimeEffectList.cpp.
|
static |
Definition at line 47 of file RealtimeEffectList.cpp.
References masterEffects.
void RealtimeEffectList::SetActive | ( | bool | value | ) |
Done by main thread only, under a lock guard.
Definition at line 286 of file RealtimeEffectList.cpp.
References mActive, and mLock.
Referenced by RealtimeEffectListWindow::EnableEffects(), and HandleXMLTag().
|
inline |
Apply the function to all states sequentially.
Definition at line 86 of file RealtimeEffectList.h.
Referenced by RealtimeEffectManager::VisitAll(), and RealtimeEffectManager::VisitGroup().
|
inline |
Apply the function to all states sequentially.
Definition at line 94 of file RealtimeEffectList.h.
void RealtimeEffectList::WriteXML | ( | XMLWriter & | xmlFile | ) | const |
Use only in the main thread, to avoid races.
Definition at line 266 of file RealtimeEffectList.cpp.
References activeAttribute, XMLWriter::EndTag(), IsActive(), mStates, XMLWriter::StartTag(), XMLWriter::WriteAttr(), and XMLTag().
|
static |
Definition at line 236 of file RealtimeEffectList.cpp.
Referenced by HandleXMLTag(), and WriteXML().
|
private |
Definition at line 172 of file RealtimeEffectList.h.
Referenced by IsActive(), and SetActive().
|
mutableprivate |
Definition at line 170 of file RealtimeEffectList.h.
Referenced by AddState(), Clear(), MoveEffect(), RemoveState(), ReplaceState(), and SetActive().
|
private |
Definition at line 167 of file RealtimeEffectList.h.
Referenced by AddState(), Clear(), Clone(), FindState(), GetStatesCount(), HandleXMLChild(), MoveEffect(), RemoveState(), ReplaceState(), and WriteXML().