/[svn]/linuxsampler/trunk/src/plugins/InstrumentEditor.cpp
ViewVC logotype

Contents of /linuxsampler/trunk/src/plugins/InstrumentEditor.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3290 - (show annotations) (download)
Fri Jun 23 12:24:58 2017 UTC (6 years, 9 months ago) by schoenebeck
File size: 5217 byte(s)
* Revised fundamental C++ classes "Thread", "Mutex" and
  "Condition" which fixes potential undefined behavior
  (note: this addresses mainly the POSIX implementation,
   Win32 is untested yet and would also need an update).
* Bumped version (2.0.0.svn64).

1 /***************************************************************************
2 * *
3 * Copyright (C) 2007 - 2017 Christian Schoenebeck *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the Free Software *
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, *
18 * MA 02111-1307 USA *
19 ***************************************************************************/
20
21 #include "InstrumentEditor.h"
22
23 #include "../common/global_private.h"
24
25 #include <algorithm>
26 #include <functional>
27
28 namespace LinuxSampler {
29
30 InstrumentEditor::InstrumentEditor() : Thread(false, false, -1, 0) {
31 pInstrument = NULL;
32 pUserData = NULL;
33 pEngineChannel = NULL;
34 }
35
36 InstrumentEditor::~InstrumentEditor() {
37 }
38
39 void InstrumentEditor::Launch(EngineChannel* pEngineChannel, void* pInstrument, String sTypeName, String sTypeVersion, void* pUserData) {
40 dmsg(1,("InstrumentEditor::Launch(instr=%p,type=%s,version=%s)\n", pInstrument, sTypeName.c_str(), sTypeVersion.c_str()));
41 // prepare the editor's mandatory parameters
42 this->pInstrument = pInstrument;
43 this->sTypeName = sTypeName;
44 this->sTypeVersion = sTypeVersion;
45 this->pUserData = pUserData;
46 this->pEngineChannel = pEngineChannel;
47 // start the editor in its own thread
48 StartThread();
49 }
50
51 int InstrumentEditor::Main() {
52 dmsg(1,("InstrumentEditor::Main()\n"));
53 // run the editor's main loop
54 int iResult = Main(pInstrument, sTypeName, sTypeVersion, pUserData);
55 // reset editor parameters
56 this->pInstrument = NULL;
57 this->sTypeName = "";
58 this->sTypeVersion = "";
59 this->pUserData = NULL;
60 dmsg(1,("Instrument editor '%s' returned with exit status %d\n", Name().c_str(), iResult));
61 // notify all registered listeners
62 std::for_each(
63 listeners.begin(), listeners.end(),
64 std::bind2nd(std::mem_fun(&InstrumentEditorListener::OnInstrumentEditorQuit), this)
65 );
66 // done
67 StopThread();
68 return iResult;
69 }
70
71 EngineChannel* InstrumentEditor::GetEngineChannel() {
72 return pEngineChannel;
73 }
74
75 void InstrumentEditor::AddListener(InstrumentEditorListener* pListener) {
76 listeners.insert(pListener);
77 }
78
79 void InstrumentEditor::RemoveListener(InstrumentEditorListener* pListener) {
80 listeners.erase(pListener);
81 }
82
83 void InstrumentEditor::NotifySamplesToBeRemoved(std::set<void*> Samples) {
84 for ( // notify all registered listeners
85 std::set<InstrumentEditorListener*>::iterator iter = listeners.begin();
86 iter != listeners.end(); iter++
87 ) (*iter)->OnSamplesToBeRemoved(Samples, this);
88 }
89
90 void InstrumentEditor::NotifySamplesRemoved() {
91 for ( // notify all registered listeners
92 std::set<InstrumentEditorListener*>::iterator iter = listeners.begin();
93 iter != listeners.end(); iter++
94 ) (*iter)->OnSamplesRemoved(this);
95 }
96
97 void InstrumentEditor::NotifyDataStructureToBeChanged(void* pStruct, String sStructType) {
98 for ( // notify all registered listeners
99 std::set<InstrumentEditorListener*>::iterator iter = listeners.begin();
100 iter != listeners.end(); iter++
101 ) (*iter)->OnDataStructureToBeChanged(pStruct, sStructType, this);
102 }
103
104 void InstrumentEditor::NotifyDataStructureChanged(void* pStruct, String sStructType) {
105 for ( // notify all registered listeners
106 std::set<InstrumentEditorListener*>::iterator iter = listeners.begin();
107 iter != listeners.end(); iter++
108 ) (*iter)->OnDataStructureChanged(pStruct, sStructType, this);
109 }
110
111 void InstrumentEditor::NotifySampleReferenceChanged(void* pOldSample, void* pNewSample) {
112 for ( // notify all registered listeners
113 std::set<InstrumentEditorListener*>::iterator iter = listeners.begin();
114 iter != listeners.end(); iter++
115 ) (*iter)->OnSampleReferenceChanged(pOldSample, pNewSample, this);
116 }
117
118 } // namespace LinuxSampler

  ViewVC Help
Powered by ViewVC