Compare commits
809 Commits
1.6.0
...
V2MultiWea
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e7a49da774 | ||
|
|
81242f1b5e | ||
|
|
2e073f7449 | ||
|
|
58ff4a00f1 | ||
|
|
30f49526db | ||
|
|
b194d9e012 | ||
|
|
de26fff525 | ||
|
|
ca9c99577f | ||
|
|
b0c28c5eb2 | ||
|
|
ded9d1027b | ||
|
|
8a271b9621 | ||
|
|
c5f9e8cf68 | ||
|
|
4e2af85770 | ||
|
|
5a685febbf | ||
|
|
cd2dc2f3ca | ||
|
|
9c61998dac | ||
|
|
509340237c | ||
|
|
fc3436a8d1 | ||
|
|
41983b7f27 | ||
|
|
a9494d1fb0 | ||
|
|
608417ba6b | ||
|
|
c5d19cca0b | ||
|
|
4435e7ade3 | ||
|
|
f79a16ef0f | ||
|
|
947990c2ad | ||
|
|
e36042bb76 | ||
|
|
cb5474c291 | ||
|
|
77948b8ce4 | ||
|
|
2ac4f81424 | ||
|
|
7ad1b8731d | ||
|
|
d66acdf240 | ||
|
|
8eb319d3ba | ||
|
|
d703b4e076 | ||
|
|
9ddbc132bf | ||
|
|
c464a8da30 | ||
|
|
e6689f830a | ||
|
|
ece9dda7b4 | ||
|
|
361c69edd9 | ||
|
|
d0668d818c | ||
|
|
24db228406 | ||
|
|
53a570b977 | ||
|
|
4ba1509371 | ||
|
|
399d93cc36 | ||
|
|
67e1a3b004 | ||
|
|
221e3908b9 | ||
|
|
782091ff02 | ||
|
|
c02834b7e3 | ||
|
|
15fb0ac3aa | ||
|
|
0bee4a922f | ||
|
|
5996ff1fa2 | ||
|
|
e7a3a150a7 | ||
|
|
3c2f0b551f | ||
|
|
e9df867a21 | ||
|
|
4391614d6e | ||
|
|
d63c54cb78 | ||
|
|
058720824d | ||
|
|
8f6dbfc399 | ||
|
|
eb7615ad57 | ||
|
|
7234e63ce1 | ||
|
|
5f98e24efe | ||
|
|
ebf66ebe9d | ||
|
|
26810ff16a | ||
|
|
48a2d0497b | ||
|
|
b02465822b | ||
|
|
edcbec7b76 | ||
|
|
a8ebd6eebb | ||
|
|
e6b6e8b282 | ||
|
|
56fb36bbfa | ||
|
|
94eda3aa24 | ||
|
|
a3e6e96869 | ||
|
|
102565cd3e | ||
|
|
b5535c9cc4 | ||
|
|
dadfc059c7 | ||
|
|
4c45e9a9d1 | ||
|
|
3796a216d2 | ||
|
|
21f7df0dcc | ||
|
|
5b4700a8ee | ||
|
|
0286c8bf55 | ||
|
|
a399580c84 | ||
|
|
349006637e | ||
|
|
945c663359 | ||
|
|
6b1f5c388f | ||
|
|
57641db71b | ||
|
|
891d6d3448 | ||
|
|
fd59accf96 | ||
|
|
0e2ca65084 | ||
|
|
0ad533d94d | ||
|
|
0d87d3dc1c | ||
|
|
5ce477c7cc | ||
|
|
1a217b23c6 | ||
|
|
bb8417d6be | ||
|
|
332c8f997c | ||
|
|
5228aa7029 | ||
|
|
f38e8b1981 | ||
|
|
ac2f3968c2 | ||
|
|
ab5fd28cef | ||
|
|
fb1594535e | ||
|
|
73c05eff77 | ||
|
|
9835d3b27e | ||
|
|
20f138b31f | ||
|
|
b15f2d1a56 | ||
|
|
f04aabde96 | ||
|
|
063ce180d3 | ||
|
|
c6120cd283 | ||
|
|
51a4e4960f | ||
|
|
f9e40aedce | ||
|
|
271883e737 | ||
|
|
7b2c4034f1 | ||
|
|
58c58dc845 | ||
|
|
61013dd2ab | ||
|
|
a2649ceb5a | ||
|
|
eb562c2470 | ||
|
|
ae0804beea | ||
|
|
fa4ee55308 | ||
|
|
e729bd80ce | ||
|
|
9eda9ad462 | ||
|
|
dbe50efc10 | ||
|
|
d1540040a8 | ||
|
|
bf28ce4239 | ||
|
|
8192b547a8 | ||
|
|
8dc0e16f0a | ||
|
|
5a2d160ac4 | ||
|
|
e20b383aa0 | ||
|
|
a82953d0d0 | ||
|
|
16c2235510 | ||
|
|
8e6063e7b9 | ||
|
|
4799899317 | ||
|
|
37d2e41618 | ||
|
|
fd183e01b5 | ||
|
|
75ef768e7f | ||
|
|
35bd8d90be | ||
|
|
a5faea64d9 | ||
|
|
e7649d8f1c | ||
|
|
3eccd251c0 | ||
|
|
b3d91d816d | ||
|
|
3cc37fb12b | ||
|
|
71a29e347e | ||
|
|
6b66c33b47 | ||
|
|
d03b7d052d | ||
|
|
640d9489cb | ||
|
|
3d40f96dfe | ||
|
|
817085c172 | ||
|
|
5ce00cecef | ||
|
|
bb1d94ba0e | ||
|
|
5ba68ed763 | ||
|
|
ee84500735 | ||
|
|
275c85f482 | ||
|
|
f584cb3b3b | ||
|
|
5517266bda | ||
|
|
59fdf3b6e1 | ||
|
|
e1d243272f | ||
|
|
3bd9ffe135 | ||
|
|
fd1896536e | ||
|
|
1d402bfe39 | ||
|
|
06068a0361 | ||
|
|
18ac23554f | ||
|
|
b49ad1cd34 | ||
|
|
01d6095242 | ||
|
|
7774fe7f04 | ||
|
|
29e308b5ca | ||
|
|
e7bcf1e9ec | ||
|
|
0453971a85 | ||
|
|
4da4d5fd50 | ||
|
|
db4e36a99a | ||
|
|
07ff467831 | ||
|
|
86c65e492d | ||
|
|
4770e7724c | ||
|
|
f05edda4f4 | ||
|
|
be9f3178c0 | ||
|
|
d86f67f818 | ||
|
|
3acf6dc001 | ||
|
|
ce1607cf17 | ||
|
|
fee59e83b8 | ||
|
|
caaba76921 | ||
|
|
70438fa06f | ||
|
|
3f0f955a76 | ||
|
|
196e9d6c78 | ||
|
|
459751f206 | ||
|
|
2e5ea4f5a7 | ||
|
|
cd7331453a | ||
|
|
3d6511f4e1 | ||
|
|
5ce6f7eb7d | ||
|
|
90f12f1bb9 | ||
|
|
8334277838 | ||
|
|
80e53ebb2b | ||
|
|
1e9e7d701d | ||
|
|
a57ad256b5 | ||
|
|
b4bdb7ca36 | ||
|
|
6b5df7194a | ||
|
|
0fdab061b9 | ||
|
|
896f7f5b9b | ||
|
|
f885c8667b | ||
|
|
c07d90a2ba | ||
|
|
cc459cb582 | ||
|
|
8b8fe82c8e | ||
|
|
1023088c0d | ||
|
|
b18bc08600 | ||
|
|
5d6b925823 | ||
|
|
fffbda1b90 | ||
|
|
8c721c4a69 | ||
|
|
21170e1e18 | ||
|
|
87b8f6e076 | ||
|
|
406ff6872f | ||
|
|
52b4008968 | ||
|
|
c1133cb932 | ||
|
|
1db7221508 | ||
|
|
83a3bbb48e | ||
|
|
8b6f462d13 | ||
|
|
55e589375f | ||
|
|
2b833129c5 | ||
|
|
efd1b2bfa9 | ||
|
|
5eb90ef9cd | ||
|
|
edd1b4d8e7 | ||
|
|
b67fa864ff | ||
|
|
d54c86e1df | ||
|
|
0a11f09918 | ||
|
|
2d75e8fda6 | ||
|
|
9f2b668424 | ||
|
|
502b2d30d4 | ||
|
|
355883aa5c | ||
|
|
500135941a | ||
|
|
5f7f7b7d61 | ||
|
|
251b0fa5c0 | ||
|
|
ab26e1008f | ||
|
|
ecc396219d | ||
|
|
a7d70878b7 | ||
|
|
baad415f0d | ||
|
|
fb10af2723 | ||
|
|
2f632d3324 | ||
|
|
2bf940e15d | ||
|
|
840cb29f84 | ||
|
|
dcec1cb5f2 | ||
|
|
a066730acb | ||
|
|
a6a69caa4f | ||
|
|
0bdf54e6d9 | ||
|
|
10af9d64f2 | ||
|
|
5c66c70546 | ||
|
|
a76b0cb9da | ||
|
|
0450358df3 | ||
|
|
a632010b95 | ||
|
|
323ec8cf59 | ||
|
|
a1038f3972 | ||
|
|
93f6ea1a07 | ||
|
|
d721fd65b3 | ||
|
|
e207f2e025 | ||
|
|
3d39e443fe | ||
|
|
be37d9b5a9 | ||
|
|
e39327c017 | ||
|
|
edbc22961e | ||
|
|
c2da7f4570 | ||
|
|
bdeead6f8e | ||
|
|
3250725aae | ||
|
|
803011582c | ||
|
|
2206f68129 | ||
|
|
6388324552 | ||
|
|
89f35779b4 | ||
|
|
ad1e3f1d2d | ||
|
|
9477a5f32f | ||
|
|
8e71cf8e6e | ||
|
|
ea7396d2cf | ||
|
|
5c7debecc8 | ||
|
|
c6d6eed7d3 | ||
|
|
e2e65c39bf | ||
|
|
a76105a60d | ||
|
|
39f8deb498 | ||
|
|
665569dfc7 | ||
|
|
19f72cf967 | ||
|
|
a4363de59e | ||
|
|
c3aa321d51 | ||
|
|
cf4b8cf263 | ||
|
|
9b268c3654 | ||
|
|
925c42294f | ||
|
|
23811df3cf | ||
|
|
f7cc9c4d33 | ||
|
|
66ccff964b | ||
|
|
b0240320ee | ||
|
|
1810a7c7f9 | ||
|
|
0c82b8bd3a | ||
|
|
4e8b69206c | ||
|
|
0a7fc0e65e | ||
|
|
787e03e821 | ||
|
|
f381b0c2dd | ||
|
|
b8744b9e6a | ||
|
|
59ee1a1041 | ||
|
|
88d0983e37 | ||
|
|
3680e022fc | ||
|
|
a642b725e0 | ||
|
|
dbc3a8c65f | ||
|
|
86cafba0df | ||
|
|
60ded2ad14 | ||
|
|
fa560a7081 | ||
|
|
ae7b12f230 | ||
|
|
5023f23cc4 | ||
|
|
0fef1407e3 | ||
|
|
a09c505fa0 | ||
|
|
023909b8e0 | ||
|
|
a90d7bbb46 | ||
|
|
60081d7ed5 | ||
|
|
0b5235d054 | ||
|
|
071554acae | ||
|
|
f05343dec1 | ||
|
|
a403cef605 | ||
|
|
9b4b234c12 | ||
|
|
42518dbfaa | ||
|
|
4e700a5808 | ||
|
|
647af6c15a | ||
|
|
b91ba258e1 | ||
|
|
fe579d6e4b | ||
|
|
6d3044b448 | ||
|
|
db8564bb3c | ||
|
|
28f73d1037 | ||
|
|
dd9196efac | ||
|
|
c542c7bdbb | ||
|
|
f8aad35775 | ||
|
|
657c8e8729 | ||
|
|
a451a8f566 | ||
|
|
0e5b1a8fa7 | ||
|
|
e922207797 | ||
|
|
e447bd98a5 | ||
|
|
a0e9e8d4b2 | ||
|
|
09817403ff | ||
|
|
8f6ef05429 | ||
|
|
4cbf259ab3 | ||
|
|
042622b5db | ||
|
|
eff72e15cd | ||
|
|
aacd33ada7 | ||
|
|
fe00eed401 | ||
|
|
000d00579b | ||
|
|
63dd39ea51 | ||
|
|
87cb88f2f7 | ||
|
|
cb3e8215d6 | ||
|
|
a3900a4830 | ||
|
|
0f9139305a | ||
|
|
0a8504fb3c | ||
|
|
d709200fc0 | ||
|
|
77df33ebf6 | ||
|
|
8064d561f4 | ||
|
|
aaf1e4d21b | ||
|
|
9f9a4cbaaf | ||
|
|
e7806f9dac | ||
|
|
d7eb4fc656 | ||
|
|
d10724ae6f | ||
|
|
0a3116422a | ||
|
|
0a59b3bb54 | ||
|
|
e0b21b08fa | ||
|
|
d4591828c8 | ||
|
|
cad0597524 | ||
|
|
e10581e319 | ||
|
|
f7b2139e81 | ||
|
|
f55452d6dd | ||
|
|
b0c675498c | ||
|
|
f16da13198 | ||
|
|
0827b3fce9 | ||
|
|
a3a7f72b7c | ||
|
|
acf378e9f2 | ||
|
|
a39209cd37 | ||
|
|
2ef5673c18 | ||
|
|
4c10ae1a4c | ||
|
|
66c3f282de | ||
|
|
fec75d9436 | ||
|
|
ef68f43687 | ||
|
|
13780fae2a | ||
|
|
c294456e2a | ||
|
|
6410fb3209 | ||
|
|
af22591cc0 | ||
|
|
b0267e4631 | ||
|
|
69a2d0bc5e | ||
|
|
108b9211ff | ||
|
|
97f2474956 | ||
|
|
b4c68d56b6 | ||
|
|
03926c2374 | ||
|
|
787f91085d | ||
|
|
1b37bd5df6 | ||
|
|
ea0a5c521f | ||
|
|
6ba69adccc | ||
|
|
481361f714 | ||
|
|
e1e34623cb | ||
|
|
78409deaa7 | ||
|
|
787a18d3a8 | ||
|
|
548f9d0a88 | ||
|
|
8450386330 | ||
|
|
8adf2965fd | ||
|
|
e0bf075f7f | ||
|
|
8a49d4ef94 | ||
|
|
d85e1afd7e | ||
|
|
c96d1c3aa5 | ||
|
|
1cbc825461 | ||
|
|
f0d6200e8e | ||
|
|
ad24fcca39 | ||
|
|
06837a2a77 | ||
|
|
47537ba764 | ||
|
|
cd51a6f795 | ||
|
|
3d40cd86ac | ||
|
|
b03b4db7c7 | ||
|
|
859e2701f2 | ||
|
|
2617df44db | ||
|
|
01a8e11ef3 | ||
|
|
5a455eac91 | ||
|
|
e18e051bfc | ||
|
|
bf44d3f98e | ||
|
|
b6fa215c4e | ||
|
|
726dc02aaa | ||
|
|
9ee0c5acf3 | ||
|
|
5e0140ba81 | ||
|
|
a690c970e6 | ||
|
|
db28c382e0 | ||
|
|
1747d529d8 | ||
|
|
27763d8390 | ||
|
|
ef79781c9a | ||
|
|
7b6ff27c4b | ||
|
|
2526d04397 | ||
|
|
4ffa06ae07 | ||
|
|
03c0509a6c | ||
|
|
f68211d83e | ||
|
|
7694f915f5 | ||
|
|
0340778775 | ||
|
|
6fecfad2a2 | ||
|
|
e9fa5e6f3d | ||
|
|
b5ec7fe015 | ||
|
|
b0ccec2b62 | ||
|
|
55cce46454 | ||
|
|
071745007a | ||
|
|
b755bcd495 | ||
|
|
315552d1e0 | ||
|
|
e7b2972fc8 | ||
|
|
e1675f6bd1 | ||
|
|
2044b88015 | ||
|
|
77a21f95e5 | ||
|
|
a4e05eea9d | ||
|
|
373cb7fb39 | ||
|
|
2e240e70d6 | ||
|
|
bdcb5dc877 | ||
|
|
e7a59c1031 | ||
|
|
8ae25e4812 | ||
|
|
3548521bef | ||
|
|
d15ed9ed34 | ||
|
|
655365247c | ||
|
|
eaecc9a4d0 | ||
|
|
dfe33963bb | ||
|
|
661f5ede04 | ||
|
|
5858f2822c | ||
|
|
379ecccec2 | ||
|
|
e69c605c4f | ||
|
|
f6711e6b4f | ||
|
|
e327e7a15e | ||
|
|
9973dfd1c7 | ||
|
|
b045d9bd96 | ||
|
|
64181e19b8 | ||
|
|
ef927134f0 | ||
|
|
f9398a3ab1 | ||
|
|
450402d83d | ||
|
|
9f7e9299bd | ||
|
|
681901cb7c | ||
|
|
a0c549534f | ||
|
|
9453c2c2e9 | ||
|
|
32c6365bf9 | ||
|
|
6c921ba340 | ||
|
|
f5818b7621 | ||
|
|
ac1a6101e1 | ||
|
|
7ff58abc17 | ||
|
|
c548aa3497 | ||
|
|
d0c782c7ae | ||
|
|
d9640ecc65 | ||
|
|
b177324058 | ||
|
|
e7a20b04de | ||
|
|
5245547f28 | ||
|
|
ef696d895d | ||
|
|
a15e72dc03 | ||
|
|
b7997a2677 | ||
|
|
635c8d0f72 | ||
|
|
c9269c04be | ||
|
|
0c3bff3763 | ||
|
|
f06d9294a2 | ||
|
|
c39ddb5991 | ||
|
|
690338a122 | ||
|
|
9dd8f1b8ab | ||
|
|
744b5b6404 | ||
|
|
381d86adb7 | ||
|
|
26858c026a | ||
|
|
c454044913 | ||
|
|
6e57791397 | ||
|
|
1c5fc42772 | ||
|
|
9bab3a362f | ||
|
|
fc65380f2a | ||
|
|
c1b749e12c | ||
|
|
d310ae3bc6 | ||
|
|
9ab0cd11e7 | ||
|
|
51c3f3253b | ||
|
|
00c00b617c | ||
|
|
c0dd8cac46 | ||
|
|
8c35361878 | ||
|
|
2e59ae1340 | ||
|
|
856507a580 | ||
|
|
8899dbef3c | ||
|
|
8e4ea7e3b4 | ||
|
|
5524959f33 | ||
|
|
39959712c1 | ||
|
|
c652df10c6 | ||
|
|
131dc84256 | ||
|
|
afed6dad84 | ||
|
|
b18033d023 | ||
|
|
26bb68fcb7 | ||
|
|
2c4f850e5f | ||
|
|
502fd90a8d | ||
|
|
f2c6ab27e3 | ||
|
|
40bbeebd27 | ||
|
|
f9d802f832 | ||
|
|
a6f95d21af | ||
|
|
87f0edc652 | ||
|
|
97c0800701 | ||
|
|
da96043a24 | ||
|
|
f6fcf8ca38 | ||
|
|
43b826bd52 | ||
|
|
cef03d52cb | ||
|
|
29cdfdc13e | ||
|
|
2b8a5b4bd1 | ||
|
|
910cb29a7f | ||
|
|
3261332e0b | ||
|
|
6939d2d70b | ||
|
|
df65a3b7fc | ||
|
|
7d9299d870 | ||
|
|
00ae7c3cd3 | ||
|
|
769c4f43bd | ||
|
|
7fec659979 | ||
|
|
d104d15c53 | ||
|
|
22137671da | ||
|
|
9577607c22 | ||
|
|
4340cee991 | ||
|
|
d385de9139 | ||
|
|
c4e0122846 | ||
|
|
6374f012de | ||
|
|
7d4c2aa54f | ||
|
|
c5024ff04d | ||
|
|
63117686b1 | ||
|
|
f6bd78083d | ||
|
|
f176aeed8d | ||
|
|
51746dc751 | ||
|
|
94d6ef126f | ||
|
|
14f2df2a72 | ||
|
|
82693aae35 | ||
|
|
c4e55464c9 | ||
|
|
4a4b786a60 | ||
|
|
d7d65df9e0 | ||
|
|
40400d696b | ||
|
|
4c201a9b83 | ||
|
|
b338506229 | ||
|
|
7805508e8d | ||
|
|
9837b0ea2e | ||
|
|
60d5bb81f2 | ||
|
|
76cb68600c | ||
|
|
a6b270b02d | ||
|
|
f68a899185 | ||
|
|
3299d27197 | ||
|
|
a39bf61977 | ||
|
|
6a290864af | ||
|
|
20ab55752d | ||
|
|
4190816023 | ||
|
|
e33a15d410 | ||
|
|
419f7b41af | ||
|
|
670b85a86f | ||
|
|
e835d51bdf | ||
|
|
242134d2af | ||
|
|
f0f2834cfe | ||
|
|
860bddb1f5 | ||
|
|
14f9cd57e1 | ||
|
|
063112bf59 | ||
|
|
e764329701 | ||
|
|
27a17b332f | ||
|
|
373688cfb0 | ||
|
|
09d37d7dfd | ||
|
|
b2dd4f652e | ||
|
|
6bbff07e00 | ||
|
|
09c7e66844 | ||
|
|
c371b82900 | ||
|
|
5da990e8fb | ||
|
|
b96beb478c | ||
|
|
ad3a16fd3b | ||
|
|
21b6b89577 | ||
|
|
55a66737c0 | ||
|
|
198e499798 | ||
|
|
9d3b276f61 | ||
|
|
b0967463ca | ||
|
|
1cc33caaa3 | ||
|
|
0777bedde8 | ||
|
|
be978ab76b | ||
|
|
21a64b306d | ||
|
|
5a66c2bfba | ||
|
|
e5a27e6558 | ||
|
|
6f3a92d772 | ||
|
|
4feb69e342 | ||
|
|
d2b2c501bc | ||
|
|
465660e235 | ||
|
|
4eea8624b7 | ||
|
|
09213950c3 | ||
|
|
d93f0bb56a | ||
|
|
4de23007a5 | ||
|
|
8543106f5e | ||
|
|
ced937cc46 | ||
|
|
9476aedaf6 | ||
|
|
68bc6749e5 | ||
|
|
c5d4ccc78d | ||
|
|
e847b105f2 | ||
|
|
d6e9b50b99 | ||
|
|
61beedd3d9 | ||
|
|
35333f0105 | ||
|
|
be700d0719 | ||
|
|
5dd2f5e2cf | ||
|
|
e9bd6a3b0d | ||
|
|
d505e515e4 | ||
|
|
9fd813267e | ||
|
|
f14e6cdb60 | ||
|
|
fe87ac0f3d | ||
|
|
a6f36abab0 | ||
|
|
621e677898 | ||
|
|
626a94cf8f | ||
|
|
d66074d2ea | ||
|
|
bf28f6514f | ||
|
|
cf62e22409 | ||
|
|
900d063d4f | ||
|
|
b911e86b02 | ||
|
|
54bfdb7704 | ||
|
|
566152c230 | ||
|
|
dcbf39bcfa | ||
|
|
c73913a864 | ||
|
|
d3ba4a2b80 | ||
|
|
af7affa9dd | ||
|
|
89e738003c | ||
|
|
a3f7399d7d | ||
|
|
dff195d120 | ||
|
|
48552e3027 | ||
|
|
c6ce417fac | ||
|
|
a7510d3b3a | ||
|
|
aad10c9b8d | ||
|
|
ca96e00135 | ||
|
|
536189340d | ||
|
|
23b97efb69 | ||
|
|
2c8e3bb0a3 | ||
|
|
7a48cb9979 | ||
|
|
2f5caa27fd | ||
|
|
d69f00741f | ||
|
|
8c4a52e58d | ||
|
|
fd22d80dfd | ||
|
|
e071dc52fd | ||
|
|
e1cbeb7e02 | ||
|
|
9d367cf9f2 | ||
|
|
3890e61fbc | ||
|
|
3df853b74b | ||
|
|
10bc483305 | ||
|
|
f55fa45b73 | ||
|
|
acb24dd3e1 | ||
|
|
4b87c45298 | ||
|
|
a2fb56bf48 | ||
|
|
37095dc2cd | ||
|
|
a57ac5a954 | ||
|
|
29045609a3 | ||
|
|
b4dad425aa | ||
|
|
c73414f1a1 | ||
|
|
6920bee5e2 | ||
|
|
6a5e203884 | ||
|
|
6b1f44ed6d | ||
|
|
ab8cd3e5d5 | ||
|
|
78f7cc0d64 | ||
|
|
b607650d5c | ||
|
|
1bfa72fa7c | ||
|
|
0030ca3af7 | ||
|
|
a53e08032f | ||
|
|
62febda165 | ||
|
|
a726de0e99 | ||
|
|
918d527b14 | ||
|
|
5919c9a788 | ||
|
|
14f2248ea1 | ||
|
|
81499fc6ea | ||
|
|
ffb285c6ff | ||
|
|
e08e8cf131 | ||
|
|
40b4b47023 | ||
|
|
2565caf62a | ||
|
|
d63df79b85 | ||
|
|
697dd7e929 | ||
|
|
f613be9276 | ||
|
|
f5a08b1c12 | ||
|
|
f40bbb1602 | ||
|
|
aeb766ee37 | ||
|
|
cd67046b33 | ||
|
|
66f4c170cb | ||
|
|
a485760028 | ||
|
|
0b5a2cd6a3 | ||
|
|
8e7733b2ce | ||
|
|
08d2c17c65 | ||
|
|
09f7136cf4 | ||
|
|
c4b77e247e | ||
|
|
9f9daba33d | ||
|
|
dc3831c86b | ||
|
|
ab14f1908c | ||
|
|
bf6e1d6c75 | ||
|
|
5d8d402403 | ||
|
|
b8eb3076ce | ||
|
|
d16e48e128 | ||
|
|
e46c906a8b | ||
|
|
83e8a9076b | ||
|
|
56b28756ad | ||
|
|
13fad75811 | ||
|
|
1cf367aae5 | ||
|
|
70909f86c8 | ||
|
|
1fd908b2c4 | ||
|
|
f0108c17b9 | ||
|
|
0566bde61b | ||
|
|
a31fc8a612 | ||
|
|
2ba9e16a6c | ||
|
|
e6dce6ad7b | ||
|
|
c87caebcf7 | ||
|
|
121a557fe5 | ||
|
|
6aa7f219cd | ||
|
|
e9e05bec90 | ||
|
|
8421661a89 | ||
|
|
7fea7c589d | ||
|
|
0e3b735a60 | ||
|
|
236f5757a2 | ||
|
|
0a44e3ee09 | ||
|
|
ee5a9c97be | ||
|
|
2126654979 | ||
|
|
df40a8c5cf | ||
|
|
34fb647903 | ||
|
|
5de4f1e2da | ||
|
|
18dd31f51a | ||
|
|
40689f7d1e | ||
|
|
4ce0345842 | ||
|
|
844e38702a | ||
|
|
5f074c8c82 | ||
|
|
5c2b1d396b | ||
|
|
b0b7837c4d | ||
|
|
7789c5a703 | ||
|
|
b64cb8d339 | ||
|
|
3891928092 | ||
|
|
f5983208eb | ||
|
|
0ef5931212 | ||
|
|
6964cec6f1 | ||
|
|
a35ef93d19 | ||
|
|
e5f75d1e48 | ||
|
|
231af66b90 | ||
|
|
f386fc75df | ||
|
|
cc45a24aff | ||
|
|
e06d0b2e70 | ||
|
|
0281ac4afe | ||
|
|
7227c01d79 | ||
|
|
c5abde1616 | ||
|
|
c2a4951f20 | ||
|
|
0fde15246b | ||
|
|
b3423de80a | ||
|
|
743449e635 | ||
|
|
405182025d | ||
|
|
bd6d14d741 | ||
|
|
0e190cadcd | ||
|
|
408f5a4a51 | ||
|
|
53f5957b92 | ||
|
|
fb32a0be5a | ||
|
|
474e1ec7cc | ||
|
|
1e9d09b82e | ||
|
|
c3b1bf4b76 | ||
|
|
e2d9c31f5e | ||
|
|
7b81e9d248 | ||
|
|
6e6c438e2a | ||
|
|
4606c7512e | ||
|
|
88e373c960 | ||
|
|
f2deb39dac | ||
|
|
8a5793ce23 | ||
|
|
a36c5f2ee6 | ||
|
|
c63bf31328 | ||
|
|
5d811163a6 | ||
|
|
78a98cbf08 | ||
|
|
91348909b5 | ||
|
|
73f2543a6f | ||
|
|
d80458b726 | ||
|
|
22385c44c8 | ||
|
|
40261d3472 | ||
|
|
06ff562cd2 | ||
|
|
e7b023778a | ||
|
|
3e12fe15bc | ||
|
|
95634e8276 | ||
|
|
6c19346855 | ||
|
|
2e4419a295 | ||
|
|
bdc95a1544 | ||
|
|
68e143de1b | ||
|
|
5d6aadb268 | ||
|
|
4368c57243 | ||
|
|
ef54491760 | ||
|
|
d88f696604 | ||
|
|
82b0171a86 | ||
|
|
142427b3e1 | ||
|
|
9c4d50eda3 | ||
|
|
f3c8419de8 | ||
|
|
d6524fbd26 | ||
|
|
4446b0fbad | ||
|
|
58ea5f88dc | ||
|
|
8ce30e9ff7 | ||
|
|
67230a3290 | ||
|
|
c413d62536 | ||
|
|
d1b19aa389 | ||
|
|
06048ae818 | ||
|
|
18e5b94615 | ||
|
|
ff786ad2c7 | ||
|
|
c95696e8a0 | ||
|
|
4dbed63f0b | ||
|
|
3de99315e2 | ||
|
|
5945793031 | ||
|
|
449e7b2a84 | ||
|
|
cdebc1c5cc | ||
|
|
e95ee85804 | ||
|
|
5e69c9fa05 | ||
|
|
370890b704 |
3
.gitignore
vendored
3
.gitignore
vendored
@@ -1,4 +1,5 @@
|
||||
/installed.xml
|
||||
/indra/llcommon/llversionviewer.h
|
||||
/indra/build-*
|
||||
/indra/tools/vstool/obj/
|
||||
*.aps
|
||||
@@ -11,11 +12,13 @@
|
||||
/indra/viewer-*
|
||||
/indra/newview/vivox-runtime/
|
||||
/libraries/
|
||||
/lib/
|
||||
*.pyc
|
||||
*.orig
|
||||
*.rej
|
||||
*.bak
|
||||
*~
|
||||
*.DS_Store
|
||||
/LICENSES/
|
||||
/edited-files.txt
|
||||
qtcreator-build/
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
Permission is hereby granted, free of charge, to any person or organization
|
||||
obtaining a copy of the software and accompanying documentation covered by
|
||||
this license (the "Software") to use, reproduce, display, distribute,
|
||||
execute, and transmit the Software, and to prepare derivative works of the
|
||||
Software, and to permit third-parties to whom the Software is furnished to
|
||||
do so, all subject to the following:
|
||||
|
||||
The copyright notices in the Software and this entire statement, including
|
||||
the above license grant, this restriction and the following disclaimer,
|
||||
must be included in all copies of the Software, in whole or in part, and
|
||||
all derivative works of the Software, unless such copies or derivative
|
||||
works are solely in the form of machine-executable object code generated by
|
||||
a source language processor.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
@@ -1,550 +0,0 @@
|
||||
The D-Bus glib bindings are licensed to you under your choice of the Academic
|
||||
Free License version 2.1, or the GNU General Public License version 2. Both
|
||||
licenses are included here. Some of the standalone binaries are under the GPL
|
||||
only; in particular, but not limted to, tests/decode-gcov.c. Each source code
|
||||
file is marked with the proper copyright information.
|
||||
|
||||
|
||||
|
||||
The Academic Free License
|
||||
v. 2.1
|
||||
|
||||
This Academic Free License (the "License") applies to any original work of authorship (the "Original Work") whose owner (the "Licensor") has placed the following notice immediately following the copyright notice for the Original Work:
|
||||
|
||||
Licensed under the Academic Free License version 2.1
|
||||
|
||||
1) Grant of Copyright License. Licensor hereby grants You a
|
||||
world-wide, royalty-free, non-exclusive, perpetual, sublicenseable
|
||||
license to do the following:
|
||||
|
||||
a) to reproduce the Original Work in copies;
|
||||
|
||||
b) to prepare derivative works ("Derivative Works") based upon the Original Work;
|
||||
|
||||
c) to distribute copies of the Original Work and Derivative Works to the public;
|
||||
|
||||
d) to perform the Original Work publicly; and
|
||||
|
||||
e) to display the Original Work publicly.
|
||||
|
||||
2) Grant of Patent License. Licensor hereby grants You a world-wide,
|
||||
royalty-free, non-exclusive, perpetual, sublicenseable license, under
|
||||
patent claims owned or controlled by the Licensor that are embodied in
|
||||
the Original Work as furnished by the Licensor, to make, use, sell and
|
||||
offer for sale the Original Work and Derivative Works.
|
||||
|
||||
3) Grant of Source Code License. The term "Source Code" means the
|
||||
preferred form of the Original Work for making modifications to it and
|
||||
all available documentation describing how to modify the Original
|
||||
Work. Licensor hereby agrees to provide a machine-readable copy of the
|
||||
Source Code of the Original Work along with each copy of the Original
|
||||
Work that Licensor distributes. Licensor reserves the right to satisfy
|
||||
this obligation by placing a machine-readable copy of the Source Code
|
||||
in an information repository reasonably calculated to permit
|
||||
inexpensive and convenient access by You for as long as Licensor
|
||||
continues to distribute the Original Work, and by publishing the
|
||||
address of that information repository in a notice immediately
|
||||
following the copyright notice that applies to the Original Work.
|
||||
|
||||
4) Exclusions From License Grant. Neither the names of Licensor, nor
|
||||
the names of any contributors to the Original Work, nor any of their
|
||||
trademarks or service marks, may be used to endorse or promote
|
||||
products derived from this Original Work without express prior written
|
||||
permission of the Licensor. Nothing in this License shall be deemed to
|
||||
grant any rights to trademarks, copyrights, patents, trade secrets or
|
||||
any other intellectual property of Licensor except as expressly stated
|
||||
herein. No patent license is granted to make, use, sell or offer to
|
||||
sell embodiments of any patent claims other than the licensed claims
|
||||
defined in Section 2. No right is granted to the trademarks of
|
||||
Licensor even if such marks are included in the Original Work. Nothing
|
||||
in this License shall be interpreted to prohibit Licensor from
|
||||
licensing under different terms from this License any Original Work
|
||||
that Licensor otherwise would have a right to license.
|
||||
|
||||
5) This section intentionally omitted.
|
||||
|
||||
6) Attribution Rights. You must retain, in the Source Code of any
|
||||
Derivative Works that You create, all copyright, patent or trademark
|
||||
notices from the Source Code of the Original Work, as well as any
|
||||
notices of licensing and any descriptive text identified therein as an
|
||||
"Attribution Notice." You must cause the Source Code for any
|
||||
Derivative Works that You create to carry a prominent Attribution
|
||||
Notice reasonably calculated to inform recipients that You have
|
||||
modified the Original Work.
|
||||
|
||||
7) Warranty of Provenance and Disclaimer of Warranty. Licensor
|
||||
warrants that the copyright in and to the Original Work and the patent
|
||||
rights granted herein by Licensor are owned by the Licensor or are
|
||||
sublicensed to You under the terms of this License with the permission
|
||||
of the contributor(s) of those copyrights and patent rights. Except as
|
||||
expressly stated in the immediately proceeding sentence, the Original
|
||||
Work is provided under this License on an "AS IS" BASIS and WITHOUT
|
||||
WARRANTY, either express or implied, including, without limitation,
|
||||
the warranties of NON-INFRINGEMENT, MERCHANTABILITY or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY OF THE ORIGINAL
|
||||
WORK IS WITH YOU. This DISCLAIMER OF WARRANTY constitutes an essential
|
||||
part of this License. No license to Original Work is granted hereunder
|
||||
except under this disclaimer.
|
||||
|
||||
8) Limitation of Liability. Under no circumstances and under no legal
|
||||
theory, whether in tort (including negligence), contract, or
|
||||
otherwise, shall the Licensor be liable to any person for any direct,
|
||||
indirect, special, incidental, or consequential damages of any
|
||||
character arising as a result of this License or the use of the
|
||||
Original Work including, without limitation, damages for loss of
|
||||
goodwill, work stoppage, computer failure or malfunction, or any and
|
||||
all other commercial damages or losses. This limitation of liability
|
||||
shall not apply to liability for death or personal injury resulting
|
||||
from Licensor's negligence to the extent applicable law prohibits such
|
||||
limitation. Some jurisdictions do not allow the exclusion or
|
||||
limitation of incidental or consequential damages, so this exclusion
|
||||
and limitation may not apply to You.
|
||||
|
||||
9) Acceptance and Termination. If You distribute copies of the
|
||||
Original Work or a Derivative Work, You must make a reasonable effort
|
||||
under the circumstances to obtain the express assent of recipients to
|
||||
the terms of this License. Nothing else but this License (or another
|
||||
written agreement between Licensor and You) grants You permission to
|
||||
create Derivative Works based upon the Original Work or to exercise
|
||||
any of the rights granted in Section 1 herein, and any attempt to do
|
||||
so except under the terms of this License (or another written
|
||||
agreement between Licensor and You) is expressly prohibited by
|
||||
U.S. copyright law, the equivalent laws of other countries, and by
|
||||
international treaty. Therefore, by exercising any of the rights
|
||||
granted to You in Section 1 herein, You indicate Your acceptance of
|
||||
this License and all of its terms and conditions.
|
||||
|
||||
10) Termination for Patent Action. This License shall terminate
|
||||
automatically and You may no longer exercise any of the rights granted
|
||||
to You by this License as of the date You commence an action,
|
||||
including a cross-claim or counterclaim, against Licensor or any
|
||||
licensee alleging that the Original Work infringes a patent. This
|
||||
termination provision shall not apply for an action alleging patent
|
||||
infringement by combinations of the Original Work with other software
|
||||
or hardware.
|
||||
|
||||
11) Jurisdiction, Venue and Governing Law. Any action or suit relating
|
||||
to this License may be brought only in the courts of a jurisdiction
|
||||
wherein the Licensor resides or in which Licensor conducts its primary
|
||||
business, and under the laws of that jurisdiction excluding its
|
||||
conflict-of-law provisions. The application of the United Nations
|
||||
Convention on Contracts for the International Sale of Goods is
|
||||
expressly excluded. Any use of the Original Work outside the scope of
|
||||
this License or after its termination shall be subject to the
|
||||
requirements and penalties of the U.S. Copyright Act, 17 U.S.C. § 101
|
||||
et seq., the equivalent laws of other countries, and international
|
||||
treaty. This section shall survive the termination of this License.
|
||||
|
||||
12) Attorneys Fees. In any action to enforce the terms of this License
|
||||
or seeking damages relating thereto, the prevailing party shall be
|
||||
entitled to recover its costs and expenses, including, without
|
||||
limitation, reasonable attorneys' fees and costs incurred in
|
||||
connection with such action, including any appeal of such action. This
|
||||
section shall survive the termination of this License.
|
||||
|
||||
13) Miscellaneous. This License represents the complete agreement
|
||||
concerning the subject matter hereof. If any provision of this License
|
||||
is held to be unenforceable, such provision shall be reformed only to
|
||||
the extent necessary to make it enforceable.
|
||||
|
||||
14) Definition of "You" in This License. "You" throughout this
|
||||
License, whether in upper or lower case, means an individual or a
|
||||
legal entity exercising rights under, and complying with all of the
|
||||
terms of, this License. For legal entities, "You" includes any entity
|
||||
that controls, is controlled by, or is under common control with
|
||||
you. For purposes of this definition, "control" means (i) the power,
|
||||
direct or indirect, to cause the direction or management of such
|
||||
entity, whether by contract or otherwise, or (ii) ownership of fifty
|
||||
percent (50%) or more of the outstanding shares, or (iii) beneficial
|
||||
ownership of such entity.
|
||||
|
||||
15) Right to Use. You may use the Original Work in all ways not
|
||||
otherwise restricted or conditioned by this License or by law, and
|
||||
Licensor promises not to interfere with or be responsible for such
|
||||
uses by You.
|
||||
|
||||
This license is Copyright (C) 2003-2004 Lawrence E. Rosen. All rights
|
||||
reserved. Permission is hereby granted to copy and distribute this
|
||||
license without modification. This license may not be modified without
|
||||
the express written permission of its copyright owner.
|
||||
|
||||
|
||||
--
|
||||
END OF ACADEMIC FREE LICENSE. The following is intended to describe the essential
|
||||
differences between the Academic Free License (AFL) version 1.0 and other
|
||||
open source licenses:
|
||||
|
||||
The Academic Free License is similar to the BSD, MIT, UoI/NCSA and Apache
|
||||
licenses in many respects but it is intended to solve a few problems with
|
||||
those licenses.
|
||||
|
||||
* The AFL is written so as to make it clear what software is being
|
||||
licensed (by the inclusion of a statement following the copyright notice
|
||||
in the software). This way, the license functions better than a template
|
||||
license. The BSD, MIT and UoI/NCSA licenses apply to unidentified software.
|
||||
|
||||
* The AFL contains a complete copyright grant to the software. The BSD
|
||||
and Apache licenses are vague and incomplete in that respect.
|
||||
|
||||
* The AFL contains a complete patent grant to the software. The BSD, MIT,
|
||||
UoI/NCSA and Apache licenses rely on an implied patent license and contain
|
||||
no explicit patent grant.
|
||||
|
||||
* The AFL makes it clear that no trademark rights are granted to the
|
||||
licensor's trademarks. The Apache license contains such a provision, but the
|
||||
BSD, MIT and UoI/NCSA licenses do not.
|
||||
|
||||
* The AFL includes the warranty by the licensor that it either owns the
|
||||
copyright or that it is distributing the software under a license. None of
|
||||
the other licenses contain that warranty. All other warranties are disclaimed,
|
||||
as is the case for the other licenses.
|
||||
|
||||
* The AFL is itself copyrighted (with the right granted to copy and distribute
|
||||
without modification). This ensures that the owner of the copyright to the
|
||||
license will control changes. The Apache license contains a copyright notice,
|
||||
but the BSD, MIT and UoI/NCSA licenses do not.
|
||||
--
|
||||
START OF GNU GENERAL PUBLIC LICENSE
|
||||
--
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
|
||||
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
License is intended to guarantee your freedom to share and change free
|
||||
software--to make sure the software is free for all its users. This
|
||||
General Public License applies to most of the Free Software
|
||||
Foundation's software and to any other program whose authors commit to
|
||||
using it. (Some other Free Software Foundation software is covered by
|
||||
the GNU Library General Public License instead.) You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
this service if you wish), that you receive source code or can get it
|
||||
if you want it, that you can change the software or use pieces of it
|
||||
in new free programs; and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if you
|
||||
distribute copies of the software, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must give the recipients all the rights that
|
||||
you have. You must make sure that they, too, receive or can get the
|
||||
source code. And you must show them these terms so they know their
|
||||
rights.
|
||||
|
||||
We protect your rights with two steps: (1) copyright the software, and
|
||||
(2) offer you this license which gives you legal permission to copy,
|
||||
distribute and/or modify the software.
|
||||
|
||||
Also, for each author's protection and ours, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
software. If the software is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original, so
|
||||
that any problems introduced by others will not reflect on the original
|
||||
authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that redistributors of a free
|
||||
program will individually obtain patent licenses, in effect making the
|
||||
program proprietary. To prevent this, we have made it clear that any
|
||||
patent must be licensed for everyone's free use or not licensed at all.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License applies to any program or other work which contains
|
||||
a notice placed by the copyright holder saying it may be distributed
|
||||
under the terms of this General Public License. The "Program", below,
|
||||
refers to any such program or work, and a "work based on the Program"
|
||||
means either the Program or any derivative work under copyright law:
|
||||
that is to say, a work containing the Program or a portion of it,
|
||||
either verbatim or with modifications and/or translated into another
|
||||
language. (Hereinafter, translation is included without limitation in
|
||||
the term "modification".) Each licensee is addressed as "you".
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running the Program is not restricted, and the output from the Program
|
||||
is covered only if its contents constitute a work based on the
|
||||
Program (independent of having been made by running the Program).
|
||||
Whether that is true depends on what the Program does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Program's
|
||||
source code as you receive it, in any medium, provided that you
|
||||
conspicuously and appropriately publish on each copy an appropriate
|
||||
copyright notice and disclaimer of warranty; keep intact all the
|
||||
notices that refer to this License and to the absence of any warranty;
|
||||
and give any other recipients of the Program a copy of this License
|
||||
along with the Program.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and
|
||||
you may at your option offer warranty protection in exchange for a fee.
|
||||
|
||||
2. You may modify your copy or copies of the Program or any portion
|
||||
of it, thus forming a work based on the Program, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) You must cause the modified files to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
b) You must cause any work that you distribute or publish, that in
|
||||
whole or in part contains or is derived from the Program or any
|
||||
part thereof, to be licensed as a whole at no charge to all third
|
||||
parties under the terms of this License.
|
||||
|
||||
c) If the modified program normally reads commands interactively
|
||||
when run, you must cause it, when started running for such
|
||||
interactive use in the most ordinary way, to print or display an
|
||||
announcement including an appropriate copyright notice and a
|
||||
notice that there is no warranty (or else, saying that you provide
|
||||
a warranty) and that users may redistribute the program under
|
||||
these conditions, and telling the user how to view a copy of this
|
||||
License. (Exception: if the Program itself is interactive but
|
||||
does not normally print such an announcement, your work based on
|
||||
the Program is not required to print an announcement.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Program,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Program, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Program.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Program
|
||||
with the Program (or with a work based on the Program) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may copy and distribute the Program (or a work based on it,
|
||||
under Section 2) in object code or executable form under the terms of
|
||||
Sections 1 and 2 above provided that you also do one of the following:
|
||||
|
||||
a) Accompany it with the complete corresponding machine-readable
|
||||
source code, which must be distributed under the terms of Sections
|
||||
1 and 2 above on a medium customarily used for software interchange; or,
|
||||
|
||||
b) Accompany it with a written offer, valid for at least three
|
||||
years, to give any third party, for a charge no more than your
|
||||
cost of physically performing source distribution, a complete
|
||||
machine-readable copy of the corresponding source code, to be
|
||||
distributed under the terms of Sections 1 and 2 above on a medium
|
||||
customarily used for software interchange; or,
|
||||
|
||||
c) Accompany it with the information you received as to the offer
|
||||
to distribute corresponding source code. (This alternative is
|
||||
allowed only for noncommercial distribution and only if you
|
||||
received the program in object code or executable form with such
|
||||
an offer, in accord with Subsection b above.)
|
||||
|
||||
The source code for a work means the preferred form of the work for
|
||||
making modifications to it. For an executable work, complete source
|
||||
code means all the source code for all modules it contains, plus any
|
||||
associated interface definition files, plus the scripts used to
|
||||
control compilation and installation of the executable. However, as a
|
||||
special exception, the source code distributed need not include
|
||||
anything that is normally distributed (in either source or binary
|
||||
form) with the major components (compiler, kernel, and so on) of the
|
||||
operating system on which the executable runs, unless that component
|
||||
itself accompanies the executable.
|
||||
|
||||
If distribution of executable or object code is made by offering
|
||||
access to copy from a designated place, then offering equivalent
|
||||
access to copy the source code from the same place counts as
|
||||
distribution of the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
4. You may not copy, modify, sublicense, or distribute the Program
|
||||
except as expressly provided under this License. Any attempt
|
||||
otherwise to copy, modify, sublicense or distribute the Program is
|
||||
void, and will automatically terminate your rights under this License.
|
||||
However, parties who have received copies, or rights, from you under
|
||||
this License will not have their licenses terminated so long as such
|
||||
parties remain in full compliance.
|
||||
|
||||
5. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Program or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Program (or any work based on the
|
||||
Program), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Program or works based on it.
|
||||
|
||||
6. Each time you redistribute the Program (or any work based on the
|
||||
Program), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute or modify the Program subject to
|
||||
these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
this License.
|
||||
|
||||
7. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Program at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Program by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Program.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under
|
||||
any particular circumstance, the balance of the section is intended to
|
||||
apply and the section as a whole is intended to apply in other
|
||||
circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system, which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
8. If the distribution and/or use of the Program is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Program under this License
|
||||
may add an explicit geographical distribution limitation excluding
|
||||
those countries, so that distribution is permitted only in or among
|
||||
countries not thus excluded. In such case, this License incorporates
|
||||
the limitation as if written in the body of this License.
|
||||
|
||||
9. The Free Software Foundation may publish revised and/or new versions
|
||||
of the General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program
|
||||
specifies a version number of this License which applies to it and "any
|
||||
later version", you have the option of following the terms and conditions
|
||||
either of that version or of any later version published by the Free
|
||||
Software Foundation. If the Program does not specify a version number of
|
||||
this License, you may choose any version ever published by the Free Software
|
||||
Foundation.
|
||||
|
||||
10. If you wish to incorporate parts of the Program into other free
|
||||
programs whose distribution conditions are different, write to the author
|
||||
to ask for permission. For software which is copyrighted by the Free
|
||||
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||
make exceptions for this. Our decision will be guided by the two goals
|
||||
of preserving the free status of all derivatives of our free software and
|
||||
of promoting the sharing and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
||||
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
||||
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
||||
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||
REPAIR OR CORRECTION.
|
||||
|
||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
||||
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
||||
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
||||
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
||||
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program is interactive, make it output a short notice like this
|
||||
when it starts in an interactive mode:
|
||||
|
||||
Gnomovision version 69, Copyright (C) year name of author
|
||||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, the commands you use may
|
||||
be called something other than `show w' and `show c'; they could even be
|
||||
mouse-clicks or menu items--whatever suits your program.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1989
|
||||
Ty Coon, President of Vice
|
||||
|
||||
This General Public License does not permit incorporating your program into
|
||||
proprietary programs. If your program is a subroutine library, you may
|
||||
consider it more useful to permit linking proprietary applications with the
|
||||
library. If this is what you want to do, use the GNU Library General
|
||||
Public License instead of this License.
|
||||
@@ -1,4 +0,0 @@
|
||||
This is a modified version of openal-soft from GIT (56cc03860378e2758370b773b2a6f1b4e086b49a).
|
||||
The modified source which this was built from is available here:
|
||||
http://viewer-source-downloads.s3.amazonaws.com/install_pkgs/openal-soft-linden-56cc03860378e2758370b773b2a6f1b4e086b49a.tar.bz2
|
||||
|
||||
@@ -378,14 +378,7 @@
|
||||
<boolean>true</boolean>
|
||||
</map>
|
||||
|
||||
<key>ParcelMediaURLFilter</key>
|
||||
<map>
|
||||
<key>flavor</key>
|
||||
<string>llsd</string>
|
||||
<key>trusted-sender</key>
|
||||
<boolean>false</boolean>
|
||||
</map>
|
||||
|
||||
|
||||
<key>ParcelNavigateMedia</key>
|
||||
<map>
|
||||
<key>flavor</key>
|
||||
@@ -670,19 +663,19 @@
|
||||
<key>EstateChangeInfo</key>
|
||||
<boolean>true</boolean>
|
||||
|
||||
<key>FetchInventoryDescendents</key>
|
||||
<key>FetchInventoryDescendents2</key>
|
||||
<boolean>false</boolean>
|
||||
|
||||
<key>WebFetchInventoryDescendents</key>
|
||||
<boolean>false</boolean>
|
||||
|
||||
<key>FetchInventory</key>
|
||||
<key>FetchInventory2</key>
|
||||
<boolean>true</boolean>
|
||||
|
||||
<key>FetchLibDescendents</key>
|
||||
<key>FetchLibDescendents2</key>
|
||||
<boolean>true</boolean>
|
||||
|
||||
<key>FetchLib</key>
|
||||
<key>FetchLib2</key>
|
||||
<boolean>true</boolean>
|
||||
</map>
|
||||
|
||||
|
||||
@@ -26,11 +26,11 @@ set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
|
||||
include(Variables)
|
||||
|
||||
# Load versions now. Install locations need them.
|
||||
include(Versions)
|
||||
include(BuildVersion)
|
||||
|
||||
include(UnixInstall)
|
||||
|
||||
set (GCC_DISABLE_FATAL_WARNINGS TRUE)
|
||||
set (DISABLE_FATAL_WARNINGS TRUE)
|
||||
|
||||
if (NOT CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE)
|
||||
set(CMAKE_BUILD_TYPE ReleaseSSE2 CACHE STRING
|
||||
@@ -77,6 +77,7 @@ if (VIEWER)
|
||||
add_subdirectory(${LIBS_OPEN_PREFIX}llcrashlogger)
|
||||
add_subdirectory(${LIBS_OPEN_PREFIX}llplugin)
|
||||
add_subdirectory(${LIBS_OPEN_PREFIX}llui)
|
||||
add_subdirectory(${LIBS_OPEN_PREFIX}llxuixml)
|
||||
|
||||
# viewer plugins directory
|
||||
add_subdirectory(${LIBS_OPEN_PREFIX}plugins)
|
||||
|
||||
@@ -28,6 +28,9 @@ set(CMAKE_CONFIGURATION_TYPES "RelWithDebInfo;Release;ReleaseSSE2;Debug" CACHE S
|
||||
# Platform-specific compilation flags.
|
||||
|
||||
if (WINDOWS)
|
||||
# Remove default /Zm1000 flag that cmake inserts
|
||||
string (REPLACE "/Zm1000" " " CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
|
||||
|
||||
# Don't build DLLs.
|
||||
set(BUILD_SHARED_LIBS OFF)
|
||||
|
||||
@@ -67,6 +70,10 @@ if (WINDOWS)
|
||||
/Oy-
|
||||
)
|
||||
|
||||
# configure win32 API for windows XP+ compatibility
|
||||
set(WINVER "0x0501" CACHE STRING "Win32 API Target version (see http://msdn.microsoft.com/en-us/library/aa383745%28v=VS.85%29.aspx)")
|
||||
add_definitions("/DWINVER=${WINVER}" "/D_WIN32_WINNT=${WINVER}")
|
||||
|
||||
if(MSVC80 OR MSVC90 OR MSVC10)
|
||||
set(CMAKE_CXX_FLAGS_RELEASE
|
||||
"${CMAKE_CXX_FLAGS_RELEASE} -D_SECURE_STL=0 -D_HAS_ITERATOR_DEBUGGING=0"
|
||||
@@ -83,26 +90,26 @@ if (WINDOWS)
|
||||
endif (MSVC80 OR MSVC90 OR MSVC10)
|
||||
|
||||
# Are we using the crummy Visual Studio KDU build workaround?
|
||||
if (NOT VS_DISABLE_FATAL_WARNINGS)
|
||||
if (NOT DISABLE_FATAL_WARNINGS)
|
||||
add_definitions(/WX)
|
||||
endif (NOT VS_DISABLE_FATAL_WARNINGS)
|
||||
endif (NOT DISABLE_FATAL_WARNINGS)
|
||||
|
||||
# Various libs are compiler specific, generate some variables here we can just use
|
||||
# when we require them instead of reimplementing the test each time.
|
||||
|
||||
if (MSVC71)
|
||||
set(MSVC_DIR 7.1)
|
||||
set(MSVC_SUFFIX 71)
|
||||
elseif (MSVC80)
|
||||
set(MSVC_DIR 8.0)
|
||||
set(MSVC_SUFFIX 80)
|
||||
elseif (MSVC90)
|
||||
set(MSVC_DIR 9.0)
|
||||
set(MSVC_SUFFIX 90)
|
||||
elseif (MSVC10)
|
||||
set(MSVC_DIR 10.0)
|
||||
set(MSVC_SUFFIX 100)
|
||||
endif (MSVC71)
|
||||
set(MSVC_DIR 7.1)
|
||||
set(MSVC_SUFFIX 71)
|
||||
elseif (MSVC80)
|
||||
set(MSVC_DIR 8.0)
|
||||
set(MSVC_SUFFIX 80)
|
||||
elseif (MSVC90)
|
||||
set(MSVC_DIR 9.0)
|
||||
set(MSVC_SUFFIX 90)
|
||||
elseif (MSVC10)
|
||||
set(MSVC_DIR 10.0)
|
||||
set(MSVC_SUFFIX 100)
|
||||
endif (MSVC71)
|
||||
|
||||
if (MSVC10)
|
||||
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /MANIFEST:NO")
|
||||
@@ -113,135 +120,149 @@ if (WINDOWS)
|
||||
|
||||
endif (WINDOWS)
|
||||
|
||||
set (GCC_EXTRA_OPTIMIZATION "-ffast-math -frounding-math")
|
||||
set (GCC_EXTRA_OPTIMIZATIONS "-ffast-math")
|
||||
|
||||
if (LINUX)
|
||||
set(CMAKE_SKIP_RPATH TRUE)
|
||||
|
||||
# Here's a giant hack for Fedora 8, where we can't use
|
||||
# _FORTIFY_SOURCE if we're using a compiler older than gcc 4.1.
|
||||
|
||||
find_program(GXX g++)
|
||||
mark_as_advanced(GXX)
|
||||
|
||||
if (GXX)
|
||||
execute_process(
|
||||
COMMAND ${GXX} --version
|
||||
COMMAND sed "s/^[gc+ ]*//"
|
||||
COMMAND head -1
|
||||
OUTPUT_VARIABLE GXX_VERSION
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
else (GXX)
|
||||
set(GXX_VERSION x)
|
||||
endif (GXX)
|
||||
|
||||
# The quoting hack here is necessary in case we're using distcc or
|
||||
# ccache as our compiler. CMake doesn't pass the command line
|
||||
# through the shell by default, so we end up trying to run "distcc"
|
||||
# " g++" - notice the leading space. Ugh.
|
||||
|
||||
execute_process(
|
||||
COMMAND sh -c "${CMAKE_CXX_COMPILER} ${CMAKE_CXX_COMPILER_ARG1} --version"
|
||||
COMMAND sed "s/^[gc+ ]*//"
|
||||
COMMAND head -1
|
||||
OUTPUT_VARIABLE CXX_VERSION
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
|
||||
if (${GXX_VERSION} STREQUAL ${CXX_VERSION})
|
||||
add_definitions(-D_FORTIFY_SOURCE=2)
|
||||
else (${GXX_VERSION} STREQUAL ${CXX_VERSION})
|
||||
if (NOT ${GXX_VERSION} MATCHES " 4.1.*Red Hat")
|
||||
add_definitions(-D_FORTIFY_SOURCE=2)
|
||||
endif (NOT ${GXX_VERSION} MATCHES " 4.1.*Red Hat")
|
||||
endif (${GXX_VERSION} STREQUAL ${CXX_VERSION})
|
||||
|
||||
#Lets actualy get a numerical version of gxx's version
|
||||
STRING(REGEX REPLACE ".* ([0-9])\\.([0-9])\\.([0-9]).*" "\\1\\2\\3" CXX_VERSION ${CXX_VERSION})
|
||||
|
||||
#gcc 4.3 and above don't like the LL boost
|
||||
if(${CXX_VERSION} GREATER 429)
|
||||
add_definitions(-Wno-parentheses)
|
||||
endif (${CXX_VERSION} GREATER 429)
|
||||
|
||||
#gcc 4.6 has a new spammy warning
|
||||
if(NOT ${CXX_VERSION} LESS 460)
|
||||
add_definitions(-Wno-unused-but-set-variable)
|
||||
endif (NOT ${CXX_VERSION} LESS 460)
|
||||
|
||||
# End of hacks.
|
||||
|
||||
add_definitions(
|
||||
-DLL_LINUX=1
|
||||
-DAPPID=secondlife
|
||||
-D_REENTRANT
|
||||
-fexceptions
|
||||
-fno-math-errno
|
||||
-fno-strict-aliasing
|
||||
-fsigned-char
|
||||
-fvisibility=hidden
|
||||
-g
|
||||
-pthread
|
||||
)
|
||||
|
||||
if (SERVER)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ftemplate-depth-60")
|
||||
if (EXISTS /etc/debian_version)
|
||||
FILE(READ /etc/debian_version DEBIAN_VERSION)
|
||||
else (EXISTS /etc/debian_version)
|
||||
set(DEBIAN_VERSION "")
|
||||
endif (EXISTS /etc/debian_version)
|
||||
|
||||
if (NOT DEBIAN_VERSION STREQUAL "3.1")
|
||||
add_definitions(-DCTYPE_WORKAROUND)
|
||||
endif (NOT DEBIAN_VERSION STREQUAL "3.1")
|
||||
|
||||
if (EXISTS /usr/lib/mysql4/mysql)
|
||||
link_directories(/usr/lib/mysql4/mysql)
|
||||
endif (EXISTS /usr/lib/mysql4/mysql)
|
||||
|
||||
add_definitions(
|
||||
-msse2
|
||||
-mfpmath=sse
|
||||
)
|
||||
endif (SERVER)
|
||||
|
||||
if (VIEWER)
|
||||
add_definitions(-DAPPID=secondlife)
|
||||
add_definitions(-fvisibility=hidden)
|
||||
# don't catch SIGCHLD in our base application class for the viewer - some of our 3rd party libs may need their *own* SIGCHLD handler to work. Sigh! The viewer doesn't need to catch SIGCHLD anyway.
|
||||
# Don't catch SIGCHLD in our base application class for the viewer
|
||||
# some of our 3rd party libs may need their *own* SIGCHLD handler to work. Sigh!
|
||||
# The viewer doesn't need to catch SIGCHLD anyway.
|
||||
add_definitions(-DLL_IGNORE_SIGCHLD)
|
||||
|
||||
if(${CMAKE_C_COMPILER} MATCHES "gcc*")
|
||||
|
||||
find_program(GXX g++)
|
||||
mark_as_advanced(GXX)
|
||||
|
||||
if (GXX)
|
||||
execute_process(
|
||||
COMMAND ${GXX} --version
|
||||
COMMAND sed "s/^[gc+ ]*//"
|
||||
COMMAND head -1
|
||||
OUTPUT_VARIABLE GXX_VERSION
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
else (GXX)
|
||||
set(GXX_VERSION x)
|
||||
endif (GXX)
|
||||
|
||||
# The quoting hack here is necessary in case we're using distcc or
|
||||
# ccache as our compiler. CMake doesn't pass the command line
|
||||
# through the shell by default, so we end up trying to run "distcc"
|
||||
# " g++" - notice the leading space. Ugh.
|
||||
|
||||
execute_process(
|
||||
COMMAND sh -c "${CMAKE_CXX_COMPILER} ${CMAKE_CXX_COMPILER_ARG1} --version"
|
||||
COMMAND sed "s/^[gc+ ]*//"
|
||||
COMMAND head -1
|
||||
OUTPUT_VARIABLE CXX_VERSION
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
|
||||
# Here's a giant hack for Fedora 8, where we can't use
|
||||
# _FORTIFY_SOURCE if we're using a compiler older than gcc 4.1.
|
||||
if (${GXX_VERSION} STREQUAL ${CXX_VERSION})
|
||||
add_definitions(-D_FORTIFY_SOURCE=2)
|
||||
else (${GXX_VERSION} STREQUAL ${CXX_VERSION})
|
||||
if (NOT ${GXX_VERSION} MATCHES " 4.1.*Red Hat")
|
||||
add_definitions(-D_FORTIFY_SOURCE=2)
|
||||
endif (NOT ${GXX_VERSION} MATCHES " 4.1.*Red Hat")
|
||||
endif (${GXX_VERSION} STREQUAL ${CXX_VERSION})
|
||||
|
||||
#Lets actually get a numerical version of gxx's version
|
||||
STRING(REGEX REPLACE ".* ([0-9])\\.([0-9])\\.([0-9]).*" "\\1\\2\\3" CXX_VERSION ${CXX_VERSION})
|
||||
|
||||
#gcc 4.3 and above doesn't like the LL boost
|
||||
if(${CXX_VERSION} GREATER 429)
|
||||
add_definitions(-Wno-parentheses)
|
||||
endif (${CXX_VERSION} GREATER 429)
|
||||
|
||||
#gcc 4.6 has a new spammy warning
|
||||
if(NOT ${CXX_VERSION} LESS 460)
|
||||
add_definitions(-Wno-unused-but-set-variable)
|
||||
endif (NOT ${CXX_VERSION} LESS 460)
|
||||
|
||||
# End of hacks.
|
||||
|
||||
#GCC Specific
|
||||
add_definitions(-DCC_GCC)
|
||||
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99")
|
||||
|
||||
if (NOT STANDALONE)
|
||||
# this stops us requiring a really recent glibc at runtime
|
||||
add_definitions(-fno-stack-protector)
|
||||
endif (NOT STANDALONE)
|
||||
if (${ARCH} STREQUAL "x86_64")
|
||||
add_definitions(-DLINUX64=1 -pipe)
|
||||
set(CMAKE_CXX_FLAGS_RELEASESSE2 "${CMAKE_CXX_FLAGS_RELEASESSE2} -fomit-frame-pointer -mmmx -msse -mfpmath=sse -msse2 -ffast-math -ftree-vectorize -fweb -fexpensive-optimizations -frename-registers")
|
||||
set(CMAKE_C_FLAGS_RELEASESSE2 "${CMAKE_C_FLAGS_RELEASESSE2} -fomit-frame-pointer -mmmx -msse -mfpmath=sse -msse2 -ffast-math -ftree-vectorize -fweb -fexpensive-optimizations -frename-registers")
|
||||
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -fomit-frame-pointer -mmmx -msse -mfpmath=sse -msse2 -ffast-math -ftree-vectorize -fweb -fexpensive-optimizations -frename-registers")
|
||||
set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -fomit-frame-pointer -mmmx -msse -mfpmath=sse -msse2 -ffast-math -ftree-vectorize -fweb -fexpensive-optimizations -frename-registers")
|
||||
else (${ARCH} STREQUAL "x86_64")
|
||||
if (NOT STANDALONE)
|
||||
set(MARCH_FLAG " -march=pentium4")
|
||||
endif (NOT STANDALONE)
|
||||
set(CMAKE_CXX_FLAGS_RELEASESSE2 "${CMAKE_CXX_FLAGS_RELEASESSE2}${MARCH_FLAG} -mfpmath=sse -msse2 ${GCC_EXTRA_OPTIMIZATIONS}")
|
||||
set(CMAKE_C_FLAGS_RELEASESSE2 "${CMAKE_C_FLAGS_RELEASESSE2}${MARCH_FLAG} -mfpmath=sse -msse2 "${GCC_EXTRA_OPTIMIZATIONS})
|
||||
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}${MARCH_FLAG} -mfpmath=sse -msse2 ${GCC_EXTRA_OPTIMIZATIONS}")
|
||||
set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO}${MARCH_FLAG} -mfpmath=sse -msse2 "${GCC_EXTRA_OPTIMIZATIONS})
|
||||
endif (${ARCH} STREQUAL "x86_64")
|
||||
endif (VIEWER)
|
||||
if (${ARCH} STREQUAL "x86_64")
|
||||
add_definitions(-DLINUX64=1 -pipe)
|
||||
set(CMAKE_CXX_FLAGS_RELEASESSE2 "${CMAKE_CXX_FLAGS_RELEASESSE2} -fomit-frame-pointer -mmmx -msse -mfpmath=sse -msse2 -ffast-math -ftree-vectorize -fweb -fexpensive-optimizations -frename-registers")
|
||||
set(CMAKE_C_FLAGS_RELEASESSE2 "${CMAKE_C_FLAGS_RELEASESSE2} -fomit-frame-pointer -mmmx -msse -mfpmath=sse -msse2 -ffast-math -ftree-vectorize -fweb -fexpensive-optimizations -frename-registers")
|
||||
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -fomit-frame-pointer -mmmx -msse -mfpmath=sse -msse2 -ffast-math -ftree-vectorize -fweb -fexpensive-optimizations -frename-registers")
|
||||
set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -fomit-frame-pointer -mmmx -msse -mfpmath=sse -msse2 -ffast-math -ftree-vectorize -fweb -fexpensive-optimizations -frename-registers")
|
||||
else (${ARCH} STREQUAL "x86_64")
|
||||
if (NOT STANDALONE)
|
||||
set(MARCH_FLAG " -march=pentium4")
|
||||
endif (NOT STANDALONE)
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}${MARCH_FLAG} -fno-inline -msse2")
|
||||
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}${MARCH_FLAG} -fno-inline -msse2")
|
||||
set(CMAKE_CXX_FLAGS_RELEASESSE2 "${CMAKE_CXX_FLAGS_RELEASESSE2}${MARCH_FLAG} -mfpmath=sse,387 -msse2 ${GCC_EXTRA_OPTIMIZATIONS}")
|
||||
set(CMAKE_C_FLAGS_RELEASESSE2 "${CMAKE_C_FLAGS_RELEASESSE2}${MARCH_FLAG} -mfpmath=sse,387 -msse2 ${GCC_EXTRA_OPTIMIZATIONS}")
|
||||
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}${MARCH_FLAG} -mfpmath=sse,387 -msse2 ${GCC_EXTRA_OPTIMIZATIONS}")
|
||||
set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO}${MARCH_FLAG} -mfpmath=sse,387 -msse2 ${GCC_EXTRA_OPTIMIZATIONS}")
|
||||
endif (${ARCH} STREQUAL "x86_64")
|
||||
elseif(${CMAKE_C_COMPILER} MATCHES "clang*")
|
||||
|
||||
find_program(CLANG clang++)
|
||||
mark_as_advanced(CLANG)
|
||||
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "-fno-inline ${CMAKE_CXX_FLAGS_DEBUG} -msse2")
|
||||
add_definitions(
|
||||
-DCC_CLANG
|
||||
-D_FORTIFY_SOURCE=2
|
||||
)
|
||||
|
||||
if (NOT STANDALONE)
|
||||
# this stops us requiring a really recent glibc at runtime
|
||||
add_definitions(-fno-stack-protector)
|
||||
endif (NOT STANDALONE)
|
||||
|
||||
if (NOT STANDALONE)
|
||||
set(MARCH_FLAG " -march=pentium4")
|
||||
endif (NOT STANDALONE)
|
||||
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}${MARCH_FLAG} -fno-inline -msse2")
|
||||
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}${MARCH_FLAG} -fno-inline -msse2")
|
||||
set(CMAKE_CXX_FLAGS_RELEASESSE2 "${CMAKE_CXX_FLAGS_RELEASESSE2}${MARCH_FLAG} -msse2")
|
||||
set(CMAKE_C_FLAGS_RELEASESSE2 "${CMAKE_C_FLAGS_RELEASESSE2}${MARCH_FLAG} -msse2")
|
||||
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}${MARCH_FLAG} -msse2")
|
||||
set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO}${MARCH_FLAG} -msse2")
|
||||
endif()
|
||||
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "-O0 ${CMAKE_CXX_FLAGS_DEBUG}")
|
||||
set(CMAKE_C_FLAGS_DEBUG "-O0 ${CMAKE_CXX_FLAGS_DEBUG}")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "-O3 ${CMAKE_CXX_FLAGS_RELEASE}")
|
||||
set(CMAKE_C_FLAGS_RELEASE "-O3 ${CMAKE_C_FLAGS_RELEASE}")
|
||||
set(CMAKE_CXX_FLAGS_RELEASESSE2 "-O3 ${CMAKE_CXX_FLAGS_RELEASESSE2}")
|
||||
set(CMAKE_C_FLAGS_RELEASESSE2 "-O3 ${CMAKE_C_FLAGS_RELEASESSE2}")
|
||||
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O3 ${CMAKE_CXX_FLAGS_RELWITHDEBINFO}")
|
||||
set(CMAKE_C_FLAGS_RELWITHDEBINFO "-O3 ${CMAKE_C_FLAGS_RELWITHDEBINFO}")
|
||||
set(CMAKE_C_FLAGS_RELWITHDEBINFO "-O3 ${CMAKE_C_FLAGS_RELWITHDEBINFO}")
|
||||
endif (LINUX)
|
||||
|
||||
|
||||
if (DARWIN)
|
||||
add_definitions(-DLL_DARWIN=1)
|
||||
add_definitions(-DLL_DARWIN=1 -D_XOPEN_SOURCE)
|
||||
set(CMAKE_CXX_LINK_FLAGS "-Wl,-headerpad_max_install_names,-search_paths_first")
|
||||
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_CXX_LINK_FLAGS}")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mlong-branch")
|
||||
@@ -249,26 +270,30 @@ if (DARWIN)
|
||||
# NOTE: it's critical that the optimization flag is put in front.
|
||||
# NOTE: it's critical to have both CXX_FLAGS and C_FLAGS covered.
|
||||
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -O3 -msse3 -mtune=generic -mfpmath=sse ${GCC_EXTRA_OPTIMIZATIONS}")
|
||||
set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -03 -msse3 -mtune=generic -mfpmath=sse ${GCC_EXTRA_OPTIMIZATIONS}")
|
||||
set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -O3 -msse3 -mtune=generic -mfpmath=sse ${GCC_EXTRA_OPTIMIZATIONS}")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3 -msse3 -mtune=generic -mfpmath=sse ${GCC_EXTRA_OPTIMIZATIONS}")
|
||||
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -03 -msse3 -mtune=generic -mfpmath=sse ${GCC_EXTRA_OPTIMIZATIONS}")
|
||||
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -O3 -msse3 -mtune=generic -mfpmath=sse ${GCC_EXTRA_OPTIMIZATIONS}")
|
||||
set(CMAKE_CXX_FLAGS_RELEASESSE2 "${CMAKE_CXX_FLAGS_RELEASESSE2} -O3 -msse2 -mtune=generic -mfpmath=sse ${GCC_EXTRA_OPTIMIZATIONS}")
|
||||
set(CMAKE_C_FLAGS_RELEASESSE2 "${CMAKE_C_FLAGS_RELEASESSE2} -03 -msse2 -mtune=generic -mfpmath=sse ${GCC_EXTRA_OPTIMIZATIONS}")
|
||||
set(CMAKE_C_FLAGS_RELEASESSE2 "${CMAKE_C_FLAGS_RELEASESSE2} -O3 -msse2 -mtune=generic -mfpmath=sse ${GCC_EXTRA_OPTIMIZATIONS}")
|
||||
endif (DARWIN)
|
||||
|
||||
|
||||
if (LINUX OR DARWIN)
|
||||
set(GCC_WARNINGS "-Wall -Wno-sign-compare -Wno-trigraphs -Wno-non-virtual-dtor -Woverloaded-virtual")
|
||||
|
||||
if (NOT GCC_DISABLE_FATAL_WARNINGS)
|
||||
set(GCC_WARNINGS "${GCC_WARNINGS} -Werror")
|
||||
endif (NOT GCC_DISABLE_FATAL_WARNINGS)
|
||||
|
||||
set(GCC_CXX_WARNINGS "${GCC_WARNINGS} -Wno-reorder")
|
||||
|
||||
set(CMAKE_C_FLAGS "${GCC_WARNINGS} ${CMAKE_C_FLAGS}")
|
||||
set(CMAKE_CXX_FLAGS "${GCC_CXX_WARNINGS} ${CMAKE_CXX_FLAGS}")
|
||||
if(${CMAKE_C_COMPILER} MATCHES "gcc*")
|
||||
set(UNIX_WARNINGS "-Wall -Wno-sign-compare -Wno-trigraphs")
|
||||
set(UNIX_CXX_WARNINGS "${UNIX_WARNINGS} -Wno-reorder -Wno-non-virtual-dtor -Woverloaded-virtual")
|
||||
elseif(${CMAKE_C_COMPILER} MATCHES "clang*")
|
||||
set(UNIX_WARNINGS "-Wall -Wno-sign-compare -Wno-trigraphs -Wno-tautological-compare -Wno-char-subscripts -Wno-gnu -Wno-logical-op-parentheses
|
||||
-Wno-non-virtual-dtor -Woverloaded-virtual -Wno-parentheses-equality -Wno-reorder -Wno-unused-function -Wno-unused-value -Wno-unused-variable")
|
||||
set(UNIX_CXX_WARNINGS "${UNIX_WARNINGS}")
|
||||
endif()
|
||||
|
||||
if (NOT DISABLE_FATAL_WARNINGS)
|
||||
set(UNIX_WARNINGS "${UNIX_WARNINGS} -Werror")
|
||||
endif (NOT DISABLE_FATAL_WARNINGS)
|
||||
|
||||
set(CMAKE_C_FLAGS "${UNIX_WARNINGS} ${CMAKE_C_FLAGS}")
|
||||
set(CMAKE_CXX_FLAGS "${UNIX_CXX_WARNINGS} ${CMAKE_CXX_FLAGS}")
|
||||
if (WORD_SIZE EQUAL 32)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32")
|
||||
@@ -294,14 +319,14 @@ else (STANDALONE)
|
||||
endif (STANDALONE)
|
||||
|
||||
if(1 EQUAL 1)
|
||||
add_definitions(-DOPENSIM_RULES=1)
|
||||
add_definitions(-DMESH_ENABLED=1)
|
||||
add_definitions(-DOPENSIM_RULES=1)
|
||||
add_definitions(-DMESH_ENABLED=1)
|
||||
add_definitions(-DENABLE_CLASSIC_CLOUDS=1)
|
||||
if (NOT "$ENV{SHY_MOD}" STREQUAL "")
|
||||
add_definitions(-DSHY_MOD=1)
|
||||
endif (NOT "$ENV{SHY_MOD}" STREQUAL "")
|
||||
endif(1 EQUAL 1)
|
||||
|
||||
if(SERVER)
|
||||
include_directories(${LIBS_PREBUILT_DIR}/include/havok)
|
||||
endif(SERVER)
|
||||
|
||||
SET( CMAKE_EXE_LINKER_FLAGS_RELEASESSE2
|
||||
"${CMAKE_EXE_LINKER_FLAGS_RELEASE}" CACHE STRING
|
||||
"Flags used for linking binaries under SSE2 build."
|
||||
|
||||
@@ -29,12 +29,12 @@ else (STANDALONE)
|
||||
)
|
||||
elseif (DARWIN)
|
||||
set(APR_LIBRARIES
|
||||
debug ${ARCH_PREBUILT_DIRS_DEBUG}/libapr-1.0.3.7.dylib
|
||||
optimized ${ARCH_PREBUILT_DIRS_RELEASE}/libapr-1.0.3.7.dylib
|
||||
debug ${ARCH_PREBUILT_DIRS_DEBUG}/libapr-1.0.dylib
|
||||
optimized ${ARCH_PREBUILT_DIRS_RELEASE}/libapr-1.0.dylib
|
||||
)
|
||||
set(APRUTIL_LIBRARIES
|
||||
debug ${ARCH_PREBUILT_DIRS_DEBUG}/libaprutil-1.0.3.8.dylib
|
||||
optimized ${ARCH_PREBUILT_DIRS_RELEASE}/libaprutil-1.0.3.8.dylib
|
||||
debug ${ARCH_PREBUILT_DIRS_DEBUG}/libaprutil-1.0.dylib
|
||||
optimized ${ARCH_PREBUILT_DIRS_RELEASE}/libaprutil-1.0.dylib
|
||||
)
|
||||
set(APRICONV_LIBRARIES iconv)
|
||||
else (WINDOWS)
|
||||
|
||||
@@ -6,6 +6,11 @@ set(DB_FIND_REQUIRED ON)
|
||||
if (STANDALONE)
|
||||
include(FindBerkeleyDB)
|
||||
else (STANDALONE)
|
||||
set(DB_LIBRARIES db-4.2)
|
||||
if (LINUX)
|
||||
# Need to add dependency pthread explicitely to support ld.gold.
|
||||
set(DB_LIBRARIES db-4.2 pthread)
|
||||
else (LINUX)
|
||||
set(DB_LIBRARIES db-4.2)
|
||||
endif (LINUX)
|
||||
set(DB_INCLUDE_DIRS ${LIBS_PREBUILT_DIR}/include)
|
||||
endif (STANDALONE)
|
||||
|
||||
@@ -10,7 +10,7 @@ if (STANDALONE)
|
||||
set(BOOST_FILESYSTEM_LIBRARY boost_filesystem-mt)
|
||||
set(BOOST_PROGRAM_OPTIONS_LIBRARY boost_program_options-mt)
|
||||
set(BOOST_REGEX_LIBRARY boost_regex-mt)
|
||||
set(BOOST_SYSTEM_LIBRARY boost_system-mt)
|
||||
set(BOOST_SYSTEM_LIBRARY boost_system-mt)
|
||||
else (STANDALONE)
|
||||
use_prebuilt_binary(boost)
|
||||
set(Boost_INCLUDE_DIRS ${LIBS_PREBUILT_DIR}/include)
|
||||
|
||||
@@ -1,23 +1,45 @@
|
||||
# -*- cmake -*-
|
||||
|
||||
function (build_version _target)
|
||||
# Read version components from the header file.
|
||||
file(STRINGS ${LIBS_OPEN_DIR}/llcommon/llversion${_target}.h lines
|
||||
REGEX " LL_VERSION_")
|
||||
foreach(line ${lines})
|
||||
string(REGEX REPLACE ".*LL_VERSION_([A-Z]+).*" "\\1" comp "${line}")
|
||||
string(REGEX REPLACE ".* = ([0-9]+);.*" "\\1" value "${line}")
|
||||
set(v${comp} "${value}")
|
||||
endforeach(line)
|
||||
# Read version components from the header file.
|
||||
file(STRINGS ${LIBS_OPEN_DIR}/llcommon/llversionviewer.h.in lines
|
||||
REGEX " LL_VERSION_")
|
||||
foreach(line ${lines})
|
||||
string(REGEX REPLACE ".*LL_VERSION_([A-Z]+).*" "\\1" comp "${line}")
|
||||
string(REGEX REPLACE ".* = ([0-9]+);.*" "\\1" value "${line}")
|
||||
set(v${comp} "${value}")
|
||||
endforeach(line)
|
||||
|
||||
# Compose the version.
|
||||
set(${_target}_VERSION "${vMAJOR}.${vMINOR}.${vPATCH}.${vBUILD}")
|
||||
if (${_target}_VERSION MATCHES "^[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+$")
|
||||
message(STATUS "Version of ${_target} is ${${_target}_VERSION}")
|
||||
else (${_target}_VERSION MATCHES "^[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+$")
|
||||
message(FATAL_ERROR "Could not determine ${_target} version (${${_target}_VERSION})")
|
||||
endif (${_target}_VERSION MATCHES "^[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+$")
|
||||
execute_process(
|
||||
COMMAND git rev-list HEAD
|
||||
OUTPUT_VARIABLE GIT_REV_LIST_STR
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
|
||||
# Report version to caller.
|
||||
set(${_target}_VERSION "${${_target}_VERSION}" PARENT_SCOPE)
|
||||
endfunction (build_version)
|
||||
if(GIT_REV_LIST_STR)
|
||||
string(REPLACE "\n" ";" GIT_REV_LIST ${GIT_REV_LIST_STR})
|
||||
else()
|
||||
string(REPLACE "\n" ";" GIT_REV_LIST "")
|
||||
endif()
|
||||
|
||||
if(GIT_REV_LIST)
|
||||
list(LENGTH GIT_REV_LIST vBUILD)
|
||||
else()
|
||||
set(vBUILD 99)
|
||||
endif()
|
||||
|
||||
configure_file(
|
||||
${CMAKE_SOURCE_DIR}/llcommon/llversionviewer.h.in
|
||||
${CMAKE_SOURCE_DIR}/llcommon/llversionviewer.h
|
||||
)
|
||||
|
||||
# Compose the version.
|
||||
set(viewer_VERSION "${vMAJOR}.${vMINOR}.${vPATCH}.${vBUILD}")
|
||||
if (viewer_VERSION MATCHES "^[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+$")
|
||||
message(STATUS "Version is ${viewer_VERSION}")
|
||||
else (viewer_VERSION MATCHES "^[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+$")
|
||||
message(FATAL_ERROR "Could not determine version (${viewer_VERSION})")
|
||||
endif (viewer_VERSION MATCHES "^[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+$")
|
||||
|
||||
# Report version to caller.
|
||||
#set(viewer_VERSION "${viewer_VERSION}" PARENT_SCOPE)
|
||||
|
||||
@@ -10,6 +10,7 @@ if (STANDALONE)
|
||||
else (STANDALONE)
|
||||
use_prebuilt_binary(ares)
|
||||
if (WINDOWS)
|
||||
add_definitions("-DCARES_STATICLIB")
|
||||
set(CARES_LIBRARIES areslib)
|
||||
elseif (DARWIN)
|
||||
set(CARES_LIBRARIES
|
||||
|
||||
@@ -35,7 +35,7 @@ set(cmake_SOURCE_FILES
|
||||
FindNDOF.cmake
|
||||
FindOpenJPEG.cmake
|
||||
FindXmlRpcEpi.cmake
|
||||
FMOD.cmake
|
||||
FMOD.cmake
|
||||
FreeType.cmake
|
||||
GStreamer010Plugin.cmake
|
||||
GooglePerfTools.cmake
|
||||
@@ -79,11 +79,14 @@ set(cmake_SOURCE_FILES
|
||||
UI.cmake
|
||||
UnixInstall.cmake
|
||||
Variables.cmake
|
||||
Versions.cmake
|
||||
XmlRpcEpi.cmake
|
||||
ZLIB.cmake
|
||||
)
|
||||
|
||||
if(FMODEX)
|
||||
list(APPEND cmake_SOURCE_FILES FMODEX.cmake)
|
||||
endif(FMODEX)
|
||||
|
||||
source_group("Shared Rules" FILES ${cmake_SOURCE_FILES})
|
||||
|
||||
set(master_SOURCE_FILES
|
||||
|
||||
@@ -243,12 +243,51 @@ set(all_targets ${all_targets} ${out_targets})
|
||||
set(release_src_dir "${CMAKE_SOURCE_DIR}/../libraries/i686-win32/lib/release")
|
||||
set(release_files
|
||||
libtcmalloc_minimal.dll
|
||||
fmod.dll
|
||||
libhunspell.dll
|
||||
libapr-1.dll
|
||||
libaprutil-1.dll
|
||||
libapriconv-1.dll
|
||||
)
|
||||
|
||||
if(FMODEX)
|
||||
find_path(FMODEX_BINARY_DIR fmodex.dll
|
||||
${release_src_dir}
|
||||
${FMODEX_SDK_DIR}/api
|
||||
${FMODEX_SDK_DIR}
|
||||
)
|
||||
|
||||
if(FMODEX_BINARY_DIR)
|
||||
copy_if_different("${FMODEX_BINARY_DIR}" "${CMAKE_CURRENT_BINARY_DIR}/Release" out_targets fmodex.dll)
|
||||
set(all_targets ${all_targets} ${out_targets})
|
||||
copy_if_different("${FMODEX_BINARY_DIR}" "${CMAKE_CURRENT_BINARY_DIR}/ReleaseSSE2" out_targets fmodex.dll)
|
||||
set(all_targets ${all_targets} ${out_targets})
|
||||
copy_if_different("${FMODEX_BINARY_DIR}" "${CMAKE_CURRENT_BINARY_DIR}/RelWithDebInfo" out_targets fmodex.dll)
|
||||
set(all_targets ${all_targets} ${out_targets})
|
||||
copy_if_different("${FMODEX_BINARY_DIR}" "${CMAKE_CURRENT_BINARY_DIR}/Debug" out_targets fmodex.dll)
|
||||
set(all_targets ${all_targets} ${out_targets})
|
||||
endif(FMODEX_BINARY_DIR)
|
||||
endif(FMODEX)
|
||||
|
||||
if(FMOD)
|
||||
find_path(FMOD_BINARY_DIR fmod.dll
|
||||
${release_src_dir}
|
||||
${FMOD_SDK_DIR}/api
|
||||
${FMOD_SDK_DIR}
|
||||
)
|
||||
|
||||
if(FMOD_BINARY_DIR)
|
||||
copy_if_different("${FMOD_BINARY_DIR}" "${CMAKE_CURRENT_BINARY_DIR}/Release" out_targets fmod.dll)
|
||||
set(all_targets ${all_targets} ${out_targets})
|
||||
copy_if_different("${FMOD_BINARY_DIR}" "${CMAKE_CURRENT_BINARY_DIR}/ReleaseSSE2" out_targets fmod.dll)
|
||||
set(all_targets ${all_targets} ${out_targets})
|
||||
copy_if_different("${FMOD_BINARY_DIR}" "${CMAKE_CURRENT_BINARY_DIR}/RelWithDebInfo" out_targets fmod.dll)
|
||||
set(all_targets ${all_targets} ${out_targets})
|
||||
copy_if_different("${FMOD_BINARY_DIR}" "${CMAKE_CURRENT_BINARY_DIR}/Debug" out_targets fmod.dll)
|
||||
set(all_targets ${all_targets} ${out_targets})
|
||||
else(FMOD_BINARY_DIR)
|
||||
list(APPEND release_files fmod.dll) #Required for compile. This will cause an error in copying binaries.
|
||||
endif(FMOD_BINARY_DIR)
|
||||
endif(FMOD)
|
||||
|
||||
copy_if_different(
|
||||
${release_src_dir}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
if (VIEWER AND WINDOWS)
|
||||
find_path(DIRECTX_INCLUDE_DIR dxdiag.h
|
||||
"$ENV{DXSDK_DIR}/Include"
|
||||
"$ENV{PROGRAMFILES}/Microsoft DirectX SDK (June 2010)/Include"
|
||||
"$ENV{PROGRAMFILES}/Microsoft DirectX SDK (June 2010)/Include"
|
||||
"$ENV{PROGRAMFILES}/Microsoft DirectX SDK (March 2009)/Include"
|
||||
"$ENV{PROGRAMFILES}/Microsoft DirectX SDK (August 2008)/Include"
|
||||
"$ENV{PROGRAMFILES}/Microsoft DirectX SDK (June 2008)/Include"
|
||||
@@ -25,7 +25,7 @@ if (VIEWER AND WINDOWS)
|
||||
|
||||
find_path(DIRECTX_LIBRARY_DIR dxguid.lib
|
||||
"$ENV{DXSDK_DIR}/Lib/x86"
|
||||
"$ENV{PROGRAMFILES}/Microsoft DirectX SDK (June 2010)/Lib/x86"
|
||||
"$ENV{PROGRAMFILES}/Microsoft DirectX SDK (June 2010)/Lib/x86"
|
||||
"$ENV{PROGRAMFILES}/Microsoft DirectX SDK (March 2009)/Lib/x86"
|
||||
"$ENV{PROGRAMFILES}/Microsoft DirectX SDK (August 2008)/Lib/x86"
|
||||
"$ENV{PROGRAMFILES}/Microsoft DirectX SDK (June 2008)/Lib/x86"
|
||||
|
||||
@@ -6,6 +6,7 @@ set(install_dir "@CMAKE_SOURCE_DIR@/..")
|
||||
set(scp "@SCP_EXECUTABLE@")
|
||||
set(scripts_dir "@SCRIPTS_DIR@")
|
||||
set(sentinel_dir "@CMAKE_BINARY_DIR@/prepare")
|
||||
set(prebuilt_type "@PREBUILT_TYPE@")
|
||||
|
||||
# In proprietary mode we use scp for download.
|
||||
set(proprietary "@INSTALL_PROPRIETARY@")
|
||||
@@ -19,7 +20,7 @@ foreach(package ${packages})
|
||||
# This package is missing or out of date.
|
||||
message(STATUS "Obtaining${proprietary_message} prebuilt '${package}'")
|
||||
execute_process(
|
||||
COMMAND ${python} install.py --install-dir=${install_dir} ${scp_option} ${package}
|
||||
COMMAND ${python} install.py -p${prebuilt_type} --install-dir=${install_dir} ${scp_option} ${package}
|
||||
WORKING_DIRECTORY ${scripts_dir}
|
||||
RESULT_VARIABLE result
|
||||
)
|
||||
|
||||
@@ -7,26 +7,13 @@ if(INSTALL_PROPRIETARY)
|
||||
use_prebuilt_binary(fmod)
|
||||
endif(INSTALL_PROPRIETARY)
|
||||
|
||||
find_library(FMOD_LIBRARY_RELEASE
|
||||
find_library(FMOD_LIBRARY
|
||||
NAMES fmod fmodvc fmod-3.75
|
||||
PATHS
|
||||
${ARCH_PREBUILT_DIRS_RELEASE}
|
||||
optimized ${ARCH_PREBUILT_DIRS_RELEASE}
|
||||
debug ${ARCH_PREBUILT_DIRS_DEBUG}
|
||||
)
|
||||
|
||||
find_library(FMOD_LIBRARY_DEBUG
|
||||
NAMES fmod fmodvc fmod-3.75
|
||||
PATHS
|
||||
${ARCH_PREBUILT_DIRS_DEBUG}
|
||||
)
|
||||
|
||||
if (FMOD_LIBRARY_RELEASE AND FMOD_LIBRARY_DEBUG)
|
||||
set(FMOD_LIBRARY
|
||||
debug ${FMOD_LIBRARY_DEBUG}
|
||||
optimized ${FMOD_LIBRARY_RELEASE})
|
||||
elseif (FMOD_LIBRARY_RELEASE)
|
||||
set(FMOD_LIBRARY ${FMOD_LIBRARY_RELEASE})
|
||||
endif (FMOD_LIBRARY_RELEASE AND FMOD_LIBRARY_DEBUG)
|
||||
|
||||
if (NOT FMOD_LIBRARY)
|
||||
set(FMOD_SDK_DIR CACHE PATH "Path to the FMOD SDK.")
|
||||
if (FMOD_SDK_DIR)
|
||||
|
||||
70
indra/cmake/FMODEX.cmake
Normal file
70
indra/cmake/FMODEX.cmake
Normal file
@@ -0,0 +1,70 @@
|
||||
# -*- cmake -*-
|
||||
|
||||
include(Linking)
|
||||
|
||||
if(INSTALL_PROPRIETARY)
|
||||
include(Prebuilt)
|
||||
use_prebuilt_binary(fmodex)
|
||||
endif(INSTALL_PROPRIETARY)
|
||||
|
||||
find_library(FMODEX_LIBRARY
|
||||
NAMES fmodex fmodex_vc fmodexL_vc
|
||||
PATHS
|
||||
optimized ${ARCH_PREBUILT_DIRS_RELEASE}
|
||||
debug ${ARCH_PREBUILT_DIRS_DEBUG}
|
||||
)
|
||||
|
||||
if (NOT FMODEX_LIBRARY)
|
||||
set(FMODEX_SDK_DIR CACHE PATH "Path to the FMOD Ex SDK.")
|
||||
if (FMODEX_SDK_DIR)
|
||||
find_library(FMODEX_LIBRARY
|
||||
fmodex fmodex_vc fmodexL_vc
|
||||
PATHS
|
||||
${FMODEX_SDK_DIR}/api/lib
|
||||
${FMODEX_SDK_DIR}/api
|
||||
${FMODEX_SDK_DIR}/lib
|
||||
${FMODEX_SDK_DIR}
|
||||
)
|
||||
|
||||
|
||||
endif(FMODEX_SDK_DIR)
|
||||
if(WINDOWS AND NOT FMODEX_LIBRARY)
|
||||
set(FMODEX_PROG_DIR "$ENV{PROGRAMFILES}/FMOD SoundSystem/FMOD Programmers API Windows")
|
||||
find_library(FMODEX_LIBRARY
|
||||
fmodex_vc fmodexL_vc
|
||||
PATHS
|
||||
${FMODEX_PROG_DIR}/api/lib
|
||||
${FMODEX_PROG_DIR}/api
|
||||
${FMODEX_PROG_DIR}
|
||||
)
|
||||
if(FMODEX_LIBRARY)
|
||||
message(STATUS "Found fmodex in ${FMODEX_PROG_DIR}")
|
||||
set(FMODEX_SDK_DIR ${FMODEX_PROG_DIR})
|
||||
set(FMODEX_SDK_DIR ${FMODEX_PROG_DIR} CACHE PATH "Path to the FMOD Ex SDK." FORCE)
|
||||
endif(FMODEX_LIBRARY)
|
||||
endif(WINDOWS AND NOT FMODEX_LIBRARY)
|
||||
endif (NOT FMODEX_LIBRARY)
|
||||
|
||||
find_path(FMODEX_INCLUDE_DIR fmod.h
|
||||
${LIBS_PREBUILT_DIR}/include/fmodex
|
||||
${LIBS_PREBUILT_DIR}/${LL_ARCH_DIR}/fmodex
|
||||
${FMODEX_SDK_DIR}/api/inc
|
||||
${FMODEX_SDK_DIR}/inc
|
||||
${FMODEX_SDK_DIR}
|
||||
)
|
||||
|
||||
if (FMODEX_LIBRARY AND FMODEX_INCLUDE_DIR)
|
||||
set(FMODEX ON CACHE BOOL "Use closed source FMOD Ex sound library.")
|
||||
else (FMODEX_LIBRARY AND FMODEX_INCLUDE_DIR)
|
||||
set(FMODEX_LIBRARY "")
|
||||
set(FMODEX_INCLUDE_DIR "")
|
||||
if (FMODEX)
|
||||
message(STATUS "No support for FMOD Ex audio (need to set FMODEX_SDK_DIR?)")
|
||||
endif (FMODEX)
|
||||
set(FMODEX OFF CACHE BOOL "Use closed source FMOD Ex sound library.")
|
||||
set(FMODEX OFF)
|
||||
endif (FMODEX_LIBRARY AND FMODEX_INCLUDE_DIR)
|
||||
|
||||
if (FMODEX)
|
||||
message(STATUS "Building with FMOD Ex audio support")
|
||||
endif (FMODEX)
|
||||
@@ -9,7 +9,7 @@
|
||||
# also defined, but not for general use are
|
||||
# JSONCPP_LIBRARY, where to find the jsoncpp library.
|
||||
|
||||
FIND_PATH(JSONCPP_INCLUDE_DIR jsoncpp/json.h
|
||||
FIND_PATH(JSONCPP_INCLUDE_DIR json/json.h
|
||||
/usr/local/include
|
||||
/usr/include
|
||||
)
|
||||
|
||||
@@ -14,11 +14,19 @@ endif (DARWIN)
|
||||
set(LLCOMMON_INCLUDE_DIRS
|
||||
${LIBS_OPEN_DIR}/cwdebug
|
||||
${LIBS_OPEN_DIR}/llcommon
|
||||
${APRUTIL_INCLUDE_DIR}
|
||||
${APR_INCLUDE_DIR}
|
||||
${Boost_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
set(LLCOMMON_LIBRARIES llcommon)
|
||||
if (LINUX)
|
||||
# In order to support using ld.gold on linux, we need to explicitely
|
||||
# specify all libraries that llcommon uses.
|
||||
# llcommon uses `clock_gettime' which is provided by librt on linux.
|
||||
set(LLCOMMON_LIBRARIES llcommon rt)
|
||||
else (LINUX)
|
||||
set(LLCOMMON_LIBRARIES llcommon)
|
||||
endif (LINUX)
|
||||
|
||||
set(LLCOMMON_LINK_SHARED ON CACHE BOOL "Build the llcommon target as a shared library.")
|
||||
if(LLCOMMON_LINK_SHARED)
|
||||
|
||||
@@ -5,4 +5,10 @@ set(LLPLUGIN_INCLUDE_DIRS
|
||||
${LIBS_OPEN_DIR}/llplugin
|
||||
)
|
||||
|
||||
set(LLPLUGIN_LIBRARIES llplugin)
|
||||
if (LINUX)
|
||||
# In order to support using ld.gold on linux, we need to explicitely
|
||||
# specify all libraries that llplugin uses.
|
||||
set(LLPLUGIN_LIBRARIES llplugin pthread)
|
||||
else (LINUX)
|
||||
set(LLPLUGIN_LIBRARIES llplugin)
|
||||
endif (LINUX)
|
||||
|
||||
7
indra/cmake/LLXUIXML.cmake
Normal file
7
indra/cmake/LLXUIXML.cmake
Normal file
@@ -0,0 +1,7 @@
|
||||
# -*- cmake -*-
|
||||
|
||||
set(LLXUIXML_INCLUDE_DIRS
|
||||
${LIBS_OPEN_DIR}/llxuixml
|
||||
)
|
||||
|
||||
set(LLXUIXML_LIBRARIES llxuixml)
|
||||
@@ -1,10 +1,10 @@
|
||||
# -*- cmake -*-
|
||||
include(Prebuilt)
|
||||
|
||||
if (NOT STANDALONE)
|
||||
if (NOT (STANDALONE OR DARWIN))
|
||||
use_prebuilt_binary(glext)
|
||||
# possible glh_linear should have its own .cmake file instead
|
||||
#use_prebuilt_binary(glh_linear)
|
||||
# actually... not any longer, it's now in git -SG
|
||||
set(GLEXT_INCLUDE_DIR ${LIBS_PREBUILT_DIR}/include)
|
||||
endif (NOT STANDALONE)
|
||||
endif ()
|
||||
|
||||
@@ -19,7 +19,6 @@ if (WINDOWS)
|
||||
[HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\2.5\\InstallPath]
|
||||
[HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\2.4\\InstallPath]
|
||||
[HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\2.3\\InstallPath]
|
||||
|
||||
)
|
||||
elseif (EXISTS /etc/debian_version)
|
||||
# On Debian and Ubuntu, avoid Python 2.4 if possible.
|
||||
|
||||
@@ -38,6 +38,7 @@ else (STANDALONE)
|
||||
if (LINUX)
|
||||
set(UI_LIBRARIES
|
||||
atk-1.0
|
||||
X11
|
||||
gdk-x11-2.0
|
||||
gdk_pixbuf-2.0
|
||||
Xinerama
|
||||
|
||||
@@ -76,24 +76,16 @@ endif (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
||||
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
||||
set(DARWIN 1)
|
||||
|
||||
# NOTE: If specifying a different SDK with CMAKE_OSX_SYSROOT at configure
|
||||
# time you should also specify CMAKE_OSX_DEPLOYMENT_TARGET explicitly,
|
||||
# otherwise CMAKE_OSX_SYSROOT will be overridden here. We can't just check
|
||||
# for it being unset, as it gets set to the system default :(
|
||||
|
||||
# Default to building against the 10.5 SDK if no deployment target is
|
||||
# specified.
|
||||
if (NOT CMAKE_OSX_DEPLOYMENT_TARGET)
|
||||
# NOTE: setting -isysroot is NOT adequate: http://lists.apple.com/archives/Xcode-users/2007/Oct/msg00696.html
|
||||
# see http://public.kitware.com/Bug/view.php?id=9959 + poppy
|
||||
#SDK Compiler and Deployment targets for XCode
|
||||
if (${XCODE_VERSION} VERSION_LESS 4.0.0)
|
||||
set(CMAKE_OSX_SYSROOT /Developer/SDKs/MacOSX10.5.sdk)
|
||||
set(CMAKE_OSX_DEPLOYMENT_TARGET 10.5)
|
||||
endif (NOT CMAKE_OSX_DEPLOYMENT_TARGET)
|
||||
set(CMAKE_XCODE_ATTIBUTE_GCC_VERSION "4.2")
|
||||
else (${XCODE_VERSION} VERSION_LESS 4.0.0)
|
||||
set(CMAKE_OSX_SYSROOT /Developer/SDKs/MacOSX10.6.sdk)
|
||||
set(CMAKE_XCODE_ATTRIBUTE_GCC_VERSION "com.apple.compilers.llvmgcc42")
|
||||
endif (${XCODE_VERSION} VERSION_LESS 4.0.0)
|
||||
|
||||
# Use GCC 4.2
|
||||
if (${CMAKE_OSX_SYSROOT} MATCHES "10.5")
|
||||
set(CMAKE_XCODE_ATTRIBUTE_GCC_VERSION "4.2")
|
||||
endif (${CMAKE_OSX_SYSROOT} MATCHES "10.5")
|
||||
set(CMAKE_OSX_DEPLOYMENT_TARGET 10.5)
|
||||
|
||||
# NOTE: To attempt an i386/PPC Universal build, add this on the configure line:
|
||||
# -DCMAKE_OSX_ARCHITECTURES:STRING='i386;ppc'
|
||||
@@ -118,6 +110,17 @@ if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
||||
endif (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
||||
|
||||
|
||||
if (WINDOWS)
|
||||
set(PREBUILT_TYPE windows)
|
||||
elseif(DARWIN)
|
||||
set(PREBUILT_TYPE darwin)
|
||||
elseif(LINUX AND WORD_SIZE EQUAL 32)
|
||||
set(PREBUILT_TYPE linux)
|
||||
elseif(LINUX AND WORD_SIZE EQUAL 64)
|
||||
set(PREBUILT_TYPE linux64)
|
||||
endif(WINDOWS)
|
||||
|
||||
|
||||
# Default deploy grid
|
||||
set(GRID agni CACHE STRING "Target Grid")
|
||||
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
include(BuildVersion)
|
||||
|
||||
if(VIEWER)
|
||||
build_version(viewer)
|
||||
endif(VIEWER)
|
||||
|
||||
if(SERVER)
|
||||
build_version(server)
|
||||
endif(SERVER)
|
||||
@@ -67,11 +67,16 @@ elseif (LINUX)
|
||||
QtNetwork
|
||||
QtGui
|
||||
QtCore
|
||||
crypto
|
||||
ssl
|
||||
# qgif
|
||||
# qjpeg
|
||||
jscore
|
||||
jpeg
|
||||
fontconfig
|
||||
X11
|
||||
Xrender
|
||||
Xext
|
||||
GL
|
||||
)
|
||||
endif (STANDALONE)
|
||||
|
||||
@@ -171,7 +171,8 @@ void stop_recording_backtraces(void)
|
||||
channel_ct gtk DDCN("GTK"); //!< This debug channel is used for output related to gtk.
|
||||
channel_ct sdl DDCN("SDL"); //!< This debug channel is used for output related to sdl locking.
|
||||
channel_ct backtrace DDCN("BACKTRACE"); //!< This debug channel is used for backtraces.
|
||||
channel_ct statemachine DDCN("STATEMACHINE"); //!< This debug channel is used class AIStateMachine.
|
||||
channel_ct statemachine DDCN("STATEMACHINE"); //!< This debug channel is used for output related to class AIStateMachine.
|
||||
channel_ct caps DDCN("CAPS"); //!< This debug channel is used for output related to Capabilities.
|
||||
|
||||
} // namespace dc
|
||||
} // namespace DEBUGCHANNELS
|
||||
|
||||
@@ -117,6 +117,7 @@ extern CWD_API channel_ct gtk;
|
||||
extern CWD_API channel_ct sdl;
|
||||
extern CWD_API channel_ct backtrace;
|
||||
extern CWD_API channel_ct statemachine;
|
||||
extern CWD_API channel_ct caps;
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -775,9 +775,8 @@ Options:
|
||||
-p | --project=NAME set the root project name. (Doesn't effect makefiles)
|
||||
|
||||
Commands:
|
||||
build configure and build default target
|
||||
clean delete all build directories, does not affect sources
|
||||
configure configure project by running cmake (default command if none given)
|
||||
build configure and build default target
|
||||
clean delete all build directories, does not affect sources
|
||||
configure configure project by running cmake (default if none given)
|
||||
printbuilddirs print the build directory that will be used
|
||||
|
||||
|
||||
@@ -168,7 +168,10 @@ ARGUMENTS=[
|
||||
dict(name='version',
|
||||
description="""This specifies the version of Second Life that is
|
||||
being packaged up.""",
|
||||
default=get_default_version)
|
||||
default=get_default_version),
|
||||
dict(name='extra_libraries',
|
||||
description="""List of extra libraries to include in package""",
|
||||
default=None)
|
||||
]
|
||||
|
||||
def usage(srctree=""):
|
||||
|
||||
@@ -1,105 +1,84 @@
|
||||
# Main CMakeLists.txt to build the OpenJPEG project using CMake (www.cmake.org)
|
||||
# Written by Mathieu Malaterre
|
||||
# -*- cmake -*-
|
||||
|
||||
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
|
||||
project(openjpeg)
|
||||
|
||||
IF(COMMAND CMAKE_POLICY)
|
||||
CMAKE_POLICY(SET CMP0003 NEW)
|
||||
ENDIF(COMMAND CMAKE_POLICY)
|
||||
include(00-Common)
|
||||
|
||||
PROJECT(openjpeg)
|
||||
|
||||
# Do full dependency headers.
|
||||
INCLUDE_REGULAR_EXPRESSION("^.*$")
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# OPENJPEG version number, useful for packaging and doxygen doc:
|
||||
SET(OPENJPEG_VERSION_MAJOR 1)
|
||||
SET(OPENJPEG_VERSION_MINOR 4)
|
||||
SET(OPENJPEG_VERSION_BUILD 0)
|
||||
SET(OPENJPEG_VERSION
|
||||
set(OPENJPEG_VERSION_MAJOR 1)
|
||||
set(OPENJPEG_VERSION_MINOR 4)
|
||||
set(OPENJPEG_VERSION_BUILD 0)
|
||||
set(OPENJPEG_VERSION
|
||||
"${OPENJPEG_VERSION_MAJOR}.${OPENJPEG_VERSION_MINOR}.${OPENJPEG_VERSION_BUILD}")
|
||||
|
||||
set(openjpeg_SOURCE_FILES
|
||||
bio.c
|
||||
cio.c
|
||||
dwt.c
|
||||
event.c
|
||||
image.c
|
||||
j2k.c
|
||||
j2k_lib.c
|
||||
jp2.c
|
||||
jpt.c
|
||||
mct.c
|
||||
mqc.c
|
||||
openjpeg.c
|
||||
pi.c
|
||||
raw.c
|
||||
t1.c
|
||||
t2.c
|
||||
tcd.c
|
||||
tgt.c
|
||||
)
|
||||
|
||||
set(openjpeg_HEADER_FILES
|
||||
bio.h
|
||||
cio.h
|
||||
dwt.h
|
||||
event.h
|
||||
fix.h
|
||||
image.h
|
||||
int.h
|
||||
j2k.h
|
||||
j2k_lib.h
|
||||
jp2.h
|
||||
jpt.h
|
||||
mct.h
|
||||
mqc.h
|
||||
openjpeg.h
|
||||
opj_includes.h
|
||||
opj_malloc.h
|
||||
pi.h
|
||||
raw.h
|
||||
t1.h
|
||||
t1_luts.h
|
||||
t2.h
|
||||
tcd.h
|
||||
tgt.h
|
||||
)
|
||||
|
||||
IF(WINDOWS)
|
||||
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
|
||||
add_definitions(-DOPJ_STATIC)
|
||||
ENDIF(WINDOWS)
|
||||
|
||||
|
||||
set_source_files_properties(${openjpeg_HEADER_FILES}
|
||||
PROPERTIES HEADER_FILE_ONLY TRUE)
|
||||
|
||||
list(APPEND openjpeg_SOURCE_FILES ${openjpeg_HEADER_FILES})
|
||||
|
||||
add_library (openjpeg ${openjpeg_SOURCE_FILES})
|
||||
|
||||
# This setting of SOVERSION assumes that any API change
|
||||
# will increment either the minor or major version number of openjpeg
|
||||
SET(OPENJPEG_LIBRARY_PROPERTIES
|
||||
set(OPENJPEG_LIBRARY_PROPERTIES
|
||||
VERSION "${OPENJPEG_VERSION_MAJOR}.${OPENJPEG_VERSION_MINOR}.${OPENJPEG_VERSION_BUILD}"
|
||||
SOVERSION "${OPENJPEG_VERSION_MAJOR}.${OPENJPEG_VERSION_MINOR}"
|
||||
)
|
||||
|
||||
# On Visual Studio 8 MS deprecated C. This removes all 1.276E1265 security
|
||||
# warnings
|
||||
IF(WIN32)
|
||||
IF(NOT BORLAND)
|
||||
IF(NOT CYGWIN)
|
||||
IF(NOT MINGW)
|
||||
IF(NOT ITK_ENABLE_VISUAL_STUDIO_DEPRECATED_C_WARNINGS)
|
||||
ADD_DEFINITIONS(
|
||||
-D_CRT_FAR_MAPPINGS_NO_DEPRECATE
|
||||
-D_CRT_IS_WCTYPE_NO_DEPRECATE
|
||||
-D_CRT_MANAGED_FP_NO_DEPRECATE
|
||||
-D_CRT_NONSTDC_NO_DEPRECATE
|
||||
-D_CRT_SECURE_NO_DEPRECATE
|
||||
-D_CRT_SECURE_NO_DEPRECATE_GLOBALS
|
||||
-D_CRT_SETERRORMODE_BEEP_SLEEP_NO_DEPRECATE
|
||||
-D_CRT_TIME_FUNCTIONS_NO_DEPRECATE
|
||||
-D_CRT_VCCLRIT_NO_DEPRECATE
|
||||
-D_SCL_SECURE_NO_DEPRECATE
|
||||
)
|
||||
ENDIF(NOT ITK_ENABLE_VISUAL_STUDIO_DEPRECATED_C_WARNINGS)
|
||||
ENDIF(NOT MINGW)
|
||||
ENDIF(NOT CYGWIN)
|
||||
ENDIF(NOT BORLAND)
|
||||
ENDIF(WIN32)
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Test for some required system information.
|
||||
# INCLUDE (${CMAKE_ROOT}/Modules/CMakeBackwardCompatibilityC.cmake)
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Compiler specific flags:
|
||||
IF(CMAKE_COMPILER_IS_GNUCC)
|
||||
# For all builds, make sure openjpeg is std99 compliant:
|
||||
# SET(CMAKE_C_FLAGS "-Wall -std=c99 ${CMAKE_C_FLAGS}") # FIXME: this setting prevented us from setting a coverage build.
|
||||
# Do not use ffast-math for all build, it would produce incorrect results, only set for release:
|
||||
SET(CMAKE_C_FLAGS_RELEASE "-ffast-math ${CMAKE_C_FLAGS_RELEASE}")
|
||||
ENDIF(CMAKE_COMPILER_IS_GNUCC)
|
||||
|
||||
# Defines the source code for the library
|
||||
SET(OPENJPEG_SRCS
|
||||
bio.c
|
||||
cio.c
|
||||
dwt.c
|
||||
event.c
|
||||
image.c
|
||||
j2k.c
|
||||
j2k_lib.c
|
||||
jp2.c
|
||||
jpt.c
|
||||
mct.c
|
||||
mqc.c
|
||||
openjpeg.c
|
||||
pi.c
|
||||
raw.c
|
||||
t1.c
|
||||
t2.c
|
||||
tcd.c
|
||||
tgt.c
|
||||
)
|
||||
|
||||
# Pass proper definition to preprocessor to generate shared lib
|
||||
IF(WIN32)
|
||||
IF(BUILD_SHARED_LIBS)
|
||||
ADD_DEFINITIONS(-DOPJ_EXPORTS)
|
||||
ELSE(BUILD_SHARED_LIBS)
|
||||
ADD_DEFINITIONS(-DOPJ_STATIC)
|
||||
ENDIF(BUILD_SHARED_LIBS)
|
||||
ENDIF(WIN32)
|
||||
|
||||
# Create the library
|
||||
ADD_LIBRARY(openjpeg ${OPENJPEG_SRCS})
|
||||
SET_TARGET_PROPERTIES(openjpeg PROPERTIES
|
||||
set_target_properties(openjpeg PROPERTIES
|
||||
${OPENJPEG_LIBRARY_PROPERTIES})
|
||||
|
||||
|
||||
|
||||
@@ -527,7 +527,7 @@ static void dwt_decode_tile(opj_tcd_tilecomp_t* tilec, int numres, DWT1DFN dwt_1
|
||||
|
||||
int w = tilec->x1 - tilec->x0;
|
||||
|
||||
h.mem = opj_aligned_malloc(dwt_decode_max_resolution(tr, numres) * sizeof(int));
|
||||
h.mem = (int *)opj_aligned_malloc(dwt_decode_max_resolution(tr, numres) * sizeof(int));
|
||||
v.mem = h.mem;
|
||||
|
||||
while( --numres) {
|
||||
@@ -570,7 +570,7 @@ static void v4dwt_interleave_h(v4dwt_t* restrict w, float* restrict a, int x, in
|
||||
int count = w->sn;
|
||||
int i, k;
|
||||
for(k = 0; k < 2; ++k){
|
||||
if (count + 3 * x < size && ((int) a & 0x0f) == 0 && ((int) bi & 0x0f) == 0 && (x & 0x0f) == 0) {
|
||||
if (count + 3 * x < size && ((long) a & 0x0f) == 0 && ((long) bi & 0x0f) == 0 && (x & 0x0f) == 0) {
|
||||
/* Fast code path */
|
||||
for(i = 0; i < count; ++i){
|
||||
int j = i;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2005, Herv<EFBFBD> Drolon, FreeImage Team
|
||||
* Copyright (c) 2005, Hervé Drolon, FreeImage Team
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -26,41 +26,6 @@
|
||||
|
||||
#include "opj_includes.h"
|
||||
|
||||
/* ==========================================================
|
||||
Utility functions
|
||||
==========================================================*/
|
||||
|
||||
#if !defined(_MSC_VER) && !defined(__MINGW32__)
|
||||
static char*
|
||||
i2a(unsigned i, char *a, unsigned r) {
|
||||
if (i/r > 0) a = i2a(i/r,a,r);
|
||||
*a = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"[i%r];
|
||||
return a+1;
|
||||
}
|
||||
|
||||
/**
|
||||
Transforms integer i into an ascii string and stores the result in a;
|
||||
string is encoded in the base indicated by r.
|
||||
@param i Number to be converted
|
||||
@param a String result
|
||||
@param r Base of value; must be in the range 2 - 36
|
||||
@return Returns a
|
||||
*/
|
||||
static char *
|
||||
_itoa(int i, char *a, int r) {
|
||||
r = ((r < 2) || (r > 36)) ? 10 : r;
|
||||
if(i < 0) {
|
||||
*a = '-';
|
||||
*i2a(-i, a+1, r) = 0;
|
||||
}
|
||||
else *i2a(i, a, r) = 0;
|
||||
return a;
|
||||
}
|
||||
|
||||
#endif /* !WIN32 */
|
||||
|
||||
/* ----------------------------------------------------------------------- */
|
||||
|
||||
opj_event_mgr_t* OPJ_CALLCONV opj_set_event_mgr(opj_common_ptr cinfo, opj_event_mgr_t *event_mgr, void *context) {
|
||||
if(cinfo) {
|
||||
opj_event_mgr_t *previous = cinfo->event_mgr;
|
||||
|
||||
@@ -236,7 +236,7 @@ static void j2k_read_unk(opj_j2k_t *j2k);
|
||||
/* ----------------------------------------------------------------------- */
|
||||
typedef struct j2k_prog_order{
|
||||
OPJ_PROG_ORDER enum_prog;
|
||||
char str_prog[4];
|
||||
char str_prog[5];
|
||||
}j2k_prog_order_t;
|
||||
|
||||
j2k_prog_order_t j2k_prog_order_list[] = {
|
||||
|
||||
@@ -1,163 +1,163 @@
|
||||
/*
|
||||
* Copyright (c) 2005, Herv<72> Drolon, FreeImage Team
|
||||
* Copyright (c) 2007, Callum Lerwick <seg@haxxed.com>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#ifndef __OPJ_MALLOC_H
|
||||
#define __OPJ_MALLOC_H
|
||||
/**
|
||||
@file opj_malloc.h
|
||||
@brief Internal functions
|
||||
|
||||
The functions in opj_malloc.h are internal utilities used for memory management.
|
||||
*/
|
||||
|
||||
/** @defgroup MISC MISC - Miscellaneous internal functions */
|
||||
/*@{*/
|
||||
|
||||
/** @name Exported functions */
|
||||
/*@{*/
|
||||
/* ----------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
Allocate an uninitialized memory block
|
||||
@param size Bytes to allocate
|
||||
@return Returns a void pointer to the allocated space, or NULL if there is insufficient memory available
|
||||
*/
|
||||
#ifdef ALLOC_PERF_OPT
|
||||
void * OPJ_CALLCONV opj_malloc(size_t size);
|
||||
#else
|
||||
#define opj_malloc(size) malloc(size)
|
||||
#endif
|
||||
|
||||
/**
|
||||
Allocate a memory block with elements initialized to 0
|
||||
@param num Blocks to allocate
|
||||
@param size Bytes per block to allocate
|
||||
@return Returns a void pointer to the allocated space, or NULL if there is insufficient memory available
|
||||
*/
|
||||
#ifdef ALLOC_PERF_OPT
|
||||
void * OPJ_CALLCONV opj_calloc(size_t _NumOfElements, size_t _SizeOfElements);
|
||||
#else
|
||||
#define opj_calloc(num, size) calloc(num, size)
|
||||
#endif
|
||||
|
||||
/**
|
||||
Allocate memory aligned to a 16 byte boundry
|
||||
@param size Bytes to allocate
|
||||
@return Returns a void pointer to the allocated space, or NULL if there is insufficient memory available
|
||||
*/
|
||||
/* FIXME: These should be set with cmake tests, but we're currently not requiring use of cmake */
|
||||
#ifdef WIN32
|
||||
/* Someone should tell the mingw people that their malloc.h ought to provide _mm_malloc() */
|
||||
#ifdef __GNUC__
|
||||
#include <mm_malloc.h>
|
||||
#define HAVE_MM_MALLOC
|
||||
#else /* MSVC, Intel C++ */
|
||||
#include <malloc.h>
|
||||
#ifdef _mm_malloc
|
||||
#define HAVE_MM_MALLOC
|
||||
#endif
|
||||
#endif
|
||||
#else /* Not WIN32 */
|
||||
#if defined(__sun)
|
||||
#define HAVE_MEMALIGN
|
||||
/* Linux x86_64 and OSX always align allocations to 16 bytes */
|
||||
#elif !defined(__amd64__) && !defined(__APPLE__)
|
||||
#define HAVE_MEMALIGN
|
||||
#include <malloc.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define opj_aligned_malloc(size) malloc(size)
|
||||
#define opj_aligned_free(m) free(m)
|
||||
|
||||
#ifdef HAVE_MM_MALLOC
|
||||
#undef opj_aligned_malloc
|
||||
#define opj_aligned_malloc(size) _mm_malloc(size, 16)
|
||||
#undef opj_aligned_free
|
||||
#define opj_aligned_free(m) _mm_free(m)
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_MEMALIGN
|
||||
extern void* memalign(size_t, size_t);
|
||||
#undef opj_aligned_malloc
|
||||
#define opj_aligned_malloc(size) memalign(16, (size))
|
||||
#undef opj_aligned_free
|
||||
#define opj_aligned_free(m) free(m)
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_POSIX_MEMALIGN
|
||||
#undef opj_aligned_malloc
|
||||
extern int posix_memalign(void**, size_t, size_t);
|
||||
|
||||
static INLINE void* __attribute__ ((malloc)) opj_aligned_malloc(size_t size){
|
||||
void* mem = NULL;
|
||||
posix_memalign(&mem, 16, size);
|
||||
return mem;
|
||||
}
|
||||
#undef opj_aligned_free
|
||||
#define opj_aligned_free(m) free(m)
|
||||
#endif
|
||||
|
||||
#ifdef ALLOC_PERF_OPT
|
||||
#undef opj_aligned_malloc
|
||||
#define opj_aligned_malloc(size) opj_malloc(size)
|
||||
#undef opj_aligned_free
|
||||
#define opj_aligned_free(m) opj_free(m)
|
||||
#endif
|
||||
|
||||
/**
|
||||
Reallocate memory blocks.
|
||||
@param memblock Pointer to previously allocated memory block
|
||||
@param size New size in bytes
|
||||
@return Returns a void pointer to the reallocated (and possibly moved) memory block
|
||||
*/
|
||||
#ifdef ALLOC_PERF_OPT
|
||||
void * OPJ_CALLCONV opj_realloc(void * _Memory, size_t NewSize);
|
||||
#else
|
||||
#define opj_realloc(m, s) realloc(m, s)
|
||||
#endif
|
||||
|
||||
/**
|
||||
Deallocates or frees a memory block.
|
||||
@param memblock Previously allocated memory block to be freed
|
||||
*/
|
||||
#ifdef ALLOC_PERF_OPT
|
||||
void OPJ_CALLCONV opj_free(void * _Memory);
|
||||
#else
|
||||
#define opj_free(m) free(m)
|
||||
#endif
|
||||
|
||||
#ifdef __GNUC__
|
||||
#pragma GCC poison malloc calloc realloc free
|
||||
#endif
|
||||
|
||||
/* ----------------------------------------------------------------------- */
|
||||
/*@}*/
|
||||
|
||||
/*@}*/
|
||||
|
||||
#endif /* __OPJ_MALLOC_H */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2005, Herv<72> Drolon, FreeImage Team
|
||||
* Copyright (c) 2007, Callum Lerwick <seg@haxxed.com>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#ifndef __OPJ_MALLOC_H
|
||||
#define __OPJ_MALLOC_H
|
||||
/**
|
||||
@file opj_malloc.h
|
||||
@brief Internal functions
|
||||
|
||||
The functions in opj_malloc.h are internal utilities used for memory management.
|
||||
*/
|
||||
|
||||
/** @defgroup MISC MISC - Miscellaneous internal functions */
|
||||
/*@{*/
|
||||
|
||||
/** @name Exported functions */
|
||||
/*@{*/
|
||||
/* ----------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
Allocate an uninitialized memory block
|
||||
@param size Bytes to allocate
|
||||
@return Returns a void pointer to the allocated space, or NULL if there is insufficient memory available
|
||||
*/
|
||||
#ifdef ALLOC_PERF_OPT
|
||||
void * OPJ_CALLCONV opj_malloc(size_t size);
|
||||
#else
|
||||
#define opj_malloc(size) malloc(size)
|
||||
#endif
|
||||
|
||||
/**
|
||||
Allocate a memory block with elements initialized to 0
|
||||
@param num Blocks to allocate
|
||||
@param size Bytes per block to allocate
|
||||
@return Returns a void pointer to the allocated space, or NULL if there is insufficient memory available
|
||||
*/
|
||||
#ifdef ALLOC_PERF_OPT
|
||||
void * OPJ_CALLCONV opj_calloc(size_t _NumOfElements, size_t _SizeOfElements);
|
||||
#else
|
||||
#define opj_calloc(num, size) calloc(num, size)
|
||||
#endif
|
||||
|
||||
/**
|
||||
Allocate memory aligned to a 16 byte boundry
|
||||
@param size Bytes to allocate
|
||||
@return Returns a void pointer to the allocated space, or NULL if there is insufficient memory available
|
||||
*/
|
||||
/* FIXME: These should be set with cmake tests, but we're currently not requiring use of cmake */
|
||||
#ifdef WIN32
|
||||
/* Someone should tell the mingw people that their malloc.h ought to provide _mm_malloc() */
|
||||
#ifdef __GNUC__
|
||||
#include <mm_malloc.h>
|
||||
#define HAVE_MM_MALLOC
|
||||
#else /* MSVC, Intel C++ */
|
||||
#include <malloc.h>
|
||||
#ifdef _mm_malloc
|
||||
#define HAVE_MM_MALLOC
|
||||
#endif
|
||||
#endif
|
||||
#else /* Not WIN32 */
|
||||
#if defined(__sun)
|
||||
#define HAVE_MEMALIGN
|
||||
/* Linux x86_64 and OSX always align allocations to 16 bytes */
|
||||
#elif !defined(__amd64__) && !defined(__APPLE__)
|
||||
#define HAVE_MEMALIGN
|
||||
#include <malloc.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define opj_aligned_malloc(size) malloc(size)
|
||||
#define opj_aligned_free(m) free(m)
|
||||
|
||||
#ifdef HAVE_MM_MALLOC
|
||||
#undef opj_aligned_malloc
|
||||
#define opj_aligned_malloc(size) _mm_malloc(size, 16)
|
||||
#undef opj_aligned_free
|
||||
#define opj_aligned_free(m) _mm_free(m)
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_MEMALIGN
|
||||
extern void* memalign(size_t, size_t);
|
||||
#undef opj_aligned_malloc
|
||||
#define opj_aligned_malloc(size) memalign(16, (size))
|
||||
#undef opj_aligned_free
|
||||
#define opj_aligned_free(m) free(m)
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_POSIX_MEMALIGN
|
||||
#undef opj_aligned_malloc
|
||||
extern int posix_memalign(void**, size_t, size_t);
|
||||
|
||||
static INLINE void* __attribute__ ((malloc)) opj_aligned_malloc(size_t size){
|
||||
void* mem = NULL;
|
||||
posix_memalign(&mem, 16, size);
|
||||
return mem;
|
||||
}
|
||||
#undef opj_aligned_free
|
||||
#define opj_aligned_free(m) free(m)
|
||||
#endif
|
||||
|
||||
#ifdef ALLOC_PERF_OPT
|
||||
#undef opj_aligned_malloc
|
||||
#define opj_aligned_malloc(size) opj_malloc(size)
|
||||
#undef opj_aligned_free
|
||||
#define opj_aligned_free(m) opj_free(m)
|
||||
#endif
|
||||
|
||||
/**
|
||||
Reallocate memory blocks.
|
||||
@param memblock Pointer to previously allocated memory block
|
||||
@param size New size in bytes
|
||||
@return Returns a void pointer to the reallocated (and possibly moved) memory block
|
||||
*/
|
||||
#ifdef ALLOC_PERF_OPT
|
||||
void * OPJ_CALLCONV opj_realloc(void * _Memory, size_t NewSize);
|
||||
#else
|
||||
#define opj_realloc(m, s) realloc(m, s)
|
||||
#endif
|
||||
|
||||
/**
|
||||
Deallocates or frees a memory block.
|
||||
@param memblock Previously allocated memory block to be freed
|
||||
*/
|
||||
#ifdef ALLOC_PERF_OPT
|
||||
void OPJ_CALLCONV opj_free(void * _Memory);
|
||||
#else
|
||||
#define opj_free(m) free(m)
|
||||
#endif
|
||||
|
||||
#ifdef __GNUC__
|
||||
#pragma GCC poison malloc calloc realloc free
|
||||
#endif
|
||||
|
||||
/* ----------------------------------------------------------------------- */
|
||||
/*@}*/
|
||||
|
||||
/*@}*/
|
||||
|
||||
#endif /* __OPJ_MALLOC_H */
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ list(APPEND linux_crash_logger_SOURCE_FILES
|
||||
${linux_crash_logger_HEADER_FILES}
|
||||
)
|
||||
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lrt -lapr-1 -Wl,--as-needed")
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--as-needed")
|
||||
|
||||
add_executable(linux-crash-logger ${linux_crash_logger_SOURCE_FILES})
|
||||
|
||||
@@ -47,11 +47,18 @@ target_link_libraries(linux-crash-logger
|
||||
${LLVFS_LIBRARIES}
|
||||
${LLXML_LIBRARIES}
|
||||
${LLMESSAGE_LIBRARIES}
|
||||
${LLUI_LIBRARIES}
|
||||
${LLVFS_LIBRARIES}
|
||||
${LLMATH_LIBRARIES}
|
||||
${LLCOMMON_LIBRARIES}
|
||||
${UI_LIBRARIES}
|
||||
${DB_LIBRARIES}
|
||||
${XMLRPCEPI_LIBRARIES}
|
||||
${CURL_LIBRARIES}
|
||||
${APR_LIBRARIES}
|
||||
${APRUTIL_LIBRARIES}
|
||||
${CRYPTO_LIBRARIES}
|
||||
rt
|
||||
)
|
||||
|
||||
add_custom_command(
|
||||
|
||||
@@ -5,16 +5,28 @@ project(llaudio)
|
||||
include(00-Common)
|
||||
include(Audio)
|
||||
include(LLAudio)
|
||||
include(FMOD)
|
||||
if (FMODEX)
|
||||
include(FMODEX)
|
||||
set(FMOD OFF)
|
||||
endif (FMODEX)
|
||||
if (NOT FMODEX)
|
||||
include(FMOD)
|
||||
endif (NOT FMODEX)
|
||||
include(OPENAL)
|
||||
include(LLCommon)
|
||||
include(LLMath)
|
||||
include(LLMessage)
|
||||
include(LLVFS)
|
||||
|
||||
if (FMODEX)
|
||||
include_directories(${FMODEX_INCLUDE_DIR})
|
||||
endif(FMODEX)
|
||||
if(FMOD)
|
||||
include_directories(${FMOD_INCLUDE_DIR})
|
||||
endif (FMOD)
|
||||
|
||||
include_directories(
|
||||
${LLAUDIO_INCLUDE_DIRS}
|
||||
${FMOD_INCLUDE_DIR}
|
||||
${LLCOMMON_INCLUDE_DIRS}
|
||||
${LLMATH_INCLUDE_DIRS}
|
||||
${LLMESSAGE_INCLUDE_DIRS}
|
||||
@@ -46,6 +58,19 @@ set(llaudio_HEADER_FILES
|
||||
llwindgen.h
|
||||
)
|
||||
|
||||
if (FMODEX)
|
||||
list(APPEND llaudio_SOURCE_FILES
|
||||
llaudioengine_fmodex.cpp
|
||||
lllistener_fmodex.cpp
|
||||
llstreamingaudio_fmodex.cpp
|
||||
)
|
||||
|
||||
list(APPEND llaudio_HEADER_FILES
|
||||
llaudioengine_fmodex.h
|
||||
lllistener_fmodex.h
|
||||
llstreamingaudio_fmodex.h
|
||||
)
|
||||
endif (FMODEX)
|
||||
if (FMOD)
|
||||
list(APPEND llaudio_SOURCE_FILES
|
||||
llaudioengine_fmod.cpp
|
||||
|
||||
@@ -168,19 +168,13 @@ long vfs_tell (void *datasource)
|
||||
return file->tell();
|
||||
}
|
||||
|
||||
LLVorbisDecodeState::LLVorbisDecodeState(const LLUUID &uuid, const std::string &out_filename)
|
||||
{
|
||||
mDone = FALSE;
|
||||
mValid = FALSE;
|
||||
mBytesRead = -1;
|
||||
mUUID = uuid;
|
||||
mInFilep = NULL;
|
||||
mCurrentSection = 0;
|
||||
LLVorbisDecodeState::LLVorbisDecodeState(const LLUUID &uuid, const std::string &out_filename) :
|
||||
mValid(FALSE), mDone(FALSE), mBytesRead(-1), mUUID(uuid),
|
||||
#if !defined(USE_WAV_VFILE)
|
||||
mOutFilename = out_filename;
|
||||
mFileHandle = LLLFSThread::nullHandle();
|
||||
mOutFilename(out_filename), mFileHandle(LLLFSThread::nullHandle()),
|
||||
#endif
|
||||
// No default value for mVF, it's an ogg structure?
|
||||
mInFilep(NULL), mCurrentSection(0)
|
||||
{
|
||||
}
|
||||
|
||||
LLVorbisDecodeState::~LLVorbisDecodeState()
|
||||
@@ -242,8 +236,8 @@ BOOL LLVorbisDecodeState::initDecode()
|
||||
llwarns << "No default bitstream found" << llendl;
|
||||
}
|
||||
// <edit>
|
||||
// This magic value is equivilent to 150MiB of data.
|
||||
// Prevents griffers from utilizin a huge xbox sound the size of god to instafry the viewer
|
||||
// This magic value is equivalent to 150MiB of data.
|
||||
// Prevents griefers from utilizing a huge xbox sound the size of god to instafry the viewer
|
||||
if(size_guess >= 157286400)
|
||||
{
|
||||
llwarns << "Bad sound caught by zmagic" << llendl;
|
||||
@@ -616,7 +610,8 @@ void LLAudioDecodeMgr::Impl::processQueue(const F32 num_secs)
|
||||
llwarns << mCurrentDecodep->getUUID() << " has invalid vorbis data, aborting decode" << llendl;
|
||||
mCurrentDecodep->flushBadFile();
|
||||
LLAudioData *adp = gAudiop->getAudioData(mCurrentDecodep->getUUID());
|
||||
adp->setHasValidData(FALSE);
|
||||
adp->setHasValidData(false);
|
||||
adp->setHasCompletedDecode(true);
|
||||
mCurrentDecodep = NULL;
|
||||
done = TRUE;
|
||||
}
|
||||
@@ -631,11 +626,16 @@ void LLAudioDecodeMgr::Impl::processQueue(const F32 num_secs)
|
||||
if (mCurrentDecodep->finishDecode())
|
||||
{
|
||||
// We finished!
|
||||
if (mCurrentDecodep->isValid() && mCurrentDecodep->isDone())
|
||||
LLAudioData *adp = gAudiop->getAudioData(mCurrentDecodep->getUUID());
|
||||
if (!adp)
|
||||
{
|
||||
LLAudioData *adp = gAudiop->getAudioData(mCurrentDecodep->getUUID());
|
||||
adp->setHasDecodedData(TRUE);
|
||||
adp->setHasValidData(TRUE);
|
||||
llwarns << "Missing LLAudioData for decode of " << mCurrentDecodep->getUUID() << llendl;
|
||||
}
|
||||
else if (mCurrentDecodep->isValid() && mCurrentDecodep->isDone())
|
||||
{
|
||||
adp->setHasCompletedDecode(true);
|
||||
adp->setHasDecodedData(true);
|
||||
adp->setHasValidData(true);
|
||||
|
||||
// At this point, we could see if anyone needs this sound immediately, but
|
||||
// I'm not sure that there's a reason to - we need to poll all of the playing
|
||||
@@ -644,7 +644,8 @@ void LLAudioDecodeMgr::Impl::processQueue(const F32 num_secs)
|
||||
}
|
||||
else
|
||||
{
|
||||
llinfos << "Vorbis decode failed!!!" << llendl;
|
||||
adp->setHasCompletedDecode(true);
|
||||
llinfos << "Vorbis decode failed for " << mCurrentDecodep->getUUID() << llendl;
|
||||
}
|
||||
mCurrentDecodep = NULL;
|
||||
}
|
||||
@@ -712,15 +713,18 @@ BOOL LLAudioDecodeMgr::addDecodeRequest(const LLUUID &uuid)
|
||||
if (gAudiop->hasDecodedFile(uuid))
|
||||
{
|
||||
// Already have a decoded version, don't need to decode it.
|
||||
//llinfos << "addDecodeRequest for " << uuid << " has decoded file already" << llendl;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (gAssetStorage->hasLocalAsset(uuid, LLAssetType::AT_SOUND))
|
||||
{
|
||||
// Just put it on the decode queue.
|
||||
//llinfos << "addDecodeRequest for " << uuid << " has local asset file already" << llendl;
|
||||
mImpl->mDecodeQueue.push(uuid);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
//llinfos << "addDecodeRequest for " << uuid << " no file available" << llendl;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -1275,10 +1275,11 @@ void LLAudioEngine::assetCallback(LLVFS *vfs, const LLUUID &uuid, LLAssetType::E
|
||||
// Need to mark data as bad to avoid constant rerequests.
|
||||
LLAudioData *adp = gAudiop->getAudioData(uuid);
|
||||
if (adp)
|
||||
{
|
||||
{ // Make sure everything is cleared
|
||||
adp->setHasValidData(false);
|
||||
adp->setHasLocalData(false);
|
||||
adp->setHasDecodedData(false);
|
||||
adp->setHasCompletedDecode(true);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -1291,9 +1292,10 @@ void LLAudioEngine::assetCallback(LLVFS *vfs, const LLUUID &uuid, LLAssetType::E
|
||||
}
|
||||
else
|
||||
{
|
||||
// llinfos << "Got asset callback with good audio data for " << uuid << ", making decode request" << llendl;
|
||||
adp->setHasValidData(true);
|
||||
adp->setHasLocalData(true);
|
||||
gAudioDecodeMgrp->addDecodeRequest(uuid);
|
||||
adp->setHasLocalData(true);
|
||||
gAudioDecodeMgrp->addDecodeRequest(uuid);
|
||||
}
|
||||
}
|
||||
gAudiop->mCurrentTransfer = LLUUID::null;
|
||||
@@ -1321,6 +1323,7 @@ LLAudioSource::LLAudioSource(const LLUUID& id, const LLUUID& owner_id, const F32
|
||||
mSyncSlave(false),
|
||||
mQueueSounds(false),
|
||||
mPlayedOnce(false),
|
||||
mCorrupted(false),
|
||||
mType(type),
|
||||
// <edit>
|
||||
mSourceID(source_id),
|
||||
@@ -1372,16 +1375,27 @@ void LLAudioSource::setChannel(LLAudioChannel *channelp)
|
||||
|
||||
void LLAudioSource::update()
|
||||
{
|
||||
if(mCorrupted)
|
||||
{
|
||||
return ; //no need to update
|
||||
}
|
||||
|
||||
if (!getCurrentBuffer())
|
||||
{
|
||||
if (getCurrentData())
|
||||
LLAudioData *adp = getCurrentData();
|
||||
if (adp)
|
||||
{
|
||||
// Hack - try and load the sound. Will do this as a callback
|
||||
// on decode later.
|
||||
if (getCurrentData()->load())
|
||||
if (adp->load() && adp->getBuffer())
|
||||
{
|
||||
play(getCurrentData()->getID());
|
||||
}
|
||||
play(adp->getID());
|
||||
}
|
||||
else if (adp->hasCompletedDecode()) // Only mark corrupted after decode is done
|
||||
{
|
||||
llwarns << "Marking LLAudioSource corrupted for " << adp->getID() << llendl;
|
||||
mCorrupted = true ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1502,6 +1516,11 @@ bool LLAudioSource::play(const LLUUID &audio_uuid)
|
||||
|
||||
bool LLAudioSource::isDone() const
|
||||
{
|
||||
if(mCorrupted)
|
||||
{
|
||||
return true ;
|
||||
}
|
||||
|
||||
const F32 MAX_AGE = 60.f;
|
||||
const F32 MAX_UNPLAYED_AGE = 15.f;
|
||||
const F32 MAX_MUTED_AGE = 11.f;
|
||||
@@ -1797,6 +1816,7 @@ LLAudioData::LLAudioData(const LLUUID &uuid) :
|
||||
mBufferp(NULL),
|
||||
mHasLocalData(false),
|
||||
mHasDecodedData(false),
|
||||
mHasCompletedDecode(false),
|
||||
mHasValidData(true)
|
||||
{
|
||||
if (uuid.isNull())
|
||||
@@ -1808,16 +1828,17 @@ LLAudioData::LLAudioData(const LLUUID &uuid) :
|
||||
if (gAudiop && gAudiop->hasDecodedFile(uuid))
|
||||
{
|
||||
// Already have a decoded version, don't need to decode it.
|
||||
mHasLocalData = true;
|
||||
mHasDecodedData = true;
|
||||
setHasLocalData(true);
|
||||
setHasDecodedData(true);
|
||||
setHasCompletedDecode(true);
|
||||
}
|
||||
else if (gAssetStorage && gAssetStorage->hasLocalAsset(uuid, LLAssetType::AT_SOUND))
|
||||
{
|
||||
mHasLocalData = true;
|
||||
setHasLocalData(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//return false when the audio file is corrupted.
|
||||
bool LLAudioData::load()
|
||||
{
|
||||
// For now, just assume we're going to use one buffer per audiodata.
|
||||
@@ -1833,7 +1854,7 @@ bool LLAudioData::load()
|
||||
{
|
||||
// No free buffers, abort.
|
||||
llinfos << "Not able to allocate a new audio buffer, aborting." << llendl;
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string uuid_str;
|
||||
|
||||
@@ -239,12 +239,15 @@ protected:
|
||||
// A list of all audio sources that are known to the viewer at this time.
|
||||
// This is most likely a superset of the ones that we actually have audio
|
||||
// data for, or are playing back.
|
||||
public://Jay: IDGAF
|
||||
typedef std::map<LLUUID, LLAudioSource *> source_map;
|
||||
protected:
|
||||
typedef std::map<LLUUID, LLAudioData *> data_map;
|
||||
|
||||
|
||||
public://Jay: IDGAF
|
||||
source_map mAllSources;
|
||||
protected:
|
||||
data_map mAllData;
|
||||
|
||||
LLAudioChannel *mChannels[MAX_CHANNELS];
|
||||
|
||||
// Buffers needs to change into a different data structure, as the number of buffers
|
||||
@@ -351,6 +354,9 @@ public:
|
||||
protected:
|
||||
LLUUID mID; // The ID of the source is that of the object if it's attached to an object.
|
||||
LLUUID mOwnerID; // owner of the object playing the sound
|
||||
public:
|
||||
const LLUUID &getOwnerID() { return mOwnerID; }
|
||||
protected:
|
||||
F32 mPriority;
|
||||
F32 mGain;
|
||||
bool mSourceMuted;
|
||||
@@ -360,6 +366,7 @@ protected:
|
||||
bool mSyncSlave;
|
||||
bool mQueueSounds;
|
||||
bool mPlayedOnce;
|
||||
bool mCorrupted;
|
||||
S32 mType;
|
||||
LLVector3d mPositionGlobal;
|
||||
LLVector3 mVelocity;
|
||||
@@ -401,10 +408,12 @@ public:
|
||||
|
||||
bool hasLocalData() const { return mHasLocalData; }
|
||||
bool hasDecodedData() const { return mHasDecodedData; }
|
||||
bool hasCompletedDecode() const { return mHasCompletedDecode; }
|
||||
bool hasValidData() const { return mHasValidData; }
|
||||
|
||||
void setHasLocalData(const bool hld) { mHasLocalData = hld; }
|
||||
void setHasDecodedData(const bool hdd) { mHasDecodedData = hdd; }
|
||||
void setHasCompletedDecode(const bool hcd) { mHasCompletedDecode = hcd; }
|
||||
void setHasValidData(const bool hvd) { mHasValidData = hvd; }
|
||||
|
||||
friend class LLAudioEngine; // Severe laziness, bad.
|
||||
@@ -412,9 +421,10 @@ public:
|
||||
protected:
|
||||
LLUUID mID;
|
||||
LLAudioBuffer *mBufferp; // If this data is being used by the audio system, a pointer to the buffer will be set here.
|
||||
bool mHasLocalData;
|
||||
bool mHasDecodedData;
|
||||
bool mHasValidData;
|
||||
bool mHasLocalData; // Set true if the sound asset file is available locally
|
||||
bool mHasDecodedData; // Set true if the sound file has been decoded
|
||||
bool mHasCompletedDecode; // Set true when the sound is decoded
|
||||
bool mHasValidData; // Set false if decoding failed, meaning the sound asset is bad
|
||||
};
|
||||
|
||||
|
||||
|
||||
773
indra/llaudio/llaudioengine_fmodex.cpp
Normal file
773
indra/llaudio/llaudioengine_fmodex.cpp
Normal file
@@ -0,0 +1,773 @@
|
||||
/**
|
||||
* @file audioengine_FMODEX.cpp
|
||||
* @brief Implementation of LLAudioEngine class abstracting the audio support as a FMOD 3D implementation
|
||||
*
|
||||
* $LicenseInfo:firstyear=2002&license=viewergpl$
|
||||
*
|
||||
* Copyright (c) 2002-2009, Linden Research, Inc.
|
||||
*
|
||||
* Second Life Viewer Source Code
|
||||
* The source code in this file ("Source Code") is provided by Linden Lab
|
||||
* to you under the terms of the GNU General Public License, version 2.0
|
||||
* ("GPL"), unless you have obtained a separate licensing agreement
|
||||
* ("Other License"), formally executed by you and Linden Lab. Terms of
|
||||
* the GPL can be found in doc/GPL-license.txt in this distribution, or
|
||||
* online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
|
||||
*
|
||||
* There are special exceptions to the terms and conditions of the GPL as
|
||||
* it is applied to this Source Code. View the full text of the exception
|
||||
* in the file doc/FLOSS-exception.txt in this software distribution, or
|
||||
* online at
|
||||
* http://secondlifegrid.net/programs/open_source/licensing/flossexception
|
||||
*
|
||||
* By copying, modifying or distributing this software, you acknowledge
|
||||
* that you have read and understood your obligations described above,
|
||||
* and agree to abide by those obligations.
|
||||
*
|
||||
* ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
|
||||
* WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
|
||||
* COMPLETENESS OR PERFORMANCE.
|
||||
* $/LicenseInfo$
|
||||
*/
|
||||
|
||||
#include "linden_common.h"
|
||||
|
||||
#include "llstreamingaudio.h"
|
||||
#include "llstreamingaudio_fmodex.h"
|
||||
|
||||
#include "llaudioengine_fmodex.h"
|
||||
#include "lllistener_fmodex.h"
|
||||
|
||||
#include "llerror.h"
|
||||
#include "llmath.h"
|
||||
#include "llrand.h"
|
||||
|
||||
#include "fmod.hpp"
|
||||
#include "fmod_errors.h"
|
||||
#include "lldir.h"
|
||||
#include "llapr.h"
|
||||
|
||||
#include "sound_ids.h"
|
||||
|
||||
#if LL_WINDOWS //Some ugly code to make missing fmodex.dll not cause a fatal error.
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include "windows.h"
|
||||
#include <DelayImp.h>
|
||||
#pragma comment(lib, "delayimp.lib")
|
||||
|
||||
bool attemptDelayLoad()
|
||||
{
|
||||
__try
|
||||
{
|
||||
if( FAILED( __HrLoadAllImportsForDll( "fmodex.dll" ) ) )
|
||||
return false;
|
||||
}
|
||||
__except( EXCEPTION_EXECUTE_HANDLER )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
FMOD_RESULT F_CALLBACK windCallback(FMOD_DSP_STATE *dsp_state, float *inbuffer, float *outbuffer, unsigned int length, int inchannels, int outchannels);
|
||||
|
||||
LLAudioEngine_FMODEX::LLAudioEngine_FMODEX(bool enable_profiler)
|
||||
{
|
||||
mInited = false;
|
||||
mWindGen = NULL;
|
||||
mWindDSP = NULL;
|
||||
mSystem = NULL;
|
||||
mEnableProfiler = enable_profiler;
|
||||
}
|
||||
|
||||
|
||||
LLAudioEngine_FMODEX::~LLAudioEngine_FMODEX()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
inline bool Check_FMOD_Error(FMOD_RESULT result, const char *string)
|
||||
{
|
||||
if(result == FMOD_OK)
|
||||
return false;
|
||||
llwarns << string << " Error: " << FMOD_ErrorString(result) << llendl;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool LLAudioEngine_FMODEX::init(const S32 num_channels, void* userdata)
|
||||
{
|
||||
|
||||
#if LL_WINDOWS
|
||||
if(!attemptDelayLoad())
|
||||
return false;
|
||||
#endif
|
||||
|
||||
U32 version;
|
||||
FMOD_RESULT result;
|
||||
|
||||
LL_DEBUGS("AppInit") << "LLAudioEngine_FMODEX::init() initializing FMOD" << LL_ENDL;
|
||||
|
||||
result = FMOD::System_Create(&mSystem);
|
||||
if(Check_FMOD_Error(result, "FMOD::System_Create"))
|
||||
return false;
|
||||
|
||||
//will call LLAudioEngine_FMODEX::allocateListener, which needs a valid mSystem pointer.
|
||||
LLAudioEngine::init(num_channels, userdata);
|
||||
|
||||
result = mSystem->getVersion(&version);
|
||||
Check_FMOD_Error(result, "FMOD::System::getVersion");
|
||||
|
||||
if (version < FMOD_VERSION)
|
||||
{
|
||||
LL_WARNS("AppInit") << "Error : You are using the wrong FMOD Ex version (" << version
|
||||
<< ")! You should be using FMOD Ex" << FMOD_VERSION << LL_ENDL;
|
||||
}
|
||||
|
||||
#if LL_WINDOWS
|
||||
int numdrivers;
|
||||
FMOD_SPEAKERMODE speakermode;
|
||||
FMOD_CAPS caps;
|
||||
char name[256];
|
||||
|
||||
//Is this block applicable to linux?
|
||||
{
|
||||
result = mSystem->getNumDrivers(&numdrivers);
|
||||
Check_FMOD_Error(result, "FMOD::System::getNumDrivers");
|
||||
if (numdrivers == 0)
|
||||
{
|
||||
result = mSystem->setOutput(FMOD_OUTPUTTYPE_NOSOUND);
|
||||
Check_FMOD_Error(result, "FMOD::System::setOutput");
|
||||
}
|
||||
else
|
||||
{
|
||||
result = mSystem->getDriverCaps(0, &caps, 0, &speakermode);
|
||||
Check_FMOD_Error(result,"FMOD::System::getDriverCaps");
|
||||
/*
|
||||
Set the user selected speaker mode.
|
||||
*/
|
||||
result = mSystem->setSpeakerMode(speakermode);
|
||||
Check_FMOD_Error(result, "FMOD::System::setSpeakerMode");
|
||||
if (caps & FMOD_CAPS_HARDWARE_EMULATED)
|
||||
{
|
||||
/*
|
||||
The user has the 'Acceleration' slider set to off! This is really bad
|
||||
for latency! You might want to warn the user about this.
|
||||
*/
|
||||
result = mSystem->setDSPBufferSize(1024, 10);
|
||||
Check_FMOD_Error(result, "FMOD::System::setDSPBufferSize");
|
||||
}
|
||||
result = mSystem->getDriverInfo(0, name, 256, 0);
|
||||
Check_FMOD_Error(result, "FMOD::System::getDriverInfo");
|
||||
|
||||
if (strstr(name, "SigmaTel"))
|
||||
{
|
||||
/*
|
||||
Sigmatel sound devices crackle for some reason if the format is PCM 16bit.
|
||||
PCM floating point output seems to solve it.
|
||||
*/
|
||||
result = mSystem->setSoftwareFormat(48000, FMOD_SOUND_FORMAT_PCMFLOAT, 0,0, FMOD_DSP_RESAMPLER_LINEAR);
|
||||
Check_FMOD_Error(result,"FMOD::System::setSoftwareFormat");
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif //LL_WINDOWS
|
||||
|
||||
// In this case, all sounds, PLUS wind and stream will be software.
|
||||
result = mSystem->setSoftwareChannels(num_channels + 2);
|
||||
Check_FMOD_Error(result,"FMOD::System::setSoftwareChannels");
|
||||
|
||||
U32 fmod_flags = FMOD_INIT_NORMAL;
|
||||
if(mEnableProfiler)
|
||||
fmod_flags |= FMOD_INIT_ENABLE_PROFILE;
|
||||
|
||||
#if LL_LINUX
|
||||
bool audio_ok = false;
|
||||
|
||||
if (!audio_ok)
|
||||
{
|
||||
if (NULL == getenv("LL_BAD_FMOD_PULSEAUDIO")) /*Flawfinder: ignore*/
|
||||
{
|
||||
LL_DEBUGS("AppInit") << "Trying PulseAudio audio output..." << LL_ENDL;
|
||||
if(mSystem->setOutput(FMOD_OUTPUTTYPE_PULSEAUDIO) == FMOD_OK &&
|
||||
(result = mSystem->init(num_channels + 2, fmod_flags, 0)) == FMOD_OK)
|
||||
{
|
||||
LL_DEBUGS("AppInit") << "PulseAudio output initialized OKAY" << LL_ENDL;
|
||||
audio_ok = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
Check_FMOD_Error(result, "PulseAudio audio output FAILED to initialize");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LL_DEBUGS("AppInit") << "PulseAudio audio output SKIPPED" << LL_ENDL;
|
||||
}
|
||||
}
|
||||
if (!audio_ok)
|
||||
{
|
||||
if (NULL == getenv("LL_BAD_FMOD_ALSA")) /*Flawfinder: ignore*/
|
||||
{
|
||||
LL_DEBUGS("AppInit") << "Trying ALSA audio output..." << LL_ENDL;
|
||||
if(mSystem->setOutput(FMOD_OUTPUTTYPE_ALSA) == FMOD_OK &&
|
||||
(result = mSystem->init(num_channels + 2, fmod_flags, 0)) == FMOD_OK)
|
||||
{
|
||||
LL_DEBUGS("AppInit") << "ALSA audio output initialized OKAY" << LL_ENDL;
|
||||
audio_ok = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
Check_FMOD_Error(result, "ALSA audio output FAILED to initialize");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LL_DEBUGS("AppInit") << "ALSA audio output SKIPPED" << LL_ENDL;
|
||||
}
|
||||
}
|
||||
if (!audio_ok)
|
||||
{
|
||||
if (NULL == getenv("LL_BAD_FMOD_OSS")) /*Flawfinder: ignore*/
|
||||
{
|
||||
LL_DEBUGS("AppInit") << "Trying OSS audio output..." << LL_ENDL;
|
||||
if(mSystem->setOutput(FMOD_OUTPUTTYPE_OSS) == FMOD_OK &&
|
||||
(result = mSystem->init(num_channels + 2, fmod_flags, 0)) == FMOD_OK)
|
||||
{
|
||||
LL_DEBUGS("AppInit") << "OSS audio output initialized OKAY" << LL_ENDL;
|
||||
audio_ok = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
Check_FMOD_Error(result, "OSS audio output FAILED to initialize");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LL_DEBUGS("AppInit") << "OSS audio output SKIPPED" << LL_ENDL;
|
||||
}
|
||||
}
|
||||
if (!audio_ok)
|
||||
{
|
||||
LL_WARNS("AppInit") << "Overall audio init failure." << LL_ENDL;
|
||||
return false;
|
||||
}
|
||||
|
||||
// We're interested in logging which output method we
|
||||
// ended up with, for QA purposes.
|
||||
FMOD_OUTPUTTYPE output_type;
|
||||
mSystem->getOutput(&output_type);
|
||||
switch (output_type)
|
||||
{
|
||||
case FMOD_OUTPUTTYPE_NOSOUND:
|
||||
LL_INFOS("AppInit") << "Audio output: NoSound" << LL_ENDL; break;
|
||||
case FMOD_OUTPUTTYPE_PULSEAUDIO:
|
||||
LL_INFOS("AppInit") << "Audio output: PulseAudio" << LL_ENDL; break;
|
||||
case FMOD_OUTPUTTYPE_ALSA:
|
||||
LL_INFOS("AppInit") << "Audio output: ALSA" << LL_ENDL; break;
|
||||
case FMOD_OUTPUTTYPE_OSS:
|
||||
LL_INFOS("AppInit") << "Audio output: OSS" << LL_ENDL; break;
|
||||
default:
|
||||
LL_INFOS("AppInit") << "Audio output: Unknown!" << LL_ENDL; break;
|
||||
};
|
||||
#else // LL_LINUX
|
||||
|
||||
// initialize the FMOD engine
|
||||
result = mSystem->init( num_channels + 2, fmod_flags, 0);
|
||||
if (result == FMOD_ERR_OUTPUT_CREATEBUFFER)
|
||||
{
|
||||
/*
|
||||
Ok, the speaker mode selected isn't supported by this soundcard. Switch it
|
||||
back to stereo...
|
||||
*/
|
||||
result = mSystem->setSpeakerMode(FMOD_SPEAKERMODE_STEREO);
|
||||
Check_FMOD_Error(result,"Error falling back to stereo mode");
|
||||
/*
|
||||
... and re-init.
|
||||
*/
|
||||
result = mSystem->init( num_channels + 2, fmod_flags, 0);
|
||||
}
|
||||
if(Check_FMOD_Error(result, "Error initializing FMOD Ex"))
|
||||
return false;
|
||||
#endif
|
||||
|
||||
// set up our favourite FMOD-native streaming audio implementation if none has already been added
|
||||
if (!getStreamingAudioImpl()) // no existing implementation added
|
||||
setStreamingAudioImpl(new LLStreamingAudio_FMODEX(mSystem));
|
||||
|
||||
LL_INFOS("AppInit") << "LLAudioEngine_FMODEX::init() FMOD Ex initialized correctly" << LL_ENDL;
|
||||
|
||||
mInited = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
std::string LLAudioEngine_FMODEX::getDriverName(bool verbose)
|
||||
{
|
||||
llassert_always(mSystem);
|
||||
if (verbose)
|
||||
{
|
||||
U32 version;
|
||||
if(!Check_FMOD_Error(mSystem->getVersion(&version), "FMOD::System::getVersion"))
|
||||
{
|
||||
return llformat("FMOD Ex %1x.%02x.%02x", version >> 16, version >> 8 & 0x000000FF, version & 0x000000FF);
|
||||
}
|
||||
}
|
||||
return "FMODEx";
|
||||
}
|
||||
|
||||
|
||||
void LLAudioEngine_FMODEX::allocateListener(void)
|
||||
{
|
||||
mListenerp = (LLListener *) new LLListener_FMODEX(mSystem);
|
||||
if (!mListenerp)
|
||||
{
|
||||
llwarns << "Listener creation failed" << llendl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void LLAudioEngine_FMODEX::shutdown()
|
||||
{
|
||||
stopInternetStream();
|
||||
|
||||
llinfos << "About to LLAudioEngine::shutdown()" << llendl;
|
||||
LLAudioEngine::shutdown();
|
||||
|
||||
llinfos << "LLAudioEngine_FMODEX::shutdown() closing FMOD Ex" << llendl;
|
||||
mSystem->close();
|
||||
mSystem->release();
|
||||
llinfos << "LLAudioEngine_FMODEX::shutdown() done closing FMOD Ex" << llendl;
|
||||
|
||||
delete mListenerp;
|
||||
mListenerp = NULL;
|
||||
}
|
||||
|
||||
|
||||
LLAudioBuffer * LLAudioEngine_FMODEX::createBuffer()
|
||||
{
|
||||
return new LLAudioBufferFMODEX(mSystem);
|
||||
}
|
||||
|
||||
|
||||
LLAudioChannel * LLAudioEngine_FMODEX::createChannel()
|
||||
{
|
||||
return new LLAudioChannelFMODEX(mSystem);
|
||||
}
|
||||
|
||||
bool LLAudioEngine_FMODEX::initWind()
|
||||
{
|
||||
mNextWindUpdate = 0.0;
|
||||
|
||||
if (!mWindDSP)
|
||||
{
|
||||
FMOD_DSP_DESCRIPTION dspdesc;
|
||||
memset(&dspdesc, 0, sizeof(FMOD_DSP_DESCRIPTION)); //Set everything to zero
|
||||
strncpy(dspdesc.name,"Wind Unit", sizeof(dspdesc.name)); //Set name to "Wind Unit"
|
||||
dspdesc.read = &windCallback; //Assign callback.
|
||||
if(Check_FMOD_Error(mSystem->createDSP(&dspdesc, &mWindDSP), "FMOD::createDSP"))
|
||||
return false;
|
||||
|
||||
if(mWindGen)
|
||||
delete mWindGen;
|
||||
|
||||
float frequency = 44100;
|
||||
mWindDSP->getDefaults(&frequency,0,0,0);
|
||||
mWindGen = new LLWindGen<MIXBUFFERFORMAT>((U32)frequency);
|
||||
mWindDSP->setUserData((void*)mWindGen);
|
||||
}
|
||||
|
||||
if (mWindDSP)
|
||||
{
|
||||
mSystem->playDSP(FMOD_CHANNEL_FREE, mWindDSP, false, 0);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void LLAudioEngine_FMODEX::cleanupWind()
|
||||
{
|
||||
if (mWindDSP)
|
||||
{
|
||||
mWindDSP->remove();
|
||||
mWindDSP->release();
|
||||
mWindDSP = NULL;
|
||||
}
|
||||
|
||||
delete mWindGen;
|
||||
mWindGen = NULL;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
void LLAudioEngine_FMODEX::updateWind(LLVector3 wind_vec, F32 camera_height_above_water)
|
||||
{
|
||||
LLVector3 wind_pos;
|
||||
F64 pitch;
|
||||
F64 center_freq;
|
||||
|
||||
if (!mEnableWind)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (mWindUpdateTimer.checkExpirationAndReset(LL_WIND_UPDATE_INTERVAL))
|
||||
{
|
||||
|
||||
// wind comes in as Linden coordinate (+X = forward, +Y = left, +Z = up)
|
||||
// need to convert this to the conventional orientation DS3D and OpenAL use
|
||||
// where +X = right, +Y = up, +Z = backwards
|
||||
|
||||
wind_vec.setVec(-wind_vec.mV[1], wind_vec.mV[2], -wind_vec.mV[0]);
|
||||
|
||||
// cerr << "Wind update" << endl;
|
||||
|
||||
pitch = 1.0 + mapWindVecToPitch(wind_vec);
|
||||
center_freq = 80.0 * pow(pitch,2.5*(mapWindVecToGain(wind_vec)+1.0));
|
||||
|
||||
mWindGen->mTargetFreq = (F32)center_freq;
|
||||
mWindGen->mTargetGain = (F32)mapWindVecToGain(wind_vec) * mMaxWindGain;
|
||||
mWindGen->mTargetPanGainR = (F32)mapWindVecToPan(wind_vec);
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
void LLAudioEngine_FMODEX::setInternalGain(F32 gain)
|
||||
{
|
||||
if (!mInited)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
gain = llclamp( gain, 0.0f, 1.0f );
|
||||
|
||||
FMOD::ChannelGroup *master_group;
|
||||
mSystem->getMasterChannelGroup(&master_group);
|
||||
|
||||
master_group->setVolume(gain);
|
||||
|
||||
LLStreamingAudioInterface *saimpl = getStreamingAudioImpl();
|
||||
if ( saimpl )
|
||||
{
|
||||
// fmod likes its streaming audio channel gain re-asserted after
|
||||
// master volume change.
|
||||
saimpl->setGain(saimpl->getGain());
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// LLAudioChannelFMODEX implementation
|
||||
//
|
||||
|
||||
LLAudioChannelFMODEX::LLAudioChannelFMODEX(FMOD::System *system) : LLAudioChannel(), mSystemp(system), mChannelp(NULL), mLastSamplePos(0)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
LLAudioChannelFMODEX::~LLAudioChannelFMODEX()
|
||||
{
|
||||
cleanup();
|
||||
}
|
||||
|
||||
bool LLAudioChannelFMODEX::updateBuffer()
|
||||
{
|
||||
if (LLAudioChannel::updateBuffer())
|
||||
{
|
||||
// Base class update returned true, which means that we need to actually
|
||||
// set up the channel for a different buffer.
|
||||
|
||||
LLAudioBufferFMODEX *bufferp = (LLAudioBufferFMODEX *)mCurrentSourcep->getCurrentBuffer();
|
||||
|
||||
// Grab the FMOD sample associated with the buffer
|
||||
FMOD::Sound *soundp = bufferp->getSound();
|
||||
if (!soundp)
|
||||
{
|
||||
// This is bad, there should ALWAYS be a sound associated with a legit
|
||||
// buffer.
|
||||
llerrs << "No FMOD sound!" << llendl;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// Actually play the sound. Start it off paused so we can do all the necessary
|
||||
// setup.
|
||||
if(!mChannelp)
|
||||
{
|
||||
FMOD_RESULT result = getSystem()->playSound(FMOD_CHANNEL_FREE, soundp, true, &mChannelp);
|
||||
Check_FMOD_Error(result, "FMOD::System::playSound");
|
||||
}
|
||||
|
||||
//llinfos << "Setting up channel " << std::hex << mChannelID << std::dec << llendl;
|
||||
}
|
||||
|
||||
// If we have a source for the channel, we need to update its gain.
|
||||
if (mCurrentSourcep)
|
||||
{
|
||||
// SJB: warnings can spam and hurt framerate, disabling
|
||||
FMOD_RESULT result;
|
||||
|
||||
result = mChannelp->setVolume(getSecondaryGain() * mCurrentSourcep->getGain());
|
||||
//Check_FMOD_Error(result, "FMOD::Channel::setVolume");
|
||||
|
||||
result = mChannelp->setMode(mCurrentSourcep->isLoop() ? FMOD_LOOP_NORMAL : FMOD_LOOP_OFF);
|
||||
/*if(Check_FMOD_Error(result, "FMOD::Channel::setMode"))
|
||||
{
|
||||
S32 index;
|
||||
mChannelp->getIndex(&index);
|
||||
llwarns << "Channel " << index << "Source ID: " << mCurrentSourcep->getID()
|
||||
<< " at " << mCurrentSourcep->getPositionGlobal() << llendl;
|
||||
}*/
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void LLAudioChannelFMODEX::update3DPosition()
|
||||
{
|
||||
if (!mChannelp)
|
||||
{
|
||||
// We're not actually a live channel (i.e., we're not playing back anything)
|
||||
return;
|
||||
}
|
||||
|
||||
LLAudioBufferFMODEX *bufferp = (LLAudioBufferFMODEX *)mCurrentBufferp;
|
||||
if (!bufferp)
|
||||
{
|
||||
// We don't have a buffer associated with us (should really have been picked up
|
||||
// by the above if.
|
||||
return;
|
||||
}
|
||||
|
||||
if (mCurrentSourcep->isAmbient())
|
||||
{
|
||||
// Ambient sound, don't need to do any positional updates.
|
||||
set3DMode(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Localized sound. Update the position and velocity of the sound.
|
||||
set3DMode(true);
|
||||
|
||||
LLVector3 float_pos;
|
||||
float_pos.setVec(mCurrentSourcep->getPositionGlobal());
|
||||
FMOD_RESULT result = mChannelp->set3DAttributes((FMOD_VECTOR*)float_pos.mV, (FMOD_VECTOR*)mCurrentSourcep->getVelocity().mV);
|
||||
Check_FMOD_Error(result, "FMOD::Channel::set3DAttributes");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void LLAudioChannelFMODEX::updateLoop()
|
||||
{
|
||||
if (!mChannelp)
|
||||
{
|
||||
// May want to clear up the loop/sample counters.
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
// Hack: We keep track of whether we looped or not by seeing when the
|
||||
// sample position looks like it's going backwards. Not reliable; may
|
||||
// yield false negatives.
|
||||
//
|
||||
U32 cur_pos;
|
||||
mChannelp->getPosition(&cur_pos,FMOD_TIMEUNIT_PCMBYTES);
|
||||
|
||||
if (cur_pos < (U32)mLastSamplePos)
|
||||
{
|
||||
mLoopedThisFrame = true;
|
||||
}
|
||||
mLastSamplePos = cur_pos;
|
||||
}
|
||||
|
||||
|
||||
void LLAudioChannelFMODEX::cleanup()
|
||||
{
|
||||
if (!mChannelp)
|
||||
{
|
||||
//llinfos << "Aborting cleanup with no channel handle." << llendl;
|
||||
return;
|
||||
}
|
||||
|
||||
//llinfos << "Cleaning up channel: " << mChannelID << llendl;
|
||||
Check_FMOD_Error(mChannelp->stop(),"FMOD::Channel::stop");
|
||||
|
||||
mCurrentBufferp = NULL;
|
||||
mChannelp = NULL;
|
||||
}
|
||||
|
||||
|
||||
void LLAudioChannelFMODEX::play()
|
||||
{
|
||||
if (!mChannelp)
|
||||
{
|
||||
llwarns << "Playing without a channel handle, aborting" << llendl;
|
||||
return;
|
||||
}
|
||||
|
||||
Check_FMOD_Error(mChannelp->setPaused(false), "FMOD::Channel::pause");
|
||||
|
||||
getSource()->setPlayedOnce(true);
|
||||
}
|
||||
|
||||
|
||||
void LLAudioChannelFMODEX::playSynced(LLAudioChannel *channelp)
|
||||
{
|
||||
LLAudioChannelFMODEX *fmod_channelp = (LLAudioChannelFMODEX*)channelp;
|
||||
if (!(fmod_channelp->mChannelp && mChannelp))
|
||||
{
|
||||
// Don't have channels allocated to both the master and the slave
|
||||
return;
|
||||
}
|
||||
|
||||
U32 cur_pos;
|
||||
if(Check_FMOD_Error(mChannelp->getPosition(&cur_pos,FMOD_TIMEUNIT_PCMBYTES), "Unable to retrieve current position"))
|
||||
return;
|
||||
|
||||
cur_pos %= mCurrentBufferp->getLength();
|
||||
|
||||
// Try to match the position of our sync master
|
||||
Check_FMOD_Error(mChannelp->setPosition(cur_pos,FMOD_TIMEUNIT_PCMBYTES),"Unable to set current position");
|
||||
|
||||
// Start us playing
|
||||
play();
|
||||
}
|
||||
|
||||
|
||||
bool LLAudioChannelFMODEX::isPlaying()
|
||||
{
|
||||
if (!mChannelp)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool paused, playing;
|
||||
mChannelp->getPaused(&paused);
|
||||
mChannelp->isPlaying(&playing);
|
||||
return !paused && playing;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// LLAudioChannelFMODEX implementation
|
||||
//
|
||||
|
||||
|
||||
LLAudioBufferFMODEX::LLAudioBufferFMODEX(FMOD::System *system) : mSystemp(system), mSoundp(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
LLAudioBufferFMODEX::~LLAudioBufferFMODEX()
|
||||
{
|
||||
if(mSoundp)
|
||||
{
|
||||
mSoundp->release();
|
||||
mSoundp = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool LLAudioBufferFMODEX::loadWAV(const std::string& filename)
|
||||
{
|
||||
// Try to open a wav file from disk. This will eventually go away, as we don't
|
||||
// really want to block doing this.
|
||||
if (filename.empty())
|
||||
{
|
||||
// invalid filename, abort.
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!LLAPRFile::isExist(filename, LL_APR_RPB))
|
||||
{
|
||||
// File not found, abort.
|
||||
return false;
|
||||
}
|
||||
|
||||
if (mSoundp)
|
||||
{
|
||||
// If there's already something loaded in this buffer, clean it up.
|
||||
mSoundp->release();
|
||||
mSoundp = NULL;
|
||||
}
|
||||
|
||||
FMOD_MODE base_mode = FMOD_LOOP_NORMAL | FMOD_SOFTWARE;
|
||||
FMOD_CREATESOUNDEXINFO exinfo;
|
||||
memset(&exinfo,0,sizeof(exinfo));
|
||||
exinfo.cbsize = sizeof(exinfo);
|
||||
exinfo.suggestedsoundtype = FMOD_SOUND_TYPE_WAV; //Hint to speed up loading.
|
||||
// Load up the wav file into an fmod sample
|
||||
#if LL_WINDOWS
|
||||
FMOD_RESULT result = getSystem()->createSound((const char*)utf8str_to_utf16str(filename).c_str(), base_mode | FMOD_UNICODE, &exinfo, &mSoundp);
|
||||
#else
|
||||
FMOD_RESULT result = getSystem()->createSound(filename.c_str(), base_mode, &exinfo, &mSoundp);
|
||||
#endif
|
||||
|
||||
if (result != FMOD_OK)
|
||||
{
|
||||
// We failed to load the file for some reason.
|
||||
llwarns << "Could not load data '" << filename << "': " << FMOD_ErrorString(result) << llendl;
|
||||
|
||||
//
|
||||
// If we EVER want to load wav files provided by end users, we need
|
||||
// to rethink this!
|
||||
//
|
||||
// file is probably corrupt - remove it.
|
||||
LLFile::remove(filename);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Everything went well, return true
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
U32 LLAudioBufferFMODEX::getLength()
|
||||
{
|
||||
if (!mSoundp)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
U32 length;
|
||||
mSoundp->getLength(&length, FMOD_TIMEUNIT_PCMBYTES);
|
||||
return length;
|
||||
}
|
||||
|
||||
|
||||
void LLAudioChannelFMODEX::set3DMode(bool use3d)
|
||||
{
|
||||
FMOD_MODE current_mode;
|
||||
if(mChannelp->getMode(¤t_mode) != FMOD_OK)
|
||||
return;
|
||||
FMOD_MODE new_mode = current_mode;
|
||||
new_mode &= ~(use3d ? FMOD_2D : FMOD_3D);
|
||||
new_mode |= use3d ? FMOD_3D : FMOD_2D;
|
||||
|
||||
if(current_mode != new_mode)
|
||||
{
|
||||
mChannelp->setMode(new_mode);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
FMOD_RESULT F_CALLBACK windCallback(FMOD_DSP_STATE *dsp_state, float *originalbuffer, float *newbuffer, unsigned int length, int inchannels, int outchannels)
|
||||
{
|
||||
// originalbuffer = fmod's original mixbuffer.
|
||||
// newbuffer = the buffer passed from the previous DSP unit.
|
||||
// length = length in samples at this mix time.
|
||||
// userdata = user parameter passed through in FSOUND_DSP_Create.
|
||||
|
||||
LLWindGen<LLAudioEngine_FMODEX::MIXBUFFERFORMAT> *windgen;
|
||||
FMOD::DSP *thisdsp = (FMOD::DSP *)dsp_state->instance;
|
||||
|
||||
thisdsp->getUserData((void **)&windgen);
|
||||
S32 channels, configwidth, configheight;
|
||||
thisdsp->getInfo(0, 0, &channels, &configwidth, &configheight);
|
||||
|
||||
windgen->windGenerate((LLAudioEngine_FMODEX::MIXBUFFERFORMAT *)newbuffer, length);
|
||||
|
||||
return FMOD_OK;
|
||||
}
|
||||
131
indra/llaudio/llaudioengine_fmodex.h
Normal file
131
indra/llaudio/llaudioengine_fmodex.h
Normal file
@@ -0,0 +1,131 @@
|
||||
/**
|
||||
* @file audioengine_FMODEX.h
|
||||
* @brief Definition of LLAudioEngine class abstracting the audio
|
||||
* support as a FMOD 3D implementation
|
||||
*
|
||||
* $LicenseInfo:firstyear=2002&license=viewergpl$
|
||||
*
|
||||
* Copyright (c) 2002-2009, Linden Research, Inc.
|
||||
*
|
||||
* Second Life Viewer Source Code
|
||||
* The source code in this file ("Source Code") is provided by Linden Lab
|
||||
* to you under the terms of the GNU General Public License, version 2.0
|
||||
* ("GPL"), unless you have obtained a separate licensing agreement
|
||||
* ("Other License"), formally executed by you and Linden Lab. Terms of
|
||||
* the GPL can be found in doc/GPL-license.txt in this distribution, or
|
||||
* online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
|
||||
*
|
||||
* There are special exceptions to the terms and conditions of the GPL as
|
||||
* it is applied to this Source Code. View the full text of the exception
|
||||
* in the file doc/FLOSS-exception.txt in this software distribution, or
|
||||
* online at
|
||||
* http://secondlifegrid.net/programs/open_source/licensing/flossexception
|
||||
*
|
||||
* By copying, modifying or distributing this software, you acknowledge
|
||||
* that you have read and understood your obligations described above,
|
||||
* and agree to abide by those obligations.
|
||||
*
|
||||
* ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
|
||||
* WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
|
||||
* COMPLETENESS OR PERFORMANCE.
|
||||
* $/LicenseInfo$
|
||||
*/
|
||||
|
||||
#ifndef LL_AUDIOENGINE_FMODEX_H
|
||||
#define LL_AUDIOENGINE_FMODEX_H
|
||||
|
||||
#include "llaudioengine.h"
|
||||
#include "lllistener_fmod.h"
|
||||
#include "llwindgen.h"
|
||||
|
||||
//Stubs
|
||||
class LLAudioStreamManagerFMODEX;
|
||||
namespace FMOD
|
||||
{
|
||||
class System;
|
||||
class Channel;
|
||||
class Sound;
|
||||
class DSP;
|
||||
}
|
||||
|
||||
//Interfaces
|
||||
class LLAudioEngine_FMODEX : public LLAudioEngine
|
||||
{
|
||||
public:
|
||||
LLAudioEngine_FMODEX(bool enable_profiler);
|
||||
virtual ~LLAudioEngine_FMODEX();
|
||||
|
||||
// initialization/startup/shutdown
|
||||
virtual bool init(const S32 num_channels, void *user_data);
|
||||
virtual std::string getDriverName(bool verbose);
|
||||
virtual void allocateListener();
|
||||
|
||||
virtual void shutdown();
|
||||
|
||||
/*virtual*/ bool initWind();
|
||||
/*virtual*/ void cleanupWind();
|
||||
|
||||
/*virtual*/void updateWind(LLVector3 direction, F32 camera_height_above_water);
|
||||
|
||||
typedef F32 MIXBUFFERFORMAT;
|
||||
|
||||
FMOD::System *getSystem() const {return mSystem;}
|
||||
protected:
|
||||
/*virtual*/ LLAudioBuffer *createBuffer(); // Get a free buffer, or flush an existing one if you have to.
|
||||
/*virtual*/ LLAudioChannel *createChannel(); // Create a new audio channel.
|
||||
|
||||
/*virtual*/ void setInternalGain(F32 gain);
|
||||
|
||||
bool mInited;
|
||||
|
||||
LLWindGen<MIXBUFFERFORMAT> *mWindGen;
|
||||
|
||||
FMOD::DSP *mWindDSP;
|
||||
FMOD::System *mSystem;
|
||||
bool mEnableProfiler;
|
||||
};
|
||||
|
||||
|
||||
class LLAudioChannelFMODEX : public LLAudioChannel
|
||||
{
|
||||
public:
|
||||
LLAudioChannelFMODEX(FMOD::System *audioengine);
|
||||
virtual ~LLAudioChannelFMODEX();
|
||||
|
||||
protected:
|
||||
/*virtual*/ void play();
|
||||
/*virtual*/ void playSynced(LLAudioChannel *channelp);
|
||||
/*virtual*/ void cleanup();
|
||||
/*virtual*/ bool isPlaying();
|
||||
|
||||
/*virtual*/ bool updateBuffer();
|
||||
/*virtual*/ void update3DPosition();
|
||||
/*virtual*/ void updateLoop();
|
||||
|
||||
void set3DMode(bool use3d);
|
||||
protected:
|
||||
FMOD::System *getSystem() const {return mSystemp;}
|
||||
FMOD::System *mSystemp;
|
||||
FMOD::Channel *mChannelp;
|
||||
S32 mLastSamplePos;
|
||||
};
|
||||
|
||||
|
||||
class LLAudioBufferFMODEX : public LLAudioBuffer
|
||||
{
|
||||
public:
|
||||
LLAudioBufferFMODEX(FMOD::System *audioengine);
|
||||
virtual ~LLAudioBufferFMODEX();
|
||||
|
||||
/*virtual*/ bool loadWAV(const std::string& filename);
|
||||
/*virtual*/ U32 getLength();
|
||||
friend class LLAudioChannelFMODEX;
|
||||
protected:
|
||||
FMOD::System *getSystem() const {return mSystemp;}
|
||||
FMOD::System *mSystemp;
|
||||
FMOD::Sound *getSound() const{ return mSoundp; }
|
||||
FMOD::Sound *mSoundp;
|
||||
};
|
||||
|
||||
|
||||
#endif // LL_AUDIOENGINE_FMODEX_H
|
||||
132
indra/llaudio/lllistener_fmodex.cpp
Normal file
132
indra/llaudio/lllistener_fmodex.cpp
Normal file
@@ -0,0 +1,132 @@
|
||||
/**
|
||||
* @file listener_fmod.cpp
|
||||
* @brief implementation of LISTENER class abstracting the audio
|
||||
* support as a FMOD 3D implementation (windows only)
|
||||
*
|
||||
* $LicenseInfo:firstyear=2002&license=viewergpl$
|
||||
*
|
||||
* Copyright (c) 2002-2009, Linden Research, Inc.
|
||||
*
|
||||
* Second Life Viewer Source Code
|
||||
* The source code in this file ("Source Code") is provided by Linden Lab
|
||||
* to you under the terms of the GNU General Public License, version 2.0
|
||||
* ("GPL"), unless you have obtained a separate licensing agreement
|
||||
* ("Other License"), formally executed by you and Linden Lab. Terms of
|
||||
* the GPL can be found in doc/GPL-license.txt in this distribution, or
|
||||
* online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
|
||||
*
|
||||
* There are special exceptions to the terms and conditions of the GPL as
|
||||
* it is applied to this Source Code. View the full text of the exception
|
||||
* in the file doc/FLOSS-exception.txt in this software distribution, or
|
||||
* online at
|
||||
* http://secondlifegrid.net/programs/open_source/licensing/flossexception
|
||||
*
|
||||
* By copying, modifying or distributing this software, you acknowledge
|
||||
* that you have read and understood your obligations described above,
|
||||
* and agree to abide by those obligations.
|
||||
*
|
||||
* ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
|
||||
* WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
|
||||
* COMPLETENESS OR PERFORMANCE.
|
||||
* $/LicenseInfo$
|
||||
*/
|
||||
|
||||
#include "linden_common.h"
|
||||
#include "llaudioengine.h"
|
||||
#include "lllistener_fmodex.h"
|
||||
#include "fmod.hpp"
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
// constructor
|
||||
//-----------------------------------------------------------------------
|
||||
LLListener_FMODEX::LLListener_FMODEX(FMOD::System *system)
|
||||
{
|
||||
mSystem = system;
|
||||
init();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
LLListener_FMODEX::~LLListener_FMODEX()
|
||||
{
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
void LLListener_FMODEX::init(void)
|
||||
{
|
||||
// do inherited
|
||||
LLListener::init();
|
||||
mDopplerFactor = 1.0f;
|
||||
mRolloffFactor = 1.0f;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
void LLListener_FMODEX::translate(LLVector3 offset)
|
||||
{
|
||||
LLListener::translate(offset);
|
||||
|
||||
mSystem->set3DListenerAttributes(0, (FMOD_VECTOR*)mPosition.mV, NULL, (FMOD_VECTOR*)mListenAt.mV, (FMOD_VECTOR*)mListenUp.mV);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
void LLListener_FMODEX::setPosition(LLVector3 pos)
|
||||
{
|
||||
LLListener::setPosition(pos);
|
||||
|
||||
mSystem->set3DListenerAttributes(0, (FMOD_VECTOR*)mPosition.mV, NULL, (FMOD_VECTOR*)mListenAt.mV, (FMOD_VECTOR*)mListenUp.mV);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
void LLListener_FMODEX::setVelocity(LLVector3 vel)
|
||||
{
|
||||
LLListener::setVelocity(vel);
|
||||
|
||||
mSystem->set3DListenerAttributes(0, NULL, (FMOD_VECTOR*)mVelocity.mV, (FMOD_VECTOR*)mListenAt.mV, (FMOD_VECTOR*)mListenUp.mV);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
void LLListener_FMODEX::orient(LLVector3 up, LLVector3 at)
|
||||
{
|
||||
LLListener::orient(up, at);
|
||||
|
||||
// Welcome to the transition between right and left
|
||||
// (coordinate systems, that is)
|
||||
// Leaving the at vector alone results in a L/R reversal
|
||||
// since DX is left-handed and we (LL, OpenGL, OpenAL) are right-handed
|
||||
at = -at;
|
||||
|
||||
mSystem->set3DListenerAttributes(0, NULL, NULL, (FMOD_VECTOR*)at.mV, (FMOD_VECTOR*)up.mV);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
void LLListener_FMODEX::commitDeferredChanges()
|
||||
{
|
||||
mSystem->update();
|
||||
}
|
||||
|
||||
|
||||
void LLListener_FMODEX::setRolloffFactor(F32 factor)
|
||||
{
|
||||
mRolloffFactor = factor;
|
||||
mSystem->set3DSettings(mDopplerFactor, 1.f, mRolloffFactor);
|
||||
}
|
||||
|
||||
|
||||
F32 LLListener_FMODEX::getRolloffFactor()
|
||||
{
|
||||
return mRolloffFactor;
|
||||
}
|
||||
|
||||
|
||||
void LLListener_FMODEX::setDopplerFactor(F32 factor)
|
||||
{
|
||||
mDopplerFactor = factor;
|
||||
mSystem->set3DSettings(mDopplerFactor, 1.f, mRolloffFactor);
|
||||
}
|
||||
|
||||
|
||||
F32 LLListener_FMODEX::getDopplerFactor()
|
||||
{
|
||||
return mDopplerFactor;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
/**
|
||||
* @file llversionserver.h
|
||||
* @brief
|
||||
* @file listener_fmod.h
|
||||
* @brief Description of LISTENER class abstracting the audio support
|
||||
* as an FMOD 3D implementation (windows and Linux)
|
||||
*
|
||||
* $LicenseInfo:firstyear=2002&license=viewergpl$
|
||||
*
|
||||
@@ -30,15 +31,41 @@
|
||||
* $/LicenseInfo$
|
||||
*/
|
||||
|
||||
#ifndef LL_LLVERSIONSERVER_H
|
||||
#define LL_LLVERSIONSERVER_H
|
||||
#ifndef LL_LISTENER_FMODEX_H
|
||||
#define LL_LISTENER_FMODEX_H
|
||||
|
||||
const S32 LL_VERSION_MAJOR = 1;
|
||||
const S32 LL_VERSION_MINOR = 27;
|
||||
const S32 LL_VERSION_PATCH = 0;
|
||||
const S32 LL_VERSION_BUILD = 132845;
|
||||
#include "lllistener.h"
|
||||
|
||||
const char * const LL_CHANNEL = "Second Life Server";
|
||||
//Stubs
|
||||
namespace FMOD
|
||||
{
|
||||
class System;
|
||||
}
|
||||
|
||||
//Interfaces
|
||||
class LLListener_FMODEX : public LLListener
|
||||
{
|
||||
public:
|
||||
LLListener_FMODEX(FMOD::System *system);
|
||||
virtual ~LLListener_FMODEX();
|
||||
virtual void init();
|
||||
|
||||
virtual void translate(LLVector3 offset);
|
||||
virtual void setPosition(LLVector3 pos);
|
||||
virtual void setVelocity(LLVector3 vel);
|
||||
virtual void orient(LLVector3 up, LLVector3 at);
|
||||
virtual void commitDeferredChanges();
|
||||
|
||||
virtual void setDopplerFactor(F32 factor);
|
||||
virtual F32 getDopplerFactor();
|
||||
virtual void setRolloffFactor(F32 factor);
|
||||
virtual F32 getRolloffFactor();
|
||||
protected:
|
||||
FMOD::System *mSystem;
|
||||
F32 mDopplerFactor;
|
||||
F32 mRolloffFactor;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -36,6 +36,8 @@
|
||||
|
||||
#include "stdtypes.h" // from llcommon
|
||||
|
||||
class LLSD;
|
||||
|
||||
// Entirely abstract. Based exactly on the historic API.
|
||||
class LLStreamingAudioInterface
|
||||
{
|
||||
@@ -51,6 +53,11 @@ class LLStreamingAudioInterface
|
||||
virtual void setGain(F32 vol) = 0;
|
||||
virtual F32 getGain() = 0;
|
||||
virtual std::string getURL() = 0;
|
||||
|
||||
virtual bool supportsMetaData() = 0;
|
||||
virtual const LLSD *getMetaData() = 0;
|
||||
virtual bool supportsWaveData() = 0;
|
||||
virtual bool getWaveData(float* arr, S32 count, S32 stride = 1) = 0;
|
||||
};
|
||||
|
||||
#endif // LL_STREAMINGAUDIO_H
|
||||
|
||||
@@ -51,6 +51,8 @@ public:
|
||||
const std::string& getURL() { return mInternetStreamURL; }
|
||||
|
||||
int getOpenState();
|
||||
|
||||
FSOUND_STREAM* getStream() { return mInternetStream; }
|
||||
protected:
|
||||
FSOUND_STREAM* mInternetStream;
|
||||
bool mReady;
|
||||
@@ -66,7 +68,8 @@ protected:
|
||||
LLStreamingAudio_FMOD::LLStreamingAudio_FMOD() :
|
||||
mCurrentInternetStreamp(NULL),
|
||||
mFMODInternetStreamChannel(-1),
|
||||
mGain(1.0f)
|
||||
mGain(1.0f),
|
||||
mMetaData(NULL)
|
||||
{
|
||||
// Number of milliseconds of audio to buffer for the audio card.
|
||||
// Must be larger than the usual Second Life frame stutter time.
|
||||
@@ -87,6 +90,17 @@ LLStreamingAudio_FMOD::~LLStreamingAudio_FMOD()
|
||||
// nothing interesting/safe to do.
|
||||
}
|
||||
|
||||
signed char F_CALLBACKAPI MetaDataCallback(char *name, char *value, void *userdata)
|
||||
{
|
||||
std::string szName(name);
|
||||
if(szName == "TITLE" || szName=="TIT2" || szName=="Title")
|
||||
(*(LLSD*)userdata)["TITLE"] = value;
|
||||
if(szName == "ARTIST" || szName=="TPE1" || szName =="WM/AlbumTitle")
|
||||
(*(LLSD*)userdata)["ARTIST"] = value;
|
||||
else
|
||||
(*(LLSD*)userdata)[std::string(name)] = value;
|
||||
return true;
|
||||
}
|
||||
|
||||
void LLStreamingAudio_FMOD::start(const std::string& url)
|
||||
{
|
||||
@@ -104,6 +118,10 @@ void LLStreamingAudio_FMOD::start(const std::string& url)
|
||||
llinfos << "Starting internet stream: " << url << llendl;
|
||||
mCurrentInternetStreamp = new LLAudioStreamManagerFMOD(url);
|
||||
mURL = url;
|
||||
if(mCurrentInternetStreamp->getStream())
|
||||
{
|
||||
mMetaData = new LLSD;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -154,6 +172,10 @@ void LLStreamingAudio_FMOD::update()
|
||||
// Reset volume to previously set volume
|
||||
setGain(getGain());
|
||||
FSOUND_SetPaused(mFMODInternetStreamChannel, false);
|
||||
if(mCurrentInternetStreamp->getStream() && mMetaData)
|
||||
{
|
||||
FSOUND_Stream_Net_SetMetadataCallback(mCurrentInternetStreamp->getStream(),&MetaDataCallback, mMetaData);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -184,11 +206,17 @@ void LLStreamingAudio_FMOD::update()
|
||||
// buffering
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void LLStreamingAudio_FMOD::stop()
|
||||
{
|
||||
if(mMetaData)
|
||||
{
|
||||
if(mCurrentInternetStreamp && mCurrentInternetStreamp->getStream())
|
||||
FSOUND_Stream_Net_SetMetadataCallback(mCurrentInternetStreamp->getStream(),NULL,NULL);
|
||||
delete mMetaData;
|
||||
mMetaData = NULL;
|
||||
}
|
||||
if (mFMODInternetStreamChannel != -1)
|
||||
{
|
||||
FSOUND_SetPaused(mFMODInternetStreamChannel, true);
|
||||
|
||||
@@ -55,6 +55,10 @@ class LLStreamingAudio_FMOD : public LLStreamingAudioInterface
|
||||
/*virtual*/ F32 getGain();
|
||||
/*virtual*/ std::string getURL();
|
||||
|
||||
/*virtual*/ bool supportsMetaData(){return true;}
|
||||
/*virtual*/ const LLSD *getMetaData(){return mMetaData;} //return NULL if not playing.
|
||||
/*virtual*/ bool supportsWaveData(){return false;}
|
||||
/*virtual*/ bool getWaveData(float* arr, S32 count, S32 stride = 1){return false;}
|
||||
private:
|
||||
LLAudioStreamManagerFMOD *mCurrentInternetStreamp;
|
||||
int mFMODInternetStreamChannel;
|
||||
@@ -62,6 +66,8 @@ private:
|
||||
|
||||
std::string mURL;
|
||||
F32 mGain;
|
||||
|
||||
LLSD *mMetaData;
|
||||
};
|
||||
|
||||
|
||||
|
||||
450
indra/llaudio/llstreamingaudio_fmodex.cpp
Normal file
450
indra/llaudio/llstreamingaudio_fmodex.cpp
Normal file
@@ -0,0 +1,450 @@
|
||||
/**
|
||||
* @file streamingaudio_fmod.cpp
|
||||
* @brief LLStreamingAudio_FMODEX implementation
|
||||
*
|
||||
* $LicenseInfo:firstyear=2009&license=viewergpl$
|
||||
*
|
||||
* Copyright (c) 2009, Linden Research, Inc.
|
||||
*
|
||||
* Second Life Viewer Source Code
|
||||
* The source code in this file ("Source Code") is provided by Linden Lab
|
||||
* to you under the terms of the GNU General Public License, version 2.0
|
||||
* ("GPL"), unless you have obtained a separate licensing agreement
|
||||
* ("Other License"), formally executed by you and Linden Lab. Terms of
|
||||
* the GPL can be found in doc/GPL-license.txt in this distribution, or
|
||||
* online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
|
||||
*
|
||||
* There are special exceptions to the terms and conditions of the GPL as
|
||||
* it is applied to this Source Code. View the full text of the exception
|
||||
* in the file doc/FLOSS-exception.txt in this software distribution, or
|
||||
* online at
|
||||
* http://secondlifegrid.net/programs/open_source/licensing/flossexception
|
||||
*
|
||||
* By copying, modifying or distributing this software, you acknowledge
|
||||
* that you have read and understood your obligations described above,
|
||||
* and agree to abide by those obligations.
|
||||
*
|
||||
* ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
|
||||
* WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
|
||||
* COMPLETENESS OR PERFORMANCE.
|
||||
* $/LicenseInfo$
|
||||
*/
|
||||
|
||||
#include "linden_common.h"
|
||||
|
||||
#include "llmath.h"
|
||||
|
||||
#include "fmod.hpp"
|
||||
#include "fmod_errors.h"
|
||||
|
||||
#include "llstreamingaudio_fmodex.h"
|
||||
|
||||
|
||||
class LLAudioStreamManagerFMODEX
|
||||
{
|
||||
public:
|
||||
LLAudioStreamManagerFMODEX(FMOD::System *system, const std::string& url);
|
||||
FMOD::Channel* startStream();
|
||||
bool stopStream(); // Returns true if the stream was successfully stopped.
|
||||
bool ready();
|
||||
|
||||
const std::string& getURL() { return mInternetStreamURL; }
|
||||
|
||||
FMOD_OPENSTATE getOpenState();
|
||||
protected:
|
||||
FMOD::System* mSystem;
|
||||
FMOD::Channel* mStreamChannel;
|
||||
FMOD::Sound* mInternetStream;
|
||||
bool mReady;
|
||||
|
||||
std::string mInternetStreamURL;
|
||||
};
|
||||
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Internet Streaming
|
||||
//---------------------------------------------------------------------------
|
||||
LLStreamingAudio_FMODEX::LLStreamingAudio_FMODEX(FMOD::System *system) :
|
||||
mSystem(system),
|
||||
mCurrentInternetStreamp(NULL),
|
||||
mFMODInternetStreamChannelp(NULL),
|
||||
mGain(1.0f),
|
||||
mMetaData(NULL)
|
||||
{
|
||||
// Number of milliseconds of audio to buffer for the audio card.
|
||||
// Must be larger than the usual Second Life frame stutter time.
|
||||
const U32 buffer_seconds = 5; //sec
|
||||
const U32 estimated_bitrate = 128; //kbit/sec
|
||||
mSystem->setStreamBufferSize(estimated_bitrate * buffer_seconds * 128/*bytes/kbit*/, FMOD_TIMEUNIT_RAWBYTES);
|
||||
|
||||
// Here's where we set the size of the network buffer and some buffering
|
||||
// parameters. In this case we want a network buffer of 16k, we want it
|
||||
// to prebuffer 40% of that when we first connect, and we want it
|
||||
// to rebuffer 80% of that whenever we encounter a buffer underrun.
|
||||
|
||||
// Leave the net buffer properties at the default.
|
||||
//FSOUND_Stream_Net_SetBufferProperties(20000, 40, 80);
|
||||
}
|
||||
|
||||
|
||||
LLStreamingAudio_FMODEX::~LLStreamingAudio_FMODEX()
|
||||
{
|
||||
// nothing interesting/safe to do.
|
||||
}
|
||||
|
||||
|
||||
void LLStreamingAudio_FMODEX::start(const std::string& url)
|
||||
{
|
||||
//if (!mInited)
|
||||
//{
|
||||
// llwarns << "startInternetStream before audio initialized" << llendl;
|
||||
// return;
|
||||
//}
|
||||
|
||||
// "stop" stream but don't clear url, etc. in case url == mInternetStreamURL
|
||||
stop();
|
||||
|
||||
if (!url.empty())
|
||||
{
|
||||
llinfos << "Starting internet stream: " << url << llendl;
|
||||
mCurrentInternetStreamp = new LLAudioStreamManagerFMODEX(mSystem,url);
|
||||
mURL = url;
|
||||
mMetaData = new LLSD;
|
||||
}
|
||||
else
|
||||
{
|
||||
llinfos << "Set internet stream to null" << llendl;
|
||||
mURL.clear();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void LLStreamingAudio_FMODEX::update()
|
||||
{
|
||||
// Kill dead internet streams, if possible
|
||||
std::list<LLAudioStreamManagerFMODEX *>::iterator iter;
|
||||
for (iter = mDeadStreams.begin(); iter != mDeadStreams.end();)
|
||||
{
|
||||
LLAudioStreamManagerFMODEX *streamp = *iter;
|
||||
if (streamp->stopStream())
|
||||
{
|
||||
llinfos << "Closed dead stream" << llendl;
|
||||
delete streamp;
|
||||
mDeadStreams.erase(iter++);
|
||||
}
|
||||
else
|
||||
{
|
||||
iter++;
|
||||
}
|
||||
}
|
||||
|
||||
// Don't do anything if there are no streams playing
|
||||
if (!mCurrentInternetStreamp)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
FMOD_OPENSTATE open_state = mCurrentInternetStreamp->getOpenState();
|
||||
|
||||
if (open_state == FMOD_OPENSTATE_READY)
|
||||
{
|
||||
// Stream is live
|
||||
|
||||
// start the stream if it's ready
|
||||
if (!mFMODInternetStreamChannelp &&
|
||||
(mFMODInternetStreamChannelp = mCurrentInternetStreamp->startStream()))
|
||||
{
|
||||
// Reset volume to previously set volume
|
||||
setGain(getGain());
|
||||
mFMODInternetStreamChannelp->setPaused(false);
|
||||
}
|
||||
}
|
||||
else if(open_state == FMOD_OPENSTATE_ERROR)
|
||||
{
|
||||
stop();
|
||||
return;
|
||||
}
|
||||
|
||||
if(mFMODInternetStreamChannelp)
|
||||
{
|
||||
if(!mMetaData)
|
||||
mMetaData = new LLSD;
|
||||
|
||||
FMOD::Sound *sound = NULL;
|
||||
|
||||
if(mFMODInternetStreamChannelp->getCurrentSound(&sound) == FMOD_OK && sound)
|
||||
{
|
||||
FMOD_TAG tag;
|
||||
S32 tagcount, dirtytagcount;
|
||||
if(sound->getNumTags(&tagcount, &dirtytagcount) == FMOD_OK && dirtytagcount)
|
||||
{
|
||||
mMetaData->clear();
|
||||
|
||||
for(S32 i = 0; i < tagcount; ++i)
|
||||
{
|
||||
if(sound->getTag(NULL, i, &tag)!=FMOD_OK)
|
||||
continue;
|
||||
std::string name = tag.name;
|
||||
switch(tag.type) //Crappy tag translate table.
|
||||
{
|
||||
case(FMOD_TAGTYPE_ID3V2):
|
||||
if(name == "TIT2") name = "TITLE";
|
||||
else if(name == "TPE1") name = "ARTIST";
|
||||
break;
|
||||
case(FMOD_TAGTYPE_ASF):
|
||||
if(name == "Title") name = "TITLE";
|
||||
else if(name == "WM/AlbumArtist") name = "ARTIST";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
switch(tag.datatype)
|
||||
{
|
||||
case(FMOD_TAGDATATYPE_INT):
|
||||
(*mMetaData)[name]=*(LLSD::Integer*)(tag.data);
|
||||
llinfos << tag.name << ": " << *(int*)(tag.data) << llendl;
|
||||
break;
|
||||
case(FMOD_TAGDATATYPE_FLOAT):
|
||||
(*mMetaData)[name]=*(LLSD::Float*)(tag.data);
|
||||
llinfos << tag.name << ": " << *(float*)(tag.data) << llendl;
|
||||
break;
|
||||
case(FMOD_TAGDATATYPE_STRING):
|
||||
{
|
||||
std::string out = rawstr_to_utf8(std::string((char*)tag.data,tag.datalen));
|
||||
(*mMetaData)[name]=out;
|
||||
llinfos << tag.name << ": " << out << llendl;
|
||||
}
|
||||
break;
|
||||
case(FMOD_TAGDATATYPE_STRING_UTF16):
|
||||
{
|
||||
std::string out((char*)tag.data,tag.datalen);
|
||||
(*mMetaData)[std::string(tag.name)]=out;
|
||||
llinfos << tag.name << ": " << out << llendl;
|
||||
}
|
||||
break;
|
||||
case(FMOD_TAGDATATYPE_STRING_UTF16BE):
|
||||
{
|
||||
std::string out((char*)tag.data,tag.datalen);
|
||||
U16* buf = (U16*)out.c_str();
|
||||
for(U32 j = 0; j < out.size()/2; ++j)
|
||||
(((buf[j] & 0xff)<<8) | ((buf[j] & 0xff00)>>8));
|
||||
(*mMetaData)[std::string(tag.name)]=out;
|
||||
llinfos << tag.name << ": " << out << llendl;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void LLStreamingAudio_FMODEX::stop()
|
||||
{
|
||||
if(mMetaData)
|
||||
{
|
||||
delete mMetaData;
|
||||
mMetaData = NULL;
|
||||
}
|
||||
if (mFMODInternetStreamChannelp)
|
||||
{
|
||||
mFMODInternetStreamChannelp->setPaused(true);
|
||||
mFMODInternetStreamChannelp->setPriority(0);
|
||||
mFMODInternetStreamChannelp = NULL;
|
||||
}
|
||||
|
||||
if (mCurrentInternetStreamp)
|
||||
{
|
||||
llinfos << "Stopping internet stream: " << mCurrentInternetStreamp->getURL() << llendl;
|
||||
if (mCurrentInternetStreamp->stopStream())
|
||||
{
|
||||
delete mCurrentInternetStreamp;
|
||||
}
|
||||
else
|
||||
{
|
||||
llwarns << "Pushing stream to dead list: " << mCurrentInternetStreamp->getURL() << llendl;
|
||||
mDeadStreams.push_back(mCurrentInternetStreamp);
|
||||
}
|
||||
mCurrentInternetStreamp = NULL;
|
||||
//mURL.clear();
|
||||
}
|
||||
}
|
||||
|
||||
void LLStreamingAudio_FMODEX::pause(int pauseopt)
|
||||
{
|
||||
if (pauseopt < 0)
|
||||
{
|
||||
pauseopt = mCurrentInternetStreamp ? 1 : 0;
|
||||
}
|
||||
|
||||
if (pauseopt)
|
||||
{
|
||||
if (mCurrentInternetStreamp)
|
||||
{
|
||||
stop();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
start(getURL());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// A stream is "playing" if it has been requested to start. That
|
||||
// doesn't necessarily mean audio is coming out of the speakers.
|
||||
int LLStreamingAudio_FMODEX::isPlaying()
|
||||
{
|
||||
if (mCurrentInternetStreamp)
|
||||
{
|
||||
return 1; // Active and playing
|
||||
}
|
||||
else if (!mURL.empty())
|
||||
{
|
||||
return 2; // "Paused"
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
F32 LLStreamingAudio_FMODEX::getGain()
|
||||
{
|
||||
return mGain;
|
||||
}
|
||||
|
||||
|
||||
std::string LLStreamingAudio_FMODEX::getURL()
|
||||
{
|
||||
return mURL;
|
||||
}
|
||||
|
||||
|
||||
void LLStreamingAudio_FMODEX::setGain(F32 vol)
|
||||
{
|
||||
mGain = vol;
|
||||
|
||||
if (mFMODInternetStreamChannelp)
|
||||
{
|
||||
vol = llclamp(vol * vol, 0.f, 1.f); //should vol be squared here?
|
||||
|
||||
mFMODInternetStreamChannelp->setVolume(vol);
|
||||
}
|
||||
}
|
||||
|
||||
/*virtual*/ bool LLStreamingAudio_FMODEX::getWaveData(float* arr, S32 count, S32 stride/*=1*/)
|
||||
{
|
||||
if(!mFMODInternetStreamChannelp || !mCurrentInternetStreamp)
|
||||
return false;
|
||||
|
||||
static std::vector<float> local_array(count); //Have to have an extra buffer to mix channels. Bleh.
|
||||
if(count > (S32)local_array.size()) //Expand the array if needed. Try to minimize allocation calls, so don't ever shrink.
|
||||
local_array.resize(count);
|
||||
|
||||
if( mFMODInternetStreamChannelp->getWaveData(&local_array[0],count,0) == FMOD_OK &&
|
||||
mFMODInternetStreamChannelp->getWaveData(&arr[0],count,1) == FMOD_OK )
|
||||
{
|
||||
for(S32 i = count-1;i>=0;i-=stride)
|
||||
{
|
||||
arr[i] += local_array[i];
|
||||
arr[i] *= .5f;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////
|
||||
// manager of possibly-multiple internet audio streams
|
||||
|
||||
LLAudioStreamManagerFMODEX::LLAudioStreamManagerFMODEX(FMOD::System *system, const std::string& url) :
|
||||
mSystem(system),
|
||||
mStreamChannel(NULL),
|
||||
mInternetStream(NULL),
|
||||
mReady(false)
|
||||
{
|
||||
mInternetStreamURL = url;
|
||||
|
||||
FMOD_CREATESOUNDEXINFO exinfo;
|
||||
memset(&exinfo,0,sizeof(exinfo));
|
||||
exinfo.cbsize = sizeof(exinfo);
|
||||
exinfo.suggestedsoundtype = FMOD_SOUND_TYPE_MPEG; //Hint to speed up loading.
|
||||
|
||||
FMOD_RESULT result = mSystem->createStream(url.c_str(), FMOD_2D | FMOD_NONBLOCKING | FMOD_IGNORETAGS, &exinfo, &mInternetStream);
|
||||
|
||||
if (result!= FMOD_OK)
|
||||
{
|
||||
llwarns << "Couldn't open fmod stream, error "
|
||||
<< FMOD_ErrorString(result)
|
||||
<< llendl;
|
||||
mReady = false;
|
||||
return;
|
||||
}
|
||||
|
||||
mReady = true;
|
||||
}
|
||||
|
||||
FMOD::Channel *LLAudioStreamManagerFMODEX::startStream()
|
||||
{
|
||||
// We need a live and opened stream before we try and play it.
|
||||
if (!mInternetStream || getOpenState() != FMOD_OPENSTATE_READY)
|
||||
{
|
||||
llwarns << "No internet stream to start playing!" << llendl;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(mStreamChannel)
|
||||
return mStreamChannel; //Already have a channel for this stream.
|
||||
|
||||
mSystem->playSound(FMOD_CHANNEL_FREE, mInternetStream, true, &mStreamChannel);
|
||||
return mStreamChannel;
|
||||
}
|
||||
|
||||
bool LLAudioStreamManagerFMODEX::stopStream()
|
||||
{
|
||||
if (mInternetStream)
|
||||
{
|
||||
|
||||
|
||||
bool close = true;
|
||||
switch (getOpenState())
|
||||
{
|
||||
case FMOD_OPENSTATE_CONNECTING:
|
||||
close = false;
|
||||
break;
|
||||
/*case FSOUND_STREAM_NET_NOTCONNECTED:
|
||||
case FSOUND_STREAM_NET_BUFFERING:
|
||||
case FSOUND_STREAM_NET_READY:
|
||||
case FSOUND_STREAM_NET_ERROR:*/
|
||||
default:
|
||||
close = true;
|
||||
}
|
||||
|
||||
if (close)
|
||||
{
|
||||
mInternetStream->release();
|
||||
mStreamChannel = NULL;
|
||||
mInternetStream = NULL;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
FMOD_OPENSTATE LLAudioStreamManagerFMODEX::getOpenState()
|
||||
{
|
||||
FMOD_OPENSTATE state;
|
||||
mInternetStream->getOpenState(&state,NULL,NULL,NULL);
|
||||
return state;
|
||||
}
|
||||
83
indra/llaudio/llstreamingaudio_fmodex.h
Normal file
83
indra/llaudio/llstreamingaudio_fmodex.h
Normal file
@@ -0,0 +1,83 @@
|
||||
/**
|
||||
* @file streamingaudio_fmod.h
|
||||
* @author Tofu Linden
|
||||
* @brief Definition of LLStreamingAudio_FMOD implementation
|
||||
*
|
||||
* $LicenseInfo:firstyear=2009&license=viewergpl$
|
||||
*
|
||||
* Copyright (c) 2009, Linden Research, Inc.
|
||||
*
|
||||
* Second Life Viewer Source Code
|
||||
* The source code in this file ("Source Code") is provided by Linden Lab
|
||||
* to you under the terms of the GNU General Public License, version 2.0
|
||||
* ("GPL"), unless you have obtained a separate licensing agreement
|
||||
* ("Other License"), formally executed by you and Linden Lab. Terms of
|
||||
* the GPL can be found in doc/GPL-license.txt in this distribution, or
|
||||
* online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
|
||||
*
|
||||
* There are special exceptions to the terms and conditions of the GPL as
|
||||
* it is applied to this Source Code. View the full text of the exception
|
||||
* in the file doc/FLOSS-exception.txt in this software distribution, or
|
||||
* online at
|
||||
* http://secondlifegrid.net/programs/open_source/licensing/flossexception
|
||||
*
|
||||
* By copying, modifying or distributing this software, you acknowledge
|
||||
* that you have read and understood your obligations described above,
|
||||
* and agree to abide by those obligations.
|
||||
*
|
||||
* ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
|
||||
* WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
|
||||
* COMPLETENESS OR PERFORMANCE.
|
||||
* $/LicenseInfo$
|
||||
*/
|
||||
|
||||
#ifndef LL_STREAMINGAUDIO_FMOD_H
|
||||
#define LL_STREAMINGAUDIO_FMOD_H
|
||||
|
||||
#include "stdtypes.h" // from llcommon
|
||||
|
||||
#include "llstreamingaudio.h"
|
||||
|
||||
//Stubs
|
||||
class LLAudioStreamManagerFMODEX;
|
||||
namespace FMOD
|
||||
{
|
||||
class System;
|
||||
class Channel;
|
||||
}
|
||||
|
||||
//Interfaces
|
||||
class LLStreamingAudio_FMODEX : public LLStreamingAudioInterface
|
||||
{
|
||||
public:
|
||||
LLStreamingAudio_FMODEX(FMOD::System *system);
|
||||
/*virtual*/ ~LLStreamingAudio_FMODEX();
|
||||
|
||||
/*virtual*/ void start(const std::string& url);
|
||||
/*virtual*/ void stop();
|
||||
/*virtual*/ void pause(int pause);
|
||||
/*virtual*/ void update();
|
||||
/*virtual*/ int isPlaying();
|
||||
/*virtual*/ void setGain(F32 vol);
|
||||
/*virtual*/ F32 getGain();
|
||||
/*virtual*/ std::string getURL();
|
||||
|
||||
/*virtual*/ bool supportsMetaData(){return true;}
|
||||
/*virtual*/ const LLSD *getMetaData(){return mMetaData;} //return NULL if not playing.
|
||||
/*virtual*/ bool supportsWaveData(){return true;}
|
||||
/*virtual*/ bool getWaveData(float* arr, S32 count, S32 stride = 1);
|
||||
private:
|
||||
FMOD::System *mSystem;
|
||||
|
||||
LLAudioStreamManagerFMODEX *mCurrentInternetStreamp;
|
||||
FMOD::Channel *mFMODInternetStreamChannelp;
|
||||
std::list<LLAudioStreamManagerFMODEX *> mDeadStreams;
|
||||
|
||||
std::string mURL;
|
||||
F32 mGain;
|
||||
|
||||
LLSD *mMetaData;
|
||||
};
|
||||
|
||||
|
||||
#endif // LL_STREAMINGAUDIO_FMOD_H
|
||||
@@ -133,10 +133,10 @@ BOOL decode_vorbis_file(LLVFS *vfs, const LLUUID &in_uuid, char *out_fname)
|
||||
return(FALSE);
|
||||
}
|
||||
|
||||
//**********************************
|
||||
// **********************************
|
||||
LLAPRFile outfile ;
|
||||
outfile.open(out_fname,LL_APR_WPB);
|
||||
//**********************************
|
||||
// **********************************
|
||||
if (!outfile.getFileHandle())
|
||||
{
|
||||
llwarning("unable to open vorbis destination file for writing",0);
|
||||
@@ -308,9 +308,9 @@ BOOL decode_vorbis_file(LLVFS *vfs, const LLUUID &in_uuid, char *out_fname)
|
||||
|
||||
outfile.seek(SEEK_END,-fade_length*2);
|
||||
outfile.write(pcmout,2*fade_length); //write back xfaded last 16 samples
|
||||
//*******************
|
||||
// *******************
|
||||
outfile.close();
|
||||
//*******************
|
||||
// *******************
|
||||
|
||||
if ((36 == data_length) || (!(eof)))
|
||||
{
|
||||
|
||||
@@ -87,10 +87,10 @@ S32 check_for_invalid_wav_formats(const std::string& in_fname, std::string& erro
|
||||
|
||||
error_msg.clear();
|
||||
|
||||
//********************************
|
||||
// ********************************
|
||||
LLAPRFile infile ;
|
||||
infile.open(in_fname,LL_APR_RB);
|
||||
//********************************
|
||||
infile.open(in_fname,LL_APR_RB);
|
||||
// ********************************
|
||||
if (!infile.getFileHandle())
|
||||
{
|
||||
error_msg = "CannotUploadSoundFile";
|
||||
@@ -159,9 +159,9 @@ S32 check_for_invalid_wav_formats(const std::string& in_fname, std::string& erro
|
||||
file_pos += (chunk_length + 8);
|
||||
chunk_length = 0;
|
||||
}
|
||||
//****************
|
||||
// ****************
|
||||
infile.close();
|
||||
//****************
|
||||
// ****************
|
||||
|
||||
if (!uncompressed_pcm)
|
||||
{
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
#define WINDGEN_H
|
||||
|
||||
#include "llcommon.h"
|
||||
#include "llrand.h"
|
||||
|
||||
template <class MIXBUFFERFORMAT_T>
|
||||
class LLWindGen
|
||||
@@ -60,7 +61,9 @@ public:
|
||||
}
|
||||
|
||||
const U32 getInputSamplingRate() { return mInputSamplingRate; }
|
||||
|
||||
const F32 getNextSample();
|
||||
const F32 getClampedSample(bool clamp, F32 sample);
|
||||
|
||||
// newbuffer = the buffer passed from the previous DSP unit.
|
||||
// numsamples = length in samples-per-channel at this mix time.
|
||||
// NOTE: generates L/R interleaved stereo
|
||||
@@ -95,7 +98,7 @@ public:
|
||||
|
||||
// Start with white noise
|
||||
// This expression is fragile, rearrange it and it will break!
|
||||
next_sample = (F32)rand() * (1.0f / (F32)(RAND_MAX / (U16_MAX / 8))) + (F32)(S16_MIN / 8);
|
||||
next_sample = getNextSample();
|
||||
|
||||
// Apply a pinking filter
|
||||
// Magic numbers taken from PKE method at http://www.firstpr.com.au/dsp/pink-noise/
|
||||
@@ -132,23 +135,13 @@ public:
|
||||
for (U8 i=mSubSamples; i && numsamples; --i, --numsamples)
|
||||
{
|
||||
mLastSample = mLastSample + delta;
|
||||
S32 sample_right = (S32)(mLastSample * mCurrentPanGainR);
|
||||
S32 sample_left = (S32)mLastSample - sample_right;
|
||||
MIXBUFFERFORMAT_T sample_right = (MIXBUFFERFORMAT_T)getClampedSample(clip, mLastSample * mCurrentPanGainR);
|
||||
MIXBUFFERFORMAT_T sample_left = (MIXBUFFERFORMAT_T)getClampedSample(clip, mLastSample - (F32)sample_right);
|
||||
|
||||
if (!clip)
|
||||
{
|
||||
*cursamplep = (MIXBUFFERFORMAT_T)sample_left;
|
||||
++cursamplep;
|
||||
*cursamplep = (MIXBUFFERFORMAT_T)sample_right;
|
||||
++cursamplep;
|
||||
}
|
||||
else
|
||||
{
|
||||
*cursamplep = (MIXBUFFERFORMAT_T)llclamp(sample_left, (S32)S16_MIN, (S32)S16_MAX);
|
||||
++cursamplep;
|
||||
*cursamplep = (MIXBUFFERFORMAT_T)llclamp(sample_right, (S32)S16_MIN, (S32)S16_MAX);
|
||||
++cursamplep;
|
||||
}
|
||||
*cursamplep = sample_left;
|
||||
++cursamplep;
|
||||
*cursamplep = sample_right;
|
||||
++cursamplep;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -179,4 +172,9 @@ private:
|
||||
F32 mLastSample;
|
||||
};
|
||||
|
||||
template<class T> inline const F32 LLWindGen<T>::getNextSample() { return (F32)rand() * (1.0f / (F32)(RAND_MAX / (U16_MAX / 8))) + (F32)(S16_MIN / 8); }
|
||||
template<> inline const F32 LLWindGen<F32>::getNextSample() { return ll_frand()-.5f; }
|
||||
template<class T> inline const F32 LLWindGen<T>::getClampedSample(bool clamp, F32 sample) { return clamp ? (F32)llclamp((S32)sample,(S32)S16_MIN,(S32)S16_MAX) : sample; }
|
||||
template<> inline const F32 LLWindGen<F32>::getClampedSample(bool clamp, F32 sample) { return sample; }
|
||||
|
||||
#endif
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
#include "llapr.h"
|
||||
|
||||
|
||||
using namespace std;
|
||||
//using namespace std;
|
||||
|
||||
#define INCHES_TO_METERS 0.02540005f
|
||||
|
||||
@@ -1575,7 +1575,7 @@ BOOL LLBVHLoader::serialize(LLDataPacker& dp)
|
||||
constraint_it++)
|
||||
{
|
||||
U8 byte = constraint_it->mChainLength;
|
||||
dp.packU8(byte, "chain_lenght");
|
||||
dp.packU8(byte, "chain_length");
|
||||
|
||||
byte = constraint_it->mConstraintType;
|
||||
dp.packU8(byte, "constraint_type");
|
||||
|
||||
@@ -56,8 +56,7 @@ LLCharacter::LLCharacter()
|
||||
mPreferredPelvisHeight( 0.f ),
|
||||
mSex( SEX_FEMALE ),
|
||||
mAppearanceSerialNum( 0 ),
|
||||
mSkeletonSerialNum( 0 ),
|
||||
mInAppearance( false )
|
||||
mSkeletonSerialNum( 0 )
|
||||
{
|
||||
llassert_always(sAllowInstancesChange) ;
|
||||
sInstances.push_back(this);
|
||||
@@ -195,15 +194,19 @@ void LLCharacter::requestStopMotion( LLMotion* motion)
|
||||
//-----------------------------------------------------------------------------
|
||||
// updateMotions()
|
||||
//-----------------------------------------------------------------------------
|
||||
static LLFastTimer::DeclareTimer FTM_UPDATE_ANIMATION("Update Animation");
|
||||
static LLFastTimer::DeclareTimer FTM_UPDATE_HIDDEN_ANIMATION("Update Hidden Anim");
|
||||
|
||||
void LLCharacter::updateMotions(e_update_t update_type)
|
||||
{
|
||||
LLFastTimer t(LLFastTimer::FTM_UPDATE_ANIMATION);
|
||||
if (update_type == HIDDEN_UPDATE)
|
||||
{
|
||||
LLFastTimer t(FTM_UPDATE_HIDDEN_ANIMATION);
|
||||
mMotionController.updateMotionsMinimal();
|
||||
}
|
||||
else
|
||||
{
|
||||
LLFastTimer t(FTM_UPDATE_ANIMATION);
|
||||
// unpause if the number of outstanding pause requests has dropped to the initial one
|
||||
if (mMotionController.isPaused() && mPauseRequest->getNumRefs() == 1)
|
||||
{
|
||||
|
||||
@@ -132,7 +132,7 @@ public:
|
||||
|
||||
virtual void addDebugText( const std::string& text ) = 0;
|
||||
|
||||
virtual const LLUUID& getID() = 0;
|
||||
virtual const LLUUID& getID() const = 0;
|
||||
//-------------------------------------------------------------------------
|
||||
// End Interface
|
||||
//-------------------------------------------------------------------------
|
||||
@@ -268,10 +268,6 @@ public:
|
||||
ESex getSex() const { return mSex; }
|
||||
void setSex( ESex sex ) { mSex = sex; }
|
||||
|
||||
// set appearance flag
|
||||
void setAppearanceFlag( bool flag ) { mInAppearance = flag; }
|
||||
bool getAppearanceFlag() { return mInAppearance; }
|
||||
|
||||
U32 getAppearanceSerialNum() const { return mAppearanceSerialNum; }
|
||||
void setAppearanceSerialNum( U32 num ) { mAppearanceSerialNum = num; }
|
||||
|
||||
@@ -293,8 +289,6 @@ protected:
|
||||
U32 mSkeletonSerialNum;
|
||||
LLAnimPauseRequest mPauseRequest;
|
||||
|
||||
BOOL mInAppearance;
|
||||
|
||||
private:
|
||||
// visual parameter stuff
|
||||
typedef std::map<S32, LLVisualParam *> visual_param_index_map_t;
|
||||
|
||||
@@ -1,31 +1,25 @@
|
||||
/**
|
||||
* @file llgesture.cpp
|
||||
*
|
||||
* $LicenseInfo:firstyear=2002&license=viewergpl$
|
||||
*
|
||||
* Copyright (c) 2002-2009, Linden Research, Inc.
|
||||
*
|
||||
* $LicenseInfo:firstyear=2002&license=viewerlgpl$
|
||||
* Second Life Viewer Source Code
|
||||
* The source code in this file ("Source Code") is provided by Linden Lab
|
||||
* to you under the terms of the GNU General Public License, version 2.0
|
||||
* ("GPL"), unless you have obtained a separate licensing agreement
|
||||
* ("Other License"), formally executed by you and Linden Lab. Terms of
|
||||
* the GPL can be found in doc/GPL-license.txt in this distribution, or
|
||||
* online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
|
||||
* Copyright (C) 2010, Linden Research, Inc.
|
||||
*
|
||||
* There are special exceptions to the terms and conditions of the GPL as
|
||||
* it is applied to this Source Code. View the full text of the exception
|
||||
* in the file doc/FLOSS-exception.txt in this software distribution, or
|
||||
* online at
|
||||
* http://secondlifegrid.net/programs/open_source/licensing/flossexception
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation;
|
||||
* version 2.1 of the License only.
|
||||
*
|
||||
* By copying, modifying or distributing this software, you acknowledge
|
||||
* that you have read and understood your obligations described above,
|
||||
* and agree to abide by those obligations.
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
|
||||
* WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
|
||||
* COMPLETENESS OR PERFORMANCE.
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
|
||||
* $/LicenseInfo$
|
||||
*/
|
||||
|
||||
|
||||
@@ -3,31 +3,25 @@
|
||||
* @brief A gesture is a combination of a triggering chat phrase or
|
||||
* key, a sound, an animation, and a chat string.
|
||||
*
|
||||
* $LicenseInfo:firstyear=2002&license=viewergpl$
|
||||
*
|
||||
* Copyright (c) 2002-2009, Linden Research, Inc.
|
||||
*
|
||||
* $LicenseInfo:firstyear=2002&license=viewerlgpl$
|
||||
* Second Life Viewer Source Code
|
||||
* The source code in this file ("Source Code") is provided by Linden Lab
|
||||
* to you under the terms of the GNU General Public License, version 2.0
|
||||
* ("GPL"), unless you have obtained a separate licensing agreement
|
||||
* ("Other License"), formally executed by you and Linden Lab. Terms of
|
||||
* the GPL can be found in doc/GPL-license.txt in this distribution, or
|
||||
* online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
|
||||
* Copyright (C) 2010, Linden Research, Inc.
|
||||
*
|
||||
* There are special exceptions to the terms and conditions of the GPL as
|
||||
* it is applied to this Source Code. View the full text of the exception
|
||||
* in the file doc/FLOSS-exception.txt in this software distribution, or
|
||||
* online at
|
||||
* http://secondlifegrid.net/programs/open_source/licensing/flossexception
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation;
|
||||
* version 2.1 of the License only.
|
||||
*
|
||||
* By copying, modifying or distributing this software, you acknowledge
|
||||
* that you have read and understood your obligations described above,
|
||||
* and agree to abide by those obligations.
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
|
||||
* WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
|
||||
* COMPLETENESS OR PERFORMANCE.
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
|
||||
* $/LicenseInfo$
|
||||
*/
|
||||
|
||||
|
||||
@@ -510,20 +510,6 @@ BOOL LLEyeMotion::onUpdate(F32 time, U8* joint_mask)
|
||||
vergence_quat.transQuat();
|
||||
right_eye_rot = vergence_quat * eye_jitter_rot * right_eye_rot;
|
||||
|
||||
//if in appearance, set the eyes straight forward
|
||||
if(mCharacter->getAppearanceFlag()) // no idea why this variable is reversed
|
||||
{
|
||||
LLVector3 forward(1.f, 0.0, 0.0);
|
||||
LLVector3 left;
|
||||
LLVector3 up;
|
||||
left.setVec(forward % forward);
|
||||
up.setVec(forward % left);
|
||||
target_eye_rot = LLQuaternion(forward, left, up);
|
||||
mLeftEyeState->setRotation( target_eye_rot );
|
||||
mRightEyeState->setRotation( target_eye_rot );
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
mLeftEyeState->setRotation( left_eye_rot );
|
||||
mRightEyeState->setRotation( right_eye_rot );
|
||||
|
||||
|
||||
@@ -56,9 +56,7 @@ LLJoint::LLJoint()
|
||||
mUpdateXform = TRUE;
|
||||
mJointNum = -1;
|
||||
touch();
|
||||
#if MESH_ENABLED
|
||||
mResetAfterRestoreOldXform = false;
|
||||
#endif //MESH_ENABLED
|
||||
}
|
||||
|
||||
|
||||
@@ -242,7 +240,6 @@ void LLJoint::setPosition( const LLVector3& pos )
|
||||
}
|
||||
}
|
||||
|
||||
#if MESH_ENABLED
|
||||
//--------------------------------------------------------------------
|
||||
// setPosition()
|
||||
//--------------------------------------------------------------------
|
||||
@@ -278,7 +275,6 @@ void LLJoint::restoreToDefaultXform( void )
|
||||
mXform = mDefaultXform;
|
||||
setPosition( mXform.getPosition() );
|
||||
}
|
||||
#endif //MESH_ENABLED
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// getWorldPosition()
|
||||
|
||||
@@ -86,19 +86,14 @@ protected:
|
||||
|
||||
// explicit transformation members
|
||||
LLXformMatrix mXform;
|
||||
#if MESH_ENABLED
|
||||
LLXformMatrix mOldXform;
|
||||
LLXformMatrix mDefaultXform;
|
||||
|
||||
LLUUID mId;
|
||||
#endif //MESH_ENABLED
|
||||
public:
|
||||
U32 mDirtyFlags;
|
||||
BOOL mUpdateXform;
|
||||
|
||||
#if MESH_ENABLED
|
||||
BOOL mResetAfterRestoreOldXform;
|
||||
#endif //MESH_ENABLED
|
||||
|
||||
// describes the skin binding pose
|
||||
LLVector3 mSkinOffset;
|
||||
@@ -188,8 +183,6 @@ public:
|
||||
S32 getJointNum() const { return mJointNum; }
|
||||
void setJointNum(S32 joint_num) { mJointNum = joint_num; }
|
||||
|
||||
#if MESH_ENABLED
|
||||
|
||||
void restoreOldXform( void );
|
||||
void restoreToDefaultXform( void );
|
||||
void setDefaultFromCurrentXform( void );
|
||||
@@ -204,7 +197,6 @@ public:
|
||||
const BOOL doesJointNeedToBeReset( void ) const { return mResetAfterRestoreOldXform; }
|
||||
//Setter for joint reset flag
|
||||
void setJointToBeReset( BOOL val ) { mResetAfterRestoreOldXform = val; }
|
||||
#endif //MESH_ENABLED
|
||||
|
||||
// <edit>
|
||||
std::string exportString(U32 tabs = 0);
|
||||
|
||||
@@ -480,7 +480,7 @@ LLPointer<LLJointState>& LLKeyframeMotion::getJointState(U32 index)
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// getJoin()
|
||||
// getJoint()
|
||||
//-----------------------------------------------------------------------------
|
||||
LLJoint* LLKeyframeMotion::getJoint(U32 index)
|
||||
{
|
||||
|
||||
@@ -637,9 +637,9 @@ void LLMotionController::updateMotionsByType(LLMotion::LLMotionBlendType anim_ty
|
||||
motionp->fadeIn();
|
||||
}
|
||||
|
||||
//**********************
|
||||
// **********************
|
||||
// MOTION INACTIVE
|
||||
//**********************
|
||||
// **********************
|
||||
if (motionp->isStopped() && mAnimTime > motionp->getStopTime() + motionp->getEaseOutDuration())
|
||||
{
|
||||
// this motion has gone on too long, deactivate it
|
||||
@@ -659,9 +659,9 @@ void LLMotionController::updateMotionsByType(LLMotion::LLMotionBlendType anim_ty
|
||||
}
|
||||
}
|
||||
|
||||
//**********************
|
||||
// **********************
|
||||
// MOTION EASE OUT
|
||||
//**********************
|
||||
// **********************
|
||||
else if (motionp->isStopped() && mAnimTime > motionp->getStopTime())
|
||||
{
|
||||
// is this the first iteration in the ease out phase?
|
||||
@@ -684,9 +684,9 @@ void LLMotionController::updateMotionsByType(LLMotion::LLMotionBlendType anim_ty
|
||||
update_result = motionp->onUpdate(mAnimTime - motionp->mActivationTimestamp, last_joint_signature);
|
||||
}
|
||||
|
||||
//**********************
|
||||
// **********************
|
||||
// MOTION ACTIVE
|
||||
//**********************
|
||||
// **********************
|
||||
else if (mAnimTime > motionp->mActivationTimestamp + motionp->getEaseInDuration())
|
||||
{
|
||||
posep->setWeight(motionp->getFadeWeight());
|
||||
@@ -707,9 +707,9 @@ void LLMotionController::updateMotionsByType(LLMotion::LLMotionBlendType anim_ty
|
||||
update_result = motionp->onUpdate(mAnimTime - motionp->mActivationTimestamp, last_joint_signature);
|
||||
}
|
||||
|
||||
//**********************
|
||||
// **********************
|
||||
// MOTION EASE IN
|
||||
//**********************
|
||||
// **********************
|
||||
else if (mAnimTime >= motionp->mActivationTimestamp)
|
||||
{
|
||||
if (mLastTime < motionp->mActivationTimestamp)
|
||||
|
||||
@@ -2,31 +2,25 @@
|
||||
* @file llmultigesture.cpp
|
||||
* @brief Gestures that are asset-based and can have multiple steps.
|
||||
*
|
||||
* $LicenseInfo:firstyear=2004&license=viewergpl$
|
||||
*
|
||||
* Copyright (c) 2004-2009, Linden Research, Inc.
|
||||
*
|
||||
* $LicenseInfo:firstyear=2004&license=viewerlgpl$
|
||||
* Second Life Viewer Source Code
|
||||
* The source code in this file ("Source Code") is provided by Linden Lab
|
||||
* to you under the terms of the GNU General Public License, version 2.0
|
||||
* ("GPL"), unless you have obtained a separate licensing agreement
|
||||
* ("Other License"), formally executed by you and Linden Lab. Terms of
|
||||
* the GPL can be found in doc/GPL-license.txt in this distribution, or
|
||||
* online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
|
||||
* Copyright (C) 2010, Linden Research, Inc.
|
||||
*
|
||||
* There are special exceptions to the terms and conditions of the GPL as
|
||||
* it is applied to this Source Code. View the full text of the exception
|
||||
* in the file doc/FLOSS-exception.txt in this software distribution, or
|
||||
* online at
|
||||
* http://secondlifegrid.net/programs/open_source/licensing/flossexception
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation;
|
||||
* version 2.1 of the License only.
|
||||
*
|
||||
* By copying, modifying or distributing this software, you acknowledge
|
||||
* that you have read and understood your obligations described above,
|
||||
* and agree to abide by those obligations.
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
|
||||
* WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
|
||||
* COMPLETENESS OR PERFORMANCE.
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
|
||||
* $/LicenseInfo$
|
||||
*/
|
||||
|
||||
@@ -50,6 +44,7 @@ const S32 GESTURE_VERSION = 2;
|
||||
LLMultiGesture::LLMultiGesture()
|
||||
: mKey(),
|
||||
mMask(),
|
||||
mName(),
|
||||
mTrigger(),
|
||||
mReplaceText(),
|
||||
mSteps(),
|
||||
@@ -292,20 +287,27 @@ BOOL LLGestureStepAnimation::deserialize(LLDataPacker& dp)
|
||||
dp.unpackU32(mFlags, "flags");
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
std::string LLGestureStepAnimation::getLabel() const
|
||||
// *NOTE: result is translated in LLPreviewGesture::getLabel()
|
||||
std::vector<std::string> LLGestureStepAnimation::getLabel() const
|
||||
{
|
||||
std::string label;
|
||||
std::vector<std::string> strings;
|
||||
|
||||
// std::string label;
|
||||
if (mFlags & ANIM_FLAG_STOP)
|
||||
{
|
||||
label = "Stop Animation: ";
|
||||
strings.push_back( "AnimFlagStop");
|
||||
|
||||
// label = "Stop Animation: ";
|
||||
}
|
||||
else
|
||||
{
|
||||
label = "Start Animation: ";
|
||||
strings.push_back( "AnimFlagStart");
|
||||
|
||||
// label = "Start Animation: ";
|
||||
}
|
||||
label += mAnimName;
|
||||
return label;
|
||||
strings.push_back( mAnimName);
|
||||
// label += mAnimName;
|
||||
return strings;
|
||||
}
|
||||
|
||||
void LLGestureStepAnimation::dump()
|
||||
@@ -359,12 +361,15 @@ BOOL LLGestureStepSound::deserialize(LLDataPacker& dp)
|
||||
dp.unpackU32(mFlags, "flags");
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
std::string LLGestureStepSound::getLabel() const
|
||||
// *NOTE: result is translated in LLPreviewGesture::getLabel()
|
||||
std::vector<std::string> LLGestureStepSound::getLabel() const
|
||||
{
|
||||
std::string label("Sound: ");
|
||||
label += mSoundName;
|
||||
return label;
|
||||
std::vector<std::string> strings;
|
||||
strings.push_back( "Sound");
|
||||
strings.push_back( mSoundName);
|
||||
// std::string label("Sound: ");
|
||||
// label += mSoundName;
|
||||
return strings;
|
||||
}
|
||||
|
||||
void LLGestureStepSound::dump()
|
||||
@@ -414,12 +419,13 @@ BOOL LLGestureStepChat::deserialize(LLDataPacker& dp)
|
||||
dp.unpackU32(mFlags, "flags");
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
std::string LLGestureStepChat::getLabel() const
|
||||
// *NOTE: result is translated in LLPreviewGesture::getLabel()
|
||||
std::vector<std::string> LLGestureStepChat::getLabel() const
|
||||
{
|
||||
std::string label("Chat: ");
|
||||
label += mChatText;
|
||||
return label;
|
||||
std::vector<std::string> strings;
|
||||
strings.push_back("Chat");
|
||||
strings.push_back(mChatText);
|
||||
return strings;
|
||||
}
|
||||
|
||||
void LLGestureStepChat::dump()
|
||||
@@ -467,22 +473,31 @@ BOOL LLGestureStepWait::deserialize(LLDataPacker& dp)
|
||||
dp.unpackU32(mFlags, "flags");
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
std::string LLGestureStepWait::getLabel() const
|
||||
// *NOTE: result is translated in LLPreviewGesture::getLabel()
|
||||
std::vector<std::string> LLGestureStepWait::getLabel() const
|
||||
{
|
||||
std::string label("--- Wait: ");
|
||||
std::vector<std::string> strings;
|
||||
strings.push_back( "Wait" );
|
||||
|
||||
// std::string label("--- Wait: ");
|
||||
if (mFlags & WAIT_FLAG_TIME)
|
||||
{
|
||||
char buffer[64]; /* Flawfinder: ignore */
|
||||
snprintf(buffer, sizeof(buffer), "%.1f seconds", (double)mWaitSeconds); /* Flawfinder: ignore */
|
||||
label += buffer;
|
||||
strings.push_back(buffer);
|
||||
// label += buffer;
|
||||
}
|
||||
else if (mFlags & WAIT_FLAG_ALL_ANIM)
|
||||
{
|
||||
label += "until animations are done";
|
||||
strings.push_back("until animations are done");
|
||||
// label += "until animations are done";
|
||||
}
|
||||
else
|
||||
{
|
||||
strings.push_back("");
|
||||
}
|
||||
|
||||
return label;
|
||||
return strings;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -70,6 +70,10 @@ public:
|
||||
KEY mKey;
|
||||
MASK mMask;
|
||||
|
||||
// This name can be empty if the inventory item is not around and
|
||||
// the gesture manager has not yet set the name
|
||||
std::string mName;
|
||||
|
||||
// String, like "/foo" or "hello" that makes it play
|
||||
std::string mTrigger;
|
||||
|
||||
@@ -130,7 +134,7 @@ public:
|
||||
virtual EStepType getType() = 0;
|
||||
|
||||
// Return a user-readable label for this step
|
||||
virtual std::string getLabel() const = 0;
|
||||
virtual std::vector<std::string> getLabel() const = 0;
|
||||
|
||||
virtual S32 getMaxSerialSize() const = 0;
|
||||
virtual BOOL serialize(LLDataPacker& dp) const = 0;
|
||||
@@ -152,7 +156,7 @@ public:
|
||||
|
||||
virtual EStepType getType() { return STEP_ANIMATION; }
|
||||
|
||||
virtual std::string getLabel() const;
|
||||
virtual std::vector<std::string> getLabel() const;
|
||||
|
||||
virtual S32 getMaxSerialSize() const;
|
||||
virtual BOOL serialize(LLDataPacker& dp) const;
|
||||
@@ -175,7 +179,7 @@ public:
|
||||
|
||||
virtual EStepType getType() { return STEP_SOUND; }
|
||||
|
||||
virtual std::string getLabel() const;
|
||||
virtual std::vector<std::string> getLabel() const;
|
||||
|
||||
virtual S32 getMaxSerialSize() const;
|
||||
virtual BOOL serialize(LLDataPacker& dp) const;
|
||||
@@ -198,7 +202,7 @@ public:
|
||||
|
||||
virtual EStepType getType() { return STEP_CHAT; }
|
||||
|
||||
virtual std::string getLabel() const;
|
||||
virtual std::vector<std::string> getLabel() const;
|
||||
|
||||
virtual S32 getMaxSerialSize() const;
|
||||
virtual BOOL serialize(LLDataPacker& dp) const;
|
||||
@@ -223,7 +227,7 @@ public:
|
||||
|
||||
virtual EStepType getType() { return STEP_WAIT; }
|
||||
|
||||
virtual std::string getLabel() const;
|
||||
virtual std::vector<std::string> getLabel() const;
|
||||
|
||||
virtual S32 getMaxSerialSize() const;
|
||||
virtual BOOL serialize(LLDataPacker& dp) const;
|
||||
|
||||
@@ -2,31 +2,25 @@
|
||||
* @file llvisualparam.cpp
|
||||
* @brief Implementation of LLPolyMesh class.
|
||||
*
|
||||
* $LicenseInfo:firstyear=2001&license=viewergpl$
|
||||
*
|
||||
* Copyright (c) 2001-2009, Linden Research, Inc.
|
||||
*
|
||||
* $LicenseInfo:firstyear=2001&license=viewerlgpl$
|
||||
* Second Life Viewer Source Code
|
||||
* The source code in this file ("Source Code") is provided by Linden Lab
|
||||
* to you under the terms of the GNU General Public License, version 2.0
|
||||
* ("GPL"), unless you have obtained a separate licensing agreement
|
||||
* ("Other License"), formally executed by you and Linden Lab. Terms of
|
||||
* the GPL can be found in doc/GPL-license.txt in this distribution, or
|
||||
* online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
|
||||
* Copyright (C) 2010, Linden Research, Inc.
|
||||
*
|
||||
* There are special exceptions to the terms and conditions of the GPL as
|
||||
* it is applied to this Source Code. View the full text of the exception
|
||||
* in the file doc/FLOSS-exception.txt in this software distribution, or
|
||||
* online at
|
||||
* http://secondlifegrid.net/programs/open_source/licensing/flossexception
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation;
|
||||
* version 2.1 of the License only.
|
||||
*
|
||||
* By copying, modifying or distributing this software, you acknowledge
|
||||
* that you have read and understood your obligations described above,
|
||||
* and agree to abide by those obligations.
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
|
||||
* WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
|
||||
* COMPLETENESS OR PERFORMANCE.
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
|
||||
* $/LicenseInfo$
|
||||
*/
|
||||
|
||||
|
||||
@@ -2,31 +2,25 @@
|
||||
* @file llvisualparam.h
|
||||
* @brief Implementation of LLPolyMesh class.
|
||||
*
|
||||
* $LicenseInfo:firstyear=2001&license=viewergpl$
|
||||
*
|
||||
* Copyright (c) 2001-2009, Linden Research, Inc.
|
||||
*
|
||||
* $LicenseInfo:firstyear=2001&license=viewerlgpl$
|
||||
* Second Life Viewer Source Code
|
||||
* The source code in this file ("Source Code") is provided by Linden Lab
|
||||
* to you under the terms of the GNU General Public License, version 2.0
|
||||
* ("GPL"), unless you have obtained a separate licensing agreement
|
||||
* ("Other License"), formally executed by you and Linden Lab. Terms of
|
||||
* the GPL can be found in doc/GPL-license.txt in this distribution, or
|
||||
* online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
|
||||
* Copyright (C) 2010, Linden Research, Inc.
|
||||
*
|
||||
* There are special exceptions to the terms and conditions of the GPL as
|
||||
* it is applied to this Source Code. View the full text of the exception
|
||||
* in the file doc/FLOSS-exception.txt in this software distribution, or
|
||||
* online at
|
||||
* http://secondlifegrid.net/programs/open_source/licensing/flossexception
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation;
|
||||
* version 2.1 of the License only.
|
||||
*
|
||||
* By copying, modifying or distributing this software, you acknowledge
|
||||
* that you have read and understood your obligations described above,
|
||||
* and agree to abide by those obligations.
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
|
||||
* WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
|
||||
* COMPLETENESS OR PERFORMANCE.
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
|
||||
* $/LicenseInfo$
|
||||
*/
|
||||
|
||||
|
||||
@@ -15,8 +15,11 @@ include_directories(
|
||||
)
|
||||
|
||||
set(llcommon_SOURCE_FILES
|
||||
aiframetimer.cpp
|
||||
imageids.cpp
|
||||
indra_constants.cpp
|
||||
indra_constants.cpp
|
||||
llallocator.cpp
|
||||
llallocator_heap_profile.cpp
|
||||
llapp.cpp
|
||||
llapr.cpp
|
||||
llaprpool.cpp
|
||||
@@ -26,16 +29,23 @@ set(llcommon_SOURCE_FILES
|
||||
llbase64.cpp
|
||||
llcommon.cpp
|
||||
llcommonutils.cpp
|
||||
llcoros.cpp
|
||||
llcrc.cpp
|
||||
llcriticaldamp.cpp
|
||||
llcursortypes.cpp
|
||||
lldate.cpp
|
||||
lldependencies.cpp
|
||||
lldictionary.cpp
|
||||
llerror.cpp
|
||||
llerrorthread.cpp
|
||||
llevent.cpp
|
||||
lleventapi.cpp
|
||||
lleventcoro.cpp
|
||||
lleventdispatcher.cpp
|
||||
lleventfilter.cpp
|
||||
llevents.cpp
|
||||
lleventtimer.cpp
|
||||
llfasttimer.cpp
|
||||
llfasttimer_class.cpp
|
||||
llfile.cpp
|
||||
llfindlocale.cpp
|
||||
llfixedbuffer.cpp
|
||||
@@ -51,9 +61,11 @@ set(llcommon_SOURCE_FILES
|
||||
llmd5.cpp
|
||||
llmemory.cpp
|
||||
llmemorystream.cpp
|
||||
llmemtype.cpp
|
||||
llmetrics.cpp
|
||||
llmortician.cpp
|
||||
lloptioninterface.cpp
|
||||
llptrto.cpp
|
||||
llprocesslauncher.cpp
|
||||
llprocessor.cpp
|
||||
llqueuedthread.cpp
|
||||
@@ -79,6 +91,7 @@ set(llcommon_SOURCE_FILES
|
||||
lluri.cpp
|
||||
lluuid.cpp
|
||||
llworkerthread.cpp
|
||||
ll_template_cast.h
|
||||
metaclass.cpp
|
||||
metaproperty.cpp
|
||||
reflective.cpp
|
||||
@@ -89,6 +102,7 @@ set(llcommon_SOURCE_FILES
|
||||
set(llcommon_HEADER_FILES
|
||||
CMakeLists.txt
|
||||
|
||||
aiframetimer.h
|
||||
aithreadsafe.h
|
||||
bitpack.h
|
||||
ctype_workaround.h
|
||||
@@ -98,6 +112,8 @@ set(llcommon_HEADER_FILES
|
||||
linden_common.h
|
||||
linked_lists.h
|
||||
llaccountingcost.h
|
||||
llallocator.h
|
||||
llallocator_heap_profile.h
|
||||
llagentconstants.h
|
||||
llavatarname.h
|
||||
llapp.h
|
||||
@@ -105,6 +121,7 @@ set(llcommon_HEADER_FILES
|
||||
llaprpool.h
|
||||
llassettype.h
|
||||
llassoclist.h
|
||||
llatomic.h
|
||||
llavatarconstants.h
|
||||
llbase32.h
|
||||
llbase64.h
|
||||
@@ -113,6 +130,7 @@ set(llcommon_HEADER_FILES
|
||||
llclickaction.h
|
||||
llcommon.h
|
||||
llcommonutils.h
|
||||
llcoros.h
|
||||
llcrc.h
|
||||
llcriticaldamp.h
|
||||
llcursortypes.h
|
||||
@@ -120,6 +138,7 @@ set(llcommon_HEADER_FILES
|
||||
lldarrayptr.h
|
||||
lldate.h
|
||||
lldefs.h
|
||||
lldependencies.h
|
||||
lldeleteutils.h
|
||||
lldepthstack.h
|
||||
lldictionary.h
|
||||
@@ -132,10 +151,16 @@ set(llcommon_HEADER_FILES
|
||||
llerrorlegacy.h
|
||||
llerrorthread.h
|
||||
llevent.h
|
||||
lleventapi.h
|
||||
lleventcoro.h
|
||||
lleventdispatcher.h
|
||||
lleventfilter.h
|
||||
llevents.h
|
||||
lleventemitter.h
|
||||
llextendedstatus.h
|
||||
lleventtimer.h
|
||||
llfasttimer.h
|
||||
llfasttimer_class.h
|
||||
llfile.h
|
||||
llfindlocale.h
|
||||
llfixedbuffer.h
|
||||
@@ -171,6 +196,7 @@ set(llcommon_HEADER_FILES
|
||||
llprocessor.h
|
||||
llptrskiplist.h
|
||||
llptrskipmap.h
|
||||
llptrto.h
|
||||
llqueuedthread.h
|
||||
llrand.h
|
||||
llrefcount.h
|
||||
@@ -203,8 +229,7 @@ set(llcommon_HEADER_FILES
|
||||
lluri.h
|
||||
lluuid.h
|
||||
lluuidhashmap.h
|
||||
llversionserver.h
|
||||
llversionviewer.h
|
||||
llversionviewer.h.in
|
||||
llworkerthread.h
|
||||
metaclass.h
|
||||
metaclasst.h
|
||||
|
||||
180
indra/llcommon/aiframetimer.cpp
Normal file
180
indra/llcommon/aiframetimer.cpp
Normal file
@@ -0,0 +1,180 @@
|
||||
/**
|
||||
* @file aiframetimer.cpp
|
||||
*
|
||||
* Copyright (c) 2011, Aleric Inglewood.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* There are special exceptions to the terms and conditions of the GPL as
|
||||
* it is applied to this Source Code. View the full text of the exception
|
||||
* in the file doc/FLOSS-exception.txt in this software distribution.
|
||||
*
|
||||
* CHANGELOG
|
||||
* and additional copyright holders.
|
||||
*
|
||||
* 06/08/2011
|
||||
* - Initial version, written by Aleric Inglewood @ SL
|
||||
*/
|
||||
|
||||
// An AIFrameTimer object provides a callback API for timer events.
|
||||
//
|
||||
// Typical usage:
|
||||
//
|
||||
// // Any thread.
|
||||
// AIFrameTimer timer;
|
||||
//
|
||||
// ...
|
||||
// // Any thread (after successful construction is guaranteed).
|
||||
// timer.create(5.5, boost::bind(&the_callback, <optional params>)); // Call the_callback(<optional params>) in 5.5 seconds.
|
||||
//
|
||||
// The callback function is always called by the main thread and should therefore
|
||||
// be light weight.
|
||||
//
|
||||
// If timer.cancel() is called before the timer expires, then the callback
|
||||
// function isn't called. If cancel() is called by another thread than the
|
||||
// main thread, then it is possible that the callback function is called
|
||||
// even while still inside cancel(), but as soon as cancel() returned it
|
||||
// is guarenteed that the callback function won't be called anymore.
|
||||
// Hence, if the callback function is a member of some object then
|
||||
// cancel() must be called before the destruction of that object (ie from
|
||||
// it's destructor). Calling cancel() multiple times is not a problem.
|
||||
// Note: if cancel() is called while the callback function is being
|
||||
// called then cancel() will block until the callback function returned.
|
||||
//
|
||||
// The timer object can be reused (by calling create() again), but
|
||||
// only after either the callback function was called, or after cancel()
|
||||
// returned. Most notably, you can call create() again from inside the
|
||||
// callback function to "restart" the timer.
|
||||
//
|
||||
|
||||
#include "linden_common.h"
|
||||
#include "aiframetimer.h"
|
||||
|
||||
static F64 const NEVER = 1e16; // 317 million years.
|
||||
|
||||
F64 AIFrameTimer::sNextExpiration;
|
||||
AIFrameTimer::timer_list_type AIFrameTimer::sTimerList;
|
||||
LLMutex AIFrameTimer::sMutex;
|
||||
|
||||
// Notes on thread-safety of AIRunningFrameTimer (continued from aiframetimer.h)
|
||||
//
|
||||
// Most notably, the constructor and init() should be called as follows:
|
||||
// 1) The object is constructed (AIRunningFrameTimer::AIRunningFrameTimer).
|
||||
// 2) The lock is obtained.
|
||||
// 3) The object is inserted in the list (operator<(AIRunningFrameTimer const&, AIRunningFrameTimer const&)).
|
||||
// 4) The object is initialized (AIRunningFrameTimer::init).
|
||||
// 5) The lock is released.
|
||||
// This assures that the object is not yet shared at the moment that it is initialized.
|
||||
|
||||
void AIFrameTimer::create(F64 expiration, signal_type::slot_type const& slot)
|
||||
{
|
||||
AIRunningFrameTimer new_timer(expiration, this);
|
||||
sMutex.lock();
|
||||
llassert(mHandle.mRunningTimer == sTimerList.end()); // Create may only be called when the timer isn't already running.
|
||||
mHandle.init(sTimerList.insert(new_timer), slot);
|
||||
sNextExpiration = sTimerList.begin()->expiration();
|
||||
sMutex.unlock();
|
||||
}
|
||||
|
||||
void AIFrameTimer::cancel(void)
|
||||
{
|
||||
// In order to stop us from returning from cancel() while
|
||||
// the callback function is being called (which is done
|
||||
// in AIFrameTimer::handleExpiration after obtaining the
|
||||
// mHandle.mMutex lock), we start with trying to obtain
|
||||
// it here and as such wait till the callback function
|
||||
// returned.
|
||||
mHandle.mMutex.lock();
|
||||
// Next we have to grab this lock in order to stop
|
||||
// AIFrameTimer::handleExpiration from even entering
|
||||
// in the case we manage to get it first.
|
||||
sMutex.lock();
|
||||
if (mHandle.mRunningTimer != sTimerList.end())
|
||||
{
|
||||
sTimerList.erase(mHandle.mRunningTimer);
|
||||
mHandle.mRunningTimer = sTimerList.end();
|
||||
sNextExpiration = sTimerList.empty() ? NEVER : sTimerList.begin()->expiration();
|
||||
}
|
||||
sMutex.unlock();
|
||||
mHandle.mMutex.unlock();
|
||||
}
|
||||
|
||||
void AIFrameTimer::handleExpiration(F64 current_frame_time)
|
||||
{
|
||||
sMutex.lock();
|
||||
for(;;)
|
||||
{
|
||||
if (sTimerList.empty())
|
||||
{
|
||||
// No running timers left.
|
||||
sNextExpiration = NEVER;
|
||||
break;
|
||||
}
|
||||
timer_list_type::iterator running_timer = sTimerList.begin();
|
||||
sNextExpiration = running_timer->expiration();
|
||||
if (sNextExpiration > current_frame_time)
|
||||
{
|
||||
// Didn't expire yet.
|
||||
break;
|
||||
}
|
||||
|
||||
// Obtain handle of running timer through the associated AIFrameTimer object.
|
||||
// Note that if the AIFrameTimer object was destructed (when running_timer->getTimer()
|
||||
// would return an invalid pointer) then it called cancel(), so we can't be here.
|
||||
Handle& handle(running_timer->getTimer()->mHandle);
|
||||
llassert_always(running_timer == handle.mRunningTimer);
|
||||
|
||||
// We're going to erase this timer, so stop cancel() from doing the same.
|
||||
handle.mRunningTimer = sTimerList.end();
|
||||
|
||||
// We keep handle.mMutex during the callback to prevent the thread that
|
||||
// owns the AIFrameTimer from deleting the callback function while we
|
||||
// call it: in order to do so it first has to call cancel(), which will
|
||||
// block until we release this mutex again, or we won't call the callback
|
||||
// function here because the trylock fails.
|
||||
//
|
||||
// Assuming the main thread arrived here, there are two possible states
|
||||
// for the other thread that tries to delete the callback function,
|
||||
// right after calling the cancel() function too:
|
||||
//
|
||||
// 1. It hasn't obtained the first lock yet, we obtain the handle.mMutex
|
||||
// lock and the other thread will stall on the first line of cancel().
|
||||
// After do_callback returns, the other thread will do nothing because
|
||||
// handle.mRunningTimer equals sTimerList.end(), exit the function and
|
||||
// (possibly) delete the callback object, but that is ok as we already
|
||||
// returned from the callback function.
|
||||
//
|
||||
// 2. It already called cancel() and hangs on the second line trying to
|
||||
// obtain sMutex.lock(). The trylock below fails and we never call the
|
||||
// callback function. We erase the running timer here and release sMutex
|
||||
// at the end, after which the other thread does nothing because
|
||||
// handle.mRunningTimer equals sTimerList.end(), exits the function and
|
||||
// (possibly) deletes the callback object.
|
||||
//
|
||||
// Note that if the other thread actually obtained the sMutex then we
|
||||
// can't be here: this is still inside the critical area of sMutex.
|
||||
if (handle.mMutex.tryLock()) // If this fails then another thread is in the process of cancelling this timer, so do nothing.
|
||||
{
|
||||
sMutex.unlock();
|
||||
running_timer->do_callback(); // May not throw exceptions.
|
||||
sMutex.lock();
|
||||
handle.mMutex.unlock(); // Allow other thread to return from cancel() and possibly delete the callback object.
|
||||
}
|
||||
|
||||
// Erase the timer from the running list.
|
||||
sTimerList.erase(running_timer);
|
||||
}
|
||||
sMutex.unlock();
|
||||
}
|
||||
|
||||
155
indra/llcommon/aiframetimer.h
Normal file
155
indra/llcommon/aiframetimer.h
Normal file
@@ -0,0 +1,155 @@
|
||||
/**
|
||||
* @file aiframetimer.h
|
||||
* @brief Implementation of AIFrameTimer.
|
||||
*
|
||||
* Copyright (c) 2011, Aleric Inglewood.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* There are special exceptions to the terms and conditions of the GPL as
|
||||
* it is applied to this Source Code. View the full text of the exception
|
||||
* in the file doc/FLOSS-exception.txt in this software distribution.
|
||||
*
|
||||
* CHANGELOG
|
||||
* and additional copyright holders.
|
||||
*
|
||||
* 05/08/2011
|
||||
* Initial version, written by Aleric Inglewood @ SL
|
||||
*/
|
||||
|
||||
#ifndef AIFRAMETIMER_H
|
||||
#define AIFRAMETIMER_H
|
||||
|
||||
#include "llframetimer.h"
|
||||
#include "llthread.h"
|
||||
#include <boost/signals2.hpp>
|
||||
#include <set>
|
||||
|
||||
class LL_COMMON_API AIFrameTimer
|
||||
{
|
||||
protected:
|
||||
typedef boost::signals2::signal<void (void)> signal_type;
|
||||
|
||||
private:
|
||||
// Use separate struct for this object because it is non-copyable.
|
||||
struct Signal {
|
||||
signal_type mSignal;
|
||||
};
|
||||
|
||||
// Notes on Thread-Safety
|
||||
//
|
||||
// This is the type of the objects stored in AIFrameTimer::sTimerList, and as such leans
|
||||
// for it's thread-safety on the same lock as is used for that std::multiset as follows.
|
||||
// An arbitrary thread can create, insert and initialize this object. Other threads can
|
||||
// not access it until that has completed.
|
||||
//
|
||||
// After creation two threads can access it: the thread that created it (owns the
|
||||
// AIFrameTimer object, which has an mHandle that points to this object), or the main
|
||||
// thread by finding it in sTimerList.
|
||||
//
|
||||
// See aiframetimer.cpp for more notes.
|
||||
class AIRunningFrameTimer {
|
||||
private:
|
||||
F64 mExpire; // Time at which the timer expires, in seconds since application start (compared to LLFrameTimer::sFrameTime).
|
||||
AIFrameTimer* mTimer; // The actual timer.
|
||||
// Can be mutable, since only the mExpire is used for ordering this object in the multiset AIFrameTimer::sTimerList.
|
||||
mutable Signal* mCallback; // Pointer to callback struct, or NULL when the object wasn't added to sTimerList yet.
|
||||
|
||||
public:
|
||||
AIRunningFrameTimer(F64 expiration, AIFrameTimer* timer) : mExpire(LLFrameTimer::getElapsedSeconds() + expiration), mCallback(NULL), mTimer(timer) { }
|
||||
~AIRunningFrameTimer() { delete mCallback; }
|
||||
|
||||
// This function is called after the final object was added to sTimerList (where it is initialized in-place).
|
||||
void init(signal_type::slot_type const& slot) const
|
||||
{
|
||||
// We may only call init() once.
|
||||
llassert(!mCallback);
|
||||
mCallback = new Signal;
|
||||
mCallback->mSignal.connect(slot);
|
||||
}
|
||||
|
||||
// Order AIFrameTimer::sTimerList so that the timer that expires first is up front.
|
||||
friend bool operator<(AIRunningFrameTimer const& ft1, AIRunningFrameTimer const& ft2) { return ft1.mExpire < ft2.mExpire; }
|
||||
|
||||
void do_callback(void) const { mCallback->mSignal(); }
|
||||
F64 expiration(void) const { return mExpire; }
|
||||
AIFrameTimer* getTimer(void) const { return mTimer; }
|
||||
|
||||
#if LL_DEBUG
|
||||
// May not copy this object after it was initialized.
|
||||
AIRunningFrameTimer(AIRunningFrameTimer const& running_frame_timer) :
|
||||
mExpire(running_frame_timer.mExpire), mCallback(running_frame_timer.mCallback), mTimer(running_frame_timer.mTimer)
|
||||
{ llassert(!mCallback); }
|
||||
#endif
|
||||
};
|
||||
|
||||
typedef std::multiset<AIRunningFrameTimer> timer_list_type;
|
||||
|
||||
static LLMutex sMutex; // Mutex for the two global variables below.
|
||||
static timer_list_type sTimerList; // List with all running timers.
|
||||
static F64 sNextExpiration; // Cache of smallest value in sTimerList.
|
||||
friend class LLFrameTimer; // Access to sNextExpiration.
|
||||
|
||||
class Handle {
|
||||
public:
|
||||
timer_list_type::iterator mRunningTimer; // Points to the running timer, or to sTimerList.end() when not running.
|
||||
// Access to this iterator is protected by the AIFrameTimer::sMutex!
|
||||
LLMutex mMutex; // A mutex used to protect us from deletion of the callback object while
|
||||
// calling the callback function in the case of simultaneous expiration
|
||||
// and cancellation by the thread owning the AIFrameTimer (by calling
|
||||
// AIFrameTimer::cancel).
|
||||
|
||||
// Constructor for a not-running timer.
|
||||
Handle(void) : mRunningTimer(sTimerList.end()) { }
|
||||
|
||||
// Actual initialization used by AIFrameTimer::create.
|
||||
void init(timer_list_type::iterator const& running_timer, signal_type::slot_type const& slot)
|
||||
{
|
||||
// Locking AIFrameTimer::sMutex is not neccessary here, because we're creating
|
||||
// the object and no other thread knows of mRunningTimer at this point.
|
||||
mRunningTimer = running_timer;
|
||||
mRunningTimer->init(slot);
|
||||
}
|
||||
|
||||
private:
|
||||
// LLMutex has no assignment operator.
|
||||
Handle& operator=(Handle const&) { return *this; }
|
||||
};
|
||||
|
||||
Handle mHandle;
|
||||
|
||||
public:
|
||||
// Construct an AIFrameTimer that is not running.
|
||||
AIFrameTimer(void) { }
|
||||
|
||||
// Construction of a running AIFrameTimer with expiration time expiration in seconds, and callback slot.
|
||||
AIFrameTimer(F64 expiration, signal_type::slot_type const& slot) { create(expiration, slot); }
|
||||
|
||||
// Destructing the AIFrameTimer object terminates the running timer (if still running).
|
||||
// Note that cancel() must have returned BEFORE anything is destructed that would disallow the callback function to be called.
|
||||
// So, if the AIFrameTimer is a member of an object whose callback function is called then cancel() has
|
||||
// to be called manually (or from the destructor of THAT object), before that object is destructed.
|
||||
// Cancel may be called multiple times.
|
||||
~AIFrameTimer() { cancel(); }
|
||||
|
||||
void create(F64 expiration, signal_type::slot_type const& slot);
|
||||
void cancel(void);
|
||||
|
||||
bool isRunning(void) const { bool running; sMutex.lock(); running = mHandle.mRunningTimer != sTimerList.end(); sMutex.unlock(); return running; }
|
||||
|
||||
protected:
|
||||
static void handleExpiration(F64 current_frame_time);
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -26,8 +26,65 @@
|
||||
*
|
||||
* 31/03/2010
|
||||
* Initial version, written by Aleric Inglewood @ SL
|
||||
*
|
||||
* 14/03/2012
|
||||
* Added AIThreadSafeSingleThread and friends.
|
||||
* Added AIAccessConst (and derived AIAccess from it) to allow read
|
||||
* access to a const AIThreadSafeSimple.
|
||||
*/
|
||||
|
||||
// This file defines wrapper template classes for arbitrary types T
|
||||
// adding locking to the instance and shielding it from access
|
||||
// without first being locked.
|
||||
//
|
||||
// Locking and getting access works by creating a temporary (local)
|
||||
// access object that takes the wrapper class as argument. Creating
|
||||
// the access object obtains the lock, while destructing it releases
|
||||
// the lock.
|
||||
//
|
||||
// There are three types of wrapper classes:
|
||||
// AIThreadSafe, AIThreadSafeSimple and AIThreadSafeSingleThread.
|
||||
//
|
||||
// AIThreadSafe is for use with the access classes:
|
||||
// AIReadAccessConst, AIReadAccess and AIWriteAccess.
|
||||
//
|
||||
// AIThreadSafeSimple is for use with the access classes:
|
||||
// AIAccessConst and AIAccess.
|
||||
//
|
||||
// AIThreadSafeSingleThread is for use with the access classes:
|
||||
// AISTAccessConst and AISTAccess.
|
||||
//
|
||||
// AIReadAccessConst provides read access to a const AIThreadSafe.
|
||||
// AIReadAccess provides read access to a non-const AIThreadSafe.
|
||||
// AIWriteAccess provides read/write access to a non-const AIThreadSafe.
|
||||
//
|
||||
// AIAccessConst provides read access to a const AIThreadSafeSimple.
|
||||
// AIAccess provides read/write access to a non-const AIThreadSafeSimple.
|
||||
//
|
||||
// AISTAccessConst provides read access to a const AIThreadSafeSingleThread.
|
||||
// AISTAccess provides read/write access to a non-const AIThreadSafeSingleThread.
|
||||
//
|
||||
// Thus, AIThreadSafe is to protect objects with a read/write lock,
|
||||
// AIThreadSafeSimple is to protect objects with a single mutex,
|
||||
// and AIThreadSafeSingleThread doesn't do any locking but makes sure
|
||||
// (in Debug mode) that the wrapped object is only accessed by one thread.
|
||||
//
|
||||
// Each wrapper class allows its wrapped object to be constructed
|
||||
// with arbitrary parameters by using operator new with placement;
|
||||
// for example, to instantiate a class Foo with read/write locking:
|
||||
//
|
||||
// AIThreadSafe<Foo> foo(new (foo.memory()) Foo(param1, param2, ...));
|
||||
//
|
||||
// Each wrapper class has a derived class that end on 'DC' (which
|
||||
// stand for Default Constructed): AIThreadSafeDC, AIThreadSafeSimpleDC
|
||||
// and AIThreadSafeSingleThreadDC. The default constructors of those
|
||||
// wrapper classes cause the wrapped instance to be default constructed
|
||||
// as well. They also provide a general one-parameter constructor.
|
||||
// For example:
|
||||
//
|
||||
// AIThreadSafeDC<Foo> foo; // Default constructed Foo.
|
||||
// AIThreadSafeDC<Foo> foo(3.4); // Foo with one constructor parameter.
|
||||
//
|
||||
#ifndef AITHREADSAFE_H
|
||||
#define AITHREADSAFE_H
|
||||
|
||||
@@ -49,15 +106,10 @@
|
||||
template<typename T> struct AIReadAccessConst;
|
||||
template<typename T> struct AIReadAccess;
|
||||
template<typename T> struct AIWriteAccess;
|
||||
template<typename T> struct AIAccessConst;
|
||||
template<typename T> struct AIAccess;
|
||||
|
||||
#if LL_WINDOWS
|
||||
template<typename T> class AIThreadSafeBits;
|
||||
template<typename T>
|
||||
struct AIThreadSafeWindowsHack {
|
||||
AIThreadSafeWindowsHack(AIThreadSafeBits<T>& var, T* object);
|
||||
};
|
||||
#endif
|
||||
template<typename T> struct AISTAccessConst;
|
||||
template<typename T> struct AISTAccess;
|
||||
|
||||
template<typename T>
|
||||
class AIThreadSafeBits
|
||||
@@ -80,10 +132,15 @@ public:
|
||||
// Only for use by AITHREADSAFE, see below.
|
||||
void* memory() const { return const_cast<long*>(&mMemory[0]); }
|
||||
|
||||
// Cast a T* back to AIThreadSafeBits<T>. This is the inverse of memory().
|
||||
template<typename T2>
|
||||
static AIThreadSafeBits<T2>* wrapper_cast(T2* ptr)
|
||||
{ return reinterpret_cast<AIThreadSafeBits<T2>*>(reinterpret_cast<char*>(ptr) - offsetof(AIThreadSafeBits<T2>, mMemory[0])); }
|
||||
template<typename T2>
|
||||
static AIThreadSafeBits<T2> const* wrapper_cast(T2 const* ptr)
|
||||
{ return reinterpret_cast<AIThreadSafeBits<T2> const*>(reinterpret_cast<char const*>(ptr) - offsetof(AIThreadSafeBits<T2>, mMemory[0])); }
|
||||
|
||||
protected:
|
||||
#if LL_WINDOWS
|
||||
template<typename T2> friend struct AIThreadSafeWindowsHack;
|
||||
#endif
|
||||
// Accessors.
|
||||
T const* ptr() const { return reinterpret_cast<T const*>(mMemory); }
|
||||
T* ptr() { return reinterpret_cast<T*>(mMemory); }
|
||||
@@ -185,6 +242,14 @@ public:
|
||||
llassert(object == AIThreadSafeBits<T>::ptr());
|
||||
#endif
|
||||
}
|
||||
|
||||
#if LL_DEBUG
|
||||
// Can only be locked when there still exists an AIAccess object that
|
||||
// references this object and will access it upon destruction.
|
||||
// If the assertion fails, make sure that such AIAccess object is
|
||||
// destructed before the deletion of this object.
|
||||
~AIThreadSafe() { llassert(!mRWLock.isLocked()); }
|
||||
#endif
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -194,48 +259,39 @@ public:
|
||||
*
|
||||
* <code>
|
||||
* Foo foo(x, y);
|
||||
* static Bar bar;
|
||||
* static Bar bar(0.1, true);
|
||||
* </code>
|
||||
*
|
||||
* One can instantiate a thread-safe instance with
|
||||
*
|
||||
* <code>
|
||||
* AITHREADSAFE(Foo, foo, (x, y));
|
||||
* static AITHREADSAFE(Bar, bar, );
|
||||
* static AITHREADSAFE(Bar, bar, (0.1, true));
|
||||
* </code>
|
||||
*
|
||||
* Note: This macro does not allow to allocate such object on the heap.
|
||||
* If that is needed, have a look at AIThreadSafeDC.
|
||||
*/
|
||||
#if LL_WINDOWS
|
||||
template<typename T>
|
||||
AIThreadSafeWindowsHack<T>::AIThreadSafeWindowsHack(AIThreadSafeBits<T>& var, T* object)
|
||||
{
|
||||
llassert(object == var.ptr());
|
||||
}
|
||||
#define AITHREADSAFE(type, var, paramlist) \
|
||||
AIThreadSafe<type> var(NULL); \
|
||||
AIThreadSafeWindowsHack<type> dummy_##var(var, new (var.memory()) type paramlist)
|
||||
#else
|
||||
#define AITHREADSAFE(type, var, paramlist) AIThreadSafe<type> var(new (var.memory()) type paramlist)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief A wrapper class for objects that need to be accessed by more than one thread.
|
||||
*
|
||||
* This class is the same as an AIThreadSafe wrapper, except that it can only
|
||||
* be used for default constructed objects.
|
||||
* be used for default constructed objects, or constructed with one parameter.
|
||||
*
|
||||
* For example, instead of
|
||||
*
|
||||
* <code>
|
||||
* Foo foo;
|
||||
* Bar bar(3);
|
||||
* </code>
|
||||
*
|
||||
* One would use
|
||||
*
|
||||
* <code>
|
||||
* AIThreadSafeDC<Foo> foo;
|
||||
* AIThreadSafeDC<Bar> bar(3);
|
||||
* </code>
|
||||
*
|
||||
* The advantage over AITHREADSAFE is that this object can be allocated with
|
||||
@@ -253,6 +309,8 @@ class AIThreadSafeDC : public AIThreadSafe<T>
|
||||
public:
|
||||
// Construct a wrapper around a default constructed object.
|
||||
AIThreadSafeDC(void) { new (AIThreadSafe<T>::ptr()) T; }
|
||||
// Allow an arbitrary parameter to be passed for construction.
|
||||
template<typename T2> AIThreadSafeDC(T2 const& val) { new (AIThreadSafe<T>::ptr()) T(val); }
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -390,6 +448,7 @@ struct AIWriteAccess : public AIReadAccess<T>
|
||||
*
|
||||
* AIAccess<Foo> foo_w(foo);
|
||||
* // Use foo_w-> for read and write access.
|
||||
* </code>
|
||||
*
|
||||
* See also AIThreadSafe
|
||||
*/
|
||||
@@ -398,6 +457,7 @@ class AIThreadSafeSimple : public AIThreadSafeBits<T>
|
||||
{
|
||||
protected:
|
||||
// Only this one may access the object (through ptr()).
|
||||
friend struct AIAccessConst<T>;
|
||||
friend struct AIAccess<T>;
|
||||
|
||||
// Locking control.
|
||||
@@ -411,6 +471,14 @@ protected:
|
||||
public:
|
||||
// Only for use by AITHREADSAFESIMPLE, see below.
|
||||
AIThreadSafeSimple(T* object) { llassert(object == AIThreadSafeBits<T>::ptr()); }
|
||||
|
||||
#if LL_DEBUG
|
||||
// Can only be locked when there still exists an AIAccess object that
|
||||
// references this object and will access it upon destruction.
|
||||
// If the assertion fails, make sure that such AIAccess object is
|
||||
// destructed before the deletion of this object.
|
||||
~AIThreadSafeSimple() { llassert(!mMutex.isLocked()); }
|
||||
#endif
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -420,14 +488,14 @@ public:
|
||||
*
|
||||
* <code>
|
||||
* Foo foo(x, y);
|
||||
* static Bar bar;
|
||||
* static Bar bar(0.1, true);
|
||||
* </code>
|
||||
*
|
||||
* One can instantiate a thread-safe instance with
|
||||
*
|
||||
* <code>
|
||||
* AITHREADSAFESIMPLE(Foo, foo, (x, y));
|
||||
* static AITHREADSAFESIMPLE(Bar, bar, );
|
||||
* static AITHREADSAFESIMPLE(Bar, bar, (0.1, true));
|
||||
* </code>
|
||||
*
|
||||
* Note: This macro does not allow to allocate such object on the heap.
|
||||
@@ -439,18 +507,20 @@ public:
|
||||
* @brief A wrapper class for objects that need to be accessed by more than one thread.
|
||||
*
|
||||
* This class is the same as an AIThreadSafeSimple wrapper, except that it can only
|
||||
* be used for default constructed objects.
|
||||
* be used for default constructed objects, or constructed with one parameter.
|
||||
*
|
||||
* For example, instead of
|
||||
*
|
||||
* <code>
|
||||
* Foo foo;
|
||||
* Bar bar(0.1);
|
||||
* </code>
|
||||
*
|
||||
* One would use
|
||||
*
|
||||
* <code>
|
||||
* AIThreadSafeSimpleDC<Foo> foo;
|
||||
* AIThreadSafeSimpleDC<Bar> bar(0.1);
|
||||
* </code>
|
||||
*
|
||||
* The advantage over AITHREADSAFESIMPLE is that this object can be allocated with
|
||||
@@ -468,10 +538,12 @@ class AIThreadSafeSimpleDC : public AIThreadSafeSimple<T>
|
||||
public:
|
||||
// Construct a wrapper around a default constructed object.
|
||||
AIThreadSafeSimpleDC(void) { new (AIThreadSafeSimple<T>::ptr()) T; }
|
||||
// Allow an arbitrary parameter to be passed for construction.
|
||||
template<typename T2> AIThreadSafeSimpleDC(T2 const& val) { new (AIThreadSafeSimple<T>::ptr()) T(val); }
|
||||
|
||||
protected:
|
||||
// For use by AIThreadSafeSimpleDCRootPool
|
||||
AIThreadSafeSimpleDC(LLAPRPool& parent) : AIThreadSafeSimple<T>(parent) { new (AIThreadSafeSimple<T>::ptr()) T; }
|
||||
AIThreadSafeSimpleDC(LLAPRRootPool& parent) : AIThreadSafeSimple<T>(parent) { new (AIThreadSafeSimple<T>::ptr()) T; }
|
||||
};
|
||||
|
||||
// Helper class for AIThreadSafeSimpleDCRootPool to assure initialization of
|
||||
@@ -493,7 +565,7 @@ private:
|
||||
* for the internally used mutexes and condition, instead of using the current threads
|
||||
* root pool. The advantage of this is that it can be used for objects that need to
|
||||
* be accessed from the destructors of global objects (after main). The disadvantage
|
||||
* is that it's less efficient to use your own root pool, therefore it's use should be
|
||||
* is that it's less efficient to use your own root pool, therefore its use should be
|
||||
* restricted to those cases where it is absolutely necessary.
|
||||
*/
|
||||
template<typename T>
|
||||
@@ -509,13 +581,13 @@ public:
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Write lock object and provide read/write access.
|
||||
* @brief Write lock object and provide read access.
|
||||
*/
|
||||
template<typename T>
|
||||
struct AIAccess
|
||||
struct AIAccessConst
|
||||
{
|
||||
//! Construct a AIAccess from a non-constant AIThreadSafeSimple.
|
||||
AIAccess(AIThreadSafeSimple<T>& wrapper) : mWrapper(wrapper)
|
||||
//! Construct a AIAccessConst from a constant AIThreadSafeSimple.
|
||||
AIAccessConst(AIThreadSafeSimple<T> const& wrapper) : mWrapper(const_cast<AIThreadSafeSimple<T>&>(wrapper))
|
||||
#if AI_NEED_ACCESS_CC
|
||||
, mIsCopyConstructed(false)
|
||||
#endif
|
||||
@@ -524,12 +596,12 @@ struct AIAccess
|
||||
}
|
||||
|
||||
//! Access the underlaying object for (read and) write access.
|
||||
T* operator->() const { return this->mWrapper.ptr(); }
|
||||
T const* operator->() const { return this->mWrapper.ptr(); }
|
||||
|
||||
//! Access the underlaying object for (read and) write access.
|
||||
T& operator*() const { return *this->mWrapper.ptr(); }
|
||||
T const& operator*() const { return *this->mWrapper.ptr(); }
|
||||
|
||||
~AIAccess()
|
||||
~AIAccessConst()
|
||||
{
|
||||
#if AI_NEED_ACCESS_CC
|
||||
if (mIsCopyConstructed) return;
|
||||
@@ -538,17 +610,229 @@ struct AIAccess
|
||||
}
|
||||
|
||||
protected:
|
||||
AIThreadSafeSimple<T>& mWrapper; //!< Reference to the object that we provide access to.
|
||||
AIThreadSafeSimple<T>& mWrapper; //!< Reference to the object that we provide access to.
|
||||
|
||||
#if AI_NEED_ACCESS_CC
|
||||
bool mIsCopyConstructed;
|
||||
public:
|
||||
AIAccess(AIAccess const& orig) : mWrapper(orig.mWrapper), mIsCopyConstructed(true) { }
|
||||
AIAccessConst(AIAccessConst const& orig) : mWrapper(orig.mWrapper), mIsCopyConstructed(true) { }
|
||||
#else
|
||||
private:
|
||||
// Disallow copy constructing directly.
|
||||
AIAccess(AIAccess const&);
|
||||
AIAccessConst(AIAccessConst const&);
|
||||
#endif
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Write lock object and provide read/write access.
|
||||
*/
|
||||
template<typename T>
|
||||
struct AIAccess : public AIAccessConst<T>
|
||||
{
|
||||
//! Construct a AIAccess from a non-constant AIThreadSafeSimple.
|
||||
AIAccess(AIThreadSafeSimple<T>& wrapper) : AIAccessConst<T>(wrapper) { }
|
||||
|
||||
//! Access the underlaying object for (read and) write access.
|
||||
T* operator->() const { return this->mWrapper.ptr(); }
|
||||
|
||||
//! Access the underlaying object for (read and) write access.
|
||||
T& operator*() const { return *this->mWrapper.ptr(); }
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief A wrapper class for objects that should only be accessed by a single thread.
|
||||
*
|
||||
* Use AITHREADSAFESINGLETHREAD to define instances of any type, and use AISTAccess
|
||||
* to get access to the instance.
|
||||
*
|
||||
* For example,
|
||||
*
|
||||
* <code>
|
||||
* class Foo { public: Foo(int, int); };
|
||||
*
|
||||
* AITHREADSAFESINGLETHREAD(Foo, foo, (2, 3));
|
||||
*
|
||||
* AISTAccess<Foo> foo_w(foo);
|
||||
* // Use foo_w-> for read and write access.
|
||||
* </code>
|
||||
*/
|
||||
template<typename T>
|
||||
class AIThreadSafeSingleThread : public AIThreadSafeBits<T>
|
||||
{
|
||||
protected:
|
||||
// Only these one may access the object (through ptr()).
|
||||
friend struct AISTAccessConst<T>;
|
||||
friend struct AISTAccess<T>;
|
||||
|
||||
// For use by AIThreadSafeSingleThreadDC.
|
||||
AIThreadSafeSingleThread(void)
|
||||
#ifdef LL_DEBUG
|
||||
: mAccessed(false)
|
||||
#endif
|
||||
{ }
|
||||
|
||||
#ifdef LL_DEBUG
|
||||
mutable bool mAccessed;
|
||||
mutable apr_os_thread_t mTheadID;
|
||||
|
||||
void accessed(void) const
|
||||
{
|
||||
if (!mAccessed)
|
||||
{
|
||||
mAccessed = true;
|
||||
mTheadID = apr_os_thread_current();
|
||||
}
|
||||
else
|
||||
{
|
||||
llassert_always(apr_os_thread_equal(mTheadID, apr_os_thread_current()));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
public:
|
||||
// Only for use by AITHREADSAFESINGLETHREAD, see below.
|
||||
AIThreadSafeSingleThread(T* object)
|
||||
#ifdef LL_DEBUG
|
||||
: mAccessed(false)
|
||||
#endif
|
||||
{
|
||||
llassert(object == AIThreadSafeBits<T>::ptr());
|
||||
}
|
||||
|
||||
private:
|
||||
// Disallow copying or assignments.
|
||||
AIThreadSafeSingleThread(AIThreadSafeSingleThread const&);
|
||||
void operator=(AIThreadSafeSingleThread const&);
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief A wrapper class for objects that should only be accessed by a single thread.
|
||||
*
|
||||
* This class is the same as an AIThreadSafeSingleThread wrapper, except that it can only
|
||||
* be used for default constructed objects, or constructed with one parameter.
|
||||
*
|
||||
* For example, instead of
|
||||
*
|
||||
* <code>
|
||||
* Foo foo;
|
||||
* Bar bar(0.1);
|
||||
* </code>
|
||||
*
|
||||
* One would use
|
||||
*
|
||||
* <code>
|
||||
* AIThreadSafeSingleThreadDC<Foo> foo;
|
||||
* AIThreadSafeSingleThreadDC<Bar> bar(0.1);
|
||||
* </code>
|
||||
*
|
||||
* The advantage over AITHREADSAFESINGLETHREAD is that this object can be allocated with
|
||||
* new on the heap. For example:
|
||||
*
|
||||
* <code>
|
||||
* AIThreadSafeSingleThreadDC<Foo>* ptr = new AIThreadSafeSingleThreadDC<Foo>;
|
||||
* </code>
|
||||
*
|
||||
* which is not possible with AITHREADSAFESINGLETHREAD.
|
||||
*
|
||||
* This class is primarily intended to test if some (member) variable needs locking,
|
||||
* during development (in debug mode), and is therefore more flexible in that it
|
||||
* automatically converts to the underlying type, can be assigned to and can be
|
||||
* written to an ostream, as if it wasn't wrapped at all. This is to reduce the
|
||||
* impact on the source code.
|
||||
*/
|
||||
template<typename T>
|
||||
class AIThreadSafeSingleThreadDC : public AIThreadSafeSingleThread<T>
|
||||
{
|
||||
public:
|
||||
// Construct a wrapper around a default constructed object.
|
||||
AIThreadSafeSingleThreadDC(void) { new (AIThreadSafeSingleThread<T>::ptr()) T; }
|
||||
// Allow an arbitrary parameter to be passed for construction.
|
||||
template<typename T2> AIThreadSafeSingleThreadDC(T2 const& val) { new (AIThreadSafeSingleThread<T>::ptr()) T(val); }
|
||||
|
||||
// Allow assigning with T.
|
||||
AIThreadSafeSingleThreadDC& operator=(T const& val) { AIThreadSafeSingleThread<T>::accessed(); *AIThreadSafeSingleThread<T>::ptr() = val; return *this; }
|
||||
// Allow writing to an ostream.
|
||||
friend std::ostream& operator<<(std::ostream& os, AIThreadSafeSingleThreadDC const& wrapped_val) { wrapped_val.accessed(); return os << *wrapped_val.ptr(); }
|
||||
|
||||
// Automatic conversion to T.
|
||||
operator T&(void) { AIThreadSafeSingleThread<T>::accessed(); return *AIThreadSafeSingleThread<T>::ptr(); }
|
||||
operator T const&(void) const { AIThreadSafeSingleThread<T>::accessed(); return *AIThreadSafeSingleThread<T>::ptr(); }
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Instantiate a static, global or local object of a given type wrapped in AIThreadSafeSingleThread, using an arbitrary constructor.
|
||||
*
|
||||
* For example, instead of doing
|
||||
*
|
||||
* <code>
|
||||
* Foo foo(x, y);
|
||||
* static Bar bar;
|
||||
* </code>
|
||||
*
|
||||
* One can instantiate a thread-safe instance with
|
||||
*
|
||||
* <code>
|
||||
* AITHREADSAFESINGLETHREAD(Foo, foo, (x, y));
|
||||
* static AITHREADSAFESINGLETHREAD(Bar, bar, );
|
||||
* </code>
|
||||
*
|
||||
* Note: This macro does not allow to allocate such object on the heap.
|
||||
* If that is needed, have a look at AIThreadSafeSingleThreadDC.
|
||||
*/
|
||||
#define AITHREADSAFESINGLETHREAD(type, var, paramlist) AIThreadSafeSingleThread<type> var(new (var.memory()) type paramlist)
|
||||
|
||||
/**
|
||||
* @brief Access single threaded object for read access.
|
||||
*/
|
||||
template<typename T>
|
||||
struct AISTAccessConst
|
||||
{
|
||||
//! Construct a AISTAccessConst from a constant AIThreadSafeSingleThread.
|
||||
AISTAccessConst(AIThreadSafeSingleThread<T> const& wrapper) : mWrapper(const_cast<AIThreadSafeSingleThread<T>&>(wrapper))
|
||||
{
|
||||
#if LL_DEBUG
|
||||
wrapper.accessed();
|
||||
#endif
|
||||
}
|
||||
|
||||
//! Access the underlaying object for read access.
|
||||
T const* operator->() const { return this->mWrapper.ptr(); }
|
||||
|
||||
//! Access the underlaying object for read write access.
|
||||
T const& operator*() const { return *this->mWrapper.ptr(); }
|
||||
|
||||
protected:
|
||||
AIThreadSafeSingleThread<T>& mWrapper; //!< Reference to the object that we provide access to.
|
||||
|
||||
#if AI_NEED_ACCESS_CC
|
||||
public:
|
||||
AISTAccessConst(AISTAccessConst const& orig) : mWrapper(orig.mWrapper) { }
|
||||
#else
|
||||
private:
|
||||
// Disallow copy constructing directly.
|
||||
AISTAccessConst(AISTAccessConst const&);
|
||||
#endif
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Access single threaded object for read/write access.
|
||||
*/
|
||||
template<typename T>
|
||||
struct AISTAccess : public AISTAccessConst<T>
|
||||
{
|
||||
//! Construct a AISTAccess from a non-constant AIThreadSafeSingleThread.
|
||||
AISTAccess(AIThreadSafeSingleThread<T>& wrapper) : AISTAccessConst<T>(wrapper)
|
||||
{
|
||||
#if LL_DEBUG
|
||||
wrapper.accessed();
|
||||
#endif
|
||||
}
|
||||
|
||||
//! Access the underlaying object for (read and) write access.
|
||||
T* operator->() const { return this->mWrapper.ptr(); }
|
||||
|
||||
//! Access the underlaying object for (read and) write access.
|
||||
T& operator*() const { return *this->mWrapper.ptr(); }
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -124,7 +124,7 @@ public:
|
||||
|
||||
// NOTE: This next two funtions are only included here
|
||||
// for those too familiar with the LLLinkedList template class.
|
||||
// They are depreciated. resetList() is unecessary while
|
||||
// They are deprecated. resetList() is unecessary while
|
||||
// getCurrentData() is identical to getNextData() and has
|
||||
// a misleading name.
|
||||
//
|
||||
@@ -604,7 +604,7 @@ BOOL LLDoubleLinkedList<DATA_TYPE>::checkData(const DATA_TYPE *data)
|
||||
|
||||
// NOTE: This next two funtions are only included here
|
||||
// for those too familiar with the LLLinkedList template class.
|
||||
// They are depreciated. resetList() is unecessary while
|
||||
// They are deprecated. resetList() is unecessary while
|
||||
// getCurrentData() is identical to getNextData() and has
|
||||
// a misleading name.
|
||||
//
|
||||
|
||||
@@ -153,11 +153,6 @@ const char LAND_LAYER_CODE = 'L';
|
||||
const char WATER_LAYER_CODE = 'W';
|
||||
const char WIND_LAYER_CODE = '7';
|
||||
const char CLOUD_LAYER_CODE = '8';
|
||||
// Extended land layer for Aurora Sim
|
||||
const char AURORA_LAND_LAYER_CODE = 'M';
|
||||
const char AURORA_WATER_LAYER_CODE = 'X';
|
||||
const char AURORA_WIND_LAYER_CODE = '9';
|
||||
const char AURORA_CLOUD_LAYER_CODE = ':';
|
||||
|
||||
// keys
|
||||
// Bit masks for various keyboard modifier keys.
|
||||
@@ -380,7 +375,7 @@ const U32 PARCEL_MEDIA_COMMAND_LOOP_SET = 13;
|
||||
const U32 MAP_ITEM_TELEHUB = 0x01;
|
||||
const U32 MAP_ITEM_PG_EVENT = 0x02;
|
||||
const U32 MAP_ITEM_MATURE_EVENT = 0x03;
|
||||
const U32 MAP_ITEM_POPULAR = 0x04;
|
||||
//const U32 MAP_ITEM_POPULAR = 0x04; // No longer supported, 2009-03-02 KLW
|
||||
//const U32 MAP_ITEM_AGENT_COUNT = 0x05;
|
||||
const U32 MAP_ITEM_AGENT_LOCATIONS = 0x06;
|
||||
const U32 MAP_ITEM_LAND_FOR_SALE = 0x07;
|
||||
|
||||
177
indra/llcommon/ll_template_cast.h
Normal file
177
indra/llcommon/ll_template_cast.h
Normal file
@@ -0,0 +1,177 @@
|
||||
/**
|
||||
* @file ll_template_cast.h
|
||||
* @author Nat Goodspeed
|
||||
* @date 2009-11-21
|
||||
* @brief Define ll_template_cast function
|
||||
*
|
||||
* $LicenseInfo:firstyear=2009&license=viewerlgpl$
|
||||
* Second Life Viewer Source Code
|
||||
* Copyright (C) 2010, Linden Research, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation;
|
||||
* version 2.1 of the License only.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
|
||||
* $/LicenseInfo$
|
||||
*/
|
||||
|
||||
#if ! defined(LL_LL_TEMPLATE_CAST_H)
|
||||
#define LL_LL_TEMPLATE_CAST_H
|
||||
|
||||
/**
|
||||
* Implementation for ll_template_cast() (q.v.).
|
||||
*
|
||||
* Default implementation: trying to cast two completely unrelated types
|
||||
* returns 0. Typically you'd specify T and U as pointer types, but in fact T
|
||||
* can be any type that can be initialized with 0.
|
||||
*/
|
||||
template <typename T, typename U>
|
||||
struct ll_template_cast_impl
|
||||
{
|
||||
T operator()(U)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* ll_template_cast<T>(some_value) is for use in a template function when
|
||||
* some_value might be of arbitrary type, but you want to recognize type T
|
||||
* specially.
|
||||
*
|
||||
* It's designed for use with pointer types. Example:
|
||||
* @code
|
||||
* struct SpecialClass
|
||||
* {
|
||||
* void someMethod(const std::string&) const;
|
||||
* };
|
||||
*
|
||||
* template <class REALCLASS>
|
||||
* void somefunc(const REALCLASS& instance)
|
||||
* {
|
||||
* const SpecialClass* ptr = ll_template_cast<const SpecialClass*>(&instance);
|
||||
* if (ptr)
|
||||
* {
|
||||
* ptr->someMethod("Call method only available on SpecialClass");
|
||||
* }
|
||||
* }
|
||||
* @endcode
|
||||
*
|
||||
* Why is this better than dynamic_cast<>? Because unless OtherClass is
|
||||
* polymorphic, the following won't even compile (gcc 4.0.1):
|
||||
* @code
|
||||
* OtherClass other;
|
||||
* SpecialClass* ptr = dynamic_cast<SpecialClass*>(&other);
|
||||
* @endcode
|
||||
* to say nothing of this:
|
||||
* @code
|
||||
* void function(int);
|
||||
* SpecialClass* ptr = dynamic_cast<SpecialClass*>(&function);
|
||||
* @endcode
|
||||
* ll_template_cast handles these kinds of cases by returning 0.
|
||||
*/
|
||||
template <typename T, typename U>
|
||||
T ll_template_cast(U value)
|
||||
{
|
||||
return ll_template_cast_impl<T, U>()(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation for ll_template_cast() (q.v.).
|
||||
*
|
||||
* Implementation for identical types: return same value.
|
||||
*/
|
||||
template <typename T>
|
||||
struct ll_template_cast_impl<T, T>
|
||||
{
|
||||
T operator()(T value)
|
||||
{
|
||||
return value;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* LL_TEMPLATE_CONVERTIBLE(dest, source) asserts that, for a value @c s of
|
||||
* type @c source, <tt>ll_template_cast<dest>(s)</tt> will return @c s --
|
||||
* presuming that @c source can be converted to @c dest by the normal rules of
|
||||
* C++.
|
||||
*
|
||||
* By default, <tt>ll_template_cast<dest>(s)</tt> will return 0 unless @c s's
|
||||
* type is literally identical to @c dest. (This is because of the
|
||||
* straightforward application of template specialization rules.) That can
|
||||
* lead to surprising results, e.g.:
|
||||
*
|
||||
* @code
|
||||
* Foo myFoo;
|
||||
* const Foo* fooptr = ll_template_cast<const Foo*>(&myFoo);
|
||||
* @endcode
|
||||
*
|
||||
* Here @c fooptr will be 0 because <tt>&myFoo</tt> is of type <tt>Foo*</tt>
|
||||
* -- @em not <tt>const Foo*</tt>. (Declaring <tt>const Foo myFoo;</tt> would
|
||||
* force the compiler to do the right thing.)
|
||||
*
|
||||
* More disappointingly:
|
||||
* @code
|
||||
* struct Base {};
|
||||
* struct Subclass: public Base {};
|
||||
* Subclass object;
|
||||
* Base* ptr = ll_template_cast<Base*>(&object);
|
||||
* @endcode
|
||||
*
|
||||
* Here @c ptr will be 0 because <tt>&object</tt> is of type
|
||||
* <tt>Subclass*</tt> rather than <tt>Base*</tt>. We @em want this cast to
|
||||
* succeed, but without our help ll_template_cast can't recognize it.
|
||||
*
|
||||
* The following would suffice:
|
||||
* @code
|
||||
* LL_TEMPLATE_CONVERTIBLE(Base*, Subclass*);
|
||||
* ...
|
||||
* Base* ptr = ll_template_cast<Base*>(&object);
|
||||
* @endcode
|
||||
*
|
||||
* However, as noted earlier, this is easily fooled:
|
||||
* @code
|
||||
* const Base* ptr = ll_template_cast<const Base*>(&object);
|
||||
* @endcode
|
||||
* would still produce 0 because we haven't yet seen:
|
||||
* @code
|
||||
* LL_TEMPLATE_CONVERTIBLE(const Base*, Subclass*);
|
||||
* @endcode
|
||||
*
|
||||
* @TODO
|
||||
* This macro should use Boost type_traits facilities for stripping and
|
||||
* re-adding @c const and @c volatile qualifiers so that invoking
|
||||
* LL_TEMPLATE_CONVERTIBLE(dest, source) will automatically generate all
|
||||
* permitted permutations. It's really not fair to the coder to require
|
||||
* separate:
|
||||
* @code
|
||||
* LL_TEMPLATE_CONVERTIBLE(Base*, Subclass*);
|
||||
* LL_TEMPLATE_CONVERTIBLE(const Base*, Subclass*);
|
||||
* LL_TEMPLATE_CONVERTIBLE(const Base*, const Subclass*);
|
||||
* @endcode
|
||||
*
|
||||
* (Naturally we omit <tt>LL_TEMPLATE_CONVERTIBLE(Base*, const Subclass*)</tt>
|
||||
* because that's not permitted by normal C++ assignment anyway.)
|
||||
*/
|
||||
#define LL_TEMPLATE_CONVERTIBLE(DEST, SOURCE) \
|
||||
template <> \
|
||||
struct ll_template_cast_impl<DEST, SOURCE> \
|
||||
{ \
|
||||
DEST operator()(SOURCE wrapper) \
|
||||
{ \
|
||||
return wrapper; \
|
||||
} \
|
||||
}
|
||||
|
||||
#endif /* ! defined(LL_LL_TEMPLATE_CAST_H) */
|
||||
134
indra/llcommon/llallocator.cpp
Normal file
134
indra/llcommon/llallocator.cpp
Normal file
@@ -0,0 +1,134 @@
|
||||
/**
|
||||
* @file llallocator.cpp
|
||||
* @brief Implementation of the LLAllocator class.
|
||||
*
|
||||
* $LicenseInfo:firstyear=2009&license=viewerlgpl$
|
||||
* Second Life Viewer Source Code
|
||||
* Copyright (C) 2010, Linden Research, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation;
|
||||
* version 2.1 of the License only.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
|
||||
* $/LicenseInfo$
|
||||
*/
|
||||
|
||||
#include "linden_common.h"
|
||||
#include "llallocator.h"
|
||||
|
||||
#if LL_USE_TCMALLOC
|
||||
|
||||
#include "google/heap-profiler.h"
|
||||
#include "google/commandlineflags_public.h"
|
||||
|
||||
DECLARE_bool(heap_profile_use_stack_trace);
|
||||
//DECLARE_double(tcmalloc_release_rate);
|
||||
|
||||
// static
|
||||
void LLAllocator::pushMemType(S32 type)
|
||||
{
|
||||
if(isProfiling())
|
||||
{
|
||||
PushMemType(type);
|
||||
}
|
||||
}
|
||||
|
||||
// static
|
||||
S32 LLAllocator::popMemType()
|
||||
{
|
||||
if (isProfiling())
|
||||
{
|
||||
return PopMemType();
|
||||
}
|
||||
else
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
void LLAllocator::setProfilingEnabled(bool should_enable)
|
||||
{
|
||||
// NULL disables dumping to disk
|
||||
static char const * const PREFIX = NULL;
|
||||
if(should_enable)
|
||||
{
|
||||
HeapProfilerSetUseStackTrace(false);
|
||||
HeapProfilerStart(PREFIX);
|
||||
}
|
||||
else
|
||||
{
|
||||
HeapProfilerStop();
|
||||
}
|
||||
}
|
||||
|
||||
// static
|
||||
bool LLAllocator::isProfiling()
|
||||
{
|
||||
return IsHeapProfilerRunning();
|
||||
}
|
||||
|
||||
std::string LLAllocator::getRawProfile()
|
||||
{
|
||||
// *TODO - fix google-perftools to accept an buffer to avoid this
|
||||
// malloc-copy-free cycle.
|
||||
char * buffer = GetHeapProfile();
|
||||
std::string ret = buffer;
|
||||
free(buffer);
|
||||
return ret;
|
||||
}
|
||||
|
||||
#else // LL_USE_TCMALLOC
|
||||
|
||||
//
|
||||
// stub implementations for when tcmalloc is disabled
|
||||
//
|
||||
|
||||
// static
|
||||
void LLAllocator::pushMemType(S32 type)
|
||||
{
|
||||
}
|
||||
|
||||
// static
|
||||
S32 LLAllocator::popMemType()
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
void LLAllocator::setProfilingEnabled(bool should_enable)
|
||||
{
|
||||
}
|
||||
|
||||
// static
|
||||
bool LLAllocator::isProfiling()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string LLAllocator::getRawProfile()
|
||||
{
|
||||
return std::string();
|
||||
}
|
||||
|
||||
#endif // LL_USE_TCMALLOC
|
||||
|
||||
LLAllocatorHeapProfile const & LLAllocator::getProfile()
|
||||
{
|
||||
mProf.mLines.clear();
|
||||
|
||||
// *TODO - avoid making all these extra copies of things...
|
||||
std::string prof_text = getRawProfile();
|
||||
//std::cout << prof_text << std::endl;
|
||||
mProf.parse(prof_text);
|
||||
return mProf;
|
||||
}
|
||||
57
indra/llcommon/llallocator.h
Normal file
57
indra/llcommon/llallocator.h
Normal file
@@ -0,0 +1,57 @@
|
||||
/**
|
||||
* @file llallocator.h
|
||||
* @brief Declaration of the LLAllocator class.
|
||||
*
|
||||
* $LicenseInfo:firstyear=2009&license=viewerlgpl$
|
||||
* Second Life Viewer Source Code
|
||||
* Copyright (C) 2010, Linden Research, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation;
|
||||
* version 2.1 of the License only.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
|
||||
* $/LicenseInfo$
|
||||
*/
|
||||
|
||||
#ifndef LL_LLALLOCATOR_H
|
||||
#define LL_LLALLOCATOR_H
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "llmemtype.h"
|
||||
#include "llallocator_heap_profile.h"
|
||||
|
||||
class LL_COMMON_API LLAllocator {
|
||||
friend class LLMemoryView;
|
||||
friend class LLMemType;
|
||||
|
||||
private:
|
||||
static void pushMemType(S32 type);
|
||||
static S32 popMemType();
|
||||
|
||||
public:
|
||||
void setProfilingEnabled(bool should_enable);
|
||||
|
||||
static bool isProfiling();
|
||||
|
||||
LLAllocatorHeapProfile const & getProfile();
|
||||
|
||||
private:
|
||||
std::string getRawProfile();
|
||||
|
||||
private:
|
||||
LLAllocatorHeapProfile mProf;
|
||||
};
|
||||
|
||||
#endif // LL_LLALLOCATOR_H
|
||||
147
indra/llcommon/llallocator_heap_profile.cpp
Normal file
147
indra/llcommon/llallocator_heap_profile.cpp
Normal file
@@ -0,0 +1,147 @@
|
||||
/**
|
||||
* @file llallocator_heap_profile.cpp
|
||||
* @brief Implementation of the parser for tcmalloc heap profile data.
|
||||
* @author Brad Kittenbrink
|
||||
*
|
||||
* $LicenseInfo:firstyear=2009&license=viewerlgpl$
|
||||
* Second Life Viewer Source Code
|
||||
* Copyright (C) 2010, Linden Research, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation;
|
||||
* version 2.1 of the License only.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
|
||||
* $/LicenseInfo$
|
||||
*/
|
||||
|
||||
#include "linden_common.h"
|
||||
#include "llallocator_heap_profile.h"
|
||||
|
||||
#if LL_MSVC
|
||||
// disable warning about boost::lexical_cast returning uninitialized data
|
||||
// when it fails to parse the string
|
||||
#pragma warning (disable:4701)
|
||||
#pragma warning (disable:4702)
|
||||
#endif
|
||||
|
||||
#include <boost/algorithm/string/split.hpp>
|
||||
#include <boost/bind.hpp>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <boost/range/iterator_range.hpp>
|
||||
|
||||
static const std::string HEAP_PROFILE_MAGIC_STR = "heap profile:";
|
||||
|
||||
static bool is_separator(char c)
|
||||
{
|
||||
return isspace(c) || c == '[' || c == ']' || c == ':';
|
||||
}
|
||||
|
||||
void LLAllocatorHeapProfile::parse(std::string const & prof_text)
|
||||
{
|
||||
// a typedef for handling a token in the string buffer
|
||||
// it's a begin/end pair of string::const_iterators
|
||||
typedef boost::iterator_range<std::string::const_iterator> range_t;
|
||||
|
||||
mLines.clear();
|
||||
|
||||
if(prof_text.compare(0, HEAP_PROFILE_MAGIC_STR.length(), HEAP_PROFILE_MAGIC_STR) != 0)
|
||||
{
|
||||
// *TODO - determine if there should be some better error state than
|
||||
// mLines being empty. -brad
|
||||
llwarns << "invalid heap profile data passed into parser." << llendl;
|
||||
return;
|
||||
}
|
||||
|
||||
std::vector< range_t > prof_lines;
|
||||
|
||||
std::string::const_iterator prof_begin = prof_text.begin() + HEAP_PROFILE_MAGIC_STR.length();
|
||||
|
||||
range_t prof_range(prof_begin, prof_text.end());
|
||||
boost::algorithm::split(prof_lines,
|
||||
prof_range,
|
||||
boost::bind(std::equal_to<llwchar>(), '\n', _1));
|
||||
|
||||
std::vector< range_t >::const_iterator i;
|
||||
for(i = prof_lines.begin(); i != prof_lines.end() && !i->empty(); ++i)
|
||||
{
|
||||
range_t const & line_text = *i;
|
||||
|
||||
std::vector<range_t> line_elems;
|
||||
|
||||
boost::algorithm::split(line_elems,
|
||||
line_text,
|
||||
is_separator);
|
||||
|
||||
std::vector< range_t >::iterator j;
|
||||
j = line_elems.begin();
|
||||
|
||||
while(j != line_elems.end() && j->empty()) { ++j; } // skip any separator tokens
|
||||
llassert_always(j != line_elems.end());
|
||||
U32 live_count = boost::lexical_cast<U32>(*j);
|
||||
++j;
|
||||
|
||||
while(j != line_elems.end() && j->empty()) { ++j; } // skip any separator tokens
|
||||
llassert_always(j != line_elems.end());
|
||||
U64 live_size = boost::lexical_cast<U64>(*j);
|
||||
++j;
|
||||
|
||||
while(j != line_elems.end() && j->empty()) { ++j; } // skip any separator tokens
|
||||
llassert_always(j != line_elems.end());
|
||||
U32 tot_count = boost::lexical_cast<U32>(*j);
|
||||
++j;
|
||||
|
||||
while(j != line_elems.end() && j->empty()) { ++j; } // skip any separator tokens
|
||||
llassert_always(j != line_elems.end());
|
||||
U64 tot_size = boost::lexical_cast<U64>(*j);
|
||||
++j;
|
||||
|
||||
while(j != line_elems.end() && j->empty()) { ++j; } // skip any separator tokens
|
||||
llassert(j != line_elems.end());
|
||||
if (j != line_elems.end())
|
||||
{
|
||||
++j; // skip the '@'
|
||||
|
||||
mLines.push_back(line(live_count, live_size, tot_count, tot_size));
|
||||
line & current_line = mLines.back();
|
||||
|
||||
for(; j != line_elems.end(); ++j)
|
||||
{
|
||||
if(!j->empty())
|
||||
{
|
||||
U32 marker = boost::lexical_cast<U32>(*j);
|
||||
current_line.mTrace.push_back(marker);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// *TODO - parse MAPPED_LIBRARIES section here if we're ever interested in it
|
||||
}
|
||||
|
||||
void LLAllocatorHeapProfile::dump(std::ostream & out) const
|
||||
{
|
||||
lines_t::const_iterator i;
|
||||
for(i = mLines.begin(); i != mLines.end(); ++i)
|
||||
{
|
||||
out << i->mLiveCount << ": " << i->mLiveSize << '[' << i->mTotalCount << ": " << i->mTotalSize << "] @";
|
||||
|
||||
stack_trace::const_iterator j;
|
||||
for(j = i->mTrace.begin(); j != i->mTrace.end(); ++j)
|
||||
{
|
||||
out << ' ' << *j;
|
||||
}
|
||||
out << '\n';
|
||||
}
|
||||
out.flush();
|
||||
}
|
||||
|
||||
71
indra/llcommon/llallocator_heap_profile.h
Normal file
71
indra/llcommon/llallocator_heap_profile.h
Normal file
@@ -0,0 +1,71 @@
|
||||
/**
|
||||
* @file llallocator_heap_profile.h
|
||||
* @brief Declaration of the parser for tcmalloc heap profile data.
|
||||
* @author Brad Kittenbrink
|
||||
*
|
||||
* $LicenseInfo:firstyear=2009&license=viewerlgpl$
|
||||
* Second Life Viewer Source Code
|
||||
* Copyright (C) 2010, Linden Research, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation;
|
||||
* version 2.1 of the License only.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
|
||||
* $/LicenseInfo$
|
||||
*/
|
||||
|
||||
#ifndef LL_LLALLOCATOR_HEAP_PROFILE_H
|
||||
#define LL_LLALLOCATOR_HEAP_PROFILE_H
|
||||
|
||||
#include "stdtypes.h"
|
||||
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
class LLAllocatorHeapProfile
|
||||
{
|
||||
public:
|
||||
typedef int stack_marker;
|
||||
|
||||
typedef std::vector<stack_marker> stack_trace;
|
||||
|
||||
struct line {
|
||||
line(U32 live_count, U64 live_size, U32 tot_count, U64 tot_size) :
|
||||
mLiveSize(live_size),
|
||||
mTotalSize(tot_size),
|
||||
mLiveCount(live_count),
|
||||
mTotalCount(tot_count)
|
||||
{
|
||||
}
|
||||
U64 mLiveSize, mTotalSize;
|
||||
U32 mLiveCount, mTotalCount;
|
||||
stack_trace mTrace;
|
||||
};
|
||||
|
||||
typedef std::vector<line> lines_t;
|
||||
|
||||
LLAllocatorHeapProfile()
|
||||
{
|
||||
}
|
||||
|
||||
void parse(std::string const & prof_text);
|
||||
|
||||
void dump(std::ostream & out) const;
|
||||
|
||||
public:
|
||||
lines_t mLines;
|
||||
};
|
||||
|
||||
|
||||
#endif // LL_LLALLOCATOR_HEAP_PROFILE_H
|
||||
@@ -74,7 +74,7 @@ S32 LL_HEARTBEAT_SIGNAL = (SIGRTMAX >= 0) ? (SIGRTMAX-0) : SIGUSR2;
|
||||
// the static application instance
|
||||
LLApp* LLApp::sApplication = NULL;
|
||||
|
||||
// Allows the generation of core files for post mortum under gdb
|
||||
// Allows the generation of core files for post mortem under gdb
|
||||
// and disables crashlogger
|
||||
BOOL LLApp::sDisableCrashlogger = FALSE;
|
||||
|
||||
@@ -396,11 +396,24 @@ bool LLApp::isQuitting()
|
||||
return (APP_STATUS_QUITTING == sStatus);
|
||||
}
|
||||
|
||||
// static
|
||||
bool LLApp::isExiting()
|
||||
{
|
||||
return isQuitting() || isError();
|
||||
}
|
||||
|
||||
void LLApp::disableCrashlogger()
|
||||
{
|
||||
// Disable Breakpad exception handler.
|
||||
sDisableCrashlogger = TRUE;
|
||||
}
|
||||
|
||||
// static
|
||||
bool LLApp::isCrashloggerDisabled()
|
||||
{
|
||||
return (sDisableCrashlogger == TRUE);
|
||||
}
|
||||
|
||||
#if !LL_WINDOWS
|
||||
// static
|
||||
U32 LLApp::getSigChildCount()
|
||||
@@ -734,7 +747,7 @@ void default_unix_signal_handler(int signum, siginfo_t *info, void *)
|
||||
llwarns << "Signal handler - Flagging error status and waiting for shutdown" << llendl;
|
||||
}
|
||||
|
||||
if(LLApp::sDisableCrashlogger) //Don't gracefully handle any signals crash and core for a gdb post mortum
|
||||
if (LLApp::isCrashloggerDisabled()) // Don't gracefully handle any signal, crash and core for a gdb post mortem
|
||||
{
|
||||
clear_signals();
|
||||
llwarns << "Fatal signal received, not handling the crash here, passing back to operating system" << llendl;
|
||||
|
||||
@@ -191,6 +191,11 @@ public:
|
||||
//
|
||||
virtual bool mainLoop() = 0; // Override for the application main loop. Needs to at least gracefully notice the QUITTING state and exit.
|
||||
|
||||
//
|
||||
// Crash logging
|
||||
//
|
||||
void disableCrashlogger(); // Let the OS handle the crashes
|
||||
static bool isCrashloggerDisabled(); // Get the here above set value
|
||||
|
||||
//
|
||||
// Application status
|
||||
@@ -214,9 +219,6 @@ public:
|
||||
//
|
||||
void setErrorHandler(LLAppErrorHandler handler);
|
||||
void setSyncErrorHandler(LLAppErrorHandler handler);
|
||||
|
||||
static BOOL sDisableCrashlogger; // Let the OS handle crashes for us.
|
||||
|
||||
#if !LL_WINDOWS
|
||||
//
|
||||
// Child process handling (Unix only for now)
|
||||
@@ -245,6 +247,7 @@ protected:
|
||||
static void setStatus(EAppStatus status); // Use this to change the application status.
|
||||
static EAppStatus sStatus; // Reflects current application status
|
||||
static BOOL sErrorThreadRunning; // Set while the error thread is running
|
||||
static BOOL sDisableCrashlogger; // Let the OS handle crashes for us.
|
||||
|
||||
#if !LL_WINDOWS
|
||||
static LLAtomicU32* sSigChildCount; // Number of SIGCHLDs received.
|
||||
|
||||
@@ -88,7 +88,7 @@ bool ll_apr_warn_status(apr_status_t status)
|
||||
|
||||
void ll_apr_assert_status(apr_status_t status)
|
||||
{
|
||||
llassert(ll_apr_warn_status(status) == false);
|
||||
llassert(!ll_apr_warn_status(status));
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
@@ -146,7 +146,7 @@ apr_status_t LLAPRFile::open(std::string const& filename, apr_int32_t flags, acc
|
||||
|
||||
apr_status_t status;
|
||||
{
|
||||
apr_pool_t* apr_file_open_pool;
|
||||
apr_pool_t* apr_file_open_pool; // The use of apr_pool_t is OK here.
|
||||
// This is a temporary variable for a pool that is passed directly to apr_file_open below.
|
||||
if (access_type == short_lived)
|
||||
{
|
||||
@@ -199,7 +199,6 @@ apr_status_t LLAPRFile::open(const std::string& filename, apr_int32_t flags, BOO
|
||||
// File I/O
|
||||
S32 LLAPRFile::read(void *buf, S32 nbytes)
|
||||
{
|
||||
//llassert_always(mFile); (ASC-TUDCC) -HgB
|
||||
if(!mFile)
|
||||
{
|
||||
llwarns << "apr mFile is removed by somebody else. Can not read." << llendl ;
|
||||
@@ -222,7 +221,6 @@ S32 LLAPRFile::read(void *buf, S32 nbytes)
|
||||
|
||||
S32 LLAPRFile::write(const void *buf, S32 nbytes)
|
||||
{
|
||||
// llassert_always(mFile); (ASC-TUDCC) -HgB
|
||||
if(!mFile)
|
||||
{
|
||||
llwarns << "apr mFile is removed by somebody else. Can not write." << llendl ;
|
||||
@@ -249,7 +247,7 @@ S32 LLAPRFile::seek(apr_seek_where_t where, S32 offset)
|
||||
}
|
||||
|
||||
//
|
||||
//*******************************************************************************************************************************
|
||||
// *******************************************************************************************************************************
|
||||
//static components of LLAPRFile
|
||||
//
|
||||
|
||||
@@ -504,5 +502,5 @@ bool LLAPRFile::removeDir(const std::string& dirname)
|
||||
}
|
||||
//
|
||||
//end of static components of LLAPRFile
|
||||
//*******************************************************************************************************************************
|
||||
// *******************************************************************************************************************************
|
||||
//
|
||||
|
||||
@@ -91,29 +91,8 @@ protected:
|
||||
apr_thread_mutex_t* mMutex;
|
||||
};
|
||||
|
||||
template <typename Type> class LLAtomic32
|
||||
{
|
||||
public:
|
||||
LLAtomic32<Type>() {};
|
||||
LLAtomic32<Type>(Type x) {apr_atomic_set32(&mData, apr_uint32_t(x)); };
|
||||
~LLAtomic32<Type>() {};
|
||||
|
||||
operator const Type() { apr_uint32_t data = apr_atomic_read32(&mData); return Type(data); }
|
||||
Type operator =(const Type& x) { apr_atomic_set32(&mData, apr_uint32_t(x)); return Type(mData); }
|
||||
void operator -=(Type x) { apr_atomic_sub32(&mData, apr_uint32_t(x)); }
|
||||
void operator +=(Type x) { apr_atomic_add32(&mData, apr_uint32_t(x)); }
|
||||
Type operator ++(int) { return apr_atomic_inc32(&mData); } // Type++
|
||||
Type operator --(int) { return apr_atomic_dec32(&mData); } // Type--
|
||||
|
||||
private:
|
||||
apr_uint32_t mData;
|
||||
};
|
||||
|
||||
typedef LLAtomic32<U32> LLAtomicU32;
|
||||
typedef LLAtomic32<S32> LLAtomicS32;
|
||||
|
||||
// File IO convenience functions.
|
||||
// Returns NULL if the file fails to openm sets *sizep to file size of not NULL
|
||||
// Returns NULL if the file fails to open, sets *sizep to file size if not NULL
|
||||
// abbreviated flags
|
||||
#define LL_APR_R (APR_READ) // "r"
|
||||
#define LL_APR_W (APR_CREATE|APR_TRUNCATE|APR_WRITE) // "w"
|
||||
@@ -131,7 +110,7 @@ typedef LLAtomic32<S32> LLAtomicS32;
|
||||
// especially do not put some time-costly operations between open() and close().
|
||||
// otherwise it might lock the APRFilePool.
|
||||
//there are two different apr_pools the APRFile can use:
|
||||
// 1, a temperary pool passed to an APRFile function, which is used within this function and only once.
|
||||
// 1, a temporary pool passed to an APRFile function, which is used within this function and only once.
|
||||
// 2, a global pool.
|
||||
//
|
||||
|
||||
@@ -168,7 +147,7 @@ public:
|
||||
apr_file_t* getFileHandle() {return mFile;}
|
||||
|
||||
//
|
||||
//*******************************************************************************************************************************
|
||||
// *******************************************************************************************************************************
|
||||
//static components
|
||||
//
|
||||
private:
|
||||
@@ -185,11 +164,11 @@ public:
|
||||
// Returns bytes read/written, 0 if read/write fails:
|
||||
static S32 readEx(const std::string& filename, void *buf, S32 offset, S32 nbytes);
|
||||
static S32 writeEx(const std::string& filename, void *buf, S32 offset, S32 nbytes);
|
||||
//*******************************************************************************************************************************
|
||||
// *******************************************************************************************************************************
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Function which approprately logs error or remains quiet on
|
||||
* @brief Function which appropriately logs error or remains quiet on
|
||||
* APR_SUCCESS.
|
||||
* @return Returns <code>true</code> if status is an error condition.
|
||||
*/
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* @file LLAPRPool.cpp
|
||||
* @file llaprpool.cpp
|
||||
*
|
||||
* Copyright (c) 2010, Aleric Inglewood.
|
||||
*
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* @file LLAPRPool.h
|
||||
* @file llaprpool.h
|
||||
* @brief Implementation of LLAPRPool.
|
||||
*
|
||||
* Copyright (c) 2010, Aleric Inglewood.
|
||||
@@ -60,9 +60,9 @@ extern void ll_init_apr();
|
||||
class LL_COMMON_API LLAPRPool
|
||||
{
|
||||
protected:
|
||||
apr_pool_t* mPool; //!< Pointer to the underlaying pool. NULL if not initialized.
|
||||
apr_pool_t* mPool; //!< Pointer to the underlaying pool. NULL if not initialized.
|
||||
LLAPRPool* mParent; //!< Pointer to the parent pool, if any. Only valid when mPool is non-zero.
|
||||
apr_os_thread_t mOwner; //!< The thread that owns this memory pool. Only valid when mPool is non-zero.
|
||||
apr_os_thread_t mOwner; //!< The thread that owns this memory pool. Only valid when mPool is non-zero.
|
||||
|
||||
public:
|
||||
//! Construct an uninitialized (destructed) pool.
|
||||
|
||||
@@ -214,17 +214,16 @@ LLAssetType::EType LLAssetType::lookupHumanReadable(const std::string& readable_
|
||||
bool LLAssetType::lookupCanLink(EType asset_type)
|
||||
{
|
||||
//Check that enabling all these other types as linkable doesn't break things.
|
||||
/*const LLAssetDictionary *dict = LLAssetDictionary::getInstance();
|
||||
const LLAssetDictionary *dict = LLAssetDictionary::getInstance();
|
||||
const AssetEntry *entry = dict->lookup(asset_type);
|
||||
if (entry)
|
||||
{
|
||||
return entry->mCanLink;
|
||||
}
|
||||
return false;
|
||||
*/
|
||||
|
||||
return (asset_type == AT_CLOTHING || asset_type == AT_OBJECT || asset_type == AT_CATEGORY ||
|
||||
asset_type == AT_BODYPART || asset_type == AT_GESTURE);
|
||||
/*return (asset_type == AT_CLOTHING || asset_type == AT_OBJECT || asset_type == AT_CATEGORY ||
|
||||
asset_type == AT_BODYPART || asset_type == AT_GESTURE);*/
|
||||
}
|
||||
|
||||
// static
|
||||
|
||||
61
indra/llcommon/llatomic.h
Normal file
61
indra/llcommon/llatomic.h
Normal file
@@ -0,0 +1,61 @@
|
||||
/**
|
||||
* @file llatomic.h
|
||||
* @brief Definition of LLAtomic
|
||||
*
|
||||
* $LicenseInfo:firstyear=2004&license=viewergpl$
|
||||
*
|
||||
* Copyright (c) 2004-2009, Linden Research, Inc.
|
||||
* Copyright (c) 2012, Aleric Inglewood
|
||||
*
|
||||
* Second Life Viewer Source Code
|
||||
* The source code in this file ("Source Code") is provided by Linden Lab
|
||||
* to you under the terms of the GNU General Public License, version 2.0
|
||||
* ("GPL"), unless you have obtained a separate licensing agreement
|
||||
* ("Other License"), formally executed by you and Linden Lab. Terms of
|
||||
* the GPL can be found in doc/GPL-license.txt in this distribution, or
|
||||
* online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
|
||||
*
|
||||
* There are special exceptions to the terms and conditions of the GPL as
|
||||
* it is applied to this Source Code. View the full text of the exception
|
||||
* in the file doc/FLOSS-exception.txt in this software distribution, or
|
||||
* online at
|
||||
* http://secondlifegrid.net/programs/open_source/licensing/flossexception
|
||||
*
|
||||
* By copying, modifying or distributing this software, you acknowledge
|
||||
* that you have read and understood your obligations described above,
|
||||
* and agree to abide by those obligations.
|
||||
*
|
||||
* ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
|
||||
* WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
|
||||
* COMPLETENESS OR PERFORMANCE.
|
||||
* $/LicenseInfo$
|
||||
*/
|
||||
|
||||
#ifndef LL_LLATOMIC_H
|
||||
#define LL_LLATOMIC_H
|
||||
|
||||
#include "apr_atomic.h"
|
||||
|
||||
template <typename Type> class LLAtomic32
|
||||
{
|
||||
public:
|
||||
LLAtomic32(void) { }
|
||||
LLAtomic32(LLAtomic32 const& atom) { apr_uint32_t data = apr_atomic_read32(const_cast<apr_uint32_t*>(&atom.mData)); apr_atomic_set32(&mData, data); }
|
||||
LLAtomic32(Type x) { apr_atomic_set32(&mData, static_cast<apr_uint32_t>(x)); }
|
||||
LLAtomic32& operator=(LLAtomic32 const& atom) { apr_uint32_t data = apr_atomic_read32(const_cast<apr_uint32_t*>(&atom.mData)); apr_atomic_set32(&mData, data); return *this; }
|
||||
|
||||
operator Type() const { apr_uint32_t data = apr_atomic_read32(const_cast<apr_uint32_t*>(&mData)); return static_cast<Type>(data); }
|
||||
void operator=(Type x) { apr_atomic_set32(&mData, static_cast<apr_uint32_t>(x)); }
|
||||
void operator-=(Type x) { apr_atomic_sub32(&mData, static_cast<apr_uint32_t>(x)); }
|
||||
void operator+=(Type x) { apr_atomic_add32(&mData, static_cast<apr_uint32_t>(x)); }
|
||||
Type operator++(int) { return apr_atomic_inc32(&mData); } // Type++
|
||||
bool operator--() { return apr_atomic_dec32(&mData); } // Returns (--Type != 0)
|
||||
|
||||
private:
|
||||
apr_uint32_t mData;
|
||||
};
|
||||
|
||||
typedef LLAtomic32<U32> LLAtomicU32;
|
||||
typedef LLAtomic32<S32> LLAtomicS32;
|
||||
|
||||
#endif
|
||||
@@ -99,7 +99,7 @@ std::string LLAvatarName::getCompleteName(bool linefeed) const
|
||||
}
|
||||
else
|
||||
{
|
||||
name = mDisplayName + (linefeed ? "\n(" : "(") + mUsername + ")";
|
||||
name = mDisplayName + (linefeed ? "\n(" : " (") + mUsername + ")";
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
*/
|
||||
|
||||
#ifndef LLBASE32_H
|
||||
#define LLBASE32_h
|
||||
#define LLBASE32_H
|
||||
|
||||
class LL_COMMON_API LLBase32
|
||||
{
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
*/
|
||||
|
||||
#ifndef LLBASE64_H
|
||||
#define LLBASE64_h
|
||||
#define LLBASE64_H
|
||||
|
||||
class LL_COMMON_API LLBase64
|
||||
{
|
||||
|
||||
@@ -75,14 +75,15 @@ public:
|
||||
: mText(text),
|
||||
mFromName(),
|
||||
mFromID(),
|
||||
// [RLVa:KB] - Checked: 2009-07-04 (RLVa-1.0.0a)
|
||||
mRlvLocFiltered(FALSE),
|
||||
mRlvNamesFiltered(FALSE),
|
||||
// [/RLVa:KB]
|
||||
|
||||
mSourceType(CHAT_SOURCE_AGENT),
|
||||
mChatType(CHAT_TYPE_NORMAL),
|
||||
mAudible(CHAT_AUDIBLE_FULLY),
|
||||
mMuted(FALSE),
|
||||
// [RLVa:KB] - Checked: 2010-04-22 (RLVa-1.2.0f) | Modified: RLVa-1.0.0a
|
||||
mRlvLocFiltered(FALSE),
|
||||
mRlvNamesFiltered(FALSE),
|
||||
// [/RLVa:KB]
|
||||
mTime(0.0),
|
||||
mPosAgent(),
|
||||
mURL()
|
||||
@@ -104,14 +105,14 @@ public:
|
||||
std::string mText; // UTF-8 line of text
|
||||
std::string mFromName; // agent or object name
|
||||
LLUUID mFromID; // agent id or object id
|
||||
// [RLVa:KB] - Checked: 2009-07-04 (RLVa-1.0.0a)
|
||||
BOOL mRlvLocFiltered;
|
||||
BOOL mRlvNamesFiltered;
|
||||
// [/RLVa:KB]
|
||||
EChatSourceType mSourceType;
|
||||
EChatType mChatType;
|
||||
EChatAudible mAudible;
|
||||
BOOL mMuted; // pass muted chat to maintain list of chatters
|
||||
// [RLVa:KB] - Checked: 2010-04-22 (RLVa-1.2.0f) | Modified: RLVa-1.0.0a
|
||||
BOOL mRlvLocFiltered;
|
||||
BOOL mRlvNamesFiltered;
|
||||
// [/RLVa:KB]
|
||||
F64 mTime; // viewer only, seconds from viewer start
|
||||
LLVector3 mPosAgent;
|
||||
std::string mURL;
|
||||
|
||||
@@ -39,7 +39,6 @@ void LLCommon::initClass()
|
||||
{
|
||||
LLMemory::initClass();
|
||||
LLTimer::initClass();
|
||||
LLThreadSafeRefCount::initThreadSafeRefCount();
|
||||
// LLWorkerThread::initClass();
|
||||
// LLFrameCallbackManager::initClass();
|
||||
}
|
||||
@@ -49,7 +48,6 @@ void LLCommon::cleanupClass()
|
||||
{
|
||||
// LLFrameCallbackManager::cleanupClass();
|
||||
// LLWorkerThread::cleanupClass();
|
||||
LLThreadSafeRefCount::cleanupThreadSafeRefCount();
|
||||
LLTimer::cleanupClass();
|
||||
LLMemory::cleanupClass();
|
||||
}
|
||||
|
||||
154
indra/llcommon/llcoros.cpp
Normal file
154
indra/llcommon/llcoros.cpp
Normal file
@@ -0,0 +1,154 @@
|
||||
/**
|
||||
* @file llcoros.cpp
|
||||
* @author Nat Goodspeed
|
||||
* @date 2009-06-03
|
||||
* @brief Implementation for llcoros.
|
||||
*
|
||||
* $LicenseInfo:firstyear=2009&license=viewerlgpl$
|
||||
* Second Life Viewer Source Code
|
||||
* Copyright (C) 2010, Linden Research, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation;
|
||||
* version 2.1 of the License only.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
|
||||
* $/LicenseInfo$
|
||||
*/
|
||||
|
||||
// Precompiled header
|
||||
#include "linden_common.h"
|
||||
// associated header
|
||||
#include "llcoros.h"
|
||||
// STL headers
|
||||
// std headers
|
||||
// external library headers
|
||||
#include <boost/bind.hpp>
|
||||
// other Linden headers
|
||||
#include "llevents.h"
|
||||
#include "llerror.h"
|
||||
#include "stringize.h"
|
||||
|
||||
LLCoros::LLCoros()
|
||||
{
|
||||
// Register our cleanup() method for "mainloop" ticks
|
||||
LLEventPumps::instance().obtain("mainloop").listen(
|
||||
"LLCoros", boost::bind(&LLCoros::cleanup, this, _1));
|
||||
}
|
||||
|
||||
bool LLCoros::cleanup(const LLSD&)
|
||||
{
|
||||
// Walk the mCoros map, checking and removing completed coroutines.
|
||||
for (CoroMap::iterator mi(mCoros.begin()), mend(mCoros.end()); mi != mend; )
|
||||
{
|
||||
// Has this coroutine exited (normal return, exception, exit() call)
|
||||
// since last tick?
|
||||
if (mi->second->exited())
|
||||
{
|
||||
LL_INFOS("LLCoros") << "LLCoros: cleaning up coroutine " << mi->first << LL_ENDL;
|
||||
// The erase() call will invalidate its passed iterator value --
|
||||
// so increment mi FIRST -- but pass its original value to
|
||||
// erase(). This is what postincrement is all about.
|
||||
mCoros.erase(mi++);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Still live, just skip this entry as if incrementing at the top
|
||||
// of the loop as usual.
|
||||
++mi;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string LLCoros::generateDistinctName(const std::string& prefix) const
|
||||
{
|
||||
// Allowing empty name would make getName()'s not-found return ambiguous.
|
||||
if (prefix.empty())
|
||||
{
|
||||
LL_ERRS("LLCoros") << "LLCoros::launch(): pass non-empty name string" << LL_ENDL;
|
||||
}
|
||||
|
||||
// If the specified name isn't already in the map, just use that.
|
||||
std::string name(prefix);
|
||||
|
||||
// Find the lowest numeric suffix that doesn't collide with an existing
|
||||
// entry. Start with 2 just to make it more intuitive for any interested
|
||||
// parties: e.g. "joe", "joe2", "joe3"...
|
||||
for (int i = 2; ; name = STRINGIZE(prefix << i++))
|
||||
{
|
||||
if (mCoros.find(name) == mCoros.end())
|
||||
{
|
||||
LL_INFOS("LLCoros") << "LLCoros: launching coroutine " << name << LL_ENDL;
|
||||
return name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool LLCoros::kill(const std::string& name)
|
||||
{
|
||||
CoroMap::iterator found = mCoros.find(name);
|
||||
if (found == mCoros.end())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
// Because this is a boost::ptr_map, erasing the map entry also destroys
|
||||
// the referenced heap object, in this case the boost::coroutine object,
|
||||
// which will terminate the coroutine.
|
||||
mCoros.erase(found);
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string LLCoros::getNameByID(const void* self_id) const
|
||||
{
|
||||
// Walk the existing coroutines, looking for one from which the 'self_id'
|
||||
// passed to us comes.
|
||||
for (CoroMap::const_iterator mi(mCoros.begin()), mend(mCoros.end()); mi != mend; ++mi)
|
||||
{
|
||||
namespace coro_private = boost::coroutines::detail;
|
||||
if (static_cast<void*>(coro_private::coroutine_accessor::get_impl(const_cast<coro&>(*mi->second)).get())
|
||||
== self_id)
|
||||
{
|
||||
return mi->first;
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
* MUST BE LAST
|
||||
*****************************************************************************/
|
||||
// Turn off MSVC optimizations for just LLCoros::launchImpl() -- see
|
||||
// DEV-32777. But MSVC doesn't support push/pop for optimization flags as it
|
||||
// does for warning suppression, and we really don't want to force
|
||||
// optimization ON for other code even in Debug or RelWithDebInfo builds.
|
||||
|
||||
#if LL_MSVC
|
||||
// work around broken optimizations
|
||||
#pragma warning(disable: 4748)
|
||||
#pragma optimize("", off)
|
||||
#endif // LL_MSVC
|
||||
|
||||
std::string LLCoros::launchImpl(const std::string& prefix, coro* newCoro)
|
||||
{
|
||||
std::string name(generateDistinctName(prefix));
|
||||
mCoros.insert(name, newCoro);
|
||||
/* Run the coroutine until its first wait, then return here */
|
||||
(*newCoro)(std::nothrow);
|
||||
return name;
|
||||
}
|
||||
|
||||
#if LL_MSVC
|
||||
// reenable optimizations
|
||||
#pragma optimize("", on)
|
||||
#endif // LL_MSVC
|
||||
166
indra/llcommon/llcoros.h
Normal file
166
indra/llcommon/llcoros.h
Normal file
@@ -0,0 +1,166 @@
|
||||
/**
|
||||
* @file llcoros.h
|
||||
* @author Nat Goodspeed
|
||||
* @date 2009-06-02
|
||||
* @brief Manage running boost::coroutine instances
|
||||
*
|
||||
* $LicenseInfo:firstyear=2009&license=viewerlgpl$
|
||||
* Second Life Viewer Source Code
|
||||
* Copyright (C) 2010, Linden Research, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation;
|
||||
* version 2.1 of the License only.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
|
||||
* $/LicenseInfo$
|
||||
*/
|
||||
|
||||
#if ! defined(LL_LLCOROS_H)
|
||||
#define LL_LLCOROS_H
|
||||
|
||||
#include <boost/coroutine/coroutine.hpp>
|
||||
#include "llsingleton.h"
|
||||
#include <boost/ptr_container/ptr_map.hpp>
|
||||
#include <string>
|
||||
#include <boost/preprocessor/repetition/enum_params.hpp>
|
||||
#include <boost/preprocessor/repetition/enum_binary_params.hpp>
|
||||
#include <boost/preprocessor/iteration/local.hpp>
|
||||
#include <stdexcept>
|
||||
|
||||
/**
|
||||
* Registry of named Boost.Coroutine instances
|
||||
*
|
||||
* The Boost.Coroutine library supports the general case of a coroutine
|
||||
* accepting arbitrary parameters and yielding multiple (sets of) results. For
|
||||
* such use cases, it's natural for the invoking code to retain the coroutine
|
||||
* instance: the consumer repeatedly calls into the coroutine, perhaps passing
|
||||
* new parameter values, prompting it to yield its next result.
|
||||
*
|
||||
* Our typical coroutine usage is different, though. For us, coroutines
|
||||
* provide an alternative to the @c Responder pattern. Our typical coroutine
|
||||
* has @c void return, invoked in fire-and-forget mode: the handler for some
|
||||
* user gesture launches the coroutine and promptly returns to the main loop.
|
||||
* The coroutine initiates some action that will take multiple frames (e.g. a
|
||||
* capability request), waits for its result, processes it and silently steals
|
||||
* away.
|
||||
*
|
||||
* This usage poses two (related) problems:
|
||||
*
|
||||
* # Who should own the coroutine instance? If it's simply local to the
|
||||
* handler code that launches it, return from the handler will destroy the
|
||||
* coroutine object, terminating the coroutine.
|
||||
* # Once the coroutine terminates, in whatever way, who's responsible for
|
||||
* cleaning up the coroutine object?
|
||||
*
|
||||
* LLCoros is a Singleton collection of currently-active coroutine instances.
|
||||
* Each has a name. You ask LLCoros to launch a new coroutine with a suggested
|
||||
* name prefix; from your prefix it generates a distinct name, registers the
|
||||
* new coroutine and returns the actual name.
|
||||
*
|
||||
* The name can be used to kill off the coroutine prematurely, if needed. It
|
||||
* can also provide diagnostic info: we can look up the name of the
|
||||
* currently-running coroutine.
|
||||
*
|
||||
* Finally, the next frame ("mainloop" event) after the coroutine terminates,
|
||||
* LLCoros will notice its demise and destroy it.
|
||||
*/
|
||||
class LL_COMMON_API LLCoros: public LLSingleton<LLCoros>
|
||||
{
|
||||
public:
|
||||
/// Canonical boost::coroutines::coroutine signature we use
|
||||
typedef boost::coroutines::coroutine<void()> coro;
|
||||
/// Canonical 'self' type
|
||||
typedef coro::self self;
|
||||
|
||||
/**
|
||||
* Create and start running a new coroutine with specified name. The name
|
||||
* string you pass is a suggestion; it will be tweaked for uniqueness. The
|
||||
* actual name is returned to you.
|
||||
*
|
||||
* Usage looks like this, for (e.g.) two coroutine parameters:
|
||||
* @code
|
||||
* class MyClass
|
||||
* {
|
||||
* public:
|
||||
* ...
|
||||
* // Do NOT NOT NOT accept reference params other than 'self'!
|
||||
* // Pass by value only!
|
||||
* void myCoroutineMethod(LLCoros::self& self, std::string, LLSD);
|
||||
* ...
|
||||
* };
|
||||
* ...
|
||||
* std::string name = LLCoros::instance().launch(
|
||||
* "mycoro", boost::bind(&MyClass::myCoroutineMethod, this, _1,
|
||||
* "somestring", LLSD(17));
|
||||
* @endcode
|
||||
*
|
||||
* Your function/method must accept LLCoros::self& as its first parameter.
|
||||
* It can accept any other parameters you want -- but ONLY BY VALUE!
|
||||
* Other reference parameters are a BAD IDEA! You Have Been Warned. See
|
||||
* DEV-32777 comments for an explanation.
|
||||
*
|
||||
* Pass a callable that accepts the single LLCoros::self& parameter. It
|
||||
* may work to pass a free function whose only parameter is 'self'; for
|
||||
* all other cases use boost::bind(). Of course, for a non-static class
|
||||
* method, the first parameter must be the class instance. Use the
|
||||
* placeholder _1 for the 'self' parameter. Any other parameters should be
|
||||
* passed via the bind() expression.
|
||||
*
|
||||
* launch() tweaks the suggested name so it won't collide with any
|
||||
* existing coroutine instance, creates the coroutine instance, registers
|
||||
* it with the tweaked name and runs it until its first wait. At that
|
||||
* point it returns the tweaked name.
|
||||
*/
|
||||
template <typename CALLABLE>
|
||||
std::string launch(const std::string& prefix, const CALLABLE& callable)
|
||||
{
|
||||
return launchImpl(prefix, new coro(callable));
|
||||
}
|
||||
|
||||
/**
|
||||
* Abort a running coroutine by name. Normally, when a coroutine either
|
||||
* runs to completion or terminates with an exception, LLCoros quietly
|
||||
* cleans it up. This is for use only when you must explicitly interrupt
|
||||
* one prematurely. Returns @c true if the specified name was found and
|
||||
* still running at the time.
|
||||
*/
|
||||
bool kill(const std::string& name);
|
||||
|
||||
/**
|
||||
* From within a coroutine, pass its @c self object to look up the
|
||||
* (tweaked) name string by which this coroutine is registered. Returns
|
||||
* the empty string if not found (e.g. if the coroutine was launched by
|
||||
* hand rather than using LLCoros::launch()).
|
||||
*/
|
||||
template <typename COROUTINE_SELF>
|
||||
std::string getName(const COROUTINE_SELF& self) const
|
||||
{
|
||||
return getNameByID(self.get_id());
|
||||
}
|
||||
|
||||
/// getName() by self.get_id()
|
||||
std::string getNameByID(const void* self_id) const;
|
||||
|
||||
private:
|
||||
friend class LLSingleton<LLCoros>;
|
||||
LLCoros();
|
||||
std::string launchImpl(const std::string& prefix, coro* newCoro);
|
||||
std::string generateDistinctName(const std::string& prefix) const;
|
||||
bool cleanup(const LLSD&);
|
||||
|
||||
typedef boost::ptr_map<std::string, coro> CoroMap;
|
||||
CoroMap mCoros;
|
||||
};
|
||||
|
||||
#endif /* ! defined(LL_LLCOROS_H) */
|
||||
@@ -30,6 +30,8 @@
|
||||
* $/LicenseInfo$
|
||||
*/
|
||||
|
||||
#include "linden_common.h"
|
||||
|
||||
#include "llcursortypes.h"
|
||||
|
||||
ECursorType getCursorFromString(const std::string& cursor_string)
|
||||
@@ -66,14 +68,14 @@ ECursorType getCursorFromString(const std::string& cursor_string)
|
||||
cursor_string_table["UI_CURSOR_TOOLPAN"] = UI_CURSOR_TOOLPAN;
|
||||
cursor_string_table["UI_CURSOR_TOOLZOOMIN"] = UI_CURSOR_TOOLZOOMIN;
|
||||
cursor_string_table["UI_CURSOR_TOOLPICKOBJECT3"] = UI_CURSOR_TOOLPICKOBJECT3;
|
||||
cursor_string_table["UI_CURSOR_TOOLSIT"] = UI_CURSOR_TOOLSIT;
|
||||
cursor_string_table["UI_CURSOR_TOOLBUY"] = UI_CURSOR_TOOLBUY;
|
||||
cursor_string_table["UI_CURSOR_TOOLPAY"] = UI_CURSOR_TOOLPAY;
|
||||
cursor_string_table["UI_CURSOR_TOOLOPEN"] = UI_CURSOR_TOOLOPEN;
|
||||
cursor_string_table["UI_CURSOR_TOOLPLAY"] = UI_CURSOR_TOOLPLAY;
|
||||
cursor_string_table["UI_CURSOR_TOOLPAUSE"] = UI_CURSOR_TOOLPAUSE;
|
||||
cursor_string_table["UI_CURSOR_TOOLMEDIAOPEN"] = UI_CURSOR_TOOLMEDIAOPEN;
|
||||
cursor_string_table["UI_CURSOR_PIPETTE"] = UI_CURSOR_PIPETTE;
|
||||
cursor_string_table["UI_CURSOR_TOOLSIT"] = UI_CURSOR_TOOLSIT;
|
||||
cursor_string_table["UI_CURSOR_TOOLBUY"] = UI_CURSOR_TOOLBUY;
|
||||
cursor_string_table["UI_CURSOR_TOOLPAY"] = UI_CURSOR_TOOLPAY;
|
||||
cursor_string_table["UI_CURSOR_TOOLOPEN"] = UI_CURSOR_TOOLOPEN;
|
||||
}
|
||||
|
||||
std::map<std::string,U32>::const_iterator iter = cursor_string_table.find(cursor_string);
|
||||
|
||||
@@ -33,8 +33,6 @@
|
||||
#ifndef LL_LLCURSORTYPES_H
|
||||
#define LL_LLCURSORTYPES_H
|
||||
|
||||
#include "linden_common.h"
|
||||
|
||||
// If you add types here, add them in LLCursor::getCursorFromString
|
||||
enum ECursorType {
|
||||
UI_CURSOR_ARROW,
|
||||
@@ -66,14 +64,14 @@ enum ECursorType {
|
||||
UI_CURSOR_TOOLPAN,
|
||||
UI_CURSOR_TOOLZOOMIN,
|
||||
UI_CURSOR_TOOLPICKOBJECT3,
|
||||
UI_CURSOR_TOOLSIT,
|
||||
UI_CURSOR_TOOLBUY,
|
||||
UI_CURSOR_TOOLPAY,
|
||||
UI_CURSOR_TOOLOPEN,
|
||||
UI_CURSOR_TOOLPLAY,
|
||||
UI_CURSOR_TOOLPAUSE,
|
||||
UI_CURSOR_TOOLMEDIAOPEN,
|
||||
UI_CURSOR_PIPETTE,
|
||||
UI_CURSOR_TOOLSIT,
|
||||
UI_CURSOR_TOOLBUY,
|
||||
UI_CURSOR_TOOLPAY,
|
||||
UI_CURSOR_TOOLOPEN,
|
||||
UI_CURSOR_COUNT // Number of elements in this enum (NOT a cursor)
|
||||
};
|
||||
|
||||
|
||||
@@ -43,6 +43,7 @@
|
||||
#include <iomanip>
|
||||
#include <sstream>
|
||||
|
||||
#include "llfasttimer.h"
|
||||
#include "lltimer.h"
|
||||
#include "llstring.h"
|
||||
|
||||
@@ -94,9 +95,11 @@ std::string LLDate::asRFC1123() const
|
||||
return toHTTPDateString (std::string ("%A, %d %b %Y %H:%M:%S GMT"));
|
||||
}
|
||||
|
||||
LLFastTimer::DeclareTimer FT_DATE_FORMAT("Date Format");
|
||||
|
||||
std::string LLDate::toHTTPDateString (std::string fmt) const
|
||||
{
|
||||
LLFastTimer ft1(FT_DATE_FORMAT);
|
||||
|
||||
time_t locSeconds = (time_t) mSecondsSinceEpoch;
|
||||
struct tm * gmt = gmtime (&locSeconds);
|
||||
@@ -105,7 +108,7 @@ std::string LLDate::toHTTPDateString (std::string fmt) const
|
||||
|
||||
std::string LLDate::toHTTPDateString (tm * gmt, std::string fmt)
|
||||
{
|
||||
// Return Epoch UTC date
|
||||
LLFastTimer ft1(FT_DATE_FORMAT);
|
||||
|
||||
// avoid calling setlocale() unnecessarily - it's expensive.
|
||||
static std::string prev_locale = "";
|
||||
|
||||
103
indra/llcommon/lldependencies.cpp
Normal file
103
indra/llcommon/lldependencies.cpp
Normal file
@@ -0,0 +1,103 @@
|
||||
/**
|
||||
* @file lldependencies.cpp
|
||||
* @author Nat Goodspeed
|
||||
* @date 2008-09-17
|
||||
* @brief Implementation for lldependencies.
|
||||
*
|
||||
* $LicenseInfo:firstyear=2008&license=viewerlgpl$
|
||||
* Second Life Viewer Source Code
|
||||
* Copyright (C) 2010, Linden Research, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation;
|
||||
* version 2.1 of the License only.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
|
||||
* $/LicenseInfo$
|
||||
*/
|
||||
|
||||
// Precompiled header
|
||||
#include "linden_common.h"
|
||||
// associated header
|
||||
#include "lldependencies.h"
|
||||
// STL headers
|
||||
#include <map>
|
||||
#include <sstream>
|
||||
// std headers
|
||||
// external library headers
|
||||
#include <boost/graph/graph_traits.hpp> // for boost::graph_traits
|
||||
#include <boost/graph/adjacency_list.hpp>
|
||||
#include <boost/graph/topological_sort.hpp>
|
||||
#include <boost/graph/exception.hpp>
|
||||
// other Linden headers
|
||||
|
||||
LLDependenciesBase::VertexList LLDependenciesBase::topo_sort(int vertices, const EdgeList& edges) const
|
||||
{
|
||||
// Construct a Boost Graph Library graph according to the constraints
|
||||
// we've collected. It seems as though we ought to be able to capture
|
||||
// the uniqueness of vertex keys using a setS of vertices with a
|
||||
// string property -- but I don't yet understand adjacency_list well
|
||||
// enough to get there. All the examples I've seen so far use integers
|
||||
// for vertices.
|
||||
// Define the Graph type. Use a vector for vertices so we can use the
|
||||
// default topological_sort vertex lookup by int index. Use a set for
|
||||
// edges because the same dependency may be stated twice: Node "a" may
|
||||
// specify that it must precede "b", while "b" may also state that it
|
||||
// must follow "a".
|
||||
typedef boost::adjacency_list<boost::setS, boost::vecS, boost::directedS,
|
||||
boost::no_property> Graph;
|
||||
// Instantiate the graph. Without vertex properties, we need say no
|
||||
// more about vertices than the total number.
|
||||
Graph g(edges.begin(), edges.end(), vertices);
|
||||
// topo sort
|
||||
typedef boost::graph_traits<Graph>::vertex_descriptor VertexDesc;
|
||||
typedef std::vector<VertexDesc> SortedList;
|
||||
SortedList sorted;
|
||||
// note that it throws not_a_dag if it finds a cycle
|
||||
try
|
||||
{
|
||||
boost::topological_sort(g, std::back_inserter(sorted));
|
||||
}
|
||||
catch (const boost::not_a_dag& e)
|
||||
{
|
||||
// translate to the exception we define
|
||||
std::ostringstream out;
|
||||
out << "LLDependencies cycle: " << e.what() << '\n';
|
||||
// Omit independent nodes: display only those that might contribute to
|
||||
// the cycle.
|
||||
describe(out, false);
|
||||
throw Cycle(out.str());
|
||||
}
|
||||
// A peculiarity of boost::topological_sort() is that it emits results in
|
||||
// REVERSE topological order: to get the result you want, you must
|
||||
// traverse the SortedList using reverse iterators.
|
||||
return VertexList(sorted.rbegin(), sorted.rend());
|
||||
}
|
||||
|
||||
std::ostream& LLDependenciesBase::describe(std::ostream& out, bool full) const
|
||||
{
|
||||
// Should never encounter this base-class implementation; may mean that
|
||||
// the KEY type doesn't have a suitable ostream operator<<().
|
||||
out << "<no description available>";
|
||||
return out;
|
||||
}
|
||||
|
||||
std::string LLDependenciesBase::describe(bool full) const
|
||||
{
|
||||
// Just use the ostream-based describe() on a std::ostringstream. The
|
||||
// implementation is here mostly so that we can avoid #include <sstream>
|
||||
// in the header file.
|
||||
std::ostringstream out;
|
||||
describe(out, full);
|
||||
return out.str();
|
||||
}
|
||||
799
indra/llcommon/lldependencies.h
Normal file
799
indra/llcommon/lldependencies.h
Normal file
@@ -0,0 +1,799 @@
|
||||
/**
|
||||
* @file lldependencies.h
|
||||
* @author Nat Goodspeed
|
||||
* @date 2008-09-17
|
||||
* @brief LLDependencies: a generic mechanism for expressing "b must follow a,
|
||||
* but precede c"
|
||||
*
|
||||
* $LicenseInfo:firstyear=2008&license=viewerlgpl$
|
||||
* Second Life Viewer Source Code
|
||||
* Copyright (C) 2010, Linden Research, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation;
|
||||
* version 2.1 of the License only.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
|
||||
* $/LicenseInfo$
|
||||
*/
|
||||
|
||||
#if ! defined(LL_LLDEPENDENCIES_H)
|
||||
#define LL_LLDEPENDENCIES_H
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <set>
|
||||
#include <map>
|
||||
#include <stdexcept>
|
||||
#include <iosfwd>
|
||||
#include <boost/iterator/transform_iterator.hpp>
|
||||
#include <boost/iterator/indirect_iterator.hpp>
|
||||
#include <boost/range/iterator_range.hpp>
|
||||
#include <boost/function.hpp>
|
||||
#include <boost/bind.hpp>
|
||||
|
||||
/*****************************************************************************
|
||||
* Utilities
|
||||
*****************************************************************************/
|
||||
/**
|
||||
* generic range transformer: given a range acceptable to Boost.Range (e.g. a
|
||||
* standard container, an iterator pair, ...) and a unary function to apply to
|
||||
* each element of the range, make a corresponding range that lazily applies
|
||||
* that function to each element on dereferencing.
|
||||
*/
|
||||
template<typename FUNCTION, typename RANGE>
|
||||
inline
|
||||
boost::iterator_range<boost::transform_iterator<FUNCTION,
|
||||
typename boost::range_const_iterator<RANGE>::type> >
|
||||
make_transform_range(const RANGE& range, FUNCTION function)
|
||||
{
|
||||
// shorthand for the iterator type embedded in our return type
|
||||
typedef boost::transform_iterator<FUNCTION, typename boost::range_const_iterator<RANGE>::type>
|
||||
transform_iterator;
|
||||
return boost::make_iterator_range(transform_iterator(boost::begin(range), function),
|
||||
transform_iterator(boost::end(range), function));
|
||||
}
|
||||
|
||||
/// non-const version of make_transform_range()
|
||||
template<typename FUNCTION, typename RANGE>
|
||||
inline
|
||||
boost::iterator_range<boost::transform_iterator<FUNCTION,
|
||||
typename boost::range_iterator<RANGE>::type> >
|
||||
make_transform_range(RANGE& range, FUNCTION function)
|
||||
{
|
||||
// shorthand for the iterator type embedded in our return type
|
||||
typedef boost::transform_iterator<FUNCTION, typename boost::range_iterator<RANGE>::type>
|
||||
transform_iterator;
|
||||
return boost::make_iterator_range(transform_iterator(boost::begin(range), function),
|
||||
transform_iterator(boost::end(range), function));
|
||||
}
|
||||
|
||||
/**
|
||||
* From any range compatible with Boost.Range, instantiate any class capable
|
||||
* of accepting an iterator pair.
|
||||
*/
|
||||
template<class TYPE>
|
||||
struct instance_from_range: public TYPE
|
||||
{
|
||||
template<typename RANGE>
|
||||
instance_from_range(RANGE range):
|
||||
TYPE(boost::begin(range), boost::end(range))
|
||||
{}
|
||||
};
|
||||
|
||||
/*****************************************************************************
|
||||
* LLDependencies
|
||||
*****************************************************************************/
|
||||
/**
|
||||
* LLDependencies components that should not be reinstantiated for each KEY,
|
||||
* NODE specialization
|
||||
*/
|
||||
class LL_COMMON_API LLDependenciesBase
|
||||
{
|
||||
public:
|
||||
virtual ~LLDependenciesBase() {}
|
||||
|
||||
/**
|
||||
* Exception thrown by sort() if there's a cycle
|
||||
*/
|
||||
struct Cycle: public std::runtime_error
|
||||
{
|
||||
Cycle(const std::string& what): std::runtime_error(what) {}
|
||||
};
|
||||
|
||||
/**
|
||||
* Provide a short description of this LLDependencies instance on the
|
||||
* specified output stream, assuming that its KEY type has an operator<<()
|
||||
* that works with std::ostream.
|
||||
*
|
||||
* Pass @a full as @c false to omit any keys without dependency constraints.
|
||||
*/
|
||||
virtual std::ostream& describe(std::ostream& out, bool full=true) const;
|
||||
|
||||
/// describe() to a string
|
||||
virtual std::string describe(bool full=true) const;
|
||||
|
||||
protected:
|
||||
typedef std::vector< std::pair<int, int> > EdgeList;
|
||||
typedef std::vector<int> VertexList;
|
||||
VertexList topo_sort(int vertices, const EdgeList& edges) const;
|
||||
|
||||
/**
|
||||
* refpair is specifically intended to capture a pair of references. This
|
||||
* is better than std::pair<T1&, T2&> because some implementations of
|
||||
* std::pair's ctor accept const references to the two types. If the
|
||||
* types are themselves references, this results in an illegal reference-
|
||||
* to-reference.
|
||||
*/
|
||||
template<typename T1, typename T2>
|
||||
struct refpair
|
||||
{
|
||||
refpair(T1 value1, T2 value2):
|
||||
first(value1),
|
||||
second(value2)
|
||||
{}
|
||||
T1 first;
|
||||
T2 second;
|
||||
};
|
||||
};
|
||||
|
||||
/// describe() helper: for most types, report the type as usual
|
||||
template<typename T>
|
||||
inline
|
||||
std::ostream& LLDependencies_describe(std::ostream& out, const T& key)
|
||||
{
|
||||
out << key;
|
||||
return out;
|
||||
}
|
||||
|
||||
/// specialize LLDependencies_describe() for std::string
|
||||
template<>
|
||||
inline
|
||||
std::ostream& LLDependencies_describe(std::ostream& out, const std::string& key)
|
||||
{
|
||||
out << '"' << key << '"';
|
||||
return out;
|
||||
}
|
||||
|
||||
/**
|
||||
* It's reasonable to use LLDependencies in a keys-only way, more or less like
|
||||
* std::set. For that case, the default NODE type is an empty struct.
|
||||
*/
|
||||
struct LLDependenciesEmpty
|
||||
{
|
||||
LLDependenciesEmpty() {}
|
||||
/**
|
||||
* Give it a constructor accepting void* so caller can pass placeholder
|
||||
* values such as NULL or 0 rather than having to write
|
||||
* LLDependenciesEmpty().
|
||||
*/
|
||||
LLDependenciesEmpty(void*) {}
|
||||
};
|
||||
|
||||
/**
|
||||
* This class manages abstract dependencies between node types of your
|
||||
* choosing. As with a std::map, nodes are copied when add()ed, so the node
|
||||
* type should be relatively lightweight; to manipulate dependencies between
|
||||
* expensive objects, use a pointer type.
|
||||
*
|
||||
* For a given node, you may state the keys of nodes that must precede it
|
||||
* and/or nodes that must follow it. The sort() method will produce an order
|
||||
* that should work, or throw an exception if the constraints are impossible.
|
||||
* We cache results to minimize the cost of repeated sort() calls.
|
||||
*/
|
||||
template<typename KEY = std::string,
|
||||
typename NODE = LLDependenciesEmpty>
|
||||
class LLDependencies: public LLDependenciesBase
|
||||
{
|
||||
typedef LLDependencies<KEY, NODE> self_type;
|
||||
|
||||
/**
|
||||
* Internally, we bundle the client's NODE with its before/after keys.
|
||||
*/
|
||||
struct DepNode
|
||||
{
|
||||
typedef std::set<KEY> dep_set;
|
||||
DepNode(const NODE& node_, const dep_set& after_, const dep_set& before_):
|
||||
node(node_),
|
||||
after(after_),
|
||||
before(before_)
|
||||
{}
|
||||
NODE node;
|
||||
dep_set after, before;
|
||||
};
|
||||
typedef std::map<KEY, DepNode> DepNodeMap;
|
||||
typedef typename DepNodeMap::value_type DepNodeMapEntry;
|
||||
|
||||
/// We have various ways to get the dependencies for a given DepNode.
|
||||
/// Rather than having to restate each one for 'after' and 'before'
|
||||
/// separately, pass a dep_selector so we can apply each to either.
|
||||
typedef boost::function<const typename DepNode::dep_set&(const DepNode&)> dep_selector;
|
||||
|
||||
public:
|
||||
LLDependencies() {}
|
||||
|
||||
typedef KEY key_type;
|
||||
typedef NODE node_type;
|
||||
|
||||
/// param type used to express lists of other node keys -- note that such
|
||||
/// lists can be initialized with boost::assign::list_of()
|
||||
typedef std::vector<KEY> KeyList;
|
||||
|
||||
/**
|
||||
* Add a new node. State its dependencies on other nodes (which may not
|
||||
* yet have been added) by listing the keys of nodes this new one must
|
||||
* follow, and separately the keys of nodes this new one must precede.
|
||||
*
|
||||
* The node you pass is @em copied into an internal data structure. If you
|
||||
* want to modify the node value after add()ing it, capture the returned
|
||||
* NODE& reference.
|
||||
*
|
||||
* @note
|
||||
* Actual dependency analysis is deferred to the sort() method, so
|
||||
* you can add an arbitrary number of nodes without incurring analysis
|
||||
* overhead for each. The flip side of this is that add()ing nodes that
|
||||
* define a cycle leaves this object in a state in which sort() will
|
||||
* always throw the Cycle exception.
|
||||
*
|
||||
* Two distinct use cases are anticipated:
|
||||
* * The data used to load this object are completely known at compile
|
||||
* time (e.g. LLEventPump listener names). A Cycle exception represents a
|
||||
* bug which can be corrected by the coder. The program need neither catch
|
||||
* Cycle nor attempt to salvage the state of this object.
|
||||
* * The data are loaded at runtime, therefore the universe of
|
||||
* dependencies cannot be known at compile time. The client code should
|
||||
* catch Cycle.
|
||||
* ** If a Cycle exception indicates fatally-flawed input data, this
|
||||
* object can simply be discarded, possibly with the entire program run.
|
||||
* ** If it is essential to restore this object to a working state, the
|
||||
* simplest workaround is to remove() nodes in LIFO order.
|
||||
* *** It may be useful to add functionality to this class to track the
|
||||
* add() chronology, providing a pop() method to remove the most recently
|
||||
* added node.
|
||||
* *** It may further be useful to add a restore() method which would
|
||||
* pop() until sort() no longer throws Cycle. This method would be
|
||||
* expensive -- but it's not clear that client code could resolve the
|
||||
* problem more cheaply.
|
||||
*/
|
||||
NODE& add(const KEY& key, const NODE& node = NODE(),
|
||||
const KeyList& after = KeyList(),
|
||||
const KeyList& before = KeyList())
|
||||
{
|
||||
// Get the passed-in lists as sets for equality comparison
|
||||
typename DepNode::dep_set
|
||||
after_set(after.begin(), after.end()),
|
||||
before_set(before.begin(), before.end());
|
||||
// Try to insert the new node; if it already exists, find the old
|
||||
// node instead.
|
||||
std::pair<typename DepNodeMap::iterator, bool> inserted =
|
||||
mNodes.insert(typename DepNodeMap::value_type(key,
|
||||
DepNode(node, after_set, before_set)));
|
||||
if (! inserted.second) // bool indicating success of insert()
|
||||
{
|
||||
// We already have a node by this name. Have its dependencies
|
||||
// changed? If the existing node's dependencies are identical, the
|
||||
// result will be unchanged, so we can leave the cache intact.
|
||||
// Regardless of inserted.second, inserted.first is the iterator
|
||||
// to the newly-inserted (or existing) map entry. Of course, that
|
||||
// entry's second is the DepNode of interest.
|
||||
if (inserted.first->second.after != after_set ||
|
||||
inserted.first->second.before != before_set)
|
||||
{
|
||||
// Dependencies have changed: clear the cached result.
|
||||
mCache.clear();
|
||||
// save the new dependencies
|
||||
inserted.first->second.after = after_set;
|
||||
inserted.first->second.before = before_set;
|
||||
}
|
||||
}
|
||||
else // this node is new
|
||||
{
|
||||
// This will change results.
|
||||
mCache.clear();
|
||||
}
|
||||
return inserted.first->second.node;
|
||||
}
|
||||
|
||||
/// the value of an iterator, showing both KEY and its NODE
|
||||
typedef refpair<const KEY&, NODE&> value_type;
|
||||
/// the value of a const_iterator
|
||||
typedef refpair<const KEY&, const NODE&> const_value_type;
|
||||
|
||||
private:
|
||||
// Extract functors
|
||||
static value_type value_extract(DepNodeMapEntry& entry)
|
||||
{
|
||||
return value_type(entry.first, entry.second.node);
|
||||
}
|
||||
|
||||
static const_value_type const_value_extract(const DepNodeMapEntry& entry)
|
||||
{
|
||||
return const_value_type(entry.first, entry.second.node);
|
||||
}
|
||||
|
||||
// All the iterator access methods return iterator ranges just to cut down
|
||||
// on the friggin' boilerplate!!
|
||||
|
||||
/// generic mNodes range method
|
||||
template<typename ITERATOR, typename FUNCTION>
|
||||
boost::iterator_range<ITERATOR> generic_range(FUNCTION function)
|
||||
{
|
||||
return make_transform_range(mNodes, function);
|
||||
}
|
||||
|
||||
/// generic mNodes const range method
|
||||
template<typename ITERATOR, typename FUNCTION>
|
||||
boost::iterator_range<ITERATOR> generic_range(FUNCTION function) const
|
||||
{
|
||||
return make_transform_range(mNodes, function);
|
||||
}
|
||||
|
||||
public:
|
||||
/// iterator over value_type entries
|
||||
typedef boost::transform_iterator<boost::function<value_type(DepNodeMapEntry&)>,
|
||||
typename DepNodeMap::iterator> iterator;
|
||||
/// range over value_type entries
|
||||
typedef boost::iterator_range<iterator> range;
|
||||
|
||||
/// iterate over value_type <i>in @c KEY order</i> rather than dependency order
|
||||
range get_range()
|
||||
{
|
||||
return generic_range<iterator>(value_extract);
|
||||
}
|
||||
|
||||
/// iterator over const_value_type entries
|
||||
typedef boost::transform_iterator<boost::function<const_value_type(const DepNodeMapEntry&)>,
|
||||
typename DepNodeMap::const_iterator> const_iterator;
|
||||
/// range over const_value_type entries
|
||||
typedef boost::iterator_range<const_iterator> const_range;
|
||||
|
||||
/// iterate over const_value_type <i>in @c KEY order</i> rather than dependency order
|
||||
const_range get_range() const
|
||||
{
|
||||
return generic_range<const_iterator>(const_value_extract);
|
||||
}
|
||||
|
||||
/// iterator over stored NODEs
|
||||
typedef boost::transform_iterator<boost::function<NODE&(DepNodeMapEntry&)>,
|
||||
typename DepNodeMap::iterator> node_iterator;
|
||||
/// range over stored NODEs
|
||||
typedef boost::iterator_range<node_iterator> node_range;
|
||||
|
||||
/// iterate over NODE <i>in @c KEY order</i> rather than dependency order
|
||||
node_range get_node_range()
|
||||
{
|
||||
// First take a DepNodeMapEntry and extract a reference to its
|
||||
// DepNode, then from that extract a reference to its NODE.
|
||||
return generic_range<node_iterator>(
|
||||
boost::bind<NODE&>(&DepNode::node,
|
||||
boost::bind<DepNode&>(&DepNodeMapEntry::second, _1)));
|
||||
}
|
||||
|
||||
/// const iterator over stored NODEs
|
||||
typedef boost::transform_iterator<boost::function<const NODE&(const DepNodeMapEntry&)>,
|
||||
typename DepNodeMap::const_iterator> const_node_iterator;
|
||||
/// const range over stored NODEs
|
||||
typedef boost::iterator_range<const_node_iterator> const_node_range;
|
||||
|
||||
/// iterate over const NODE <i>in @c KEY order</i> rather than dependency order
|
||||
const_node_range get_node_range() const
|
||||
{
|
||||
// First take a DepNodeMapEntry and extract a reference to its
|
||||
// DepNode, then from that extract a reference to its NODE.
|
||||
return generic_range<const_node_iterator>(
|
||||
boost::bind<const NODE&>(&DepNode::node,
|
||||
boost::bind<const DepNode&>(&DepNodeMapEntry::second, _1)));
|
||||
}
|
||||
|
||||
/// const iterator over stored KEYs
|
||||
typedef boost::transform_iterator<boost::function<const KEY&(const DepNodeMapEntry&)>,
|
||||
typename DepNodeMap::const_iterator> const_key_iterator;
|
||||
/// const range over stored KEYs
|
||||
typedef boost::iterator_range<const_key_iterator> const_key_range;
|
||||
// We don't provide a non-const iterator over KEYs because they should be
|
||||
// immutable, and in fact our underlying std::map won't give us non-const
|
||||
// references.
|
||||
|
||||
/// iterate over const KEY <i>in @c KEY order</i> rather than dependency order
|
||||
const_key_range get_key_range() const
|
||||
{
|
||||
// From a DepNodeMapEntry, extract a reference to its KEY.
|
||||
return generic_range<const_key_iterator>(
|
||||
boost::bind<const KEY&>(&DepNodeMapEntry::first, _1));
|
||||
}
|
||||
|
||||
/**
|
||||
* Find an existing NODE, or return NULL. We decided to avoid providing a
|
||||
* method analogous to std::map::find(), for a couple of reasons:
|
||||
*
|
||||
* * For a find-by-key, getting back an iterator to the (key, value) pair
|
||||
* is less than useful, since you already have the key in hand.
|
||||
* * For a failed request, comparing to end() is problematic. First, we
|
||||
* provide range accessors, so it's more code to get end(). Second, we
|
||||
* provide a number of different ranges -- quick, to which one's end()
|
||||
* should we compare the iterator returned by find()?
|
||||
*
|
||||
* The returned pointer is solely to allow expressing the not-found
|
||||
* condition. LLDependencies still owns the found NODE.
|
||||
*/
|
||||
const NODE* get(const KEY& key) const
|
||||
{
|
||||
typename DepNodeMap::const_iterator found = mNodes.find(key);
|
||||
if (found != mNodes.end())
|
||||
{
|
||||
return &found->second.node;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* non-const get()
|
||||
*/
|
||||
NODE* get(const KEY& key)
|
||||
{
|
||||
// Use const implementation, then cast away const-ness of return
|
||||
return const_cast<NODE*>(const_cast<const self_type*>(this)->get(key));
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a node with specified key. This operation is the major reason
|
||||
* we rebuild the graph on the fly instead of storing it.
|
||||
*/
|
||||
bool remove(const KEY& key)
|
||||
{
|
||||
typename DepNodeMap::iterator found = mNodes.find(key);
|
||||
if (found != mNodes.end())
|
||||
{
|
||||
mNodes.erase(found);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private:
|
||||
/// cached list of iterators
|
||||
typedef std::vector<iterator> iterator_list;
|
||||
typedef typename iterator_list::iterator iterator_list_iterator;
|
||||
|
||||
public:
|
||||
/**
|
||||
* The return type of the sort() method needs some explanation. Provide a
|
||||
* public typedef to facilitate storing the result.
|
||||
*
|
||||
* * We will prepare mCache by looking up DepNodeMap iterators.
|
||||
* * We want to return a range containing iterators that will walk mCache.
|
||||
* * If we simply stored DepNodeMap iterators and returned
|
||||
* (mCache.begin(), mCache.end()), dereferencing each iterator would
|
||||
* obtain a DepNodeMap iterator.
|
||||
* * We want the caller to loop over @c value_type: pair<KEY, NODE>.
|
||||
* * This requires two transformations:
|
||||
* ** mCache must contain @c LLDependencies::iterator so that
|
||||
* dereferencing each entry will obtain an @c LLDependencies::value_type
|
||||
* rather than a DepNodeMapEntry.
|
||||
* ** We must wrap mCache's iterators in boost::indirect_iterator so that
|
||||
* dereferencing one of our returned iterators will also dereference the
|
||||
* iterator contained in mCache.
|
||||
*/
|
||||
typedef boost::iterator_range<boost::indirect_iterator<iterator_list_iterator> > sorted_range;
|
||||
/// for convenience in looping over a sorted_range
|
||||
typedef typename sorted_range::iterator sorted_iterator;
|
||||
|
||||
/**
|
||||
* Once we've loaded in the dependencies of interest, arrange them into an
|
||||
* order that works -- or throw Cycle exception.
|
||||
*
|
||||
* Return an iterator range over (key, node) pairs that traverses them in
|
||||
* the desired order.
|
||||
*/
|
||||
sorted_range sort() const
|
||||
{
|
||||
// Changes to mNodes cause us to clear our cache, so empty mCache
|
||||
// means it's invalid and should be recomputed. However, if mNodes is
|
||||
// also empty, then an empty mCache represents a valid order, so don't
|
||||
// bother sorting.
|
||||
if (mCache.empty() && ! mNodes.empty())
|
||||
{
|
||||
// Construct a map of node keys to distinct vertex numbers -- even for
|
||||
// nodes mentioned only in before/after constraints, that haven't yet
|
||||
// been explicitly added. Rely on std::map rejecting a second attempt
|
||||
// to insert the same key. Use the map's size() as the vertex number
|
||||
// to get a distinct value for each successful insertion.
|
||||
typedef std::map<KEY, int> VertexMap;
|
||||
VertexMap vmap;
|
||||
// Nest each of these loops because !@#$%? MSVC warns us that its
|
||||
// former broken behavior has finally been fixed -- and our builds
|
||||
// treat warnings as errors.
|
||||
{
|
||||
for (typename DepNodeMap::const_iterator nmi = mNodes.begin(), nmend = mNodes.end();
|
||||
nmi != nmend; ++nmi)
|
||||
{
|
||||
vmap.insert(typename VertexMap::value_type(nmi->first, vmap.size()));
|
||||
for (typename DepNode::dep_set::const_iterator ai = nmi->second.after.begin(),
|
||||
aend = nmi->second.after.end();
|
||||
ai != aend; ++ai)
|
||||
{
|
||||
vmap.insert(typename VertexMap::value_type(*ai, vmap.size()));
|
||||
}
|
||||
for (typename DepNode::dep_set::const_iterator bi = nmi->second.before.begin(),
|
||||
bend = nmi->second.before.end();
|
||||
bi != bend; ++bi)
|
||||
{
|
||||
vmap.insert(typename VertexMap::value_type(*bi, vmap.size()));
|
||||
}
|
||||
}
|
||||
}
|
||||
// Define the edges. For this we must traverse mNodes again, mapping
|
||||
// all the known key dependencies to integer pairs.
|
||||
EdgeList edges;
|
||||
{
|
||||
for (typename DepNodeMap::const_iterator nmi = mNodes.begin(), nmend = mNodes.end();
|
||||
nmi != nmend; ++nmi)
|
||||
{
|
||||
int thisnode = vmap[nmi->first];
|
||||
// after dependencies: build edges from the named node to this one
|
||||
for (typename DepNode::dep_set::const_iterator ai = nmi->second.after.begin(),
|
||||
aend = nmi->second.after.end();
|
||||
ai != aend; ++ai)
|
||||
{
|
||||
edges.push_back(EdgeList::value_type(vmap[*ai], thisnode));
|
||||
}
|
||||
// before dependencies: build edges from this node to the
|
||||
// named one
|
||||
for (typename DepNode::dep_set::const_iterator bi = nmi->second.before.begin(),
|
||||
bend = nmi->second.before.end();
|
||||
bi != bend; ++bi)
|
||||
{
|
||||
edges.push_back(EdgeList::value_type(thisnode, vmap[*bi]));
|
||||
}
|
||||
}
|
||||
}
|
||||
// Hide the gory details of our topological sort, since they shouldn't
|
||||
// get reinstantiated for each distinct NODE type.
|
||||
VertexList sorted(topo_sort(vmap.size(), edges));
|
||||
// Build the reverse of vmap to look up the key for each vertex
|
||||
// descriptor. vmap contains exactly one entry for each distinct key,
|
||||
// and we're certain that the associated int values are distinct
|
||||
// indexes. The fact that they're not in order is irrelevant.
|
||||
KeyList vkeys(vmap.size());
|
||||
for (typename VertexMap::const_iterator vmi = vmap.begin(), vmend = vmap.end();
|
||||
vmi != vmend; ++vmi)
|
||||
{
|
||||
vkeys[vmi->second] = vmi->first;
|
||||
}
|
||||
// Walk the sorted output list, building the result into mCache so
|
||||
// we'll have it next time someone asks.
|
||||
mCache.clear();
|
||||
for (VertexList::const_iterator svi = sorted.begin(), svend = sorted.end();
|
||||
svi != svend; ++svi)
|
||||
{
|
||||
// We're certain that vkeys[*svi] exists. However, there might not
|
||||
// yet be a corresponding entry in mNodes.
|
||||
self_type* non_const_this(const_cast<self_type*>(this));
|
||||
typename DepNodeMap::iterator found = non_const_this->mNodes.find(vkeys[*svi]);
|
||||
if (found != non_const_this->mNodes.end())
|
||||
{
|
||||
// Make an iterator of appropriate type.
|
||||
mCache.push_back(iterator(found, value_extract));
|
||||
}
|
||||
}
|
||||
}
|
||||
// Whether or not we've just recomputed mCache, it should now contain
|
||||
// the results we want. Return a range of indirect_iterators over it
|
||||
// so that dereferencing a returned iterator will dereference the
|
||||
// iterator stored in mCache and directly reference the (key, node)
|
||||
// pair.
|
||||
boost::indirect_iterator<iterator_list_iterator>
|
||||
begin(mCache.begin()),
|
||||
end(mCache.end());
|
||||
return sorted_range(begin, end);
|
||||
}
|
||||
|
||||
using LLDependenciesBase::describe; // unhide virtual std::string describe(bool full=true) const;
|
||||
|
||||
/// Override base-class describe() with actual implementation
|
||||
virtual std::ostream& describe(std::ostream& out, bool full=true) const
|
||||
{
|
||||
typename DepNodeMap::const_iterator dmi(mNodes.begin()), dmend(mNodes.end());
|
||||
if (dmi != dmend)
|
||||
{
|
||||
std::string sep;
|
||||
describe(out, sep, *dmi, full);
|
||||
while (++dmi != dmend)
|
||||
{
|
||||
describe(out, sep, *dmi, full);
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
/// describe() helper: report a DepNodeEntry
|
||||
static std::ostream& describe(std::ostream& out, std::string& sep,
|
||||
const DepNodeMapEntry& entry, bool full)
|
||||
{
|
||||
// If we were asked for a full report, describe every node regardless
|
||||
// of whether it has dependencies. If we were asked to suppress
|
||||
// independent nodes, describe this one if either after or before is
|
||||
// non-empty.
|
||||
if (full || (! entry.second.after.empty()) || (! entry.second.before.empty()))
|
||||
{
|
||||
out << sep;
|
||||
sep = "\n";
|
||||
if (! entry.second.after.empty())
|
||||
{
|
||||
out << "after ";
|
||||
describe(out, entry.second.after);
|
||||
out << " -> ";
|
||||
}
|
||||
LLDependencies_describe(out, entry.first);
|
||||
if (! entry.second.before.empty())
|
||||
{
|
||||
out << " -> before ";
|
||||
describe(out, entry.second.before);
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
/// describe() helper: report a dep_set
|
||||
static std::ostream& describe(std::ostream& out, const typename DepNode::dep_set& keys)
|
||||
{
|
||||
out << '(';
|
||||
typename DepNode::dep_set::const_iterator ki(keys.begin()), kend(keys.end());
|
||||
if (ki != kend)
|
||||
{
|
||||
LLDependencies_describe(out, *ki);
|
||||
while (++ki != kend)
|
||||
{
|
||||
out << ", ";
|
||||
LLDependencies_describe(out, *ki);
|
||||
}
|
||||
}
|
||||
out << ')';
|
||||
return out;
|
||||
}
|
||||
|
||||
/// Iterator over the before/after KEYs on which a given NODE depends
|
||||
typedef typename DepNode::dep_set::const_iterator dep_iterator;
|
||||
/// range over the before/after KEYs on which a given NODE depends
|
||||
typedef boost::iterator_range<dep_iterator> dep_range;
|
||||
|
||||
/// dependencies access from key
|
||||
dep_range get_dep_range_from_key(const KEY& key, const dep_selector& selector) const
|
||||
{
|
||||
typename DepNodeMap::const_iterator found = mNodes.find(key);
|
||||
if (found != mNodes.end())
|
||||
{
|
||||
return dep_range(selector(found->second));
|
||||
}
|
||||
// We want to return an empty range. On some platforms a default-
|
||||
// constructed range (e.g. dep_range()) does NOT suffice! The client
|
||||
// is likely to try to iterate from boost::begin(range) to
|
||||
// boost::end(range); yet these iterators might not be valid. Instead
|
||||
// return a range over a valid, empty container.
|
||||
static const typename DepNode::dep_set empty_deps;
|
||||
return dep_range(empty_deps.begin(), empty_deps.end());
|
||||
}
|
||||
|
||||
/// dependencies access from any one of our key-order iterators
|
||||
template<typename ITERATOR>
|
||||
dep_range get_dep_range_from_xform(const ITERATOR& iterator, const dep_selector& selector) const
|
||||
{
|
||||
return dep_range(selector(iterator.base()->second));
|
||||
}
|
||||
|
||||
/// dependencies access from sorted_iterator
|
||||
dep_range get_dep_range_from_sorted(const sorted_iterator& sortiter,
|
||||
const dep_selector& selector) const
|
||||
{
|
||||
// sorted_iterator is a boost::indirect_iterator wrapping an mCache
|
||||
// iterator, which we can obtain by sortiter.base(). Deferencing that
|
||||
// gets us an mCache entry, an 'iterator' -- one of our traversal
|
||||
// iterators -- on which we can use get_dep_range_from_xform().
|
||||
return get_dep_range_from_xform(*sortiter.base(), selector);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a range over the after KEYs stored for the passed KEY or iterator,
|
||||
* in <i>arbitrary order.</i> If you pass a nonexistent KEY, returns empty
|
||||
* range -- same as a KEY with no after KEYs. Detect existence of a KEY
|
||||
* using get() instead.
|
||||
*/
|
||||
template<typename KEY_OR_ITER>
|
||||
dep_range get_after_range(const KEY_OR_ITER& key) const;
|
||||
|
||||
/**
|
||||
* Get a range over the before KEYs stored for the passed KEY or iterator,
|
||||
* in <i>arbitrary order.</i> If you pass a nonexistent KEY, returns empty
|
||||
* range -- same as a KEY with no before KEYs. Detect existence of a KEY
|
||||
* using get() instead.
|
||||
*/
|
||||
template<typename KEY_OR_ITER>
|
||||
dep_range get_before_range(const KEY_OR_ITER& key) const;
|
||||
|
||||
private:
|
||||
DepNodeMap mNodes;
|
||||
mutable iterator_list mCache;
|
||||
};
|
||||
|
||||
/**
|
||||
* Functor to get a dep_range from a KEY or iterator -- generic case. If the
|
||||
* passed value isn't one of our iterator specializations, assume it's
|
||||
* convertible to the KEY type.
|
||||
*/
|
||||
template<typename KEY_ITER>
|
||||
struct LLDependencies_dep_range_from
|
||||
{
|
||||
template<typename KEY, typename NODE, typename SELECTOR>
|
||||
typename LLDependencies<KEY, NODE>::dep_range
|
||||
operator()(const LLDependencies<KEY, NODE>& deps,
|
||||
const KEY_ITER& key,
|
||||
const SELECTOR& selector)
|
||||
{
|
||||
return deps.get_dep_range_from_key(key, selector);
|
||||
}
|
||||
};
|
||||
|
||||
/// Specialize LLDependencies_dep_range_from for our key-order iterators
|
||||
template<typename FUNCTION, typename ITERATOR>
|
||||
struct LLDependencies_dep_range_from< boost::transform_iterator<FUNCTION, ITERATOR> >
|
||||
{
|
||||
template<typename KEY, typename NODE, typename SELECTOR>
|
||||
typename LLDependencies<KEY, NODE>::dep_range
|
||||
operator()(const LLDependencies<KEY, NODE>& deps,
|
||||
const boost::transform_iterator<FUNCTION, ITERATOR>& iter,
|
||||
const SELECTOR& selector)
|
||||
{
|
||||
return deps.get_dep_range_from_xform(iter, selector);
|
||||
}
|
||||
};
|
||||
|
||||
/// Specialize LLDependencies_dep_range_from for sorted_iterator
|
||||
template<typename BASEITER>
|
||||
struct LLDependencies_dep_range_from< boost::indirect_iterator<BASEITER> >
|
||||
{
|
||||
template<typename KEY, typename NODE, typename SELECTOR>
|
||||
typename LLDependencies<KEY, NODE>::dep_range
|
||||
operator()(const LLDependencies<KEY, NODE>& deps,
|
||||
const boost::indirect_iterator<BASEITER>& iter,
|
||||
const SELECTOR& selector)
|
||||
{
|
||||
return deps.get_dep_range_from_sorted(iter, selector);
|
||||
}
|
||||
};
|
||||
|
||||
/// generic get_after_range() implementation
|
||||
template<typename KEY, typename NODE>
|
||||
template<typename KEY_OR_ITER>
|
||||
typename LLDependencies<KEY, NODE>::dep_range
|
||||
LLDependencies<KEY, NODE>::get_after_range(const KEY_OR_ITER& key_iter) const
|
||||
{
|
||||
return LLDependencies_dep_range_from<KEY_OR_ITER>()(
|
||||
*this,
|
||||
key_iter,
|
||||
boost::bind<const typename DepNode::dep_set&>(&DepNode::after, _1));
|
||||
}
|
||||
|
||||
/// generic get_before_range() implementation
|
||||
template<typename KEY, typename NODE>
|
||||
template<typename KEY_OR_ITER>
|
||||
typename LLDependencies<KEY, NODE>::dep_range
|
||||
LLDependencies<KEY, NODE>::get_before_range(const KEY_OR_ITER& key_iter) const
|
||||
{
|
||||
return LLDependencies_dep_range_from<KEY_OR_ITER>()(
|
||||
*this,
|
||||
key_iter,
|
||||
boost::bind<const typename DepNode::dep_set&>(&DepNode::before, _1));
|
||||
}
|
||||
|
||||
#endif /* ! defined(LL_LLDEPENDENCIES_H) */
|
||||
@@ -402,7 +402,7 @@ namespace
|
||||
{
|
||||
/* This pattern, of returning a reference to a static function
|
||||
variable, is to ensure that this global is constructed before
|
||||
it is used, no matter what the global initializeation sequence
|
||||
it is used, no matter what the global initialization sequence
|
||||
is.
|
||||
See C++ FAQ Lite, sections 10.12 through 10.14
|
||||
*/
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user