-
Notifications
You must be signed in to change notification settings - Fork 15
/
ShoutVSTEditor.cpp
153 lines (123 loc) · 3.83 KB
/
ShoutVSTEditor.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
#include "ShoutVST.h"
#include <shout/shout.h>
#include <string>
#include "ShoutVSTEditor.h"
#ifdef __linux__
#include <X11/Xlib.h>
#endif
recursive_mutex ShoutVSTEditor::mtx_;
typedef std::lock_guard<std::recursive_mutex> guard;
ShoutVSTEditor::ShoutVSTEditor(AudioEffect* effect) : AEffEditor(effect) {
pVST = reinterpret_cast<ShoutVST*>(effect);
systemWindow = nullptr;
shoutVSTEditorFL = new ShoutVSTEditorFL();
shoutVSTEditorFL->connectCallback = std::bind(callbackConnect, this);
shoutVSTEditorFL->disconnectCallback = std::bind(callbackDisconnect, this);
shoutVSTEditorFL->metadataCallback = std::bind(callbackMetadata, this);
}
ShoutVSTEditor::~ShoutVSTEditor() {
guard lock(mtx_);
shoutVSTEditorFL->hide();
systemWindow = nullptr;
delete shoutVSTEditorFL;
}
void ShoutVSTEditor::callbackConnect(ShoutVSTEditor* p) {
guard lock(mtx_);
p->shoutVSTEditorFL->setDisable(true);
p->pVST->connect();
}
void ShoutVSTEditor::callbackDisconnect(ShoutVSTEditor* p) {
p->pVST->disconnect();
}
void ShoutVSTEditor::callbackMetadata(ShoutVSTEditor* p) {
guard lock(mtx_);
const string metadata = p->getStreamMetaData();
p->pVST->UpdateMetadata(metadata.c_str());
}
void ShoutVSTEditor::idle() { Fl::wait(0); }
string ShoutVSTEditor::getStreamMetaData() const {
return shoutVSTEditorFL->getStreamMetaData();
}
string ShoutVSTEditor::getHostName() const {
return shoutVSTEditorFL->getHostName();
}
string ShoutVSTEditor::getStreamName() const {
return shoutVSTEditorFL->getStreamName();
}
string ShoutVSTEditor::getStreamURL() const {
return shoutVSTEditorFL->getStreamURL();
}
string ShoutVSTEditor::getStreamGenre() const {
return shoutVSTEditorFL->getStreamGenre();
}
string ShoutVSTEditor::getStreamDescription() const {
return shoutVSTEditorFL->getStreamDescription();
}
string ShoutVSTEditor::getStreamArtist() const {
return shoutVSTEditorFL->getStreamArtist();
}
string ShoutVSTEditor::getStreamTitle() const {
return shoutVSTEditorFL->getStreamTitle();
}
unsigned short ShoutVSTEditor::getPort() const {
return std::stoi(shoutVSTEditorFL->getPort());
}
string ShoutVSTEditor::getUserName() const {
return shoutVSTEditorFL->getUserName();
}
string ShoutVSTEditor::getPassword() const {
return shoutVSTEditorFL->getPassword();
}
string ShoutVSTEditor::getMountPoint() const {
return shoutVSTEditorFL->getMountPoint();
}
string ShoutVSTEditor::getEncodingFormat() const {
return shoutVSTEditorFL->getEncodingFormat();
}
string ShoutVSTEditor::getProtocol() const {
return shoutVSTEditorFL->getProtocol();
}
bool ShoutVSTEditor::open(void* parentWindow) {
guard lock(mtx_);
systemWindow = parentWindow;
Fl::scheme("Plastic");
shoutVSTEditorFL->show();
#ifdef _WIN32
HWND hWnd = (HWND)fl_xid(shoutVSTEditorFL->fl_window);
// SetWindowLong(hWnd, GWL_STYLE, (GetWindowLong(hWnd, GWL_STYLE) & ~WS_POPUP)
// | WS_CHILD);
SetParent(hWnd, (HWND)parentWindow);
#endif
#ifdef __linux__
Window xid = fl_xid(shoutVSTEditorFL->fl_window);
Display* display = XOpenDisplay(NULL);
if (display) {
Window parent = (Window)parentWindow;
XReparentWindow(display, xid, parent, 0, 0);
XSync(display, False);
XCloseDisplay(display);
}
#endif
shoutVSTEditorFL->fl_window->position(0, 0);
DisableAccordingly();
return true;
}
void ShoutVSTEditor::close() {
guard lock(mtx_);
shoutVSTEditorFL->hide();
}
bool ShoutVSTEditor::getRect(ERect** erect) {
static ERect r = {};
r.right = shoutVSTEditorFL->fl_window->decorated_w();
r.bottom = shoutVSTEditorFL->fl_window->decorated_h();
*erect = &r;
return true;
}
string ShoutVSTEditor::GetBitrate() { return shoutVSTEditorFL->getBitRate(); }
string ShoutVSTEditor::GetTargetSampleRate() {
return shoutVSTEditorFL->getSampleRate();
}
void ShoutVSTEditor::DisableAccordingly() {
guard lock(mtx_);
shoutVSTEditorFL->setDisable(pVST->IsConnected());
}