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
154
155
|
#include <iostream>
#include "paman.hh"
#include "SinkInputWindow.hh"
#define GLADE_NAME "sinkInputWindow"
SinkInputWindow::SinkInputWindow(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade::Xml>& refGlade) :
Gtk::Window(cobject),
nameLabel(NULL),
indexLabel(NULL),
sampleTypeLabel(NULL),
latencyLabel(NULL),
sinkLabel(NULL),
clientLabel(NULL),
ownerModuleLabel(NULL),
volumeLabel(NULL),
resampleMethodLabel(NULL),
closeButton(NULL),
toOwnerModuleButton(NULL),
toClientButton(NULL),
toSinkButton(NULL),
volumeResetButton(NULL),
volumeMuteButton(NULL),
killButton(NULL),
volumeScale(NULL),
scaleEnabled(true) {
refGlade->get_widget("nameLabel", nameLabel);
refGlade->get_widget("indexLabel", indexLabel);
refGlade->get_widget("sampleTypeLabel", sampleTypeLabel);
refGlade->get_widget("latencyLabel", latencyLabel);
refGlade->get_widget("sinkLabel", sinkLabel);
refGlade->get_widget("clientLabel", clientLabel);
refGlade->get_widget("ownerModuleLabel", ownerModuleLabel);
refGlade->get_widget("closeButton", closeButton);
refGlade->get_widget("toOwnerModuleButton", toOwnerModuleButton);
refGlade->get_widget("toClientButton", toClientButton);
refGlade->get_widget("toSinkButton", toSinkButton);
refGlade->get_widget("volumeLabel", volumeLabel);
refGlade->get_widget("volumeScale", volumeScale);
refGlade->get_widget("volumeResetButton", volumeResetButton);
refGlade->get_widget("volumeMuteButton", volumeMuteButton);
refGlade->get_widget("killButton", killButton);
refGlade->get_widget("resampleMethodLabel", resampleMethodLabel);
closeButton->signal_clicked().connect(sigc::mem_fun(*this, &SinkInputWindow::onCloseButton));
toOwnerModuleButton->signal_clicked().connect(sigc::mem_fun(*this, &SinkInputWindow::onToOwnerModuleButton));
toClientButton->signal_clicked().connect(sigc::mem_fun(*this, &SinkInputWindow::onToClientButton));
toSinkButton->signal_clicked().connect(sigc::mem_fun(*this, &SinkInputWindow::onToSinkButton));
volumeScale->signal_value_changed().connect(sigc::mem_fun(*this, &SinkInputWindow::onVolumeScaleValueChanged));
volumeResetButton->signal_clicked().connect(sigc::mem_fun(*this, &SinkInputWindow::onVolumeResetButton));
volumeMuteButton->signal_clicked().connect(sigc::mem_fun(*this, &SinkInputWindow::onVolumeMuteButton));
killButton->signal_clicked().connect(sigc::mem_fun(*this, &SinkInputWindow::onKillButton));
}
SinkInputWindow* SinkInputWindow::create() {
SinkInputWindow *w = NULL;
Glib::RefPtr<Gnome::Glade::Xml> refXml = Gnome::Glade::Xml::create(GLADE_FILE, GLADE_NAME);
refXml->get_widget_derived(GLADE_NAME, w);
return w;
}
void SinkInputWindow::updateInfo(const SinkInputInfo &i) {
char t[80], ss[PA_SAMPLE_SPEC_SNPRINT_MAX];
double percent, db;
nameLabel->set_text(i.name);
snprintf(t, sizeof(t), "#%u", i.index);
indexLabel->set_text(t);
pa_sample_spec_snprint(ss, sizeof(ss), &i.sample_spec);
sampleTypeLabel->set_text(ss);
if (i.owner_module == PA_INVALID_INDEX)
ownerModuleLabel->set_markup("<i>n/a</i>");
else {
snprintf(t, sizeof(t), "#%u", i.owner_module);
ownerModuleLabel->set_text(t);
}
snprintf(t, sizeof(t), "%0.0f μs (= buffer: %0.0f μs + sink: %0.0f μs)", (double) i.buffer_usec+i.sink_usec, (double) i.buffer_usec, (double) i.sink_usec);
latencyLabel->set_markup(t);
SinkInfo *sink = serverInfoManager->getSinkInfo(i.sink);
sinkLabel->set_text(sink->name);
if (i.client == PA_INVALID_INDEX)
clientLabel->set_markup("<i>n/a</i>");
else {
ClientInfo *client = serverInfoManager->getClientInfo(i.client);
clientLabel->set_text(client->name);
}
percent = pa_volume_to_user(i.volume) * 100;
db = pa_volume_to_dB(i.volume);
scaleEnabled = false;
volumeScale->set_value(percent);
scaleEnabled = true;
if (db != PA_DECIBEL_MININFTY)
snprintf(t, sizeof(t), "%0.0f%% (%0.2fdB)", percent, db);
else
snprintf(t, sizeof(t), "%0.0f%% (-∞dB)", percent);
volumeLabel->set_markup(t);
resampleMethodLabel->set_markup(i.resample_method);
set_title("Sink Input: "+i.name);
this->sink = i.sink;
client = i.client;
owner_module = i.owner_module;
index = i.index;
toOwnerModuleButton->set_sensitive(owner_module != PA_INVALID_INDEX);
toClientButton->set_sensitive(client != PA_INVALID_INDEX);
}
void SinkInputWindow::onCloseButton() {
hide();
}
void SinkInputWindow::onToOwnerModuleButton() {
if (owner_module != PA_INVALID_INDEX)
serverInfoManager->showModuleWindow(owner_module);
}
void SinkInputWindow::onToSinkButton() {
serverInfoManager->showSinkWindow(sink);
}
void SinkInputWindow::onToClientButton() {
serverInfoManager->showClientWindow(client);
}
void SinkInputWindow::onVolumeScaleValueChanged() {
if (scaleEnabled)
serverInfoManager->setSinkInputVolume(index, pa_volume_from_user(volumeScale->get_value()/100));
}
void SinkInputWindow::onVolumeResetButton() {
serverInfoManager->setSinkInputVolume(index, PA_VOLUME_NORM);
}
void SinkInputWindow::onVolumeMuteButton() {
serverInfoManager->setSinkInputVolume(index, PA_VOLUME_MUTED);
}
bool SinkInputWindow::on_delete_event(GdkEventAny* ) {
hide();
return false;
}
void SinkInputWindow::onKillButton() {
serverInfoManager->killSinkInput(index);
}
|