diff options
author | Jacek Antonelli | 2008-08-15 23:44:46 -0500 |
---|---|---|
committer | Jacek Antonelli | 2008-08-15 23:44:46 -0500 |
commit | 38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4 (patch) | |
tree | adca584755d22ca041a2dbfc35d4eca01f70b32c /linden/indra/newview/llaudiostatus.cpp | |
parent | README.txt (diff) | |
download | meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.zip meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.gz meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.bz2 meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.xz |
Second Life viewer sources 1.13.2.12
Diffstat (limited to 'linden/indra/newview/llaudiostatus.cpp')
-rw-r--r-- | linden/indra/newview/llaudiostatus.cpp | 411 |
1 files changed, 411 insertions, 0 deletions
diff --git a/linden/indra/newview/llaudiostatus.cpp b/linden/indra/newview/llaudiostatus.cpp new file mode 100644 index 0000000..397f7e4 --- /dev/null +++ b/linden/indra/newview/llaudiostatus.cpp | |||
@@ -0,0 +1,411 @@ | |||
1 | /** | ||
2 | * @file llaudiostatus.cpp | ||
3 | * @brief Audio channel allocation information | ||
4 | * | ||
5 | * Copyright (c) 2001-2007, Linden Research, Inc. | ||
6 | * | ||
7 | * The source code in this file ("Source Code") is provided by Linden Lab | ||
8 | * to you under the terms of the GNU General Public License, version 2.0 | ||
9 | * ("GPL"), unless you have obtained a separate licensing agreement | ||
10 | * ("Other License"), formally executed by you and Linden Lab. Terms of | ||
11 | * the GPL can be found in doc/GPL-license.txt in this distribution, or | ||
12 | * online at http://secondlife.com/developers/opensource/gplv2 | ||
13 | * | ||
14 | * There are special exceptions to the terms and conditions of the GPL as | ||
15 | * it is applied to this Source Code. View the full text of the exception | ||
16 | * in the file doc/FLOSS-exception.txt in this software distribution, or | ||
17 | * online at http://secondlife.com/developers/opensource/flossexception | ||
18 | * | ||
19 | * By copying, modifying or distributing this software, you acknowledge | ||
20 | * that you have read and understood your obligations described above, | ||
21 | * and agree to abide by those obligations. | ||
22 | * | ||
23 | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | ||
24 | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | ||
25 | * COMPLETENESS OR PERFORMANCE. | ||
26 | */ | ||
27 | |||
28 | #include "llviewerprecompiledheaders.h" | ||
29 | |||
30 | #include "llaudiostatus.h" | ||
31 | |||
32 | #include "linked_lists.h" | ||
33 | #include "llmath.h" // clampf() | ||
34 | #include "llgl.h" | ||
35 | #include "llview.h" | ||
36 | #include "llfontgl.h" | ||
37 | #include "llcircuit.h" | ||
38 | #include "message.h" | ||
39 | #include "sound_ids.h" | ||
40 | #include "audioengine.h" | ||
41 | |||
42 | #include "llui.h" | ||
43 | #include "llagent.h" | ||
44 | #include "llviewercontrol.h" | ||
45 | #include "viewer.h" | ||
46 | |||
47 | #include "llglheaders.h" | ||
48 | |||
49 | // | ||
50 | // Imported globals | ||
51 | // | ||
52 | extern LLMessageSystem* gMessageSystem; | ||
53 | extern LLAudioEngine* gAudiop; | ||
54 | |||
55 | // | ||
56 | // Constants | ||
57 | // | ||
58 | |||
59 | |||
60 | LLAudiostatus::LLAudiostatus(const std::string& name, const LLRect& rect) | ||
61 | : LLView(name, rect, FALSE) | ||
62 | { | ||
63 | mPage = 0; | ||
64 | } | ||
65 | |||
66 | // | ||
67 | // Functions | ||
68 | // | ||
69 | |||
70 | EWidgetType LLAudiostatus::getWidgetType() const | ||
71 | { | ||
72 | return WIDGET_TYPE_AUDIO_STATUS; | ||
73 | } | ||
74 | |||
75 | LLString LLAudiostatus::getWidgetTag() const | ||
76 | { | ||
77 | return LL_AUDIOSTATUS_TAG; | ||
78 | } | ||
79 | |||
80 | const F32 AUDIOSTATUS_SIZE = 64; | ||
81 | |||
82 | void LLAudiostatus::draw() | ||
83 | { | ||
84 | /* | ||
85 | mPage = gSavedSettings.getS32("AudioInfoPage"); | ||
86 | |||
87 | if (!getVisible() || !mPage) | ||
88 | { | ||
89 | return; | ||
90 | } | ||
91 | |||
92 | glMatrixMode(GL_MODELVIEW); | ||
93 | glPushMatrix(); | ||
94 | |||
95 | // We're going to be drawing flat shaded rectangles | ||
96 | { | ||
97 | LLGLSNoTexture gls_ui_no_texture; | ||
98 | |||
99 | // Draw background black rectangle | ||
100 | glColor4f(0.f, 0.f, 0.f, 0.3f); | ||
101 | gl_rect_2d(0, 0, 325, -340); // -y is down (don't know why) | ||
102 | } | ||
103 | |||
104 | glPopMatrix(); | ||
105 | glPushMatrix(); | ||
106 | |||
107 | S32 channel; | ||
108 | char out_str[64]; | ||
109 | LLColor4 color; | ||
110 | |||
111 | if (gAudiop) | ||
112 | { | ||
113 | for (channel = 0; channel < MAX_BUFFERS; channel++) | ||
114 | { | ||
115 | if (gAudiop->getFlags(channel) & LL_SOUND_FLAG_LOOP) | ||
116 | { | ||
117 | color.setVec(0.5f,0.5f,1.f,1.f); | ||
118 | } | ||
119 | else | ||
120 | { | ||
121 | color.setVec(1.f,1.f,1.f,1.f); | ||
122 | } | ||
123 | |||
124 | sprintf(out_str,"%d:",channel); | ||
125 | |||
126 | U8 render_style = LLFontGL::NORMAL; | ||
127 | |||
128 | if (gAudiop->getFlags(channel) & LL_SOUND_FLAG_SYNC_MASTER) | ||
129 | { | ||
130 | render_style |= LLFontGL::BOLD; | ||
131 | } | ||
132 | |||
133 | if (gAudiop->getFlags(channel) & LL_SOUND_FLAG_SYNC_SLAVE) | ||
134 | { | ||
135 | render_style |= LLFontGL::ITALIC; | ||
136 | } | ||
137 | |||
138 | if (gAudiop->getFlags(channel) & LL_SOUND_FLAG_SYNC_PENDING) | ||
139 | { | ||
140 | render_style |= LLFontGL::UNDERLINE; | ||
141 | } | ||
142 | |||
143 | LLFontGL::sMonospace->render(out_str, 0, -channel*10, color, LLFontGL::LEFT, LLFontGL::TOP, render_style, S32_MAX, S32_MAX, NULL); | ||
144 | |||
145 | // render_style = LLFontGL::NORMAL; | ||
146 | // if (gAudiop->mCurrentSyncMaster == channel) | ||
147 | // { | ||
148 | // render_style |= LLFontGL::BOLD; | ||
149 | // } | ||
150 | |||
151 | if (!gAudiop->mBufferInUse[channel]) | ||
152 | { | ||
153 | color.setVec(0.5f,0.5f,0.5f,1.f); | ||
154 | } | ||
155 | else if (gAudiop->isPlaying(channel)) | ||
156 | { | ||
157 | color.setVec(0.f,1.f,0.f,1.f); | ||
158 | } | ||
159 | else | ||
160 | { | ||
161 | color.setVec(1.f,0.f,0.f,1.f); | ||
162 | } | ||
163 | |||
164 | if (gAudiop->mWindBufferID ==channel) | ||
165 | { | ||
166 | strcpy(out_str,"wind DMO"); | ||
167 | } | ||
168 | else if (gAudiop->mWaterBufferID ==channel) | ||
169 | { | ||
170 | strcpy(out_str,"water DMO"); | ||
171 | } | ||
172 | else if (gAudiop->mGUID[channel] == SND_CHIRP) | ||
173 | { | ||
174 | strcpy(out_str,"chirp"); | ||
175 | } | ||
176 | else if (gAudiop->mGUID[channel] == SND_SHOT) | ||
177 | { | ||
178 | strcpy(out_str,"shot"); | ||
179 | } | ||
180 | else if (gAudiop->mGUID[channel] == SND_MORTAR) | ||
181 | { | ||
182 | strcpy(out_str,"mortar"); | ||
183 | } | ||
184 | else if (gAudiop->mGUID[channel] == SND_HIT) | ||
185 | { | ||
186 | strcpy(out_str,"hit"); | ||
187 | } | ||
188 | else if (gAudiop->mGUID[channel] == SND_EXPLOSION) | ||
189 | { | ||
190 | strcpy(out_str,"explosion"); | ||
191 | } | ||
192 | else if (gAudiop->mGUID[channel] == SND_BOING) | ||
193 | { | ||
194 | strcpy(out_str,"boing"); | ||
195 | } | ||
196 | else if (gAudiop->mGUID[channel] == SND_MUNCH) | ||
197 | { | ||
198 | strcpy(out_str,"munch"); | ||
199 | } | ||
200 | else if (gAudiop->mGUID[channel] == SND_PUNCH) | ||
201 | { | ||
202 | strcpy(out_str,"punch"); | ||
203 | } | ||
204 | else if (gAudiop->mGUID[channel] == SND_SPLASH) | ||
205 | { | ||
206 | strcpy(out_str,"splash"); | ||
207 | } | ||
208 | else if (gAudiop->mGUID[channel] == SND_CLICK) | ||
209 | { | ||
210 | strcpy(out_str,"click"); | ||
211 | } | ||
212 | else if (gAudiop->mGUID[channel] == SND_ARROW_SHOT) | ||
213 | { | ||
214 | strcpy(out_str,"arrow"); | ||
215 | } | ||
216 | else if (gAudiop->mGUID[channel] == SND_ARROW_THUD) | ||
217 | { | ||
218 | strcpy(out_str,"arrow thud"); | ||
219 | } | ||
220 | else if (gAudiop->mGUID[channel] == SND_SILENCE) | ||
221 | { | ||
222 | strcpy(out_str,"silence"); | ||
223 | } | ||
224 | else if (gAudiop->mGUID[channel] == SND_WELCOME) | ||
225 | { | ||
226 | strcpy(out_str,"welcome"); | ||
227 | } | ||
228 | else if (gAudiop->mGUID[channel] == SND_WELCOME) | ||
229 | { | ||
230 | strcpy(out_str,"welcome"); | ||
231 | } | ||
232 | else if (gAudiop->mGUID[channel] == SND_READY_FOR_BATTLE) | ||
233 | { | ||
234 | strcpy(out_str,"ready for battle"); | ||
235 | } | ||
236 | else if (gAudiop->mGUID[channel] == SND_SQUISH) | ||
237 | { | ||
238 | strcpy(out_str,"squish"); | ||
239 | } | ||
240 | else if (gAudiop->mGUID[channel] == SND_FOOTSTEPS) | ||
241 | { | ||
242 | strcpy(out_str,"footsteps"); | ||
243 | } | ||
244 | else if (gAudiop->mGUID[channel] == SND_BALL_COLLISION) | ||
245 | { | ||
246 | strcpy(out_str,"ball collision"); | ||
247 | } | ||
248 | else | ||
249 | { | ||
250 | gAudiop->mGUID[channel].toString(out_str); | ||
251 | } | ||
252 | |||
253 | out_str[8] = 0; | ||
254 | LLFontGL::sMonospace->render(out_str, 23, -channel*10, color, LLFontGL::LEFT, LLFontGL::TOP, render_style, S32_MAX, S32_MAX, NULL); | ||
255 | |||
256 | if (mPage == 1) | ||
257 | { | ||
258 | LLVector3 pos = gAudiop->getSourcePos(channel); | ||
259 | sprintf(out_str,"%6.2f %6.2f %6.2f",pos.mV[VX],pos.mV[VY],pos.mV[VZ]); | ||
260 | LLFontGL::sMonospace->render(out_str, 103, -channel*10, color, LLFontGL::LEFT, LLFontGL::TOP); | ||
261 | |||
262 | F32 gain = gAudiop->getSourceGain_dB(channel); | ||
263 | sprintf(out_str,"%7.2f",gain); | ||
264 | LLFontGL::sMonospace->render(out_str, 260, -channel*10, color, LLFontGL::LEFT, LLFontGL::TOP); | ||
265 | |||
266 | sprintf(out_str,"%X", gAudiop->mPriority[channel] >> 28); | ||
267 | LLFontGL::sMonospace->render(out_str, 315, -channel*10, color, LLFontGL::LEFT, LLFontGL::TOP); | ||
268 | } | ||
269 | else if (mPage == 4) | ||
270 | { | ||
271 | F32 indicator_width = 240; | ||
272 | |||
273 | glPushMatrix(); | ||
274 | // We're going to be drawing flat shaded rectangles | ||
275 | LLGLSNoTexture gls_no_texture; | ||
276 | // Draw background black rectangle | ||
277 | glColor4f(0.f, 0.f, 0.f, 1.0f); | ||
278 | |||
279 | F32 length = gAudiop->getSourceLength(channel); | ||
280 | length = length/(44100.0*2.0); // length in seconds | ||
281 | length = length/10.f; // rescale per maximum length | ||
282 | |||
283 | gl_rect_2d(80, (-channel*10)-1, 80 + llfloor((F32)(indicator_width * length)), (-channel*10)-9); // -y is down (don't know why) | ||
284 | |||
285 | F32 current_pointer = gAudiop->getSourceCurrentSample(channel); | ||
286 | current_pointer = current_pointer/(44100.0*2.0); // length in seconds | ||
287 | current_pointer = current_pointer/10.f; // rescale per maximum length | ||
288 | |||
289 | if (!gAudiop->mBufferInUse[channel]) | ||
290 | { | ||
291 | glColor4f(0.5f,0.5f,0.5f,1.f); | ||
292 | } | ||
293 | else if (gAudiop->isPlaying(channel)) | ||
294 | { | ||
295 | glColor4f(0.f,1.f,0.f,1.f); | ||
296 | } | ||
297 | else | ||
298 | { | ||
299 | glColor4f(1.f,0.f,0.f,1.f); | ||
300 | } | ||
301 | |||
302 | gl_rect_2d(80, (-channel*10)-1, 80 + llfloor((F32)(indicator_width * current_pointer)), (-channel*10)-9); // -y is down (don't know why) | ||
303 | |||
304 | glPopMatrix(); | ||
305 | { | ||
306 | LLGLSUIDefault gls_ui; | ||
307 | |||
308 | color.setVec(1.f,1.f,1.f,1.f); | ||
309 | |||
310 | sprintf(out_str,"%6.3f",length*10.f); | ||
311 | LLFontGL::sMonospace->render(out_str, 200, -channel*10, color, LLFontGL::LEFT, LLFontGL::TOP, render_style, S32_MAX, S32_MAX, NULL); | ||
312 | |||
313 | if (!(gAudiop->mVO_ID[channel].isNull())) | ||
314 | { | ||
315 | gAudiop->mVO_ID[channel].toString(out_str); | ||
316 | out_str[8] = 0; | ||
317 | LLFontGL::sMonospace->render(out_str, 260, -channel*10, color, LLFontGL::LEFT, LLFontGL::TOP, render_style, S32_MAX, S32_MAX, NULL); | ||
318 | } | ||
319 | if (gAudiop->mQueuedTrigger[channel]) | ||
320 | { | ||
321 | gAudiop->mQueuedTrigger[channel]->mID.toString(out_str); | ||
322 | out_str[8] = 0; | ||
323 | LLFontGL::sMonospace->render(out_str, 320, -channel*10, color, LLFontGL::LEFT, LLFontGL::TOP, render_style, S32_MAX, S32_MAX, NULL); | ||
324 | } | ||
325 | } | ||
326 | } | ||
327 | else | ||
328 | { | ||
329 | S32 volume; | ||
330 | S32 freq; | ||
331 | S32 inside; | ||
332 | S32 outside; | ||
333 | LLVector3 orient; | ||
334 | S32 out_volume; | ||
335 | F32 min_dist; | ||
336 | F32 max_dist; | ||
337 | |||
338 | gAudiop->get3DParams(channel, &volume, &freq, &inside, &outside, &orient, &out_volume, &min_dist, &max_dist); | ||
339 | |||
340 | if (mPage == 2) | ||
341 | { | ||
342 | sprintf(out_str,"%4.2f %4.2f %4.2f",orient.mV[VX],orient.mV[VY],orient.mV[VZ]); | ||
343 | LLFontGL::sMonospace->render(out_str, 103, -channel*10, color, LLFontGL::LEFT, LLFontGL::TOP); | ||
344 | |||
345 | sprintf(out_str,"%4d %4d",inside, outside); | ||
346 | LLFontGL::sMonospace->render(out_str, 210, -channel*10, color, LLFontGL::LEFT, LLFontGL::TOP); | ||
347 | |||
348 | sprintf(out_str,"%6d", out_volume); | ||
349 | LLFontGL::sMonospace->render(out_str, 280, -channel*10, color, LLFontGL::LEFT, LLFontGL::TOP); | ||
350 | } | ||
351 | else // mPage == 3 | ||
352 | { | ||
353 | F32 distance = 0.f; | ||
354 | if (gAudiop->isSourceAmbient(channel)) | ||
355 | { | ||
356 | distance = dist_vec(gAudiop->getSourcePos(channel),LLVector3::zero); | ||
357 | } | ||
358 | else | ||
359 | { | ||
360 | distance = dist_vec(gAudiop->getSourcePos(channel),gAudiop->getListenerPos()); | ||
361 | } | ||
362 | |||
363 | sprintf(out_str,"%6.2f %6.2f %6.2f",distance, min_dist, max_dist); | ||
364 | LLFontGL::sMonospace->render(out_str, 103, -channel*10, color, LLFontGL::LEFT, LLFontGL::TOP); | ||
365 | |||
366 | F32 gain = gAudiop->getSourceGain_dB(channel); | ||
367 | sprintf(out_str,"%7.2f",gain); | ||
368 | LLFontGL::sMonospace->render(out_str, 280, -channel*10, color, LLFontGL::LEFT, LLFontGL::TOP); | ||
369 | } | ||
370 | } | ||
371 | } | ||
372 | LLFontGL::sMonospace->render("Listener", 23, -(channel*10+5), color, LLFontGL::LEFT, LLFontGL::TOP); | ||
373 | |||
374 | |||
375 | if (mPage == 1) | ||
376 | { | ||
377 | LLVector3 lpos = gAudiop->getListenerPos(); | ||
378 | sprintf(out_str,"%6.2f %6.2f %6.2f",lpos.mV[VX],lpos.mV[VY],lpos.mV[VZ]); | ||
379 | LLFontGL::sMonospace->render(out_str, 103, -(channel*10+5), color, LLFontGL::LEFT, LLFontGL::TOP); | ||
380 | |||
381 | F32 gain = gAudiop->getMasterGain_dB(); | ||
382 | sprintf(out_str,"%7.2f",gain); | ||
383 | LLFontGL::sMonospace->render(out_str, 280, -(channel*10+5), color, LLFontGL::LEFT, LLFontGL::TOP); | ||
384 | } | ||
385 | else if (mPage == 2) | ||
386 | { | ||
387 | sprintf(out_str,"cone orient inner outer gain"); | ||
388 | LLFontGL::sMonospace->render(out_str, 103, -(channel*10+5), color, LLFontGL::LEFT, LLFontGL::TOP); | ||
389 | } | ||
390 | else if (mPage == 3) | ||
391 | { | ||
392 | sprintf(out_str,"distance min max gain"); | ||
393 | LLFontGL::sMonospace->render(out_str, 103, -(channel*10+5), color, LLFontGL::LEFT, LLFontGL::TOP); | ||
394 | } | ||
395 | } | ||
396 | else | ||
397 | { | ||
398 | LLFontGL::sMonospace->render("No Audio Engine available", 50 , -175, | ||
399 | LLColor4(1.f,0.1f,0.1f,1.f), | ||
400 | LLFontGL::LEFT, LLFontGL::TOP); | ||
401 | } | ||
402 | |||
403 | glPopMatrix(); | ||
404 | */ | ||
405 | } | ||
406 | |||
407 | |||
408 | |||
409 | |||
410 | |||
411 | |||