1 |
/*************************************************************************** |
/*************************************************************************** |
2 |
* * |
* * |
3 |
* Copyright (C) 2007 Christian Schoenebeck * |
* Copyright (C) 2007 - 2020 Christian Schoenebeck * |
4 |
* * |
* * |
5 |
* This program is free software; you can redistribute it and/or modify * |
* 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 * |
* it under the terms of the GNU General Public License as published by * |
20 |
|
|
21 |
#include "InstrumentEditor.h" |
#include "InstrumentEditor.h" |
22 |
|
|
23 |
|
#include "../common/global_private.h" |
24 |
|
|
25 |
#include <algorithm> |
#include <algorithm> |
26 |
#include <functional> |
#include <functional> |
27 |
|
|
29 |
|
|
30 |
InstrumentEditor::InstrumentEditor() : Thread(false, false, -1, 0) { |
InstrumentEditor::InstrumentEditor() : Thread(false, false, -1, 0) { |
31 |
pInstrument = NULL; |
pInstrument = NULL; |
32 |
|
pUserData = NULL; |
33 |
|
pEngineChannel = NULL; |
34 |
|
} |
35 |
|
|
36 |
|
InstrumentEditor::~InstrumentEditor() { |
37 |
} |
} |
38 |
|
|
39 |
void InstrumentEditor::Launch(void* pInstrument, String sTypeName, String sTypeVersion) { |
void InstrumentEditor::Launch(EngineChannel* pEngineChannel, void* pInstrument, String sTypeName, String sTypeVersion, void* pUserData) { |
40 |
dmsg(1,("InstrumentEditor::Launch(instr=%x,type=%s,version=%s)\n", pInstrument, sTypeName.c_str(), sTypeVersion.c_str())); |
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 |
// prepare the editor's mandatory parameters |
42 |
this->pInstrument = pInstrument; |
this->pInstrument = pInstrument; |
43 |
this->sTypeName = sTypeName; |
this->sTypeName = sTypeName; |
44 |
this->sTypeVersion = sTypeVersion; |
this->sTypeVersion = sTypeVersion; |
45 |
|
this->pUserData = pUserData; |
46 |
|
this->pEngineChannel = pEngineChannel; |
47 |
// start the editor in its own thread |
// start the editor in its own thread |
48 |
StartThread(); |
StartThread(); |
49 |
} |
} |
50 |
|
|
51 |
int InstrumentEditor::Main() { |
int InstrumentEditor::Main() { |
52 |
dmsg(1,("InstrumentEditor::Main()\n")); |
dmsg(1,("InstrumentEditor::Main()\n")); |
53 |
|
|
54 |
|
#if DEBUG |
55 |
|
Thread::setNameOfCaller("InstrEditorPlug"); |
56 |
|
#endif |
57 |
|
|
58 |
// run the editor's main loop |
// run the editor's main loop |
59 |
int iResult = Main(pInstrument, sTypeName, sTypeVersion); |
int iResult = Main(pInstrument, sTypeName, sTypeVersion, pUserData); |
60 |
// reset editor parameters |
// reset editor parameters |
61 |
this->pInstrument = NULL; |
this->pInstrument = NULL; |
62 |
this->sTypeName = ""; |
this->sTypeName = ""; |
63 |
this->sTypeVersion = ""; |
this->sTypeVersion = ""; |
64 |
|
this->pUserData = NULL; |
65 |
dmsg(1,("Instrument editor '%s' returned with exit status %d\n", Name().c_str(), iResult)); |
dmsg(1,("Instrument editor '%s' returned with exit status %d\n", Name().c_str(), iResult)); |
66 |
// notify all registered listeners |
// notify all registered listeners |
67 |
std::for_each( |
std::for_each( |
68 |
listeners.begin(), listeners.end(), |
listeners.begin(), listeners.end(), |
69 |
std::bind2nd(std::mem_fun(&InstrumentEditorListener::OnInstrumentEditorQuit), this) |
[this](InstrumentEditorListener* listener) { |
70 |
|
listener->OnInstrumentEditorQuit(this); |
71 |
|
} |
72 |
); |
); |
73 |
// done |
// done |
74 |
|
StopThread(); |
75 |
return iResult; |
return iResult; |
76 |
} |
} |
77 |
|
|
78 |
|
EngineChannel* InstrumentEditor::GetEngineChannel() { |
79 |
|
return pEngineChannel; |
80 |
|
} |
81 |
|
|
82 |
void InstrumentEditor::AddListener(InstrumentEditorListener* pListener) { |
void InstrumentEditor::AddListener(InstrumentEditorListener* pListener) { |
83 |
listeners.insert(pListener); |
listeners.insert(pListener); |
84 |
} |
} |