Compare commits
584 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| ea90f781ff | |||
| c1b161b44b | |||
| aa84b2e328 | |||
| ebc1602816 | |||
| dcd6a55529 | |||
| fb258a7416 | |||
| 5aed927887 | |||
| d964bb9f2f | |||
| 87dc7a5b97 | |||
| ae63ca481d | |||
| 8e599103b6 | |||
| af0140e260 | |||
| 9d43907710 | |||
| a3fcd67a82 | |||
| fe3a43e2d4 | |||
| e095047b02 | |||
| 31a106344f | |||
| b0a82aa420 | |||
| c003d6032d | |||
| 1665595138 | |||
| bbccf76b45 | |||
| 1f47fa9243 | |||
| 7b24a12a66 | |||
| 921e7ac3e9 | |||
| 8d807add41 | |||
| 8501fce38b | |||
| 55d7984582 | |||
| 8dbac9c0bd | |||
| 47b8510b0c | |||
| 4e399b41cd | |||
| bdec1e037f | |||
| 9924cce466 | |||
| d3ecbd75af | |||
| 75b65ab2a2 | |||
| eca8825ab4 | |||
| 9f9b7cf885 | |||
| cd695d7f15 | |||
| 9c0ae597cd | |||
| 4461b4c56f | |||
| 93361118b7 | |||
| 50f963f6c6 | |||
| 67c3e47ed4 | |||
| f14cf8289e | |||
| 790aa68621 | |||
| 6d1d61026d | |||
| a4e3ca933b | |||
| 1fb58f9f8e | |||
| 86e0b9386d | |||
| c7c4cf221a | |||
| d6e439244a | |||
| 5ff225fa1b | |||
| 2a77e840cc | |||
| 00272883f6 | |||
| bd6f3b1273 | |||
| 4e9767bb22 | |||
| 1d54b7a266 | |||
| c9506d939a | |||
| 21217824b7 | |||
| 8024df2991 | |||
| f72b6fe717 | |||
| 8d29d25d60 | |||
| af8e7ab984 | |||
| 4289d5de7d | |||
| 83734aff0e | |||
| 617b6728d3 | |||
| 7a8fd6cb20 | |||
| 55da339586 | |||
| 774eae0f2f | |||
| 201b108a54 | |||
| bdbdbcea26 | |||
| f6c1a21cf0 | |||
| c953072a15 | |||
| 93f3e9357b | |||
| 8ea8b49464 | |||
| 62cef44dcb | |||
| a2edc95207 | |||
| 4cd41e3e08 | |||
| b641f993ac | |||
| e2905b6bc9 | |||
| e11b59a80f | |||
| 0ae02e8ad4 | |||
| 2cbdffab86 | |||
| 86eefdb2a8 | |||
| 750399ccd7 | |||
| fb97ca6022 | |||
| cbcaa54173 | |||
| 94e3fca702 | |||
| ffff104554 | |||
| 307a9dd1b2 | |||
| 5dff8ea820 | |||
| 49648fe22d | |||
| 9f037e8980 | |||
| 12f81bcbb9 | |||
| 6636131d3b | |||
| eeea9631ce | |||
| f9d228c30a | |||
| d516f8c4bd | |||
| 5d1c3a0c63 | |||
| 396f2d6050 | |||
| e25b01c3a2 | |||
| b29a24afb0 | |||
| d6d1dba3d2 | |||
| 8b36a9d121 | |||
| 59ed9338d8 | |||
| b444dea63b | |||
| 1816c8bd37 | |||
| c27948a7ee | |||
| 832dc8a585 | |||
| bb121e68a6 | |||
| 1ec26fd789 | |||
| 4ff4a7e3b9 | |||
| 6bb14e45ce | |||
| 45dc804819 | |||
| 81db01ebf1 | |||
| 06c576a945 | |||
| 929b025fd6 | |||
| 7976de05a5 | |||
| 70c88879ab | |||
| 276ee63b99 | |||
| 487f0dde75 | |||
| c8f700930a | |||
| decbe4df45 | |||
| 462f27c129 | |||
| 2d1191697a | |||
| 0b5a0d1e79 | |||
| 0b7eb9f118 | |||
| dc26261065 | |||
| 9bea67fb1c | |||
| 8246bc3418 | |||
| 01e32b58da | |||
| 9d05ff0468 | |||
| 510ccc7f17 | |||
| 43067ed2b8 | |||
| 4e4c9aef15 | |||
| 4031ee5ef0 | |||
| e079291202 | |||
| 826c641668 | |||
| 6ae845fd9e | |||
| a78fd58dca | |||
| a8ae610489 | |||
| b86a1e5797 | |||
| 45552a68ce | |||
| d46655fbb2 | |||
| 87fee8c504 | |||
| 9ff0617807 | |||
| 243939f94f | |||
| 739385bd89 | |||
| 32060f53cd | |||
| 4ee3972f15 | |||
| 00a9cf4a85 | |||
| 1dcd538ad9 | |||
| a8973514ba | |||
| 0ac9e57d28 | |||
| 5460e85c40 | |||
| 432f0ba34c | |||
| 7e01e53445 | |||
| 043fe6edd2 | |||
| ef68e5d0ff | |||
| c6f3a4e062 | |||
| 87ed53c7f6 | |||
| 89e9437b84 | |||
| 1454c46b5f | |||
| 0fac1e9115 | |||
| f3a3358e63 | |||
| 3c122b0bef | |||
| 7940003d06 | |||
| 45b16ff456 | |||
| 9341f4f884 | |||
| 2c20f26784 | |||
| 2a21a449b4 | |||
| 74dc7090fd | |||
| e12ac95d69 | |||
| 34ea7eba9e | |||
| 6d3ba44f55 | |||
| 5a8ad67660 | |||
| f1e442408b | |||
| a946af4463 | |||
| e01cd92d56 | |||
| 923af8c3a6 | |||
| ac04cf57fa | |||
| 1f6c4e01db | |||
| 04135723a2 | |||
| 93fbdb1e6c | |||
| c1de15f840 | |||
| 3be399c555 | |||
| 1f5453075c | |||
| 33a74f1594 | |||
| e4da1224cb | |||
| 5c2a47620c | |||
| 1bfa7609d2 | |||
| 7e8501123a | |||
| c447eeb2c7 | |||
| ad19cea6e0 | |||
| 0ce29863e3 | |||
| 7a7a4844f4 | |||
| a2adbb1ab5 | |||
| a97fc792d8 | |||
| e9a6a1d6f5 | |||
| f245f0ef87 | |||
| a30f431b63 | |||
| 58f48f20e2 | |||
| ee1b02b709 | |||
| 55c790c9ff | |||
| 65b69f3308 | |||
| c67fbd72dd | |||
| 30f57d0824 | |||
| 1c54018111 | |||
| e80e1b6d9f | |||
| 437f00d6de | |||
| fc6d6b1601 | |||
| 9306e36d52 | |||
| 61122a5093 | |||
| a8a4ff8af1 | |||
| 8a857c35ee | |||
| 89ddd7d8e5 | |||
| 8d0c4ccb3b | |||
| 8ee47d5573 | |||
| 9e88011417 | |||
| f8949ee7a1 | |||
| 62aa2d0ba7 | |||
| ace047d625 | |||
| d6277db209 | |||
| 7ebb28327f | |||
| 86931cbde4 | |||
| 6d7be151dc | |||
| 07227b9806 | |||
| 8348d719cd | |||
| 0fcefd865b | |||
| 57c2e9b5f8 | |||
| 7d7fc39035 | |||
| 351105b3df | |||
| cbfc33215b | |||
| 5a93b56673 | |||
| 1f4c69c17a | |||
| f5b19fad20 | |||
| bc60818e9a | |||
| f82c88f016 | |||
| 98e86decad | |||
| aaf2c0ebd4 | |||
| 778b74cae1 | |||
| 43ee1edd97 | |||
| dd7e23740b | |||
| 1acd6da745 | |||
| 3056f91ec5 | |||
| ed03570e1a | |||
| 2ec0e48d06 | |||
| 8b54d59b8c | |||
| f6a4dbabdd | |||
| a71c291bcb | |||
| 55b9ccc2de | |||
| 67d67a3bf6 | |||
| 591de1ecb4 | |||
| 3dad17c263 | |||
| eefc18170d | |||
| 5f84c5339d | |||
| 2d461379ef | |||
| c8123756ff | |||
| 76c7789ee7 | |||
| 13a2e6ef1f | |||
| 0ecb34b850 | |||
| 1f86c48d95 | |||
| 7e1295df9a | |||
| 482b160c8a | |||
| 181eb95b13 | |||
| c0ccd31a3e | |||
| d72b132c57 | |||
| 506912aed7 | |||
| 670d70d3c9 | |||
| 010f7d12f4 | |||
| da684564ea | |||
| fc4c867f27 | |||
| 9ba30c4e20 | |||
| 15334e56cd | |||
| ffa42ff22c | |||
| a7c62dbabc | |||
| eda1e41152 | |||
| af5a5b76ec | |||
| 87f3a0dc16 | |||
| 2c80a80704 | |||
| 301a4c4a95 | |||
| 8fc4a3b724 | |||
| cb6f040005 | |||
| b91c2e4a99 | |||
| 59a71b1454 | |||
| 36f133a5ae | |||
| 74a58c0d09 | |||
| bfa1107781 | |||
| 11397f7667 | |||
| 6e9e8239ef | |||
| af9932d28b | |||
| 87ff8a65e9 | |||
| 7b6f207790 | |||
| 8672008e43 | |||
| c8cd193346 | |||
| be292e5f0b | |||
| 3863dcc9cb | |||
| a2568409fc | |||
| 6567cdd7b5 | |||
| 5bbf55a401 | |||
| 4a530e2146 | |||
| 27ba8f7b60 | |||
| 6bfdb57a5b | |||
| 26e8ea60a5 | |||
| f4ea188ffa | |||
| 1266580420 | |||
| 16d96eed7b | |||
| fa76168683 | |||
| 5f3329b2c9 | |||
| db541f3cfa | |||
| 3e19ba6ca8 | |||
| ac8c082b89 | |||
| 084df2a229 | |||
| 22557070ec | |||
| f8ef66954c | |||
| ef59901e7c | |||
| cfe620ccb5 | |||
| 453b015225 | |||
| c1cf9ae8f6 | |||
| f1414c650e | |||
| 869b041f2f | |||
| 8621fbb015 | |||
| 597e01153e | |||
| d3e5fcd13e | |||
| 3e0f9cc716 | |||
| c7e49c9f57 | |||
| e2ed8ff2bf | |||
| 559c786d0c | |||
| c3a7480961 | |||
| a75e75aef5 | |||
| d45b1207d0 | |||
| 5a9e24dea1 | |||
| dc8132e965 | |||
| 20bcdc1ef6 | |||
| 93c0f61050 | |||
| 3a8c543f8b | |||
| 9e96156451 | |||
| 19aabd6d02 | |||
| 87b5d7bc7b | |||
| 646714b585 | |||
| eba60c30c5 | |||
| e66bb09156 | |||
| 0042b1f80d | |||
| 6d416ee734 | |||
| 97d3a45aff | |||
| 9e9ff44b17 | |||
| f369be148f | |||
| 3a09e446b3 | |||
| 2d0b12e49e | |||
| 55e2f294ac | |||
| 2a4b467f08 | |||
| 2ae9da696a | |||
| 376997c3ef | |||
| e963782b8c | |||
| 86c01aa62c | |||
| 15783d25e7 | |||
| 3243f69f21 | |||
| 10a87f510c | |||
| ca6feeda29 | |||
| cecf778de3 | |||
| fe79ab351a | |||
| dc0a3a6653 | |||
| fed346c285 | |||
| cad9b367a5 | |||
| 6e86146a25 | |||
| 49d9695ad9 | |||
| e15bc6b9ba | |||
| 28093a6dcb | |||
| 2af5498804 | |||
| 2b42d7fdb8 | |||
| 9b3c4faa34 | |||
| 847b3e8b61 | |||
| b1bdd7c89f | |||
| ffe7a11866 | |||
| 8c3188bc7d | |||
| 880196e5a8 | |||
| d523b440e3 | |||
| f2875d5d13 | |||
| b0720333cc | |||
| c3446a10fa | |||
| fbc869eed7 | |||
| e3e4dbbccf | |||
| 7fda645b16 | |||
| ec7f20644d | |||
| 3d5fa91703 | |||
| e8acfb069c | |||
| 4c38ed272d | |||
| acbb4f8e6c | |||
| 13a3fe8a7a | |||
| 3dd3cd4ceb | |||
| 80fcbc8adc | |||
| 33680accea | |||
| 081e593e2b | |||
| b4ffdfab81 | |||
| 1ea4aac799 | |||
| 4d6c292757 | |||
| 655a83c5c5 | |||
| e8b576bc25 | |||
| 01404ed7af | |||
| ad6237f6f7 | |||
| d06c64e1c4 | |||
| b4ad3186dd | |||
| 5f1c0450b3 | |||
| 04b62f77e3 | |||
| 029dff3f40 | |||
| 342f639771 | |||
| b5a2baafe5 | |||
| 781e4e5be4 | |||
| f3dddb5e99 | |||
| 9a5e892cad | |||
| 0317362662 | |||
| 6b403a76e8 | |||
| 6bf6c6fb7b | |||
| 29618bee10 | |||
| db80f682c9 | |||
| e1cdbac5a0 | |||
| 543eb9d217 | |||
| bc963463f3 | |||
| 86b7b3d54b | |||
| 799ba1f954 | |||
| 1a3e39e452 | |||
| 7dc73815ae | |||
| 4caf2c7edd | |||
| 1b9d740244 | |||
| 497ada9c77 | |||
| 73e386dc6f | |||
| 43cfc097de | |||
| 6735fc7911 | |||
| be34dbe608 | |||
| 70102e7cd3 | |||
| 8ad16145f6 | |||
| bb7b18d4e1 | |||
| 4742dedb45 | |||
| 10a9bc62bf | |||
| 8cbbf17519 | |||
| 24f433b938 | |||
| abc69dd3d0 | |||
| bf87aed459 | |||
| 42306f93b3 | |||
| 03ca50fa70 | |||
| 7b1b8bd741 | |||
| a11f25e47b | |||
| a6213ebfc7 | |||
| b95fcf5da1 | |||
| 707e596811 | |||
| 5678041b92 | |||
| 7f850d8fb0 | |||
| 7edc576e9c | |||
| 0041a09576 | |||
| 0f06254ecf | |||
| ff5245ca8a | |||
| fe925ada59 | |||
| b6596f38b9 | |||
| 16fb3f6db5 | |||
| a2e2522612 | |||
| df07e8a65b | |||
| 729f076c3b | |||
| dfc0118b8b | |||
| d9ef062caf | |||
| 2b8ce3b4cf | |||
| a27b855a39 | |||
| 1634b69faf | |||
| 59fa1f90d5 | |||
| e519338a2b | |||
| 7a4870bd97 | |||
| a552e32a9a | |||
| 29c6238b52 | |||
| 38db8eb64b | |||
| 3bbbf8a025 | |||
| 978764cb6b | |||
| 893ecf1af2 | |||
| aa453b4e9e | |||
| f8089d2026 | |||
| 40241b4e97 | |||
| f10408739e | |||
| e1d0ad749b | |||
| 2a5a5b5c1b | |||
| a97ecb8690 | |||
| bc56c00a9a | |||
| 1e3ad2f9ce | |||
| 9c97f07ec9 | |||
| f8acdc9497 | |||
| 90d825e7f8 | |||
| 1178e900eb | |||
| 298f6f440a | |||
| 8553fb9e30 | |||
| da3b270488 | |||
| dd60366aec | |||
| 017fc93307 | |||
| 042ec206e7 | |||
| 312108a0d3 | |||
| 5e48be27b8 | |||
| b3badbf97d | |||
| 4d5885e27b | |||
| 8fe39042da | |||
| 9ed574b399 | |||
| 7ef623c71d | |||
| 733cd120b3 | |||
| 4e2f8e305e | |||
| 3d78d93b40 | |||
| 5a2f509104 | |||
| 9382956b0e | |||
| 42027a3f94 | |||
| 1397417fcd | |||
| c9a539eade | |||
| cb1d62f254 | |||
| 1cbd625b4e | |||
| 73678f3b78 | |||
| 79b95da0a3 | |||
| 1c85273662 | |||
| 76dd568971 | |||
| a43868c32b | |||
| 7a99b1fa32 | |||
| e82c27ab04 | |||
| f32098e04d | |||
| 1e0fa58d79 | |||
| f7ef5c169b | |||
| 927763902f | |||
| fcff17c567 | |||
| 2e88a3d03b | |||
| 1061108c61 | |||
| 5f8e65e099 | |||
| d90b36cf11 | |||
| 87615fffc9 | |||
| 8343a98ec6 | |||
| d7bf7a8b0d | |||
| 9eed1e8609 | |||
| 8011ad97b5 | |||
| ab8d342df0 | |||
| dcac0de44c | |||
| 2ee389044b | |||
| a48201ed94 | |||
| e516b3c0d3 | |||
| 51c5fa94aa | |||
| d6288d63c6 | |||
| 96bd020bd3 | |||
| 8dc2aef058 | |||
| d43486f894 | |||
| 229bc0d7e1 | |||
| 5b0514a829 | |||
| 0bef94cb48 | |||
| 44df5c3567 | |||
| 7bf9ebf545 | |||
| 1e9302f564 | |||
| a433ae0ff4 | |||
| e5609279da | |||
| afd3b71849 | |||
| 4cc64fa9a8 | |||
| 7f55372727 | |||
| 919b8c5bd1 | |||
| a281027876 | |||
| 72ce653bcf | |||
| 17c8881444 | |||
| 6aabc837a9 | |||
| 233e6f1765 | |||
| 9adc20e4e7 | |||
| bdf16bf601 | |||
| cf03bfa156 | |||
| d4f556836a | |||
| ebb30ec5b0 | |||
| 168d8e3bee | |||
| 654788f2cf | |||
| 06f2076f04 | |||
| fc43a13927 | |||
| 28f80fa113 | |||
| 9ebf1c1431 | |||
| 8795932420 | |||
| be50a5f992 | |||
| 7086f5f84c | |||
| 670487b4dd | |||
| 0ac746df57 | |||
| 7458273634 | |||
| aa386041e7 | |||
| 44e0fa9325 | |||
| 91d214d713 | |||
| 635f673b95 | |||
| 35a82970a3 | |||
| ac9bef0b31 | |||
| f6bb6cc891 | |||
| 56ff747463 | |||
| d14ea2965d | |||
| e773887b4b | |||
| 5b85067f9c | |||
| 1fa1edf16b | |||
| 19156ab895 |
+1
-1
@@ -1 +1 @@
|
||||
CMakeConf
|
||||
build
|
||||
|
||||
+41
-2
@@ -18,6 +18,12 @@
|
||||
* Or go to http://www.gnu.org/copyleft/lgpl.html
|
||||
*/
|
||||
|
||||
#ifdef _WIN32
|
||||
#define _WIN32_IE 0x400
|
||||
#endif
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
@@ -25,6 +31,10 @@
|
||||
|
||||
#include "alMain.h"
|
||||
|
||||
#ifdef _WIN32_IE
|
||||
#include <shlobj.h>
|
||||
#endif
|
||||
|
||||
typedef struct ConfigEntry {
|
||||
char *key;
|
||||
char *value;
|
||||
@@ -199,8 +209,19 @@ void ReadALConfig(void)
|
||||
cfgCount = 1;
|
||||
|
||||
#ifdef _WIN32
|
||||
if(SHGetSpecialFolderPathA(NULL, buffer, CSIDL_APPDATA, FALSE) != FALSE)
|
||||
{
|
||||
int p = strlen(buffer);
|
||||
snprintf(buffer+p, sizeof(buffer)-p, "\\alsoft.ini");
|
||||
f = fopen(buffer, "rt");
|
||||
if(f)
|
||||
{
|
||||
LoadConfigFromFile(f);
|
||||
fclose(f);
|
||||
}
|
||||
}
|
||||
#else
|
||||
f = fopen("/etc/openal/config", "r");
|
||||
f = fopen("/etc/openal/alsoft.conf", "r");
|
||||
if(f)
|
||||
{
|
||||
LoadConfigFromFile(f);
|
||||
@@ -208,7 +229,7 @@ void ReadALConfig(void)
|
||||
}
|
||||
if(getenv("HOME") && *(getenv("HOME")))
|
||||
{
|
||||
snprintf(buffer, sizeof(buffer), "%s/.openalrc", getenv("HOME"));
|
||||
snprintf(buffer, sizeof(buffer), "%s/.alsoftrc", getenv("HOME"));
|
||||
f = fopen(buffer, "r");
|
||||
if(f)
|
||||
{
|
||||
@@ -217,6 +238,15 @@ void ReadALConfig(void)
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if(getenv("ALSOFT_CONF"))
|
||||
{
|
||||
f = fopen(getenv("ALSOFT_CONF"), "r");
|
||||
if(f)
|
||||
{
|
||||
LoadConfigFromFile(f);
|
||||
fclose(f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void FreeALConfig(void)
|
||||
@@ -283,3 +313,12 @@ float GetConfigValueFloat(const char *blockName, const char *keyName, float def)
|
||||
return (float)strtod(val, NULL);
|
||||
#endif
|
||||
}
|
||||
|
||||
int GetConfigValueBool(const char *blockName, const char *keyName, float def)
|
||||
{
|
||||
const char *val = GetConfigValue(blockName, keyName, "");
|
||||
|
||||
if(!val[0]) return !!def;
|
||||
return (strcasecmp(val, "true") == 0 || strcasecmp(val, "yes") == 0 ||
|
||||
strcasecmp(val, "on") == 0 || atoi(val) != 0);
|
||||
}
|
||||
|
||||
+212
@@ -0,0 +1,212 @@
|
||||
/**
|
||||
* OpenAL cross platform audio library
|
||||
* Copyright (C) 2009 by Chris Robinson.
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* 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
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
* Or go to http://www.gnu.org/copyleft/lgpl.html
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "alMain.h"
|
||||
#include "alFilter.h"
|
||||
#include "alAuxEffectSlot.h"
|
||||
#include "alError.h"
|
||||
#include "alu.h"
|
||||
|
||||
// Just a soft maximum. Being higher will cause EchoUpdate to reallocate the
|
||||
// sample buffer which may cause an abort if realloc fails
|
||||
#define MAX_ECHO_FREQ 192000
|
||||
|
||||
typedef struct ALechoState {
|
||||
// Must be first in all effects!
|
||||
ALeffectState state;
|
||||
|
||||
ALfloat *SampleBuffer;
|
||||
ALuint BufferLength;
|
||||
|
||||
// The echo is two tap. The delay is the number of samples from before the
|
||||
// current offset
|
||||
struct {
|
||||
ALuint delay;
|
||||
} Tap[2];
|
||||
ALuint Offset;
|
||||
// The LR gains for the first tap. The second tap uses the reverse
|
||||
ALfloat GainL;
|
||||
ALfloat GainR;
|
||||
|
||||
ALfloat FeedGain;
|
||||
|
||||
FILTER iirFilter;
|
||||
ALfloat history[2];
|
||||
} ALechoState;
|
||||
|
||||
// Find the next power of 2. Actually, this will return the input value if
|
||||
// it is already a power of 2.
|
||||
static ALuint NextPowerOf2(ALuint value)
|
||||
{
|
||||
ALuint powerOf2 = 1;
|
||||
|
||||
if(value)
|
||||
{
|
||||
value--;
|
||||
while(value)
|
||||
{
|
||||
value >>= 1;
|
||||
powerOf2 <<= 1;
|
||||
}
|
||||
}
|
||||
return powerOf2;
|
||||
}
|
||||
|
||||
ALvoid EchoDestroy(ALeffectState *effect)
|
||||
{
|
||||
ALechoState *state = (ALechoState*)effect;
|
||||
if(state)
|
||||
{
|
||||
free(state->SampleBuffer);
|
||||
state->SampleBuffer = NULL;
|
||||
free(state);
|
||||
}
|
||||
}
|
||||
|
||||
ALboolean EchoDeviceUpdate(ALeffectState *effect, ALCdevice *Device)
|
||||
{
|
||||
ALechoState *state = (ALechoState*)effect;
|
||||
ALuint maxlen, i;
|
||||
|
||||
// Use the next power of 2 for the buffer length, so the tap offsets can be
|
||||
// wrapped using a mask instead of a modulo
|
||||
maxlen = (ALuint)(AL_ECHO_MAX_DELAY * Device->Frequency);
|
||||
maxlen += (ALuint)(AL_ECHO_MAX_LRDELAY * Device->Frequency);
|
||||
maxlen = NextPowerOf2(maxlen+1);
|
||||
|
||||
if(maxlen != state->BufferLength)
|
||||
{
|
||||
void *temp;
|
||||
|
||||
temp = realloc(state->SampleBuffer, maxlen * sizeof(ALfloat));
|
||||
if(!temp)
|
||||
{
|
||||
alSetError(AL_OUT_OF_MEMORY);
|
||||
return AL_FALSE;
|
||||
}
|
||||
state->BufferLength = maxlen;
|
||||
}
|
||||
for(i = 0;i < state->BufferLength;i++)
|
||||
state->SampleBuffer[i] = 0.0f;
|
||||
|
||||
return AL_TRUE;
|
||||
}
|
||||
|
||||
ALvoid EchoUpdate(ALeffectState *effect, ALCcontext *Context, const ALeffect *Effect)
|
||||
{
|
||||
ALechoState *state = (ALechoState*)effect;
|
||||
ALuint frequency = Context->Device->Frequency;
|
||||
ALfloat lrpan, cw, a, g;
|
||||
|
||||
state->Tap[0].delay = (ALuint)(Effect->Echo.Delay * frequency);
|
||||
state->Tap[1].delay = (ALuint)(Effect->Echo.LRDelay * frequency);
|
||||
state->Tap[1].delay += state->Tap[0].delay;
|
||||
|
||||
lrpan = Effect->Echo.Spread*0.5f + 0.5f;
|
||||
state->GainL = aluSqrt( lrpan);
|
||||
state->GainR = aluSqrt(1.0f-lrpan);
|
||||
|
||||
state->FeedGain = Effect->Echo.Feedback;
|
||||
|
||||
cw = cos(2.0*M_PI * LOWPASSFREQCUTOFF / frequency);
|
||||
g = 1.0f - Effect->Echo.Damping;
|
||||
a = 0.0f;
|
||||
if(g < 0.9999f) // 1-epsilon
|
||||
a = (1 - g*cw - aluSqrt(2*g*(1-cw) - g*g*(1 - cw*cw))) / (1 - g);
|
||||
state->iirFilter.coeff = a;
|
||||
}
|
||||
|
||||
ALvoid EchoProcess(ALeffectState *effect, const ALeffectslot *Slot, ALuint SamplesToDo, const ALfloat *SamplesIn, ALfloat (*SamplesOut)[OUTPUTCHANNELS])
|
||||
{
|
||||
ALechoState *state = (ALechoState*)effect;
|
||||
const ALuint mask = state->BufferLength-1;
|
||||
const ALuint tap1 = state->Tap[0].delay;
|
||||
const ALuint tap2 = state->Tap[1].delay;
|
||||
ALuint offset = state->Offset;
|
||||
const ALfloat gain = Slot->Gain;
|
||||
ALfloat samp[2], smp;
|
||||
ALuint i;
|
||||
|
||||
for(i = 0;i < SamplesToDo;i++,offset++)
|
||||
{
|
||||
// Sample first tap
|
||||
smp = state->SampleBuffer[(offset-tap1) & mask];
|
||||
samp[0] = smp * state->GainL;
|
||||
samp[1] = smp * state->GainR;
|
||||
// Sample second tap. Reverse LR panning
|
||||
smp = state->SampleBuffer[(offset-tap2) & mask];
|
||||
samp[0] += smp * state->GainR;
|
||||
samp[1] += smp * state->GainL;
|
||||
|
||||
// Apply damping and feedback gain to the second tap, and mix in the
|
||||
// new sample
|
||||
smp = lpFilter2P(&state->iirFilter, 0, smp+SamplesIn[i]);
|
||||
state->SampleBuffer[offset&mask] = smp * state->FeedGain;
|
||||
|
||||
// Apply slot gain
|
||||
samp[0] *= gain;
|
||||
samp[1] *= gain;
|
||||
|
||||
SamplesOut[i][FRONT_LEFT] += samp[0];
|
||||
SamplesOut[i][FRONT_RIGHT] += samp[1];
|
||||
SamplesOut[i][SIDE_LEFT] += samp[0];
|
||||
SamplesOut[i][SIDE_RIGHT] += samp[1];
|
||||
SamplesOut[i][BACK_LEFT] += samp[0];
|
||||
SamplesOut[i][BACK_RIGHT] += samp[1];
|
||||
}
|
||||
state->Offset = offset;
|
||||
}
|
||||
|
||||
ALeffectState *EchoCreate(void)
|
||||
{
|
||||
ALechoState *state;
|
||||
|
||||
state = malloc(sizeof(*state));
|
||||
if(!state)
|
||||
{
|
||||
alSetError(AL_OUT_OF_MEMORY);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
state->state.Destroy = EchoDestroy;
|
||||
state->state.DeviceUpdate = EchoDeviceUpdate;
|
||||
state->state.Update = EchoUpdate;
|
||||
state->state.Process = EchoProcess;
|
||||
|
||||
state->BufferLength = 0;
|
||||
state->SampleBuffer = NULL;
|
||||
|
||||
state->Tap[0].delay = 0;
|
||||
state->Tap[1].delay = 0;
|
||||
state->Offset = 0;
|
||||
state->GainL = 0.0f;
|
||||
state->GainR = 0.0f;
|
||||
|
||||
state->iirFilter.coeff = 0.0f;
|
||||
state->iirFilter.history[0] = 0.0f;
|
||||
state->iirFilter.history[1] = 0.0f;
|
||||
|
||||
return &state->state;
|
||||
}
|
||||
+843
@@ -0,0 +1,843 @@
|
||||
/**
|
||||
* Reverb for the OpenAL cross platform audio library
|
||||
* Copyright (C) 2008-2009 by Christopher Fitzgerald.
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* 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
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
* Or go to http://www.gnu.org/copyleft/lgpl.html
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "AL/al.h"
|
||||
#include "AL/alc.h"
|
||||
#include "alMain.h"
|
||||
#include "alAuxEffectSlot.h"
|
||||
#include "alEffect.h"
|
||||
#include "alError.h"
|
||||
#include "alu.h"
|
||||
|
||||
typedef struct DelayLine
|
||||
{
|
||||
// The delay lines use sample lengths that are powers of 2 to allow
|
||||
// bitmasking instead of modulus wrapping.
|
||||
ALuint Mask;
|
||||
ALfloat *Line;
|
||||
} DelayLine;
|
||||
|
||||
typedef struct ALverbState {
|
||||
// Must be first in all effects!
|
||||
ALeffectState state;
|
||||
|
||||
// All delay lines are allocated as a single buffer to reduce memory
|
||||
// fragmentation and management code.
|
||||
ALfloat *SampleBuffer;
|
||||
ALuint TotalLength;
|
||||
// Master effect low-pass filter (2 chained 1-pole filters).
|
||||
FILTER LpFilter;
|
||||
ALfloat LpHistory[2];
|
||||
// Initial effect delay and decorrelation.
|
||||
DelayLine Delay;
|
||||
// The tap points for the initial delay. First tap goes to early
|
||||
// reflections, the last four decorrelate to late reverb.
|
||||
ALuint Tap[5];
|
||||
struct {
|
||||
// Total gain for early reflections.
|
||||
ALfloat Gain;
|
||||
// Early reflections are done with 4 delay lines.
|
||||
ALfloat Coeff[4];
|
||||
DelayLine Delay[4];
|
||||
ALuint Offset[4];
|
||||
// The gain for each output channel based on 3D panning.
|
||||
ALfloat PanGain[OUTPUTCHANNELS];
|
||||
} Early;
|
||||
struct {
|
||||
// Total gain for late reverb.
|
||||
ALfloat Gain;
|
||||
// Attenuation to compensate for modal density and decay rate.
|
||||
ALfloat DensityGain;
|
||||
// The feed-back and feed-forward all-pass coefficient.
|
||||
ALfloat ApFeedCoeff;
|
||||
// Mixing matrix coefficient.
|
||||
ALfloat MixCoeff;
|
||||
// Late reverb has 4 parallel all-pass filters.
|
||||
ALfloat ApCoeff[4];
|
||||
DelayLine ApDelay[4];
|
||||
ALuint ApOffset[4];
|
||||
// In addition to 4 cyclical delay lines.
|
||||
ALfloat Coeff[4];
|
||||
DelayLine Delay[4];
|
||||
ALuint Offset[4];
|
||||
// The cyclical delay lines are 1-pole low-pass filtered.
|
||||
ALfloat LpCoeff[4];
|
||||
ALfloat LpSample[4];
|
||||
// The gain for each output channel based on 3D panning.
|
||||
ALfloat PanGain[OUTPUTCHANNELS];
|
||||
} Late;
|
||||
// The current read offset for all delay lines.
|
||||
ALuint Offset;
|
||||
} ALverbState;
|
||||
|
||||
// All delay line lengths are specified in seconds.
|
||||
|
||||
// The lengths of the early delay lines.
|
||||
static const ALfloat EARLY_LINE_LENGTH[4] =
|
||||
{
|
||||
0.0015f, 0.0045f, 0.0135f, 0.0405f
|
||||
};
|
||||
|
||||
// The lengths of the late all-pass delay lines.
|
||||
static const ALfloat ALLPASS_LINE_LENGTH[4] =
|
||||
{
|
||||
0.0151f, 0.0167f, 0.0183f, 0.0200f,
|
||||
};
|
||||
|
||||
// The lengths of the late cyclical delay lines.
|
||||
static const ALfloat LATE_LINE_LENGTH[4] =
|
||||
{
|
||||
0.0211f, 0.0311f, 0.0461f, 0.0680f
|
||||
};
|
||||
|
||||
// The late cyclical delay lines have a variable length dependent on the
|
||||
// effect's density parameter (inverted for some reason) and this multiplier.
|
||||
static const ALfloat LATE_LINE_MULTIPLIER = 4.0f;
|
||||
|
||||
// Input into the late reverb is decorrelated between four channels. Their
|
||||
// timings are dependent on a fraction and multiplier. See VerbUpdate() for
|
||||
// the calculations involved.
|
||||
static const ALfloat DECO_FRACTION = 1.0f / 32.0f;
|
||||
static const ALfloat DECO_MULTIPLIER = 2.0f;
|
||||
|
||||
// The maximum length of initial delay for the master delay line (a sum of
|
||||
// the maximum early reflection and late reverb delays).
|
||||
static const ALfloat MASTER_LINE_LENGTH = 0.3f + 0.1f;
|
||||
|
||||
// Find the next power of 2. Actually, this will return the input value if
|
||||
// it is already a power of 2.
|
||||
static ALuint NextPowerOf2(ALuint value)
|
||||
{
|
||||
ALuint powerOf2 = 1;
|
||||
|
||||
if(value)
|
||||
{
|
||||
value--;
|
||||
while(value)
|
||||
{
|
||||
value >>= 1;
|
||||
powerOf2 <<= 1;
|
||||
}
|
||||
}
|
||||
return powerOf2;
|
||||
}
|
||||
|
||||
static ALuint CalcLengths(ALuint length[13], ALuint frequency)
|
||||
{
|
||||
ALuint samples, totalLength, index;
|
||||
|
||||
// All line lengths are powers of 2, calculated from their lengths, with
|
||||
// an additional sample in case of rounding errors.
|
||||
|
||||
// See VerbUpdate() for an explanation of the additional calculation
|
||||
// added to the master line length.
|
||||
samples = (ALuint)
|
||||
((MASTER_LINE_LENGTH +
|
||||
(LATE_LINE_LENGTH[0] * (1.0f + LATE_LINE_MULTIPLIER) *
|
||||
(DECO_FRACTION * ((DECO_MULTIPLIER * DECO_MULTIPLIER *
|
||||
DECO_MULTIPLIER) - 1.0f)))) *
|
||||
frequency) + 1;
|
||||
length[0] = NextPowerOf2(samples);
|
||||
totalLength = length[0];
|
||||
for(index = 0;index < 4;index++)
|
||||
{
|
||||
samples = (ALuint)(EARLY_LINE_LENGTH[index] * frequency) + 1;
|
||||
length[1 + index] = NextPowerOf2(samples);
|
||||
totalLength += length[1 + index];
|
||||
}
|
||||
for(index = 0;index < 4;index++)
|
||||
{
|
||||
samples = (ALuint)(ALLPASS_LINE_LENGTH[index] * frequency) + 1;
|
||||
length[5 + index] = NextPowerOf2(samples);
|
||||
totalLength += length[5 + index];
|
||||
}
|
||||
for(index = 0;index < 4;index++)
|
||||
{
|
||||
samples = (ALuint)(LATE_LINE_LENGTH[index] *
|
||||
(1.0f + LATE_LINE_MULTIPLIER) * frequency) + 1;
|
||||
length[9 + index] = NextPowerOf2(samples);
|
||||
totalLength += length[9 + index];
|
||||
}
|
||||
|
||||
return totalLength;
|
||||
}
|
||||
|
||||
// Basic delay line input/output routines.
|
||||
static __inline ALfloat DelayLineOut(DelayLine *Delay, ALuint offset)
|
||||
{
|
||||
return Delay->Line[offset&Delay->Mask];
|
||||
}
|
||||
|
||||
static __inline ALvoid DelayLineIn(DelayLine *Delay, ALuint offset, ALfloat in)
|
||||
{
|
||||
Delay->Line[offset&Delay->Mask] = in;
|
||||
}
|
||||
|
||||
// Delay line output routine for early reflections.
|
||||
static __inline ALfloat EarlyDelayLineOut(ALverbState *State, ALuint index)
|
||||
{
|
||||
return State->Early.Coeff[index] *
|
||||
DelayLineOut(&State->Early.Delay[index],
|
||||
State->Offset - State->Early.Offset[index]);
|
||||
}
|
||||
|
||||
// Given an input sample, this function produces stereo output for early
|
||||
// reflections.
|
||||
static __inline ALvoid EarlyReflection(ALverbState *State, ALfloat in, ALfloat *out)
|
||||
{
|
||||
ALfloat d[4], v, f[4];
|
||||
|
||||
// Obtain the decayed results of each early delay line.
|
||||
d[0] = EarlyDelayLineOut(State, 0);
|
||||
d[1] = EarlyDelayLineOut(State, 1);
|
||||
d[2] = EarlyDelayLineOut(State, 2);
|
||||
d[3] = EarlyDelayLineOut(State, 3);
|
||||
|
||||
/* The following uses a lossless scattering junction from waveguide
|
||||
* theory. It actually amounts to a householder mixing matrix, which
|
||||
* will produce a maximally diffuse response, and means this can probably
|
||||
* be considered a simple feedback delay network (FDN).
|
||||
* N
|
||||
* ---
|
||||
* \
|
||||
* v = 2/N / d_i
|
||||
* ---
|
||||
* i=1
|
||||
*/
|
||||
v = (d[0] + d[1] + d[2] + d[3]) * 0.5f;
|
||||
// The junction is loaded with the input here.
|
||||
v += in;
|
||||
|
||||
// Calculate the feed values for the delay lines.
|
||||
f[0] = v - d[0];
|
||||
f[1] = v - d[1];
|
||||
f[2] = v - d[2];
|
||||
f[3] = v - d[3];
|
||||
|
||||
// Refeed the delay lines.
|
||||
DelayLineIn(&State->Early.Delay[0], State->Offset, f[0]);
|
||||
DelayLineIn(&State->Early.Delay[1], State->Offset, f[1]);
|
||||
DelayLineIn(&State->Early.Delay[2], State->Offset, f[2]);
|
||||
DelayLineIn(&State->Early.Delay[3], State->Offset, f[3]);
|
||||
|
||||
// Output the results of the junction for all four lines.
|
||||
out[0] = State->Early.Gain * f[0];
|
||||
out[1] = State->Early.Gain * f[1];
|
||||
out[2] = State->Early.Gain * f[2];
|
||||
out[3] = State->Early.Gain * f[3];
|
||||
}
|
||||
|
||||
// All-pass input/output routine for late reverb.
|
||||
static __inline ALfloat LateAllPassInOut(ALverbState *State, ALuint index, ALfloat in)
|
||||
{
|
||||
ALfloat out;
|
||||
|
||||
out = State->Late.ApCoeff[index] *
|
||||
DelayLineOut(&State->Late.ApDelay[index],
|
||||
State->Offset - State->Late.ApOffset[index]);
|
||||
out -= (State->Late.ApFeedCoeff * in);
|
||||
DelayLineIn(&State->Late.ApDelay[index], State->Offset,
|
||||
(State->Late.ApFeedCoeff * out) + in);
|
||||
return out;
|
||||
}
|
||||
|
||||
// Delay line output routine for late reverb.
|
||||
static __inline ALfloat LateDelayLineOut(ALverbState *State, ALuint index)
|
||||
{
|
||||
return State->Late.Coeff[index] *
|
||||
DelayLineOut(&State->Late.Delay[index],
|
||||
State->Offset - State->Late.Offset[index]);
|
||||
}
|
||||
|
||||
// Low-pass filter input/output routine for late reverb.
|
||||
static __inline ALfloat LateLowPassInOut(ALverbState *State, ALuint index, ALfloat in)
|
||||
{
|
||||
State->Late.LpSample[index] = in +
|
||||
((State->Late.LpSample[index] - in) * State->Late.LpCoeff[index]);
|
||||
return State->Late.LpSample[index];
|
||||
}
|
||||
|
||||
// Given four decorrelated input samples, this function produces stereo
|
||||
// output for late reverb.
|
||||
static __inline ALvoid LateReverb(ALverbState *State, ALfloat *in, ALfloat *out)
|
||||
{
|
||||
ALfloat d[4], f[4];
|
||||
|
||||
// Obtain the decayed results of the cyclical delay lines, and add the
|
||||
// corresponding input channels attenuated by density. Then pass the
|
||||
// results through the low-pass filters.
|
||||
d[0] = LateLowPassInOut(State, 0, (State->Late.DensityGain * in[0]) +
|
||||
LateDelayLineOut(State, 0));
|
||||
d[1] = LateLowPassInOut(State, 1, (State->Late.DensityGain * in[1]) +
|
||||
LateDelayLineOut(State, 1));
|
||||
d[2] = LateLowPassInOut(State, 2, (State->Late.DensityGain * in[2]) +
|
||||
LateDelayLineOut(State, 2));
|
||||
d[3] = LateLowPassInOut(State, 3, (State->Late.DensityGain * in[3]) +
|
||||
LateDelayLineOut(State, 3));
|
||||
|
||||
// To help increase diffusion, run each line through an all-pass filter.
|
||||
// The order of the all-pass filters is selected so that the shortest
|
||||
// all-pass filter will feed the shortest delay line.
|
||||
d[0] = LateAllPassInOut(State, 1, d[0]);
|
||||
d[1] = LateAllPassInOut(State, 3, d[1]);
|
||||
d[2] = LateAllPassInOut(State, 0, d[2]);
|
||||
d[3] = LateAllPassInOut(State, 2, d[3]);
|
||||
|
||||
/* Late reverb is done with a modified feedback delay network (FDN)
|
||||
* topology. Four input lines are each fed through their own all-pass
|
||||
* filter and then into the mixing matrix. The four outputs of the
|
||||
* mixing matrix are then cycled back to the inputs. Each output feeds
|
||||
* a different input to form a circlular feed cycle.
|
||||
*
|
||||
* The mixing matrix used is a 4D skew-symmetric rotation matrix derived
|
||||
* using a single unitary rotational parameter:
|
||||
*
|
||||
* [ d, a, b, c ] 1 = a^2 + b^2 + c^2 + d^2
|
||||
* [ -a, d, c, -b ]
|
||||
* [ -b, -c, d, a ]
|
||||
* [ -c, b, -a, d ]
|
||||
*
|
||||
* The rotation is constructed from the effect's diffusion parameter,
|
||||
* yielding: 1 = x^2 + 3 y^2; where a, b, and c are the coefficient y
|
||||
* with differing signs, and d is the coefficient x. The matrix is thus:
|
||||
*
|
||||
* [ x, y, -y, y ] x = 1 - (0.5 diffusion^3)
|
||||
* [ -y, x, y, y ] y = sqrt((1 - x^2) / 3)
|
||||
* [ y, -y, x, y ]
|
||||
* [ -y, -y, -y, x ]
|
||||
*
|
||||
* To reduce the number of multiplies, the x coefficient is applied with
|
||||
* the cyclical delay line coefficients. Thus only the y coefficient is
|
||||
* applied when mixing, and is modified to be: y / x.
|
||||
*/
|
||||
f[0] = d[0] + (State->Late.MixCoeff * ( d[1] - d[2] + d[3]));
|
||||
f[1] = d[1] + (State->Late.MixCoeff * (-d[0] + d[2] + d[3]));
|
||||
f[2] = d[2] + (State->Late.MixCoeff * ( d[0] - d[1] + d[3]));
|
||||
f[3] = d[3] + (State->Late.MixCoeff * (-d[0] - d[1] - d[2]));
|
||||
|
||||
// Output the results of the matrix for all four cyclical delay lines,
|
||||
// attenuated by the late reverb gain (which is attenuated by the 'x'
|
||||
// mix coefficient).
|
||||
out[0] = State->Late.Gain * f[0];
|
||||
out[1] = State->Late.Gain * f[1];
|
||||
out[2] = State->Late.Gain * f[2];
|
||||
out[3] = State->Late.Gain * f[3];
|
||||
|
||||
// The delay lines are fed circularly in the order:
|
||||
// 0 -> 1 -> 3 -> 2 -> 0 ...
|
||||
DelayLineIn(&State->Late.Delay[0], State->Offset, f[2]);
|
||||
DelayLineIn(&State->Late.Delay[1], State->Offset, f[0]);
|
||||
DelayLineIn(&State->Late.Delay[2], State->Offset, f[3]);
|
||||
DelayLineIn(&State->Late.Delay[3], State->Offset, f[1]);
|
||||
}
|
||||
|
||||
// Process the reverb for a given input sample, resulting in separate four-
|
||||
// channel output for both early reflections and late reverb.
|
||||
static __inline ALvoid ReverbInOut(ALverbState *State, ALfloat in, ALfloat *early, ALfloat *late)
|
||||
{
|
||||
ALfloat taps[4];
|
||||
|
||||
// Low-pass filter the incoming sample.
|
||||
in = lpFilter2P(&State->LpFilter, 0, in);
|
||||
|
||||
// Feed the initial delay line.
|
||||
DelayLineIn(&State->Delay, State->Offset, in);
|
||||
|
||||
// Calculate the early reflection from the first delay tap.
|
||||
in = DelayLineOut(&State->Delay, State->Offset - State->Tap[0]);
|
||||
EarlyReflection(State, in, early);
|
||||
|
||||
// Calculate the late reverb from the last four delay taps.
|
||||
taps[0] = DelayLineOut(&State->Delay, State->Offset - State->Tap[1]);
|
||||
taps[1] = DelayLineOut(&State->Delay, State->Offset - State->Tap[2]);
|
||||
taps[2] = DelayLineOut(&State->Delay, State->Offset - State->Tap[3]);
|
||||
taps[3] = DelayLineOut(&State->Delay, State->Offset - State->Tap[4]);
|
||||
LateReverb(State, taps, late);
|
||||
|
||||
// Step all delays forward one sample.
|
||||
State->Offset++;
|
||||
}
|
||||
|
||||
// This destroys the reverb state. It should be called only when the effect
|
||||
// slot has a different (or no) effect loaded over the reverb effect.
|
||||
ALvoid VerbDestroy(ALeffectState *effect)
|
||||
{
|
||||
ALverbState *State = (ALverbState*)effect;
|
||||
if(State)
|
||||
{
|
||||
free(State->SampleBuffer);
|
||||
State->SampleBuffer = NULL;
|
||||
free(State);
|
||||
}
|
||||
}
|
||||
|
||||
// NOTE: Temp, remove later.
|
||||
static __inline ALint aluCart2LUTpos(ALfloat re, ALfloat im)
|
||||
{
|
||||
ALint pos = 0;
|
||||
ALfloat denom = aluFabs(re) + aluFabs(im);
|
||||
if(denom > 0.0f)
|
||||
pos = (ALint)(QUADRANT_NUM*aluFabs(im) / denom + 0.5);
|
||||
|
||||
if(re < 0.0)
|
||||
pos = 2 * QUADRANT_NUM - pos;
|
||||
if(im < 0.0)
|
||||
pos = LUT_NUM - pos;
|
||||
return pos%LUT_NUM;
|
||||
}
|
||||
|
||||
// This updates the device-dependant reverb state. This is called on
|
||||
// initialization and any time the device parameters (eg. playback frequency,
|
||||
// format) have been changed.
|
||||
ALboolean VerbDeviceUpdate(ALeffectState *effect, ALCdevice *Device)
|
||||
{
|
||||
ALverbState *State = (ALverbState*)effect;
|
||||
ALuint length[13], totalLength;
|
||||
ALuint index;
|
||||
|
||||
totalLength = CalcLengths(length, Device->Frequency);
|
||||
if(totalLength != State->TotalLength)
|
||||
{
|
||||
void *temp;
|
||||
|
||||
temp = realloc(State->SampleBuffer, totalLength * sizeof(ALfloat));
|
||||
if(!temp)
|
||||
{
|
||||
alSetError(AL_OUT_OF_MEMORY);
|
||||
return AL_FALSE;
|
||||
}
|
||||
State->TotalLength = totalLength;
|
||||
State->SampleBuffer = temp;
|
||||
|
||||
// All lines share a single sample buffer
|
||||
State->Delay.Mask = length[0] - 1;
|
||||
State->Delay.Line = &State->SampleBuffer[0];
|
||||
totalLength = length[0];
|
||||
for(index = 0;index < 4;index++)
|
||||
{
|
||||
State->Early.Delay[index].Mask = length[1 + index] - 1;
|
||||
State->Early.Delay[index].Line = &State->SampleBuffer[totalLength];
|
||||
totalLength += length[1 + index];
|
||||
}
|
||||
for(index = 0;index < 4;index++)
|
||||
{
|
||||
State->Late.ApDelay[index].Mask = length[5 + index] - 1;
|
||||
State->Late.ApDelay[index].Line = &State->SampleBuffer[totalLength];
|
||||
totalLength += length[5 + index];
|
||||
}
|
||||
for(index = 0;index < 4;index++)
|
||||
{
|
||||
State->Late.Delay[index].Mask = length[9 + index] - 1;
|
||||
State->Late.Delay[index].Line = &State->SampleBuffer[totalLength];
|
||||
totalLength += length[9 + index];
|
||||
}
|
||||
}
|
||||
|
||||
for(index = 0;index < 4;index++)
|
||||
{
|
||||
State->Early.Offset[index] = (ALuint)(EARLY_LINE_LENGTH[index] *
|
||||
Device->Frequency);
|
||||
State->Late.ApOffset[index] = (ALuint)(ALLPASS_LINE_LENGTH[index] *
|
||||
Device->Frequency);
|
||||
}
|
||||
|
||||
for(index = 0;index < State->TotalLength;index++)
|
||||
State->SampleBuffer[index] = 0.0f;
|
||||
|
||||
return AL_TRUE;
|
||||
}
|
||||
|
||||
// This updates the reverb state. This is called any time the reverb effect
|
||||
// is loaded into a slot.
|
||||
ALvoid VerbUpdate(ALeffectState *effect, ALCcontext *Context, const ALeffect *Effect)
|
||||
{
|
||||
ALverbState *State = (ALverbState*)effect;
|
||||
ALuint frequency = Context->Device->Frequency;
|
||||
ALuint index;
|
||||
ALfloat length, mixCoeff, cw, g, coeff;
|
||||
ALfloat hfRatio = Effect->Reverb.DecayHFRatio;
|
||||
|
||||
// Calculate the master low-pass filter (from the master effect HF gain).
|
||||
cw = cos(2.0*M_PI * Effect->Reverb.HFReference / frequency);
|
||||
g = __max(Effect->Reverb.GainHF, 0.0001f);
|
||||
State->LpFilter.coeff = 0.0f;
|
||||
if(g < 0.9999f) // 1-epsilon
|
||||
State->LpFilter.coeff = (1 - g*cw - aluSqrt(2*g*(1-cw) - g*g*(1 - cw*cw))) / (1 - g);
|
||||
|
||||
// Calculate the initial delay taps.
|
||||
length = Effect->Reverb.ReflectionsDelay;
|
||||
State->Tap[0] = (ALuint)(length * frequency);
|
||||
|
||||
length += Effect->Reverb.LateReverbDelay;
|
||||
|
||||
/* The four inputs to the late reverb are decorrelated to smooth the
|
||||
* initial reverb and reduce harsh echos. The timings are calculated as
|
||||
* multiples of a fraction of the smallest cyclical delay time. This
|
||||
* result is then adjusted so that the first tap occurs immediately (all
|
||||
* taps are reduced by the shortest fraction).
|
||||
*
|
||||
* offset[index] = ((FRACTION MULTIPLIER^index) - 1) delay
|
||||
*/
|
||||
for(index = 0;index < 4;index++)
|
||||
{
|
||||
length += LATE_LINE_LENGTH[0] *
|
||||
(1.0f + (Effect->Reverb.Density * LATE_LINE_MULTIPLIER)) *
|
||||
(DECO_FRACTION * (pow(DECO_MULTIPLIER, (ALfloat)index) - 1.0f));
|
||||
State->Tap[1 + index] = (ALuint)(length * frequency);
|
||||
}
|
||||
|
||||
// Calculate the early reflections gain (from the master effect gain, and
|
||||
// reflections gain parameters).
|
||||
State->Early.Gain = Effect->Reverb.Gain * Effect->Reverb.ReflectionsGain;
|
||||
|
||||
// Calculate the gain (coefficient) for each early delay line.
|
||||
for(index = 0;index < 4;index++)
|
||||
State->Early.Coeff[index] = pow(10.0f, EARLY_LINE_LENGTH[index] /
|
||||
Effect->Reverb.LateReverbDelay *
|
||||
-60.0f / 20.0f);
|
||||
|
||||
// Calculate the first mixing matrix coefficient (x).
|
||||
mixCoeff = 1.0f - (0.5f * pow(Effect->Reverb.Diffusion, 3.0f));
|
||||
|
||||
// Calculate the late reverb gain (from the master effect gain, and late
|
||||
// reverb gain parameters). Since the output is tapped prior to the
|
||||
// application of the delay line coefficients, this gain needs to be
|
||||
// attenuated by the 'x' mix coefficient from above.
|
||||
State->Late.Gain = Effect->Reverb.Gain * Effect->Reverb.LateReverbGain * mixCoeff;
|
||||
|
||||
/* To compensate for changes in modal density and decay time of the late
|
||||
* reverb signal, the input is attenuated based on the maximal energy of
|
||||
* the outgoing signal. This is calculated as the ratio between a
|
||||
* reference value and the current approximation of energy for the output
|
||||
* signal.
|
||||
*
|
||||
* Reverb output matches exponential decay of the form Sum(a^n), where a
|
||||
* is the attenuation coefficient, and n is the sample ranging from 0 to
|
||||
* infinity. The signal energy can thus be approximated using the area
|
||||
* under this curve, calculated as: 1 / (1 - a).
|
||||
*
|
||||
* The reference energy is calculated from a signal at the lowest (effect
|
||||
* at 1.0) density with a decay time of one second.
|
||||
*
|
||||
* The coefficient is calculated as the average length of the cyclical
|
||||
* delay lines. This produces a better result than calculating the gain
|
||||
* for each line individually (most likely a side effect of diffusion).
|
||||
*
|
||||
* The final result is the square root of the ratio bound to a maximum
|
||||
* value of 1 (no amplification).
|
||||
*/
|
||||
length = (LATE_LINE_LENGTH[0] + LATE_LINE_LENGTH[1] +
|
||||
LATE_LINE_LENGTH[2] + LATE_LINE_LENGTH[3]);
|
||||
g = length * (1.0f + LATE_LINE_MULTIPLIER) * 0.25f;
|
||||
g = pow(10.0f, g * -60.0f / 20.0f);
|
||||
g = 1.0f / (1.0f - (g * g));
|
||||
length *= 1.0f + (Effect->Reverb.Density * LATE_LINE_MULTIPLIER) * 0.25f;
|
||||
length = pow(10.0f, length / Effect->Reverb.DecayTime * -60.0f / 20.0f);
|
||||
length = 1.0f / (1.0f - (length * length));
|
||||
State->Late.DensityGain = __min(aluSqrt(g / length), 1.0f);
|
||||
|
||||
// Calculate the all-pass feed-back and feed-forward coefficient.
|
||||
State->Late.ApFeedCoeff = 0.6f * pow(Effect->Reverb.Diffusion, 3.0f);
|
||||
|
||||
// Calculate the mixing matrix coefficient (y / x).
|
||||
g = aluSqrt((1.0f - (mixCoeff * mixCoeff)) / 3.0f);
|
||||
State->Late.MixCoeff = g / mixCoeff;
|
||||
|
||||
for(index = 0;index < 4;index++)
|
||||
{
|
||||
// Calculate the gain (coefficient) for each all-pass line.
|
||||
State->Late.ApCoeff[index] = pow(10.0f, ALLPASS_LINE_LENGTH[index] /
|
||||
Effect->Reverb.DecayTime *
|
||||
-60.0f / 20.0f);
|
||||
}
|
||||
|
||||
// If the HF limit parameter is flagged, calculate an appropriate limit
|
||||
// based on the air absorption parameter.
|
||||
if(Effect->Reverb.DecayHFLimit && Effect->Reverb.AirAbsorptionGainHF < 1.0f)
|
||||
{
|
||||
ALfloat limitRatio;
|
||||
|
||||
// For each of the cyclical delays, find the attenuation due to air
|
||||
// absorption in dB (converting delay time to meters using the speed
|
||||
// of sound). Then reversing the decay equation, solve for HF ratio.
|
||||
// The delay length is cancelled out of the equation, so it can be
|
||||
// calculated once for all lines.
|
||||
limitRatio = 1.0f / (log10(Effect->Reverb.AirAbsorptionGainHF) *
|
||||
SPEEDOFSOUNDMETRESPERSEC *
|
||||
Effect->Reverb.DecayTime / -60.0f * 20.0f);
|
||||
// Need to limit the result to a minimum of 0.1, just like the HF
|
||||
// ratio parameter.
|
||||
limitRatio = __max(limitRatio, 0.1f);
|
||||
|
||||
// Using the limit calculated above, apply the upper bound to the
|
||||
// HF ratio.
|
||||
hfRatio = __min(hfRatio, limitRatio);
|
||||
}
|
||||
|
||||
// Calculate the low-pass filter frequency.
|
||||
cw = cos(2.0*M_PI * Effect->Reverb.HFReference / frequency);
|
||||
|
||||
for(index = 0;index < 4;index++)
|
||||
{
|
||||
// Calculate the length (in seconds) of each cyclical delay line.
|
||||
length = LATE_LINE_LENGTH[index] * (1.0f + (Effect->Reverb.Density *
|
||||
LATE_LINE_MULTIPLIER));
|
||||
// Calculate the delay offset for the cyclical delay lines.
|
||||
State->Late.Offset[index] = (ALuint)(length * frequency);
|
||||
|
||||
// Calculate the gain (coefficient) for each cyclical line.
|
||||
State->Late.Coeff[index] = pow(10.0f, length / Effect->Reverb.DecayTime *
|
||||
-60.0f / 20.0f);
|
||||
|
||||
// Eventually this should boost the high frequencies when the ratio
|
||||
// exceeds 1.
|
||||
coeff = 0.0f;
|
||||
if (hfRatio < 1.0f)
|
||||
{
|
||||
// Calculate the decay equation for each low-pass filter.
|
||||
g = pow(10.0f, length / (Effect->Reverb.DecayTime * hfRatio) *
|
||||
-60.0f / 20.0f) / State->Late.Coeff[index];
|
||||
g = __max(g, 0.1f);
|
||||
g *= g;
|
||||
|
||||
// Calculate the gain (coefficient) for each low-pass filter.
|
||||
if(g < 0.9999f) // 1-epsilon
|
||||
coeff = (1 - g*cw - aluSqrt(2*g*(1-cw) - g*g*(1 - cw*cw))) / (1 - g);
|
||||
|
||||
// Very low decay times will produce minimal output, so apply an
|
||||
// upper bound to the coefficient.
|
||||
coeff = __min(coeff, 0.98f);
|
||||
}
|
||||
State->Late.LpCoeff[index] = coeff;
|
||||
|
||||
// Attenuate the cyclical line coefficients by the mixing coefficient
|
||||
// (x).
|
||||
State->Late.Coeff[index] *= mixCoeff;
|
||||
}
|
||||
|
||||
// Calculate the 3D-panning gains for the early reflections and late
|
||||
// reverb (for EAX mode).
|
||||
{
|
||||
ALfloat earlyPan[3] = { Effect->Reverb.ReflectionsPan[0], Effect->Reverb.ReflectionsPan[1], Effect->Reverb.ReflectionsPan[2] };
|
||||
ALfloat latePan[3] = { Effect->Reverb.LateReverbPan[0], Effect->Reverb.LateReverbPan[1], Effect->Reverb.LateReverbPan[2] };
|
||||
ALfloat *speakerGain, dirGain, ambientGain;
|
||||
ALfloat length;
|
||||
ALint pos;
|
||||
|
||||
length = earlyPan[0]*earlyPan[0] + earlyPan[1]*earlyPan[1] + earlyPan[2]*earlyPan[2];
|
||||
if(length > 1.0f)
|
||||
{
|
||||
length = 1.0f / aluSqrt(length);
|
||||
earlyPan[0] *= length;
|
||||
earlyPan[1] *= length;
|
||||
earlyPan[2] *= length;
|
||||
}
|
||||
length = latePan[0]*latePan[0] + latePan[1]*latePan[1] + latePan[2]*latePan[2];
|
||||
if(length > 1.0f)
|
||||
{
|
||||
length = 1.0f / aluSqrt(length);
|
||||
latePan[0] *= length;
|
||||
latePan[1] *= length;
|
||||
latePan[2] *= length;
|
||||
}
|
||||
|
||||
// This code applies directional reverb just like the mixer applies
|
||||
// directional sources. It diffuses the sound toward all speakers
|
||||
// as the magnitude of the panning vector drops, which is only an
|
||||
// approximation of the expansion of sound across the speakers from
|
||||
// the panning direction.
|
||||
pos = aluCart2LUTpos(earlyPan[2], earlyPan[0]);
|
||||
speakerGain = &Context->PanningLUT[OUTPUTCHANNELS * pos];
|
||||
dirGain = aluSqrt((earlyPan[0] * earlyPan[0]) + (earlyPan[2] * earlyPan[2]));
|
||||
ambientGain = (1.0 - dirGain);
|
||||
for(index = 0;index < OUTPUTCHANNELS;index++)
|
||||
State->Early.PanGain[index] = dirGain * speakerGain[index] + ambientGain;
|
||||
|
||||
pos = aluCart2LUTpos(latePan[2], latePan[0]);
|
||||
speakerGain = &Context->PanningLUT[OUTPUTCHANNELS * pos];
|
||||
dirGain = aluSqrt((latePan[0] * latePan[0]) + (latePan[2] * latePan[2]));
|
||||
ambientGain = (1.0 - dirGain);
|
||||
for(index = 0;index < OUTPUTCHANNELS;index++)
|
||||
State->Late.PanGain[index] = dirGain * speakerGain[index] + ambientGain;
|
||||
}
|
||||
}
|
||||
|
||||
// This processes the reverb state, given the input samples and an output
|
||||
// buffer.
|
||||
ALvoid VerbProcess(ALeffectState *effect, const ALeffectslot *Slot, ALuint SamplesToDo, const ALfloat *SamplesIn, ALfloat (*SamplesOut)[OUTPUTCHANNELS])
|
||||
{
|
||||
ALverbState *State = (ALverbState*)effect;
|
||||
ALuint index;
|
||||
ALfloat early[4], late[4], out[4];
|
||||
ALfloat gain = Slot->Gain;
|
||||
|
||||
for(index = 0;index < SamplesToDo;index++)
|
||||
{
|
||||
// Process reverb for this sample.
|
||||
ReverbInOut(State, SamplesIn[index], early, late);
|
||||
|
||||
// Mix early reflections and late reverb.
|
||||
out[0] = (early[0] + late[0]) * gain;
|
||||
out[1] = (early[1] + late[1]) * gain;
|
||||
out[2] = (early[2] + late[2]) * gain;
|
||||
out[3] = (early[3] + late[3]) * gain;
|
||||
|
||||
// Output the results.
|
||||
SamplesOut[index][FRONT_LEFT] += out[0];
|
||||
SamplesOut[index][FRONT_RIGHT] += out[1];
|
||||
SamplesOut[index][FRONT_CENTER] += out[3];
|
||||
SamplesOut[index][SIDE_LEFT] += out[0];
|
||||
SamplesOut[index][SIDE_RIGHT] += out[1];
|
||||
SamplesOut[index][BACK_LEFT] += out[0];
|
||||
SamplesOut[index][BACK_RIGHT] += out[1];
|
||||
SamplesOut[index][BACK_CENTER] += out[2];
|
||||
}
|
||||
}
|
||||
|
||||
// This processes the EAX reverb state, given the input samples and an output
|
||||
// buffer.
|
||||
ALvoid EAXVerbProcess(ALeffectState *effect, const ALeffectslot *Slot, ALuint SamplesToDo, const ALfloat *SamplesIn, ALfloat (*SamplesOut)[OUTPUTCHANNELS])
|
||||
{
|
||||
ALverbState *State = (ALverbState*)effect;
|
||||
ALuint index;
|
||||
ALfloat early[4], late[4];
|
||||
ALfloat gain = Slot->Gain;
|
||||
|
||||
for(index = 0;index < SamplesToDo;index++)
|
||||
{
|
||||
// Process reverb for this sample.
|
||||
ReverbInOut(State, SamplesIn[index], early, late);
|
||||
|
||||
// Unfortunately, while the number and configuration of gains for
|
||||
// panning adjust according to OUTPUTCHANNELS, the output from the
|
||||
// reverb engine is not so scalable.
|
||||
SamplesOut[index][FRONT_LEFT] +=
|
||||
(State->Early.PanGain[FRONT_LEFT]*early[0] +
|
||||
State->Late.PanGain[FRONT_LEFT]*late[0]) * gain;
|
||||
SamplesOut[index][FRONT_RIGHT] +=
|
||||
(State->Early.PanGain[FRONT_RIGHT]*early[1] +
|
||||
State->Late.PanGain[FRONT_RIGHT]*late[1]) * gain;
|
||||
SamplesOut[index][FRONT_CENTER] +=
|
||||
(State->Early.PanGain[FRONT_CENTER]*early[3] +
|
||||
State->Late.PanGain[FRONT_CENTER]*late[3]) * gain;
|
||||
SamplesOut[index][SIDE_LEFT] +=
|
||||
(State->Early.PanGain[SIDE_LEFT]*early[0] +
|
||||
State->Late.PanGain[SIDE_LEFT]*late[0]) * gain;
|
||||
SamplesOut[index][SIDE_RIGHT] +=
|
||||
(State->Early.PanGain[SIDE_RIGHT]*early[1] +
|
||||
State->Late.PanGain[SIDE_RIGHT]*late[1]) * gain;
|
||||
SamplesOut[index][BACK_LEFT] +=
|
||||
(State->Early.PanGain[BACK_LEFT]*early[0] +
|
||||
State->Late.PanGain[BACK_LEFT]*late[0]) * gain;
|
||||
SamplesOut[index][BACK_RIGHT] +=
|
||||
(State->Early.PanGain[BACK_RIGHT]*early[1] +
|
||||
State->Late.PanGain[BACK_RIGHT]*late[1]) * gain;
|
||||
SamplesOut[index][BACK_CENTER] +=
|
||||
(State->Early.PanGain[BACK_CENTER]*early[2] +
|
||||
State->Late.PanGain[BACK_CENTER]*late[2]) * gain;
|
||||
}
|
||||
}
|
||||
|
||||
// This creates the reverb state. It should be called only when the reverb
|
||||
// effect is loaded into a slot that doesn't already have a reverb effect.
|
||||
ALeffectState *VerbCreate(void)
|
||||
{
|
||||
ALverbState *State = NULL;
|
||||
ALuint index;
|
||||
|
||||
State = malloc(sizeof(ALverbState));
|
||||
if(!State)
|
||||
{
|
||||
alSetError(AL_OUT_OF_MEMORY);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
State->state.Destroy = VerbDestroy;
|
||||
State->state.DeviceUpdate = VerbDeviceUpdate;
|
||||
State->state.Update = VerbUpdate;
|
||||
State->state.Process = VerbProcess;
|
||||
|
||||
State->TotalLength = 0;
|
||||
State->SampleBuffer = NULL;
|
||||
|
||||
State->LpFilter.coeff = 0.0f;
|
||||
State->LpFilter.history[0] = 0.0f;
|
||||
State->LpFilter.history[1] = 0.0f;
|
||||
State->Delay.Mask = 0;
|
||||
State->Delay.Line = NULL;
|
||||
|
||||
State->Tap[0] = 0;
|
||||
State->Tap[1] = 0;
|
||||
State->Tap[2] = 0;
|
||||
State->Tap[3] = 0;
|
||||
State->Tap[4] = 0;
|
||||
|
||||
State->Early.Gain = 0.0f;
|
||||
for(index = 0;index < 4;index++)
|
||||
{
|
||||
State->Early.Coeff[index] = 0.0f;
|
||||
State->Early.Delay[index].Mask = 0;
|
||||
State->Early.Delay[index].Line = NULL;
|
||||
State->Early.Offset[index] = 0;
|
||||
}
|
||||
|
||||
State->Late.Gain = 0.0f;
|
||||
State->Late.DensityGain = 0.0f;
|
||||
State->Late.ApFeedCoeff = 0.0f;
|
||||
State->Late.MixCoeff = 0.0f;
|
||||
|
||||
for(index = 0;index < 4;index++)
|
||||
{
|
||||
State->Late.ApCoeff[index] = 0.0f;
|
||||
State->Late.ApDelay[index].Mask = 0;
|
||||
State->Late.ApDelay[index].Line = NULL;
|
||||
State->Late.ApOffset[index] = 0;
|
||||
|
||||
State->Late.Coeff[index] = 0.0f;
|
||||
State->Late.Delay[index].Mask = 0;
|
||||
State->Late.Delay[index].Line = NULL;
|
||||
State->Late.Offset[index] = 0;
|
||||
|
||||
State->Late.LpCoeff[index] = 0.0f;
|
||||
State->Late.LpSample[index] = 0.0f;
|
||||
}
|
||||
|
||||
// Panning is applied as an independent gain for each output channel.
|
||||
for(index = 0;index < OUTPUTCHANNELS;index++)
|
||||
{
|
||||
State->Early.PanGain[index] = 0.0f;
|
||||
State->Late.PanGain[index] = 0.0f;
|
||||
}
|
||||
|
||||
State->Offset = 0;
|
||||
return &State->state;
|
||||
}
|
||||
|
||||
ALeffectState *EAXVerbCreate(void)
|
||||
{
|
||||
ALeffectState *State = VerbCreate();
|
||||
if(State) State->Process = EAXVerbProcess;
|
||||
return State;
|
||||
}
|
||||
+125
@@ -0,0 +1,125 @@
|
||||
/**
|
||||
* OpenAL cross platform audio library
|
||||
* Copyright (C) 1999-2007 by authors.
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* 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
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
* Or go to http://www.gnu.org/copyleft/lgpl.html
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "alMain.h"
|
||||
|
||||
|
||||
struct RingBuffer {
|
||||
ALubyte *mem;
|
||||
|
||||
ALsizei frame_size;
|
||||
ALsizei length;
|
||||
ALint read_pos;
|
||||
ALint write_pos;
|
||||
|
||||
CRITICAL_SECTION cs;
|
||||
};
|
||||
|
||||
|
||||
RingBuffer *CreateRingBuffer(ALsizei frame_size, ALsizei length)
|
||||
{
|
||||
RingBuffer *ring = calloc(1, sizeof(*ring));
|
||||
if(ring)
|
||||
{
|
||||
ring->frame_size = frame_size;
|
||||
ring->length = length+1;
|
||||
ring->write_pos = 1;
|
||||
ring->mem = malloc((length+1)*frame_size);
|
||||
if(!ring->mem)
|
||||
{
|
||||
free(ring);
|
||||
ring = NULL;
|
||||
}
|
||||
|
||||
InitializeCriticalSection(&ring->cs);
|
||||
}
|
||||
return ring;
|
||||
}
|
||||
|
||||
void DestroyRingBuffer(RingBuffer *ring)
|
||||
{
|
||||
if(ring)
|
||||
{
|
||||
DeleteCriticalSection(&ring->cs);
|
||||
free(ring->mem);
|
||||
free(ring);
|
||||
}
|
||||
}
|
||||
|
||||
ALsizei RingBufferSize(RingBuffer *ring)
|
||||
{
|
||||
ALsizei s;
|
||||
|
||||
EnterCriticalSection(&ring->cs);
|
||||
s = (ring->write_pos-ring->read_pos-1+ring->length) % ring->length;
|
||||
LeaveCriticalSection(&ring->cs);
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
void WriteRingBuffer(RingBuffer *ring, const ALubyte *data, ALsizei len)
|
||||
{
|
||||
int remain;
|
||||
|
||||
EnterCriticalSection(&ring->cs);
|
||||
|
||||
remain = ring->length - ring->write_pos;
|
||||
if((ring->read_pos-ring->write_pos+ring->length)%ring->length < len)
|
||||
ring->read_pos = (ring->write_pos+len) % ring->length;
|
||||
|
||||
if(remain < len)
|
||||
{
|
||||
memcpy(ring->mem+(ring->write_pos*ring->frame_size), data, remain*ring->frame_size);
|
||||
memcpy(ring->mem, data+(remain*ring->frame_size), (len-remain)*ring->frame_size);
|
||||
}
|
||||
else
|
||||
memcpy(ring->mem+(ring->write_pos*ring->frame_size), data, len*ring->frame_size);
|
||||
|
||||
ring->write_pos += len;
|
||||
ring->write_pos %= ring->length;
|
||||
|
||||
LeaveCriticalSection(&ring->cs);
|
||||
}
|
||||
|
||||
void ReadRingBuffer(RingBuffer *ring, ALubyte *data, ALsizei len)
|
||||
{
|
||||
int remain;
|
||||
|
||||
EnterCriticalSection(&ring->cs);
|
||||
|
||||
remain = ring->length - ring->read_pos;
|
||||
if(remain < len)
|
||||
{
|
||||
memcpy(data, ring->mem+(ring->read_pos*ring->frame_size), remain*ring->frame_size);
|
||||
memcpy(data+(remain*ring->frame_size), ring->mem, (len-remain)*ring->frame_size);
|
||||
}
|
||||
else
|
||||
memcpy(data, ring->mem+(ring->read_pos*ring->frame_size), len*ring->frame_size);
|
||||
|
||||
ring->read_pos += len;
|
||||
ring->read_pos %= ring->length;
|
||||
|
||||
LeaveCriticalSection(&ring->cs);
|
||||
}
|
||||
+14
-11
@@ -18,6 +18,8 @@
|
||||
* Or go to http://www.gnu.org/copyleft/lgpl.html
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "alMain.h"
|
||||
@@ -26,8 +28,6 @@
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
typedef struct {
|
||||
ALuint (*func)(ALvoid*);
|
||||
ALvoid *ptr;
|
||||
@@ -47,13 +47,14 @@ static DWORD CALLBACK StarterFunc(void *ptr)
|
||||
|
||||
ALvoid *StartThread(ALuint (*func)(ALvoid*), ALvoid *ptr)
|
||||
{
|
||||
DWORD dummy;
|
||||
ThreadInfo *inf = malloc(sizeof(ThreadInfo));
|
||||
if(!inf) return 0;
|
||||
|
||||
inf->func = func;
|
||||
inf->ptr = ptr;
|
||||
|
||||
inf->thread = CreateThread(NULL, 0, StarterFunc, inf, 0, NULL);
|
||||
inf->thread = CreateThread(NULL, 0, StarterFunc, inf, 0, &dummy);
|
||||
if(!inf->thread)
|
||||
{
|
||||
free(inf);
|
||||
@@ -70,6 +71,7 @@ ALuint StopThread(ALvoid *thread)
|
||||
|
||||
WaitForSingleObject(inf->thread, INFINITE);
|
||||
GetExitCodeThread(inf->thread, &ret);
|
||||
CloseHandle(inf->thread);
|
||||
|
||||
free(inf);
|
||||
|
||||
@@ -83,22 +85,21 @@ ALuint StopThread(ALvoid *thread)
|
||||
typedef struct {
|
||||
ALuint (*func)(ALvoid*);
|
||||
ALvoid *ptr;
|
||||
ALuint ret;
|
||||
pthread_t thread;
|
||||
} ThreadInfo;
|
||||
|
||||
static void *StarterFunc(void *ptr)
|
||||
{
|
||||
ThreadInfo *inf = (ThreadInfo*)ptr;
|
||||
ALint ret;
|
||||
|
||||
ret = inf->func(inf->ptr);
|
||||
return (void*)ret;
|
||||
inf->ret = inf->func(inf->ptr);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ALvoid *StartThread(ALuint (*func)(ALvoid*), ALvoid *ptr)
|
||||
{
|
||||
ThreadInfo *inf = malloc(sizeof(ThreadInfo));
|
||||
if(!inf) return 0;
|
||||
if(!inf) return NULL;
|
||||
|
||||
inf->func = func;
|
||||
inf->ptr = ptr;
|
||||
@@ -114,12 +115,14 @@ ALvoid *StartThread(ALuint (*func)(ALvoid*), ALvoid *ptr)
|
||||
ALuint StopThread(ALvoid *thread)
|
||||
{
|
||||
ThreadInfo *inf = thread;
|
||||
void *ret;
|
||||
ALuint ret;
|
||||
|
||||
pthread_join(inf->thread, NULL);
|
||||
ret = inf->ret;
|
||||
|
||||
pthread_join(inf->thread, &ret);
|
||||
free(inf);
|
||||
|
||||
return (ALuint)ret;
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
+937
-648
File diff suppressed because it is too large
Load Diff
+201
@@ -0,0 +1,201 @@
|
||||
/*-
|
||||
* Copyright (c) 2005 Boris Mikhaylov
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* 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 AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#include "bs2b.h"
|
||||
|
||||
#ifndef M_PI
|
||||
#define M_PI 3.14159265358979323846
|
||||
#endif
|
||||
|
||||
/* Single pole IIR filter.
|
||||
* O[n] = a0*I[n] + a1*I[n-1] + b1*O[n-1]
|
||||
*/
|
||||
|
||||
/* Lowpass filter */
|
||||
#define lo_filter(in, out_1) (bs2b->a0_lo*(in) + bs2b->b1_lo*(out_1))
|
||||
|
||||
/* Highboost filter */
|
||||
#define hi_filter(in, in_1, out_1) (bs2b->a0_hi*(in) + bs2b->a1_hi*(in_1) + bs2b->b1_hi*(out_1))
|
||||
|
||||
/* Set up all data. */
|
||||
static void init(struct bs2b *bs2b)
|
||||
{
|
||||
double Fc_lo, Fc_hi;
|
||||
double G_lo, G_hi;
|
||||
double x;
|
||||
|
||||
if ((bs2b->srate > 192000) || (bs2b->srate < 2000))
|
||||
bs2b->srate = BS2B_DEFAULT_SRATE;
|
||||
|
||||
switch(bs2b->level)
|
||||
{
|
||||
case BS2B_LOW_CLEVEL: /* Low crossfeed level */
|
||||
Fc_lo = 360.0;
|
||||
Fc_hi = 501.0;
|
||||
G_lo = 0.398107170553497;
|
||||
G_hi = 0.205671765275719;
|
||||
break;
|
||||
|
||||
case BS2B_MIDDLE_CLEVEL: /* Middle crossfeed level */
|
||||
Fc_lo = 500.0;
|
||||
Fc_hi = 711.0;
|
||||
G_lo = 0.459726988530872;
|
||||
G_hi = 0.228208484414988;
|
||||
break;
|
||||
|
||||
case BS2B_HIGH_CLEVEL: /* High crossfeed level (virtual speakers are closer to itself) */
|
||||
Fc_lo = 700.0;
|
||||
Fc_hi = 1021.0;
|
||||
G_lo = 0.530884444230988;
|
||||
G_hi = 0.250105790667544;
|
||||
break;
|
||||
|
||||
case BS2B_LOW_ECLEVEL: /* Low easy crossfeed level */
|
||||
Fc_lo = 360.0;
|
||||
Fc_hi = 494.0;
|
||||
G_lo = 0.316227766016838;
|
||||
G_hi = 0.168236228897329;
|
||||
break;
|
||||
|
||||
case BS2B_MIDDLE_ECLEVEL: /* Middle easy crossfeed level */
|
||||
Fc_lo = 500.0;
|
||||
Fc_hi = 689.0;
|
||||
G_lo = 0.354813389233575;
|
||||
G_hi = 0.187169483835901;
|
||||
break;
|
||||
|
||||
default: /* High easy crossfeed level */
|
||||
bs2b->level = BS2B_HIGH_ECLEVEL;
|
||||
|
||||
Fc_lo = 700.0;
|
||||
Fc_hi = 975.0;
|
||||
G_lo = 0.398107170553497;
|
||||
G_hi = 0.205671765275719;
|
||||
break;
|
||||
} /* switch */
|
||||
|
||||
/* $fc = $Fc / $s;
|
||||
* $d = 1 / 2 / pi / $fc;
|
||||
* $x = exp(-1 / $d);
|
||||
*/
|
||||
|
||||
x = exp(-2.0 * M_PI * Fc_lo / bs2b->srate);
|
||||
bs2b->b1_lo = x;
|
||||
bs2b->a0_lo = G_lo * (1.0 - x);
|
||||
|
||||
x = exp(-2.0 * M_PI * Fc_hi / bs2b->srate);
|
||||
bs2b->b1_hi = x;
|
||||
bs2b->a0_hi = 1.0 - G_hi * (1.0 - x);
|
||||
bs2b->a1_hi = -x;
|
||||
|
||||
bs2b->gain = 1.0 / (1.0 - G_hi + G_lo);
|
||||
} /* init */
|
||||
|
||||
/* Exported functions.
|
||||
* See descriptions in "bs2b.h"
|
||||
*/
|
||||
|
||||
void bs2b_set_level(struct bs2b *bs2b, int level)
|
||||
{
|
||||
if(level == bs2b->level)
|
||||
return;
|
||||
bs2b->level = level;
|
||||
init(bs2b);
|
||||
} /* bs2b_set_level */
|
||||
|
||||
int bs2b_get_level(struct bs2b *bs2b)
|
||||
{
|
||||
return bs2b->level;
|
||||
} /* bs2b_get_level */
|
||||
|
||||
void bs2b_set_srate(struct bs2b *bs2b, int srate)
|
||||
{
|
||||
if (srate == bs2b->srate)
|
||||
return;
|
||||
bs2b->srate = srate;
|
||||
init(bs2b);
|
||||
} /* bs2b_set_srate */
|
||||
|
||||
int bs2b_get_srate(struct bs2b *bs2b)
|
||||
{
|
||||
return bs2b->srate;
|
||||
} /* bs2b_get_srate */
|
||||
|
||||
void bs2b_clear(struct bs2b *bs2b)
|
||||
{
|
||||
int loopv = sizeof(bs2b->last_sample);
|
||||
|
||||
while (loopv)
|
||||
{
|
||||
((char *)&bs2b->last_sample)[--loopv] = 0;
|
||||
}
|
||||
} /* bs2b_clear */
|
||||
|
||||
int bs2b_is_clear(struct bs2b *bs2b)
|
||||
{
|
||||
int loopv = sizeof(bs2b->last_sample);
|
||||
|
||||
while (loopv)
|
||||
{
|
||||
if (((char *)&bs2b->last_sample)[--loopv] != 0)
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
} /* bs2b_is_clear */
|
||||
|
||||
void bs2b_cross_feed(struct bs2b *bs2b, float *sample)
|
||||
{
|
||||
/* Lowpass filter */
|
||||
bs2b->last_sample.lo[0] = lo_filter(sample[0], bs2b->last_sample.lo[0]);
|
||||
bs2b->last_sample.lo[1] = lo_filter(sample[1], bs2b->last_sample.lo[1]);
|
||||
|
||||
/* Highboost filter */
|
||||
bs2b->last_sample.hi[0] = hi_filter(sample[0], bs2b->last_sample.asis[0], bs2b->last_sample.hi[0]);
|
||||
bs2b->last_sample.hi[1] = hi_filter(sample[1], bs2b->last_sample.asis[1], bs2b->last_sample.hi[1]);
|
||||
bs2b->last_sample.asis[0] = sample[0];
|
||||
bs2b->last_sample.asis[1] = sample[1];
|
||||
|
||||
/* Crossfeed */
|
||||
sample[0] = bs2b->last_sample.hi[0] + bs2b->last_sample.lo[1];
|
||||
sample[1] = bs2b->last_sample.hi[1] + bs2b->last_sample.lo[0];
|
||||
|
||||
/* Bass boost cause allpass attenuation */
|
||||
sample[0] *= bs2b->gain;
|
||||
sample[1] *= bs2b->gain;
|
||||
|
||||
/* Clipping of overloaded samples */
|
||||
#if 0
|
||||
if (sample[0] > 1.0)
|
||||
sample[0] = 1.0;
|
||||
if (sample[0] < -1.0)
|
||||
sample[0] = -1.0;
|
||||
if (sample[1] > 1.0)
|
||||
sample[1] = 1.0;
|
||||
if (sample[1] < -1.0)
|
||||
sample[1] = -1.0;
|
||||
#endif
|
||||
} /* bs2b_cross_feed */
|
||||
+427
-140
@@ -18,181 +18,237 @@
|
||||
* Or go to http://www.gnu.org/copyleft/lgpl.html
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#define _WIN32_WINNT 0x0500
|
||||
#define INITGUID
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <memory.h>
|
||||
|
||||
#include <windows.h>
|
||||
#include <mmsystem.h>
|
||||
#include <dsound.h>
|
||||
#include <mmreg.h>
|
||||
#ifndef _WAVEFORMATEXTENSIBLE_
|
||||
#include <ks.h>
|
||||
#include <ksmedia.h>
|
||||
#endif
|
||||
|
||||
#include "alMain.h"
|
||||
#include "AL/al.h"
|
||||
#include "AL/alc.h"
|
||||
|
||||
#ifndef DSSPEAKER_5POINT1
|
||||
#define DSSPEAKER_5POINT1 6
|
||||
#endif
|
||||
#ifndef DSSPEAKER_7POINT1
|
||||
#define DSSPEAKER_7POINT1 7
|
||||
#endif
|
||||
|
||||
DEFINE_GUID(KSDATAFORMAT_SUBTYPE_PCM, 0x00000001, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);
|
||||
DEFINE_GUID(KSDATAFORMAT_SUBTYPE_IEEE_FLOAT, 0x00000003, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);
|
||||
|
||||
static void *ds_handle;
|
||||
static HRESULT (WINAPI *pDirectSoundCreate)(LPCGUID pcGuidDevice, LPDIRECTSOUND *ppDS, LPUNKNOWN pUnkOuter);
|
||||
static HRESULT (WINAPI *pDirectSoundEnumerateA)(LPDSENUMCALLBACKA pDSEnumCallback, LPVOID pContext);
|
||||
|
||||
|
||||
typedef struct {
|
||||
// DirectSound Playback Device
|
||||
LPDIRECTSOUND lpDS;
|
||||
LPDIRECTSOUNDBUFFER DSpbuffer;
|
||||
LPDIRECTSOUNDBUFFER DSsbuffer;
|
||||
MMRESULT ulDSTimerID;
|
||||
DWORD OldWriteCursor;
|
||||
|
||||
volatile int killNow;
|
||||
ALvoid *thread;
|
||||
} DSoundData;
|
||||
|
||||
|
||||
static ALCchar *DeviceList[16];
|
||||
typedef struct {
|
||||
ALCchar *name;
|
||||
GUID guid;
|
||||
} DevMap;
|
||||
|
||||
static void CALLBACK DirectSoundProc(UINT uID,UINT uReserved,DWORD_PTR dwUser,DWORD_PTR dwReserved1,DWORD_PTR dwReserved2)
|
||||
static const ALCchar dsDevice[] = "DirectSound Software";
|
||||
static DevMap *DeviceList;
|
||||
static ALuint NumDevices;
|
||||
static volatile ALuint load_count;
|
||||
|
||||
|
||||
void DSoundLoad(void)
|
||||
{
|
||||
ALCdevice *pDevice = (ALCdevice *)dwUser;
|
||||
DSoundData *pData = pDevice->ExtraData;
|
||||
DWORD PlayCursor,WriteCursor;
|
||||
BYTE *WritePtr1,*WritePtr2;
|
||||
DWORD WriteCnt1,WriteCnt2;
|
||||
WAVEFORMATEX OutputType;
|
||||
DWORD BytesPlayed;
|
||||
DWORD BufSize;
|
||||
HRESULT DSRes;
|
||||
|
||||
(void)uID;
|
||||
(void)uReserved;
|
||||
(void)dwReserved1;
|
||||
(void)dwReserved2;
|
||||
|
||||
BufSize = pDevice->UpdateFreq * pDevice->FrameSize;
|
||||
|
||||
// Get current play and write cursors
|
||||
IDirectSoundBuffer_GetCurrentPosition(pData->DSsbuffer,&PlayCursor,&WriteCursor);
|
||||
if (!pData->OldWriteCursor) pData->OldWriteCursor=WriteCursor-PlayCursor;
|
||||
|
||||
// Get the output format and figure the number of bytes played (block aligned)
|
||||
IDirectSoundBuffer_GetFormat(pData->DSsbuffer,&OutputType,sizeof(WAVEFORMATEX),NULL);
|
||||
BytesPlayed=((((WriteCursor<pData->OldWriteCursor)?(BufSize+WriteCursor-pData->OldWriteCursor):(WriteCursor-pData->OldWriteCursor))/OutputType.nBlockAlign)*OutputType.nBlockAlign);
|
||||
|
||||
// Lock output buffer started at 40msec in front of the old write cursor (15msec in front of the actual write cursor)
|
||||
DSRes=IDirectSoundBuffer_Lock(pData->DSsbuffer,(pData->OldWriteCursor+(OutputType.nSamplesPerSec/25)*OutputType.nBlockAlign)%BufSize,BytesPlayed,(LPVOID*)&WritePtr1,&WriteCnt1,(LPVOID*)&WritePtr2,&WriteCnt2,0);
|
||||
|
||||
// If the buffer is lost, restore it, play and lock
|
||||
if (DSRes==DSERR_BUFFERLOST)
|
||||
if(load_count == 0)
|
||||
{
|
||||
IDirectSoundBuffer_Restore(pData->DSsbuffer);
|
||||
IDirectSoundBuffer_Play(pData->DSsbuffer,0,0,DSBPLAY_LOOPING);
|
||||
DSRes=IDirectSoundBuffer_Lock(pData->DSsbuffer,(pData->OldWriteCursor+(OutputType.nSamplesPerSec/25)*OutputType.nBlockAlign)%BufSize,BytesPlayed,(LPVOID*)&WritePtr1,&WriteCnt1,(LPVOID*)&WritePtr2,&WriteCnt2,0);
|
||||
#ifdef _WIN32
|
||||
ds_handle = LoadLibraryA("dsound.dll");
|
||||
if(ds_handle == NULL)
|
||||
{
|
||||
AL_PRINT("Failed to load dsound.dll\n");
|
||||
return;
|
||||
}
|
||||
|
||||
#define LOAD_FUNC(f) do { \
|
||||
p##f = (void*)GetProcAddress((HMODULE)ds_handle, #f); \
|
||||
if(p##f == NULL) \
|
||||
{ \
|
||||
FreeLibrary(ds_handle); \
|
||||
ds_handle = NULL; \
|
||||
AL_PRINT("Could not load %s from dsound.dll\n", #f); \
|
||||
return; \
|
||||
} \
|
||||
} while(0)
|
||||
#else
|
||||
ds_handle = (void*)0xDEADBEEF;
|
||||
#define LOAD_FUNC(f) p##f = f
|
||||
#endif
|
||||
|
||||
LOAD_FUNC(DirectSoundCreate);
|
||||
LOAD_FUNC(DirectSoundEnumerateA);
|
||||
#undef LOAD_FUNC
|
||||
}
|
||||
++load_count;
|
||||
}
|
||||
|
||||
// Successfully locked the output buffer
|
||||
if (DSRes==DS_OK)
|
||||
{
|
||||
// If we have an active context, mix data directly into output buffer otherwise fill with silence
|
||||
SuspendContext(NULL);
|
||||
if (WritePtr1)
|
||||
aluMixData(pDevice->Context, WritePtr1, WriteCnt1, pDevice->Format);
|
||||
if (WritePtr2)
|
||||
aluMixData(pDevice->Context, WritePtr2, WriteCnt2, pDevice->Format);
|
||||
ProcessContext(NULL);
|
||||
void DSoundUnload(void)
|
||||
{
|
||||
if(load_count == 0 || --load_count > 0)
|
||||
return;
|
||||
|
||||
// Unlock output buffer only when successfully locked
|
||||
IDirectSoundBuffer_Unlock(pData->DSsbuffer,WritePtr1,WriteCnt1,WritePtr2,WriteCnt2);
|
||||
}
|
||||
|
||||
// Update old write cursor location
|
||||
pData->OldWriteCursor=((pData->OldWriteCursor+BytesPlayed)%BufSize);
|
||||
#ifdef _WIN32
|
||||
FreeLibrary(ds_handle);
|
||||
#endif
|
||||
ds_handle = NULL;
|
||||
}
|
||||
|
||||
|
||||
static ALuint DSoundProc(ALvoid *ptr)
|
||||
{
|
||||
ALCdevice *pDevice = (ALCdevice*)ptr;
|
||||
DSoundData *pData = (DSoundData*)pDevice->ExtraData;
|
||||
DSBCAPS DSBCaps;
|
||||
DWORD LastCursor = 0;
|
||||
DWORD PlayCursor;
|
||||
VOID *WritePtr1, *WritePtr2;
|
||||
DWORD WriteCnt1, WriteCnt2;
|
||||
DWORD FrameSize;
|
||||
DWORD FragSize;
|
||||
DWORD avail;
|
||||
HRESULT err;
|
||||
|
||||
memset(&DSBCaps, 0, sizeof(DSBCaps));
|
||||
DSBCaps.dwSize = sizeof(DSBCaps);
|
||||
err = IDirectSoundBuffer_GetCaps(pData->DSsbuffer, &DSBCaps);
|
||||
if(FAILED(err))
|
||||
{
|
||||
AL_PRINT("Failed to get buffer caps: 0x%lx\n", err);
|
||||
aluHandleDisconnect(pDevice);
|
||||
return 1;
|
||||
}
|
||||
|
||||
FrameSize = aluChannelsFromFormat(pDevice->Format) *
|
||||
aluBytesFromFormat(pDevice->Format);
|
||||
FragSize = pDevice->UpdateSize * FrameSize;
|
||||
|
||||
IDirectSoundBuffer_GetCurrentPosition(pData->DSsbuffer, &LastCursor, NULL);
|
||||
while(!pData->killNow)
|
||||
{
|
||||
// Get current play and write cursors
|
||||
IDirectSoundBuffer_GetCurrentPosition(pData->DSsbuffer, &PlayCursor, NULL);
|
||||
avail = (PlayCursor-LastCursor+DSBCaps.dwBufferBytes) % DSBCaps.dwBufferBytes;
|
||||
|
||||
if(avail < FragSize)
|
||||
{
|
||||
Sleep(1);
|
||||
continue;
|
||||
}
|
||||
avail -= avail%FragSize;
|
||||
|
||||
// Lock output buffer
|
||||
WriteCnt1 = 0;
|
||||
WriteCnt2 = 0;
|
||||
err = IDirectSoundBuffer_Lock(pData->DSsbuffer, LastCursor, avail, &WritePtr1, &WriteCnt1, &WritePtr2, &WriteCnt2, 0);
|
||||
|
||||
// If the buffer is lost, restore it, play and lock
|
||||
if(err == DSERR_BUFFERLOST)
|
||||
{
|
||||
err = IDirectSoundBuffer_Restore(pData->DSsbuffer);
|
||||
if(SUCCEEDED(err))
|
||||
err = IDirectSoundBuffer_Play(pData->DSsbuffer, 0, 0, DSBPLAY_LOOPING);
|
||||
if(SUCCEEDED(err))
|
||||
err = IDirectSoundBuffer_Lock(pData->DSsbuffer, LastCursor, avail, &WritePtr1, &WriteCnt1, &WritePtr2, &WriteCnt2, 0);
|
||||
}
|
||||
|
||||
// Successfully locked the output buffer
|
||||
if(SUCCEEDED(err))
|
||||
{
|
||||
// If we have an active context, mix data directly into output buffer otherwise fill with silence
|
||||
aluMixData(pDevice, WritePtr1, WriteCnt1/FrameSize);
|
||||
aluMixData(pDevice, WritePtr2, WriteCnt2/FrameSize);
|
||||
|
||||
// Unlock output buffer only when successfully locked
|
||||
IDirectSoundBuffer_Unlock(pData->DSsbuffer, WritePtr1, WriteCnt1, WritePtr2, WriteCnt2);
|
||||
}
|
||||
else
|
||||
AL_PRINT("Buffer lock error: %#lx\n", err);
|
||||
|
||||
// Update old write cursor location
|
||||
LastCursor += WriteCnt1+WriteCnt2;
|
||||
LastCursor %= DSBCaps.dwBufferBytes;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static ALCboolean DSoundOpenPlayback(ALCdevice *device, const ALCchar *deviceName)
|
||||
{
|
||||
DSBUFFERDESC DSBDescription;
|
||||
DSoundData *pData = NULL;
|
||||
WAVEFORMATEX OutputType;
|
||||
LPGUID guid = NULL;
|
||||
HRESULT hr;
|
||||
|
||||
if(deviceName)
|
||||
if(!deviceName)
|
||||
deviceName = dsDevice;
|
||||
else if(strcmp(deviceName, dsDevice) != 0)
|
||||
{
|
||||
int i;
|
||||
for(i = 0;DeviceList[i];i++)
|
||||
ALuint i;
|
||||
for(i = 0;i < NumDevices;i++)
|
||||
{
|
||||
if(strcmp(deviceName, DeviceList[i]) == 0)
|
||||
if(strcmp(deviceName, DeviceList[i].name) == 0)
|
||||
{
|
||||
device->szDeviceName = DeviceList[i];
|
||||
guid = &DeviceList[i].guid;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!DeviceList[i])
|
||||
if(i == NumDevices)
|
||||
return ALC_FALSE;
|
||||
}
|
||||
else
|
||||
device->szDeviceName = DeviceList[0];
|
||||
|
||||
//Platform specific
|
||||
memset(&OutputType, 0, sizeof(WAVEFORMATEX));
|
||||
OutputType.wFormatTag = WAVE_FORMAT_PCM;
|
||||
OutputType.nChannels = device->Channels;
|
||||
OutputType.wBitsPerSample = (((device->Format==AL_FORMAT_MONO16)||(device->Format==AL_FORMAT_STEREO16)||(device->Format==AL_FORMAT_QUAD16))?16:8);
|
||||
OutputType.nBlockAlign = OutputType.nChannels*OutputType.wBitsPerSample/8;
|
||||
OutputType.nSamplesPerSec = device->Frequency;
|
||||
OutputType.nAvgBytesPerSec = OutputType.nSamplesPerSec*OutputType.nBlockAlign;
|
||||
OutputType.cbSize = 0;
|
||||
DSoundLoad();
|
||||
if(ds_handle == NULL)
|
||||
return ALC_FALSE;
|
||||
|
||||
//Initialise requested device
|
||||
|
||||
pData = calloc(1, sizeof(DSoundData));
|
||||
if(!pData)
|
||||
{
|
||||
SetALCError(ALC_OUT_OF_MEMORY);
|
||||
alcSetError(ALC_OUT_OF_MEMORY);
|
||||
DSoundUnload();
|
||||
return ALC_FALSE;
|
||||
}
|
||||
|
||||
//Init COM
|
||||
CoInitialize(NULL);
|
||||
|
||||
//DirectSound Init code
|
||||
hr = CoCreateInstance(&CLSID_DirectSound, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectSound, (LPVOID*)&pData->lpDS);
|
||||
if(SUCCEEDED(hr))
|
||||
hr = IDirectSound_Initialize(pData->lpDS, NULL);
|
||||
hr = pDirectSoundCreate(guid, &pData->lpDS, NULL);
|
||||
if(SUCCEEDED(hr))
|
||||
hr = IDirectSound_SetCooperativeLevel(pData->lpDS, GetForegroundWindow(), DSSCL_PRIORITY);
|
||||
|
||||
if(SUCCEEDED(hr))
|
||||
{
|
||||
memset(&DSBDescription,0,sizeof(DSBUFFERDESC));
|
||||
DSBDescription.dwSize=sizeof(DSBUFFERDESC);
|
||||
DSBDescription.dwFlags=DSBCAPS_PRIMARYBUFFER;
|
||||
hr = IDirectSound_CreateSoundBuffer(pData->lpDS, &DSBDescription, &pData->DSpbuffer, NULL);
|
||||
}
|
||||
if(SUCCEEDED(hr))
|
||||
hr = IDirectSoundBuffer_SetFormat(pData->DSpbuffer,&OutputType);
|
||||
|
||||
if(SUCCEEDED(hr))
|
||||
{
|
||||
memset(&DSBDescription,0,sizeof(DSBUFFERDESC));
|
||||
DSBDescription.dwSize=sizeof(DSBUFFERDESC);
|
||||
DSBDescription.dwFlags=DSBCAPS_GLOBALFOCUS|DSBCAPS_GETCURRENTPOSITION2;
|
||||
DSBDescription.dwBufferBytes=device->UpdateFreq * device->FrameSize;
|
||||
DSBDescription.lpwfxFormat=&OutputType;
|
||||
hr = IDirectSound_CreateSoundBuffer(pData->lpDS, &DSBDescription, &pData->DSsbuffer, NULL);
|
||||
}
|
||||
|
||||
if(SUCCEEDED(hr))
|
||||
hr = IDirectSoundBuffer_Play(pData->DSsbuffer, 0, 0, DSBPLAY_LOOPING);
|
||||
|
||||
if(FAILED(hr))
|
||||
{
|
||||
if (pData->DSsbuffer)
|
||||
IDirectSoundBuffer_Release(pData->DSsbuffer);
|
||||
if (pData->DSpbuffer)
|
||||
IDirectSoundBuffer_Release(pData->DSpbuffer);
|
||||
if (pData->lpDS)
|
||||
if(pData->lpDS)
|
||||
IDirectSound_Release(pData->lpDS);
|
||||
|
||||
free(pData);
|
||||
DSoundUnload();
|
||||
return ALC_FALSE;
|
||||
}
|
||||
|
||||
pData->ulDSTimerID = timeSetEvent(25, 0, (LPTIMECALLBACK)DirectSoundProc, (DWORD)device, (UINT)TIME_CALLBACK_FUNCTION|TIME_PERIODIC);
|
||||
device->MaxNoOfSources = 256;
|
||||
|
||||
device->szDeviceName = strdup(deviceName);
|
||||
device->ExtraData = pData;
|
||||
return ALC_TRUE;
|
||||
}
|
||||
@@ -201,38 +257,206 @@ static void DSoundClosePlayback(ALCdevice *device)
|
||||
{
|
||||
DSoundData *pData = device->ExtraData;
|
||||
|
||||
// Stop and release the DS timer
|
||||
if (pData->ulDSTimerID)
|
||||
timeKillEvent(pData->ulDSTimerID);
|
||||
|
||||
// Wait ... just in case any timer events happen
|
||||
Sleep(100);
|
||||
|
||||
SuspendContext(NULL);
|
||||
|
||||
if (pData->DSsbuffer)
|
||||
IDirectSoundBuffer_Release(pData->DSsbuffer);
|
||||
if (pData->DSpbuffer)
|
||||
IDirectSoundBuffer_Release(pData->DSpbuffer);
|
||||
IDirectSound_Release(pData->lpDS);
|
||||
|
||||
//Deinit COM
|
||||
CoUninitialize();
|
||||
|
||||
ProcessContext(NULL);
|
||||
|
||||
free(pData);
|
||||
device->ExtraData = NULL;
|
||||
|
||||
DSoundUnload();
|
||||
}
|
||||
|
||||
static ALCboolean DSoundResetPlayback(ALCdevice *device)
|
||||
{
|
||||
DSoundData *pData = (DSoundData*)device->ExtraData;
|
||||
DSBUFFERDESC DSBDescription;
|
||||
WAVEFORMATEXTENSIBLE OutputType;
|
||||
DWORD frameSize = 0;
|
||||
ALenum format = 0;
|
||||
DWORD speakers;
|
||||
HRESULT hr;
|
||||
|
||||
memset(&OutputType, 0, sizeof(OutputType));
|
||||
|
||||
hr = IDirectSound_GetSpeakerConfig(pData->lpDS, &speakers);
|
||||
if(SUCCEEDED(hr) && *(GetConfigValue(NULL, "format", "")) != 0)
|
||||
{
|
||||
if(aluChannelsFromFormat(device->Format) == 1)
|
||||
speakers = DSSPEAKER_COMBINED(DSSPEAKER_MONO, 0);
|
||||
else if(aluChannelsFromFormat(device->Format) == 2)
|
||||
speakers = DSSPEAKER_COMBINED(DSSPEAKER_STEREO, 0);
|
||||
else if(aluChannelsFromFormat(device->Format) == 4)
|
||||
speakers = DSSPEAKER_COMBINED(DSSPEAKER_QUAD, 0);
|
||||
else if(aluChannelsFromFormat(device->Format) == 6)
|
||||
speakers = DSSPEAKER_COMBINED(DSSPEAKER_5POINT1, 0);
|
||||
else if(aluChannelsFromFormat(device->Format) == 8)
|
||||
speakers = DSSPEAKER_COMBINED(DSSPEAKER_7POINT1, 0);
|
||||
else
|
||||
{
|
||||
AL_PRINT("Unknown format: 0x%x\n", device->Format);
|
||||
return ALC_FALSE;
|
||||
}
|
||||
}
|
||||
if(SUCCEEDED(hr))
|
||||
{
|
||||
speakers = DSSPEAKER_CONFIG(speakers);
|
||||
if(speakers == DSSPEAKER_MONO)
|
||||
{
|
||||
if(aluBytesFromFormat(device->Format) == 1)
|
||||
format = AL_FORMAT_MONO8;
|
||||
else if(aluBytesFromFormat(device->Format) == 2)
|
||||
format = AL_FORMAT_MONO16;
|
||||
else if(aluBytesFromFormat(device->Format) == 4)
|
||||
format = AL_FORMAT_MONO_FLOAT32;
|
||||
}
|
||||
else if(speakers == DSSPEAKER_STEREO)
|
||||
{
|
||||
if(aluBytesFromFormat(device->Format) == 1)
|
||||
format = AL_FORMAT_STEREO8;
|
||||
else if(aluBytesFromFormat(device->Format) == 2)
|
||||
format = AL_FORMAT_STEREO16;
|
||||
else if(aluBytesFromFormat(device->Format) == 4)
|
||||
format = AL_FORMAT_STEREO_FLOAT32;
|
||||
}
|
||||
else if(speakers == DSSPEAKER_QUAD)
|
||||
{
|
||||
if(aluBytesFromFormat(device->Format) == 1)
|
||||
format = AL_FORMAT_QUAD8;
|
||||
else if(aluBytesFromFormat(device->Format) == 2)
|
||||
format = AL_FORMAT_QUAD16;
|
||||
else if(aluBytesFromFormat(device->Format) == 4)
|
||||
format = AL_FORMAT_QUAD32;
|
||||
OutputType.dwChannelMask = SPEAKER_FRONT_LEFT |
|
||||
SPEAKER_FRONT_RIGHT |
|
||||
SPEAKER_BACK_LEFT |
|
||||
SPEAKER_BACK_RIGHT;
|
||||
}
|
||||
else if(speakers == DSSPEAKER_5POINT1)
|
||||
{
|
||||
if(aluBytesFromFormat(device->Format) == 1)
|
||||
format = AL_FORMAT_51CHN8;
|
||||
else if(aluBytesFromFormat(device->Format) == 2)
|
||||
format = AL_FORMAT_51CHN16;
|
||||
else if(aluBytesFromFormat(device->Format) == 4)
|
||||
format = AL_FORMAT_51CHN32;
|
||||
OutputType.dwChannelMask = SPEAKER_FRONT_LEFT |
|
||||
SPEAKER_FRONT_RIGHT |
|
||||
SPEAKER_FRONT_CENTER |
|
||||
SPEAKER_LOW_FREQUENCY |
|
||||
SPEAKER_BACK_LEFT |
|
||||
SPEAKER_BACK_RIGHT;
|
||||
}
|
||||
else if(speakers == DSSPEAKER_7POINT1)
|
||||
{
|
||||
if(aluBytesFromFormat(device->Format) == 1)
|
||||
format = AL_FORMAT_71CHN8;
|
||||
else if(aluBytesFromFormat(device->Format) == 2)
|
||||
format = AL_FORMAT_71CHN16;
|
||||
else if(aluBytesFromFormat(device->Format) == 4)
|
||||
format = AL_FORMAT_71CHN32;
|
||||
OutputType.dwChannelMask = SPEAKER_FRONT_LEFT |
|
||||
SPEAKER_FRONT_RIGHT |
|
||||
SPEAKER_FRONT_CENTER |
|
||||
SPEAKER_LOW_FREQUENCY |
|
||||
SPEAKER_BACK_LEFT |
|
||||
SPEAKER_BACK_RIGHT |
|
||||
SPEAKER_SIDE_LEFT |
|
||||
SPEAKER_SIDE_RIGHT;
|
||||
}
|
||||
else
|
||||
format = device->Format;
|
||||
frameSize = aluBytesFromFormat(format) * aluChannelsFromFormat(format);
|
||||
|
||||
OutputType.Format.wFormatTag = WAVE_FORMAT_PCM;
|
||||
OutputType.Format.nChannels = aluChannelsFromFormat(format);
|
||||
OutputType.Format.wBitsPerSample = aluBytesFromFormat(format) * 8;
|
||||
OutputType.Format.nBlockAlign = OutputType.Format.nChannels*OutputType.Format.wBitsPerSample/8;
|
||||
OutputType.Format.nSamplesPerSec = device->Frequency;
|
||||
OutputType.Format.nAvgBytesPerSec = OutputType.Format.nSamplesPerSec*OutputType.Format.nBlockAlign;
|
||||
OutputType.Format.cbSize = 0;
|
||||
}
|
||||
|
||||
if(OutputType.Format.nChannels > 2 || OutputType.Format.wBitsPerSample > 16)
|
||||
{
|
||||
OutputType.Format.wFormatTag = WAVE_FORMAT_EXTENSIBLE;
|
||||
OutputType.Samples.wValidBitsPerSample = OutputType.Format.wBitsPerSample;
|
||||
OutputType.Format.cbSize = 22;
|
||||
if(OutputType.Format.wBitsPerSample == 32)
|
||||
OutputType.SubFormat = KSDATAFORMAT_SUBTYPE_IEEE_FLOAT;
|
||||
else
|
||||
OutputType.SubFormat = KSDATAFORMAT_SUBTYPE_PCM;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(SUCCEEDED(hr))
|
||||
{
|
||||
memset(&DSBDescription,0,sizeof(DSBUFFERDESC));
|
||||
DSBDescription.dwSize=sizeof(DSBUFFERDESC);
|
||||
DSBDescription.dwFlags=DSBCAPS_PRIMARYBUFFER;
|
||||
hr = IDirectSound_CreateSoundBuffer(pData->lpDS, &DSBDescription, &pData->DSpbuffer, NULL);
|
||||
}
|
||||
if(SUCCEEDED(hr))
|
||||
hr = IDirectSoundBuffer_SetFormat(pData->DSpbuffer,&OutputType.Format);
|
||||
}
|
||||
|
||||
if(SUCCEEDED(hr))
|
||||
{
|
||||
memset(&DSBDescription,0,sizeof(DSBUFFERDESC));
|
||||
DSBDescription.dwSize=sizeof(DSBUFFERDESC);
|
||||
DSBDescription.dwFlags=DSBCAPS_GLOBALFOCUS|DSBCAPS_GETCURRENTPOSITION2;
|
||||
DSBDescription.dwBufferBytes=device->UpdateSize * device->NumUpdates * frameSize;
|
||||
DSBDescription.lpwfxFormat=&OutputType.Format;
|
||||
hr = IDirectSound_CreateSoundBuffer(pData->lpDS, &DSBDescription, &pData->DSsbuffer, NULL);
|
||||
}
|
||||
|
||||
if(SUCCEEDED(hr))
|
||||
hr = IDirectSoundBuffer_Play(pData->DSsbuffer, 0, 0, DSBPLAY_LOOPING);
|
||||
|
||||
if(SUCCEEDED(hr))
|
||||
{
|
||||
device->ExtraData = pData;
|
||||
pData->thread = StartThread(DSoundProc, device);
|
||||
if(!pData->thread)
|
||||
hr = E_FAIL;
|
||||
}
|
||||
|
||||
if(FAILED(hr))
|
||||
{
|
||||
if (pData->DSsbuffer)
|
||||
IDirectSoundBuffer_Release(pData->DSsbuffer);
|
||||
pData->DSsbuffer = NULL;
|
||||
if (pData->DSpbuffer)
|
||||
IDirectSoundBuffer_Release(pData->DSpbuffer);
|
||||
pData->DSpbuffer = NULL;
|
||||
return ALC_FALSE;
|
||||
}
|
||||
|
||||
device->Format = format;
|
||||
|
||||
return ALC_TRUE;
|
||||
}
|
||||
|
||||
static void DSoundStopPlayback(ALCdevice *device)
|
||||
{
|
||||
DSoundData *pData = device->ExtraData;
|
||||
|
||||
if(!pData->thread)
|
||||
return;
|
||||
|
||||
pData->killNow = 1;
|
||||
StopThread(pData->thread);
|
||||
pData->thread = NULL;
|
||||
|
||||
IDirectSoundBuffer_Release(pData->DSsbuffer);
|
||||
pData->DSsbuffer = NULL;
|
||||
if (pData->DSpbuffer)
|
||||
IDirectSoundBuffer_Release(pData->DSpbuffer);
|
||||
pData->DSpbuffer = NULL;
|
||||
}
|
||||
|
||||
|
||||
static ALCboolean DSoundOpenCapture(ALCdevice *pDevice, const ALCchar *deviceName, ALCuint frequency, ALCenum format, ALCsizei SampleSize)
|
||||
static ALCboolean DSoundOpenCapture(ALCdevice *pDevice, const ALCchar *deviceName)
|
||||
{
|
||||
(void)pDevice;
|
||||
(void)deviceName;
|
||||
(void)frequency;
|
||||
(void)format;
|
||||
(void)SampleSize;
|
||||
return ALC_FALSE;
|
||||
}
|
||||
|
||||
@@ -268,6 +492,8 @@ static ALCuint DSoundAvailableSamples(ALCdevice *pDevice)
|
||||
BackendFuncs DSoundFuncs = {
|
||||
DSoundOpenPlayback,
|
||||
DSoundClosePlayback,
|
||||
DSoundResetPlayback,
|
||||
DSoundStopPlayback,
|
||||
DSoundOpenCapture,
|
||||
DSoundCloseCapture,
|
||||
DSoundStartCapture,
|
||||
@@ -276,10 +502,71 @@ BackendFuncs DSoundFuncs = {
|
||||
DSoundAvailableSamples
|
||||
};
|
||||
|
||||
static BOOL CALLBACK DSoundEnumDevices(LPGUID guid, LPCSTR desc, LPCSTR drvname, LPVOID data)
|
||||
{
|
||||
(void)data;
|
||||
(void)drvname;
|
||||
|
||||
if(guid)
|
||||
{
|
||||
char str[128];
|
||||
void *temp;
|
||||
|
||||
temp = realloc(DeviceList, sizeof(DevMap) * (NumDevices+1));
|
||||
if(temp)
|
||||
{
|
||||
DeviceList = temp;
|
||||
|
||||
snprintf(str, sizeof(str), "DirectSound Software on %s", desc);
|
||||
AppendAllDeviceList(str);
|
||||
|
||||
DeviceList[NumDevices].name = strdup(str);
|
||||
DeviceList[NumDevices].guid = *guid;
|
||||
NumDevices++;
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void alcDSoundInit(BackendFuncs *FuncList)
|
||||
{
|
||||
*FuncList = DSoundFuncs;
|
||||
|
||||
DeviceList[0] = AppendDeviceList("DirectSound Software");
|
||||
AppendAllDeviceList(DeviceList[0]);
|
||||
}
|
||||
|
||||
void alcDSoundDeinit(void)
|
||||
{
|
||||
ALuint i;
|
||||
|
||||
for(i = 0;i < NumDevices;++i)
|
||||
free(DeviceList[i].name);
|
||||
free(DeviceList);
|
||||
DeviceList = NULL;
|
||||
NumDevices = 0;
|
||||
}
|
||||
|
||||
void alcDSoundProbe(int type)
|
||||
{
|
||||
DSoundLoad();
|
||||
if(!ds_handle) return;
|
||||
|
||||
if(type == DEVICE_PROBE)
|
||||
AppendDeviceList(dsDevice);
|
||||
else if(type == ALL_DEVICE_PROBE)
|
||||
{
|
||||
HRESULT hr;
|
||||
ALuint i;
|
||||
|
||||
for(i = 0;i < NumDevices;++i)
|
||||
free(DeviceList[i].name);
|
||||
free(DeviceList);
|
||||
DeviceList = NULL;
|
||||
NumDevices = 0;
|
||||
|
||||
hr = pDirectSoundEnumerateA(DSoundEnumDevices, NULL);
|
||||
if(FAILED(hr))
|
||||
AL_PRINT("Error enumerating DirectSound devices (%#x)!\n", (unsigned int)hr);
|
||||
}
|
||||
|
||||
DSoundUnload();
|
||||
}
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
* Or go to http://www.gnu.org/copyleft/lgpl.html
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
@@ -45,16 +47,19 @@
|
||||
#define SOUND_MIXER_WRITE MIXER_WRITE
|
||||
#endif
|
||||
|
||||
static char *oss_device;
|
||||
static const ALCchar oss_device[] = "OSS Software";
|
||||
static const ALCchar oss_device_capture[] = "OSS Capture";
|
||||
|
||||
typedef struct {
|
||||
int fd;
|
||||
int killNow;
|
||||
volatile int killNow;
|
||||
ALvoid *thread;
|
||||
|
||||
ALubyte *mix_data;
|
||||
int data_size;
|
||||
int silence;
|
||||
|
||||
RingBuffer *ring;
|
||||
int doCapture;
|
||||
} oss_data;
|
||||
|
||||
|
||||
@@ -74,31 +79,68 @@ static ALuint OSSProc(ALvoid *ptr)
|
||||
{
|
||||
ALCdevice *pDevice = (ALCdevice*)ptr;
|
||||
oss_data *data = (oss_data*)pDevice->ExtraData;
|
||||
int remaining;
|
||||
int wrote;
|
||||
ALint frameSize;
|
||||
ssize_t wrote;
|
||||
|
||||
frameSize = aluChannelsFromFormat(pDevice->Format) *
|
||||
aluBytesFromFormat(pDevice->Format);
|
||||
|
||||
while(!data->killNow && pDevice->Connected)
|
||||
{
|
||||
ALint len = data->data_size;
|
||||
ALubyte *WritePtr = data->mix_data;
|
||||
|
||||
aluMixData(pDevice, WritePtr, len/frameSize);
|
||||
while(len > 0 && !data->killNow)
|
||||
{
|
||||
wrote = write(data->fd, WritePtr, len);
|
||||
if(wrote < 0)
|
||||
{
|
||||
if(errno != EAGAIN && errno != EWOULDBLOCK && errno != EINTR)
|
||||
{
|
||||
AL_PRINT("write failed: %s\n", strerror(errno));
|
||||
aluHandleDisconnect(pDevice);
|
||||
len = 0;
|
||||
}
|
||||
else
|
||||
Sleep(1);
|
||||
continue;
|
||||
}
|
||||
|
||||
len -= wrote;
|
||||
WritePtr += wrote;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static ALuint OSSCaptureProc(ALvoid *ptr)
|
||||
{
|
||||
ALCdevice *pDevice = (ALCdevice*)ptr;
|
||||
oss_data *data = (oss_data*)pDevice->ExtraData;
|
||||
int frameSize;
|
||||
int amt;
|
||||
|
||||
frameSize = aluBytesFromFormat(pDevice->Format);
|
||||
frameSize *= aluChannelsFromFormat(pDevice->Format);
|
||||
|
||||
while(!data->killNow)
|
||||
{
|
||||
SuspendContext(NULL);
|
||||
aluMixData(pDevice->Context,data->mix_data,data->data_size,pDevice->Format);
|
||||
ProcessContext(NULL);
|
||||
|
||||
remaining = data->data_size;
|
||||
while(remaining > 0)
|
||||
amt = read(data->fd, data->mix_data, data->data_size);
|
||||
if(amt < 0)
|
||||
{
|
||||
wrote = write(data->fd, data->mix_data+data->data_size-remaining, remaining);
|
||||
if(wrote < 0)
|
||||
{
|
||||
AL_PRINT("write failed: %s\n", strerror(errno));
|
||||
break;
|
||||
}
|
||||
if(wrote == 0)
|
||||
{
|
||||
usleep(1000);
|
||||
continue;
|
||||
}
|
||||
remaining -= wrote;
|
||||
AL_PRINT("read failed: %s\n", strerror(errno));
|
||||
aluHandleDisconnect(pDevice);
|
||||
break;
|
||||
}
|
||||
if(amt == 0)
|
||||
{
|
||||
Sleep(1);
|
||||
continue;
|
||||
}
|
||||
if(data->doCapture)
|
||||
WriteRingBuffer(data->ring, data->mix_data, amt/frameSize);
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -106,28 +148,15 @@ static ALuint OSSProc(ALvoid *ptr)
|
||||
|
||||
static ALCboolean oss_open_playback(ALCdevice *device, const ALCchar *deviceName)
|
||||
{
|
||||
int numFragmentsLogSize;
|
||||
int log2FragmentSize;
|
||||
unsigned int periods;
|
||||
audio_buf_info info;
|
||||
char driver[64];
|
||||
int numChannels;
|
||||
oss_data *data;
|
||||
int ossFormat;
|
||||
int ossSpeed;
|
||||
char *err;
|
||||
int i;
|
||||
|
||||
strncpy(driver, GetConfigValue("oss", "device", "/dev/dsp"), sizeof(driver)-1);
|
||||
driver[sizeof(driver)-1] = 0;
|
||||
if(deviceName)
|
||||
{
|
||||
if(strcmp(deviceName, oss_device))
|
||||
return ALC_FALSE;
|
||||
device->szDeviceName = oss_device;
|
||||
}
|
||||
else
|
||||
device->szDeviceName = oss_device;
|
||||
if(!deviceName)
|
||||
deviceName = oss_device;
|
||||
else if(strcmp(deviceName, oss_device) != 0)
|
||||
return ALC_FALSE;
|
||||
|
||||
data = (oss_data*)calloc(1, sizeof(oss_data));
|
||||
data->killNow = 0;
|
||||
@@ -140,31 +169,191 @@ static ALCboolean oss_open_playback(ALCdevice *device, const ALCchar *deviceName
|
||||
return ALC_FALSE;
|
||||
}
|
||||
|
||||
switch(device->Format)
|
||||
device->szDeviceName = strdup(deviceName);
|
||||
device->ExtraData = data;
|
||||
return ALC_TRUE;
|
||||
}
|
||||
|
||||
static void oss_close_playback(ALCdevice *device)
|
||||
{
|
||||
oss_data *data = (oss_data*)device->ExtraData;
|
||||
|
||||
close(data->fd);
|
||||
free(data);
|
||||
device->ExtraData = NULL;
|
||||
}
|
||||
|
||||
static ALCboolean oss_reset_playback(ALCdevice *device)
|
||||
{
|
||||
oss_data *data = (oss_data*)device->ExtraData;
|
||||
int numFragmentsLogSize;
|
||||
int log2FragmentSize;
|
||||
unsigned int periods;
|
||||
audio_buf_info info;
|
||||
ALuint frameSize;
|
||||
int numChannels;
|
||||
int ossFormat;
|
||||
int ossSpeed;
|
||||
char *err;
|
||||
int i;
|
||||
|
||||
switch(aluBytesFromFormat(device->Format))
|
||||
{
|
||||
case AL_FORMAT_MONO8:
|
||||
case AL_FORMAT_STEREO8:
|
||||
case AL_FORMAT_QUAD8:
|
||||
data->silence = 0x80;
|
||||
case 1:
|
||||
ossFormat = AFMT_U8;
|
||||
break;
|
||||
case AL_FORMAT_MONO16:
|
||||
case AL_FORMAT_STEREO16:
|
||||
case AL_FORMAT_QUAD16:
|
||||
data->silence = 0;
|
||||
case 4:
|
||||
switch(aluChannelsFromFormat(device->Format))
|
||||
{
|
||||
case 1: device->Format = AL_FORMAT_MONO16; break;
|
||||
case 2: device->Format = AL_FORMAT_STEREO16; break;
|
||||
case 4: device->Format = AL_FORMAT_QUAD16; break;
|
||||
case 6: device->Format = AL_FORMAT_51CHN16; break;
|
||||
case 7: device->Format = AL_FORMAT_61CHN16; break;
|
||||
case 8: device->Format = AL_FORMAT_71CHN16; break;
|
||||
}
|
||||
/* fall-through */
|
||||
case 2:
|
||||
ossFormat = AFMT_S16_NE;
|
||||
break;
|
||||
default:
|
||||
ossFormat = -1;
|
||||
AL_PRINT("Unknown format?! %x\n", device->Format);
|
||||
AL_PRINT("Unknown format: 0x%x\n", device->Format);
|
||||
return ALC_FALSE;
|
||||
}
|
||||
|
||||
periods = GetConfigValueInt("oss", "periods", 4);
|
||||
if((int)periods < 0)
|
||||
periods = 4;
|
||||
numChannels = device->Channels;
|
||||
periods = device->NumUpdates;
|
||||
numChannels = aluChannelsFromFormat(device->Format);
|
||||
frameSize = numChannels * aluBytesFromFormat(device->Format);
|
||||
|
||||
ossSpeed = device->Frequency;
|
||||
log2FragmentSize = log2i(device->UpdateFreq * device->FrameSize / periods);
|
||||
log2FragmentSize = log2i(device->UpdateSize * frameSize);
|
||||
|
||||
/* according to the OSS spec, 16 bytes are the minimum */
|
||||
if (log2FragmentSize < 4)
|
||||
log2FragmentSize = 4;
|
||||
/* Subtract one period since the temp mixing buffer counts as one. Still
|
||||
* need at least two on the card, though. */
|
||||
if(periods > 2) periods--;
|
||||
numFragmentsLogSize = (periods << 16) | log2FragmentSize;
|
||||
|
||||
#define ok(func, str) (i=(func),((i<0)?(err=(str)),0:1))
|
||||
/* Don't fail if SETFRAGMENT fails. We can handle just about anything
|
||||
* that's reported back via GETOSPACE */
|
||||
ioctl(data->fd, SNDCTL_DSP_SETFRAGMENT, &numFragmentsLogSize);
|
||||
if (!(ok(ioctl(data->fd, SNDCTL_DSP_SETFMT, &ossFormat), "set format") &&
|
||||
ok(ioctl(data->fd, SNDCTL_DSP_CHANNELS, &numChannels), "set channels") &&
|
||||
ok(ioctl(data->fd, SNDCTL_DSP_SPEED, &ossSpeed), "set speed") &&
|
||||
ok(ioctl(data->fd, SNDCTL_DSP_GETOSPACE, &info), "get space")))
|
||||
{
|
||||
AL_PRINT("%s failed: %s\n", err, strerror(errno));
|
||||
return ALC_FALSE;
|
||||
}
|
||||
#undef ok
|
||||
|
||||
if((int)aluChannelsFromFormat(device->Format) != numChannels)
|
||||
{
|
||||
AL_PRINT("Could not set %d channels, got %d instead\n", aluChannelsFromFormat(device->Format), numChannels);
|
||||
return ALC_FALSE;
|
||||
}
|
||||
|
||||
if(!((ossFormat == AFMT_U8 && aluBytesFromFormat(device->Format) == 1) ||
|
||||
(ossFormat == AFMT_S16_NE && aluBytesFromFormat(device->Format) == 2)))
|
||||
{
|
||||
AL_PRINT("Could not set %d-bit output, got format %#x\n", aluBytesFromFormat(device->Format)*8, ossFormat);
|
||||
return ALC_FALSE;
|
||||
}
|
||||
|
||||
device->Frequency = ossSpeed;
|
||||
device->UpdateSize = info.fragsize / frameSize;
|
||||
device->NumUpdates = info.fragments + 1;
|
||||
|
||||
data->data_size = device->UpdateSize * frameSize;
|
||||
data->mix_data = calloc(1, data->data_size);
|
||||
|
||||
data->thread = StartThread(OSSProc, device);
|
||||
if(data->thread == NULL)
|
||||
{
|
||||
free(data->mix_data);
|
||||
data->mix_data = NULL;
|
||||
return ALC_FALSE;
|
||||
}
|
||||
|
||||
return ALC_TRUE;
|
||||
}
|
||||
|
||||
static void oss_stop_playback(ALCdevice *device)
|
||||
{
|
||||
oss_data *data = (oss_data*)device->ExtraData;
|
||||
|
||||
if(!data->thread)
|
||||
return;
|
||||
|
||||
data->killNow = 1;
|
||||
StopThread(data->thread);
|
||||
data->thread = NULL;
|
||||
|
||||
if(ioctl(data->fd, SNDCTL_DSP_RESET) != 0)
|
||||
AL_PRINT("Error resetting device: %s\n", strerror(errno));
|
||||
|
||||
free(data->mix_data);
|
||||
data->mix_data = NULL;
|
||||
}
|
||||
|
||||
|
||||
static ALCboolean oss_open_capture(ALCdevice *device, const ALCchar *deviceName)
|
||||
{
|
||||
int numFragmentsLogSize;
|
||||
int log2FragmentSize;
|
||||
unsigned int periods;
|
||||
audio_buf_info info;
|
||||
ALuint frameSize;
|
||||
int numChannels;
|
||||
char driver[64];
|
||||
oss_data *data;
|
||||
int ossFormat;
|
||||
int ossSpeed;
|
||||
char *err;
|
||||
int i;
|
||||
|
||||
strncpy(driver, GetConfigValue("oss", "capture", "/dev/dsp"), sizeof(driver)-1);
|
||||
driver[sizeof(driver)-1] = 0;
|
||||
if(!deviceName)
|
||||
deviceName = oss_device_capture;
|
||||
else if(strcmp(deviceName, oss_device_capture) != 0)
|
||||
return ALC_FALSE;
|
||||
|
||||
data = (oss_data*)calloc(1, sizeof(oss_data));
|
||||
data->killNow = 0;
|
||||
|
||||
data->fd = open(driver, O_RDONLY);
|
||||
if(data->fd == -1)
|
||||
{
|
||||
free(data);
|
||||
AL_PRINT("Could not open %s: %s\n", driver, strerror(errno));
|
||||
return ALC_FALSE;
|
||||
}
|
||||
|
||||
switch(aluBytesFromFormat(device->Format))
|
||||
{
|
||||
case 1:
|
||||
ossFormat = AFMT_U8;
|
||||
break;
|
||||
case 2:
|
||||
ossFormat = AFMT_S16_NE;
|
||||
break;
|
||||
default:
|
||||
AL_PRINT("Unknown format: 0x%x\n", device->Format);
|
||||
close(data->fd);
|
||||
free(data);
|
||||
return ALC_FALSE;
|
||||
}
|
||||
|
||||
periods = 4;
|
||||
numChannels = aluChannelsFromFormat(device->Format);
|
||||
frameSize = numChannels * aluBytesFromFormat(device->Format);
|
||||
ossSpeed = device->Frequency;
|
||||
log2FragmentSize = log2i(device->UpdateSize * device->NumUpdates *
|
||||
frameSize / periods);
|
||||
|
||||
/* according to the OSS spec, 16 bytes are the minimum */
|
||||
if (log2FragmentSize < 4)
|
||||
@@ -176,72 +365,46 @@ static ALCboolean oss_open_playback(ALCdevice *device, const ALCchar *deviceName
|
||||
ok(ioctl(data->fd, SNDCTL_DSP_SETFMT, &ossFormat), "set format") &&
|
||||
ok(ioctl(data->fd, SNDCTL_DSP_CHANNELS, &numChannels), "set channels") &&
|
||||
ok(ioctl(data->fd, SNDCTL_DSP_SPEED, &ossSpeed), "set speed") &&
|
||||
ok(ioctl(data->fd, SNDCTL_DSP_GETOSPACE, &info), "get space")))
|
||||
ok(ioctl(data->fd, SNDCTL_DSP_GETISPACE, &info), "get space")))
|
||||
{
|
||||
AL_PRINT("%s failed: %s\n", err, strerror(i));
|
||||
AL_PRINT("%s failed: %s\n", err, strerror(errno));
|
||||
close(data->fd);
|
||||
free(data);
|
||||
return ALC_FALSE;
|
||||
}
|
||||
#undef ok
|
||||
|
||||
device->Channels = numChannels;
|
||||
device->Frequency = ossSpeed;
|
||||
device->Format = 0;
|
||||
if(ossFormat == AFMT_U8)
|
||||
if((int)aluChannelsFromFormat(device->Format) != numChannels)
|
||||
{
|
||||
if(device->Channels == 1)
|
||||
{
|
||||
device->Format = AL_FORMAT_MONO8;
|
||||
device->FrameSize = 1;
|
||||
}
|
||||
else if(device->Channels == 2)
|
||||
{
|
||||
device->Format = AL_FORMAT_STEREO8;
|
||||
device->FrameSize = 2;
|
||||
}
|
||||
else if(device->Channels == 4)
|
||||
{
|
||||
device->Format = AL_FORMAT_QUAD8;
|
||||
device->FrameSize = 4;
|
||||
}
|
||||
}
|
||||
else if(ossFormat == AFMT_S16_NE)
|
||||
{
|
||||
if(device->Channels == 1)
|
||||
{
|
||||
device->Format = AL_FORMAT_MONO16;
|
||||
device->FrameSize = 2;
|
||||
}
|
||||
else if(device->Channels == 2)
|
||||
{
|
||||
device->Format = AL_FORMAT_STEREO16;
|
||||
device->FrameSize = 4;
|
||||
}
|
||||
else if(device->Channels == 4)
|
||||
{
|
||||
device->Format = AL_FORMAT_QUAD16;
|
||||
device->FrameSize = 8;
|
||||
}
|
||||
}
|
||||
|
||||
if(!device->Format)
|
||||
{
|
||||
AL_PRINT("returned unknown format: %#x %d!\n", ossFormat, numChannels);
|
||||
AL_PRINT("Could not set %d channels, got %d instead\n", aluChannelsFromFormat(device->Format), numChannels);
|
||||
close(data->fd);
|
||||
free(data);
|
||||
return ALC_FALSE;
|
||||
}
|
||||
|
||||
device->UpdateFreq = info.fragsize / device->FrameSize;
|
||||
if(!((ossFormat == AFMT_U8 && aluBytesFromFormat(device->Format) == 1) ||
|
||||
(ossFormat == AFMT_S16_NE && aluBytesFromFormat(device->Format) == 2)))
|
||||
{
|
||||
AL_PRINT("Could not set %d-bit input, got format %#x\n", aluBytesFromFormat(device->Format)*8, ossFormat);
|
||||
close(data->fd);
|
||||
free(data);
|
||||
return ALC_FALSE;
|
||||
}
|
||||
|
||||
data->data_size = device->UpdateFreq * device->FrameSize;
|
||||
data->ring = CreateRingBuffer(frameSize, device->UpdateSize * device->NumUpdates);
|
||||
if(!data->ring)
|
||||
{
|
||||
AL_PRINT("ring buffer create failed\n");
|
||||
close(data->fd);
|
||||
free(data);
|
||||
return ALC_FALSE;
|
||||
}
|
||||
|
||||
data->data_size = info.fragsize;
|
||||
data->mix_data = calloc(1, data->data_size);
|
||||
|
||||
device->MaxNoOfSources = 256;
|
||||
|
||||
device->ExtraData = data;
|
||||
data->thread = StartThread(OSSProc, device);
|
||||
data->thread = StartThread(OSSCaptureProc, device);
|
||||
if(data->thread == NULL)
|
||||
{
|
||||
device->ExtraData = NULL;
|
||||
@@ -250,10 +413,11 @@ static ALCboolean oss_open_playback(ALCdevice *device, const ALCchar *deviceName
|
||||
return ALC_FALSE;
|
||||
}
|
||||
|
||||
device->szDeviceName = strdup(deviceName);
|
||||
return ALC_TRUE;
|
||||
}
|
||||
|
||||
static void oss_close_playback(ALCdevice *device)
|
||||
static void oss_close_capture(ALCdevice *device)
|
||||
{
|
||||
oss_data *data = (oss_data*)device->ExtraData;
|
||||
data->killNow = 1;
|
||||
@@ -261,54 +425,46 @@ static void oss_close_playback(ALCdevice *device)
|
||||
|
||||
close(data->fd);
|
||||
|
||||
DestroyRingBuffer(data->ring);
|
||||
|
||||
free(data->mix_data);
|
||||
free(data);
|
||||
device->ExtraData = NULL;
|
||||
}
|
||||
|
||||
|
||||
static ALCboolean oss_open_capture(ALCdevice *pDevice, const ALCchar *deviceName, ALCuint frequency, ALCenum format, ALCsizei SampleSize)
|
||||
{
|
||||
(void)pDevice;
|
||||
(void)deviceName;
|
||||
(void)frequency;
|
||||
(void)format;
|
||||
(void)SampleSize;
|
||||
return ALC_FALSE;
|
||||
}
|
||||
|
||||
static void oss_close_capture(ALCdevice *pDevice)
|
||||
{
|
||||
(void)pDevice;
|
||||
}
|
||||
|
||||
static void oss_start_capture(ALCdevice *pDevice)
|
||||
{
|
||||
(void)pDevice;
|
||||
oss_data *data = (oss_data*)pDevice->ExtraData;
|
||||
data->doCapture = 1;
|
||||
}
|
||||
|
||||
static void oss_stop_capture(ALCdevice *pDevice)
|
||||
{
|
||||
(void)pDevice;
|
||||
oss_data *data = (oss_data*)pDevice->ExtraData;
|
||||
data->doCapture = 0;
|
||||
}
|
||||
|
||||
static void oss_capture_samples(ALCdevice *pDevice, ALCvoid *pBuffer, ALCuint lSamples)
|
||||
{
|
||||
(void)pDevice;
|
||||
(void)pBuffer;
|
||||
(void)lSamples;
|
||||
oss_data *data = (oss_data*)pDevice->ExtraData;
|
||||
if(lSamples <= (ALCuint)RingBufferSize(data->ring))
|
||||
ReadRingBuffer(data->ring, pBuffer, lSamples);
|
||||
else
|
||||
alcSetError(ALC_INVALID_VALUE);
|
||||
}
|
||||
|
||||
static ALCuint oss_available_samples(ALCdevice *pDevice)
|
||||
{
|
||||
(void)pDevice;
|
||||
return 0;
|
||||
oss_data *data = (oss_data*)pDevice->ExtraData;
|
||||
return RingBufferSize(data->ring);
|
||||
}
|
||||
|
||||
|
||||
BackendFuncs oss_funcs = {
|
||||
oss_open_playback,
|
||||
oss_close_playback,
|
||||
oss_reset_playback,
|
||||
oss_stop_playback,
|
||||
oss_open_capture,
|
||||
oss_close_capture,
|
||||
oss_start_capture,
|
||||
@@ -320,7 +476,18 @@ BackendFuncs oss_funcs = {
|
||||
void alc_oss_init(BackendFuncs *func_list)
|
||||
{
|
||||
*func_list = oss_funcs;
|
||||
|
||||
oss_device = AppendDeviceList("OSS Software");
|
||||
AppendAllDeviceList(oss_device);
|
||||
}
|
||||
|
||||
void alc_oss_deinit(void)
|
||||
{
|
||||
}
|
||||
|
||||
void alc_oss_probe(int type)
|
||||
{
|
||||
if(type == DEVICE_PROBE)
|
||||
AppendDeviceList(oss_device);
|
||||
else if(type == ALL_DEVICE_PROBE)
|
||||
AppendAllDeviceList(oss_device);
|
||||
else if(type == CAPTURE_DEVICE_PROBE)
|
||||
AppendCaptureDeviceList(oss_device_capture);
|
||||
}
|
||||
|
||||
+298
@@ -0,0 +1,298 @@
|
||||
/**
|
||||
* OpenAL cross platform audio library
|
||||
* Copyright (C) 1999-2007 by authors.
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* 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
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
* Or go to http://www.gnu.org/copyleft/lgpl.html
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "alMain.h"
|
||||
#include "AL/al.h"
|
||||
#include "AL/alc.h"
|
||||
#ifdef HAVE_DLFCN_H
|
||||
#include <dlfcn.h>
|
||||
#endif
|
||||
|
||||
#include <portaudio.h>
|
||||
|
||||
static void *pa_handle;
|
||||
#define MAKE_FUNC(x) static typeof(x) * p##x
|
||||
MAKE_FUNC(Pa_Initialize);
|
||||
MAKE_FUNC(Pa_Terminate);
|
||||
MAKE_FUNC(Pa_GetErrorText);
|
||||
MAKE_FUNC(Pa_StartStream);
|
||||
MAKE_FUNC(Pa_StopStream);
|
||||
MAKE_FUNC(Pa_OpenStream);
|
||||
MAKE_FUNC(Pa_CloseStream);
|
||||
MAKE_FUNC(Pa_GetDefaultOutputDevice);
|
||||
MAKE_FUNC(Pa_GetStreamInfo);
|
||||
#undef MAKE_FUNC
|
||||
|
||||
|
||||
static const ALCchar pa_device[] = "PortAudio Software";
|
||||
static volatile ALuint load_count;
|
||||
|
||||
|
||||
void pa_load(void)
|
||||
{
|
||||
const char *str;
|
||||
PaError err;
|
||||
|
||||
if(load_count == 0)
|
||||
{
|
||||
#ifdef HAVE_DLFCN_H
|
||||
#if defined(__APPLE__) && defined(__MACH__)
|
||||
# define PALIB "libportaudio.2.dylib"
|
||||
#else
|
||||
# define PALIB "libportaudio.so.2"
|
||||
#endif
|
||||
pa_handle = dlopen(PALIB, RTLD_NOW);
|
||||
if(!pa_handle)
|
||||
return;
|
||||
dlerror();
|
||||
|
||||
#define LOAD_FUNC(f) do { \
|
||||
p##f = (typeof(f)*)dlsym(pa_handle, #f); \
|
||||
if((str=dlerror()) != NULL) \
|
||||
{ \
|
||||
dlclose(pa_handle); \
|
||||
pa_handle = NULL; \
|
||||
AL_PRINT("Could not load %s from "PALIB": %s\n", #f, str); \
|
||||
return; \
|
||||
} \
|
||||
} while(0)
|
||||
#else
|
||||
str = NULL;
|
||||
pa_handle = (void*)0xDEADBEEF;
|
||||
#define LOAD_FUNC(f) p##f = f
|
||||
#endif
|
||||
|
||||
LOAD_FUNC(Pa_Initialize);
|
||||
LOAD_FUNC(Pa_Terminate);
|
||||
LOAD_FUNC(Pa_GetErrorText);
|
||||
LOAD_FUNC(Pa_StartStream);
|
||||
LOAD_FUNC(Pa_StopStream);
|
||||
LOAD_FUNC(Pa_OpenStream);
|
||||
LOAD_FUNC(Pa_CloseStream);
|
||||
LOAD_FUNC(Pa_GetDefaultOutputDevice);
|
||||
LOAD_FUNC(Pa_GetStreamInfo);
|
||||
|
||||
#undef LOAD_FUNC
|
||||
|
||||
if((err=pPa_Initialize()) != paNoError)
|
||||
{
|
||||
AL_PRINT("Pa_Initialize() returned an error: %s\n", pPa_GetErrorText(err));
|
||||
#ifdef HAVE_DLFCN_H
|
||||
dlclose(pa_handle);
|
||||
#endif
|
||||
pa_handle = NULL;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
++load_count;
|
||||
}
|
||||
|
||||
void pa_unload(void)
|
||||
{
|
||||
if(load_count == 0 || --load_count > 0)
|
||||
return;
|
||||
|
||||
pPa_Terminate();
|
||||
#ifdef HAVE_DLFCN_H
|
||||
dlclose(pa_handle);
|
||||
#endif
|
||||
pa_handle = NULL;
|
||||
}
|
||||
|
||||
|
||||
typedef struct {
|
||||
PaStream *stream;
|
||||
} pa_data;
|
||||
|
||||
|
||||
static int pa_callback(const void *inputBuffer, void *outputBuffer,
|
||||
unsigned long framesPerBuffer, const PaStreamCallbackTimeInfo *timeInfo,
|
||||
const PaStreamCallbackFlags statusFlags, void *userData)
|
||||
{
|
||||
ALCdevice *device = (ALCdevice*)userData;
|
||||
|
||||
(void)inputBuffer;
|
||||
(void)timeInfo;
|
||||
(void)statusFlags;
|
||||
|
||||
aluMixData(device, outputBuffer, framesPerBuffer);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static ALCboolean pa_open_playback(ALCdevice *device, const ALCchar *deviceName)
|
||||
{
|
||||
const PaStreamInfo *streamInfo;
|
||||
PaStreamParameters outParams;
|
||||
pa_data *data;
|
||||
PaError err;
|
||||
|
||||
if(!deviceName)
|
||||
deviceName = pa_device;
|
||||
else if(strcmp(deviceName, pa_device) != 0)
|
||||
return ALC_FALSE;
|
||||
|
||||
pa_load();
|
||||
if(pa_handle == NULL)
|
||||
return ALC_FALSE;
|
||||
|
||||
data = (pa_data*)calloc(1, sizeof(pa_data));
|
||||
device->ExtraData = data;
|
||||
|
||||
outParams.device = GetConfigValueInt("port", "device", -1);
|
||||
if(outParams.device < 0)
|
||||
outParams.device = pPa_GetDefaultOutputDevice();
|
||||
outParams.suggestedLatency = (device->UpdateSize*device->NumUpdates) /
|
||||
(float)device->Frequency;
|
||||
outParams.hostApiSpecificStreamInfo = NULL;
|
||||
|
||||
switch(aluBytesFromFormat(device->Format))
|
||||
{
|
||||
case 1:
|
||||
outParams.sampleFormat = paUInt8;
|
||||
break;
|
||||
case 2:
|
||||
outParams.sampleFormat = paInt16;
|
||||
break;
|
||||
case 4:
|
||||
outParams.sampleFormat = paFloat32;
|
||||
break;
|
||||
default:
|
||||
AL_PRINT("Unknown format: 0x%x\n", device->Format);
|
||||
device->ExtraData = NULL;
|
||||
free(data);
|
||||
pa_unload();
|
||||
return ALC_FALSE;
|
||||
}
|
||||
outParams.channelCount = aluChannelsFromFormat(device->Format);
|
||||
|
||||
err = pPa_OpenStream(&data->stream, NULL, &outParams, device->Frequency,
|
||||
device->UpdateSize, paNoFlag, pa_callback, device);
|
||||
if(err != paNoError)
|
||||
{
|
||||
AL_PRINT("Pa_OpenStream() returned an error: %s\n", pPa_GetErrorText(err));
|
||||
device->ExtraData = NULL;
|
||||
free(data);
|
||||
pa_unload();
|
||||
return ALC_FALSE;
|
||||
}
|
||||
streamInfo = pPa_GetStreamInfo(data->stream);
|
||||
|
||||
err = pPa_StartStream(data->stream);
|
||||
if(err != paNoError)
|
||||
{
|
||||
AL_PRINT("Pa_StartStream() returned an error: %s\n", pPa_GetErrorText(err));
|
||||
pPa_CloseStream(data->stream);
|
||||
device->ExtraData = NULL;
|
||||
free(data);
|
||||
pa_unload();
|
||||
return ALC_FALSE;
|
||||
}
|
||||
|
||||
device->szDeviceName = strdup(deviceName);
|
||||
device->Frequency = streamInfo->sampleRate;
|
||||
return ALC_TRUE;
|
||||
}
|
||||
|
||||
static void pa_close_playback(ALCdevice *device)
|
||||
{
|
||||
pa_data *data = (pa_data*)device->ExtraData;
|
||||
PaError err;
|
||||
|
||||
err = pPa_StopStream(data->stream);
|
||||
if(err != paNoError)
|
||||
fprintf(stderr, "Error stopping stream: %s\n", pPa_GetErrorText(err));
|
||||
|
||||
err = pPa_CloseStream(data->stream);
|
||||
if(err != paNoError)
|
||||
fprintf(stderr, "Error closing stream: %s\n", pPa_GetErrorText(err));
|
||||
|
||||
free(data);
|
||||
device->ExtraData = NULL;
|
||||
|
||||
pa_unload();
|
||||
}
|
||||
|
||||
static ALCboolean pa_reset_playback(ALCdevice *device)
|
||||
{
|
||||
pa_data *data = (pa_data*)device->ExtraData;
|
||||
const PaStreamInfo *streamInfo;
|
||||
|
||||
streamInfo = pPa_GetStreamInfo(data->stream);
|
||||
device->Frequency = streamInfo->sampleRate;
|
||||
|
||||
return ALC_TRUE;
|
||||
}
|
||||
|
||||
static void pa_stop_playback(ALCdevice *device)
|
||||
{
|
||||
(void)device;
|
||||
}
|
||||
|
||||
|
||||
static ALCboolean pa_open_capture(ALCdevice *device, const ALCchar *deviceName)
|
||||
{
|
||||
return ALC_FALSE;
|
||||
(void)device;
|
||||
(void)deviceName;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static const BackendFuncs pa_funcs = {
|
||||
pa_open_playback,
|
||||
pa_close_playback,
|
||||
pa_reset_playback,
|
||||
pa_stop_playback,
|
||||
pa_open_capture,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
};
|
||||
|
||||
void alc_pa_init(BackendFuncs *func_list)
|
||||
{
|
||||
*func_list = pa_funcs;
|
||||
}
|
||||
|
||||
void alc_pa_deinit(void)
|
||||
{
|
||||
}
|
||||
|
||||
void alc_pa_probe(int type)
|
||||
{
|
||||
pa_load();
|
||||
if(!pa_handle) return;
|
||||
|
||||
if(type == DEVICE_PROBE)
|
||||
AppendDeviceList(pa_device);
|
||||
else if(type == ALL_DEVICE_PROBE)
|
||||
AppendAllDeviceList(pa_device);
|
||||
|
||||
pa_unload();
|
||||
}
|
||||
@@ -0,0 +1,814 @@
|
||||
/**
|
||||
* OpenAL cross platform audio library
|
||||
* Copyright (C) 2009 by Konstantinos Natsakis <konstantinos.natsakis@gmail.com>
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* 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
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
* Or go to http://www.gnu.org/copyleft/lgpl.html
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "alMain.h"
|
||||
#ifdef HAVE_DLFCN_H
|
||||
#include <dlfcn.h>
|
||||
#endif
|
||||
|
||||
#include <pulse/pulseaudio.h>
|
||||
|
||||
#if PA_API_VERSION == 11
|
||||
#define PA_STREAM_ADJUST_LATENCY 0x2000U
|
||||
static inline int PA_STREAM_IS_GOOD(pa_stream_state_t x)
|
||||
{
|
||||
return (x == PA_STREAM_CREATING || x == PA_STREAM_READY);
|
||||
}
|
||||
static inline int PA_CONTEXT_IS_GOOD(pa_context_state_t x)
|
||||
{
|
||||
return (x == PA_CONTEXT_CONNECTING || x == PA_CONTEXT_AUTHORIZING ||
|
||||
x == PA_CONTEXT_SETTING_NAME || x == PA_CONTEXT_READY);
|
||||
}
|
||||
#define PA_STREAM_IS_GOOD PA_STREAM_IS_GOOD
|
||||
#define PA_CONTEXT_IS_GOOD PA_CONTEXT_IS_GOOD
|
||||
#elif PA_API_VERSION != 12
|
||||
#error Invalid PulseAudio API version
|
||||
#endif
|
||||
|
||||
static void *pa_handle;
|
||||
#define MAKE_FUNC(x) static typeof(x) * p##x
|
||||
MAKE_FUNC(pa_context_unref);
|
||||
MAKE_FUNC(pa_sample_spec_valid);
|
||||
MAKE_FUNC(pa_stream_drop);
|
||||
MAKE_FUNC(pa_strerror);
|
||||
MAKE_FUNC(pa_context_get_state);
|
||||
MAKE_FUNC(pa_stream_get_state);
|
||||
MAKE_FUNC(pa_threaded_mainloop_signal);
|
||||
MAKE_FUNC(pa_stream_peek);
|
||||
MAKE_FUNC(pa_threaded_mainloop_wait);
|
||||
MAKE_FUNC(pa_threaded_mainloop_unlock);
|
||||
MAKE_FUNC(pa_threaded_mainloop_in_thread);
|
||||
MAKE_FUNC(pa_context_new);
|
||||
MAKE_FUNC(pa_threaded_mainloop_stop);
|
||||
MAKE_FUNC(pa_context_disconnect);
|
||||
MAKE_FUNC(pa_threaded_mainloop_start);
|
||||
MAKE_FUNC(pa_threaded_mainloop_get_api);
|
||||
MAKE_FUNC(pa_context_set_state_callback);
|
||||
MAKE_FUNC(pa_stream_write);
|
||||
MAKE_FUNC(pa_xfree);
|
||||
MAKE_FUNC(pa_stream_connect_record);
|
||||
MAKE_FUNC(pa_stream_connect_playback);
|
||||
MAKE_FUNC(pa_path_get_filename);
|
||||
MAKE_FUNC(pa_get_binary_name);
|
||||
MAKE_FUNC(pa_threaded_mainloop_free);
|
||||
MAKE_FUNC(pa_context_errno);
|
||||
MAKE_FUNC(pa_xmalloc0);
|
||||
MAKE_FUNC(pa_stream_unref);
|
||||
MAKE_FUNC(pa_threaded_mainloop_accept);
|
||||
MAKE_FUNC(pa_stream_set_write_callback);
|
||||
MAKE_FUNC(pa_threaded_mainloop_new);
|
||||
MAKE_FUNC(pa_context_connect);
|
||||
MAKE_FUNC(pa_stream_get_buffer_attr);
|
||||
MAKE_FUNC(pa_stream_set_buffer_attr_callback);
|
||||
MAKE_FUNC(pa_stream_set_read_callback);
|
||||
MAKE_FUNC(pa_stream_set_state_callback);
|
||||
MAKE_FUNC(pa_stream_new);
|
||||
MAKE_FUNC(pa_stream_disconnect);
|
||||
MAKE_FUNC(pa_threaded_mainloop_lock);
|
||||
MAKE_FUNC(pa_channel_map_init_auto);
|
||||
MAKE_FUNC(pa_channel_map_parse);
|
||||
#undef MAKE_FUNC
|
||||
|
||||
#ifndef PATH_MAX
|
||||
#define PATH_MAX 4096
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
ALCuint samples;
|
||||
ALCuint frame_size;
|
||||
|
||||
RingBuffer *ring;
|
||||
|
||||
pa_buffer_attr attr;
|
||||
pa_sample_spec spec;
|
||||
|
||||
char path_name[PATH_MAX];
|
||||
const char *context_name;
|
||||
const char *stream_name;
|
||||
|
||||
pa_threaded_mainloop *loop;
|
||||
|
||||
pa_stream *stream;
|
||||
pa_context *context;
|
||||
} pulse_data;
|
||||
|
||||
static const ALCchar pulse_device[] = "PulseAudio Software";
|
||||
static const ALCchar pulse_capture_device[] = "PulseAudio Capture";
|
||||
static volatile ALuint load_count;
|
||||
|
||||
|
||||
void pulse_load(void) //{{{
|
||||
{
|
||||
if(load_count == 0)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
pa_handle = LoadLibrary("libpulse-0.dll");
|
||||
#define LOAD_FUNC(x) do { \
|
||||
p##x = GetProcAddress(pa_handle, #x); \
|
||||
if(!(p##x)) { \
|
||||
AL_PRINT("Could not load %s from libpulse-0.dll\n", #x); \
|
||||
FreeLibrary(pa_handle); \
|
||||
pa_handle = NULL; \
|
||||
return; \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
#elif defined (HAVE_DLFCN_H)
|
||||
|
||||
const char *err;
|
||||
#if defined(__APPLE__) && defined(__MACH__)
|
||||
pa_handle = dlopen("libpulse.0.dylib", RTLD_NOW);
|
||||
#else
|
||||
pa_handle = dlopen("libpulse.so.0", RTLD_NOW);
|
||||
#endif
|
||||
dlerror();
|
||||
|
||||
#define LOAD_FUNC(x) do { \
|
||||
p##x = dlsym(pa_handle, #x); \
|
||||
if((err=dlerror()) != NULL) { \
|
||||
AL_PRINT("Could not load %s from libpulse: %s\n", #x, err); \
|
||||
dlclose(pa_handle); \
|
||||
pa_handle = NULL; \
|
||||
return; \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
#else
|
||||
|
||||
pa_handle = (void*)0xDEADBEEF;
|
||||
#define LOAD_FUNC(x) p##x = (x)
|
||||
|
||||
#endif
|
||||
if(!pa_handle)
|
||||
return;
|
||||
|
||||
LOAD_FUNC(pa_context_unref);
|
||||
LOAD_FUNC(pa_sample_spec_valid);
|
||||
LOAD_FUNC(pa_stream_drop);
|
||||
LOAD_FUNC(pa_strerror);
|
||||
LOAD_FUNC(pa_context_get_state);
|
||||
LOAD_FUNC(pa_stream_get_state);
|
||||
LOAD_FUNC(pa_threaded_mainloop_signal);
|
||||
LOAD_FUNC(pa_stream_peek);
|
||||
LOAD_FUNC(pa_threaded_mainloop_wait);
|
||||
LOAD_FUNC(pa_threaded_mainloop_unlock);
|
||||
LOAD_FUNC(pa_threaded_mainloop_in_thread);
|
||||
LOAD_FUNC(pa_context_new);
|
||||
LOAD_FUNC(pa_threaded_mainloop_stop);
|
||||
LOAD_FUNC(pa_context_disconnect);
|
||||
LOAD_FUNC(pa_threaded_mainloop_start);
|
||||
LOAD_FUNC(pa_threaded_mainloop_get_api);
|
||||
LOAD_FUNC(pa_context_set_state_callback);
|
||||
LOAD_FUNC(pa_stream_write);
|
||||
LOAD_FUNC(pa_xfree);
|
||||
LOAD_FUNC(pa_stream_connect_record);
|
||||
LOAD_FUNC(pa_stream_connect_playback);
|
||||
LOAD_FUNC(pa_path_get_filename);
|
||||
LOAD_FUNC(pa_get_binary_name);
|
||||
LOAD_FUNC(pa_threaded_mainloop_free);
|
||||
LOAD_FUNC(pa_context_errno);
|
||||
LOAD_FUNC(pa_xmalloc0);
|
||||
LOAD_FUNC(pa_stream_unref);
|
||||
LOAD_FUNC(pa_threaded_mainloop_accept);
|
||||
LOAD_FUNC(pa_stream_set_write_callback);
|
||||
LOAD_FUNC(pa_threaded_mainloop_new);
|
||||
LOAD_FUNC(pa_context_connect);
|
||||
LOAD_FUNC(pa_stream_get_buffer_attr);
|
||||
LOAD_FUNC(pa_stream_set_buffer_attr_callback);
|
||||
LOAD_FUNC(pa_stream_set_read_callback);
|
||||
LOAD_FUNC(pa_stream_set_state_callback);
|
||||
LOAD_FUNC(pa_stream_new);
|
||||
LOAD_FUNC(pa_stream_disconnect);
|
||||
LOAD_FUNC(pa_threaded_mainloop_lock);
|
||||
LOAD_FUNC(pa_channel_map_init_auto);
|
||||
LOAD_FUNC(pa_channel_map_parse);
|
||||
|
||||
#undef LOAD_FUNC
|
||||
}
|
||||
++load_count;
|
||||
} //}}}
|
||||
|
||||
void pulse_unload(void) //{{{
|
||||
{
|
||||
if(load_count == 0 || --load_count > 0)
|
||||
return;
|
||||
|
||||
#ifdef _WIN32
|
||||
FreeLibrary(pa_handle);
|
||||
#elif defined (HAVE_DLFCN_H)
|
||||
dlclose(pa_handle);
|
||||
#endif
|
||||
pa_handle = NULL;
|
||||
} //}}}
|
||||
|
||||
|
||||
// PulseAudio Event Callbacks //{{{
|
||||
static void context_state_callback(pa_context *context, void *pdata) //{{{
|
||||
{
|
||||
ALCdevice *Device = pdata;
|
||||
pulse_data *data = Device->ExtraData;
|
||||
(void)context;
|
||||
|
||||
if(ppa_threaded_mainloop_in_thread(data->loop))
|
||||
ppa_threaded_mainloop_signal(data->loop, 1);
|
||||
}//}}}
|
||||
|
||||
static void stream_state_callback(pa_stream *stream, void *pdata) //{{{
|
||||
{
|
||||
ALCdevice *Device = pdata;
|
||||
pulse_data *data = Device->ExtraData;
|
||||
(void)stream;
|
||||
|
||||
if(ppa_threaded_mainloop_in_thread(data->loop))
|
||||
ppa_threaded_mainloop_signal(data->loop, 1);
|
||||
}//}}}
|
||||
|
||||
static void stream_buffer_attr_callback(pa_stream *stream, void *pdata) //{{{
|
||||
{
|
||||
ALCdevice *Device = pdata;
|
||||
pulse_data *data = Device->ExtraData;
|
||||
|
||||
SuspendContext(NULL);
|
||||
|
||||
data->attr = *(ppa_stream_get_buffer_attr(stream));
|
||||
if((data->attr.tlength%data->attr.minreq) != 0)
|
||||
AL_PRINT("new tlength (%d) is not a multiple of minreq (%d)!\n",
|
||||
data->attr.tlength, data->attr.minreq);
|
||||
Device->UpdateSize = data->attr.minreq;
|
||||
Device->NumUpdates = data->attr.tlength/data->attr.minreq;
|
||||
|
||||
ProcessContext(NULL);
|
||||
}//}}}
|
||||
|
||||
static void context_state_callback2(pa_context *context, void *pdata) //{{{
|
||||
{
|
||||
ALCdevice *Device = pdata;
|
||||
|
||||
if(ppa_context_get_state(context) == PA_CONTEXT_FAILED)
|
||||
{
|
||||
AL_PRINT("Received context failure!\n");
|
||||
aluHandleDisconnect(Device);
|
||||
}
|
||||
}//}}}
|
||||
|
||||
static void stream_state_callback2(pa_stream *stream, void *pdata) //{{{
|
||||
{
|
||||
ALCdevice *Device = pdata;
|
||||
|
||||
if(ppa_stream_get_state(stream) == PA_STREAM_FAILED)
|
||||
{
|
||||
AL_PRINT("Received stream failure!\n");
|
||||
aluHandleDisconnect(Device);
|
||||
}
|
||||
}//}}}
|
||||
|
||||
//}}}
|
||||
|
||||
// PulseAudio I/O Callbacks //{{{
|
||||
static void stream_write_callback(pa_stream *stream, size_t len, void *pdata) //{{{
|
||||
{
|
||||
ALCdevice *Device = pdata;
|
||||
pulse_data *data = Device->ExtraData;
|
||||
|
||||
len -= len%data->attr.minreq;
|
||||
if(len > 0)
|
||||
{
|
||||
void *buf = ppa_xmalloc0(len);
|
||||
aluMixData(Device, buf, len/data->frame_size);
|
||||
ppa_stream_write(stream, buf, len, ppa_xfree, 0, PA_SEEK_RELATIVE);
|
||||
}
|
||||
} //}}}
|
||||
|
||||
static void stream_read_callback(pa_stream *stream, size_t length, void *pdata) //{{{
|
||||
{
|
||||
ALCdevice *Device = pdata;
|
||||
pulse_data *data = Device->ExtraData;
|
||||
const void *buf;
|
||||
|
||||
if(ppa_stream_peek(stream, &buf, &length) < 0)
|
||||
{
|
||||
AL_PRINT("pa_stream_peek() failed: %s\n",
|
||||
ppa_strerror(ppa_context_errno(data->context)));
|
||||
return;
|
||||
}
|
||||
|
||||
assert(buf);
|
||||
assert(length);
|
||||
|
||||
length /= data->frame_size;
|
||||
|
||||
if(data->samples < length)
|
||||
AL_PRINT("stream_read_callback: buffer overflow!\n");
|
||||
|
||||
WriteRingBuffer(data->ring, buf, (length<data->samples) ? length : data->samples);
|
||||
|
||||
ppa_stream_drop(stream);
|
||||
} //}}}
|
||||
//}}}
|
||||
|
||||
static ALCboolean pulse_open(ALCdevice *device, const ALCchar *device_name) //{{{
|
||||
{
|
||||
pulse_data *data = ppa_xmalloc0(sizeof(pulse_data));
|
||||
pa_context_state_t state;
|
||||
|
||||
if(ppa_get_binary_name(data->path_name, sizeof(data->path_name)))
|
||||
data->context_name = ppa_path_get_filename(data->path_name);
|
||||
else
|
||||
data->context_name = "OpenAL Soft";
|
||||
|
||||
if(!(data->loop = ppa_threaded_mainloop_new()))
|
||||
{
|
||||
AL_PRINT("pa_threaded_mainloop_new() failed!\n");
|
||||
goto out;
|
||||
}
|
||||
|
||||
if(ppa_threaded_mainloop_start(data->loop) < 0)
|
||||
{
|
||||
AL_PRINT("pa_threaded_mainloop_start() failed\n");
|
||||
goto out;
|
||||
}
|
||||
|
||||
ppa_threaded_mainloop_lock(data->loop);
|
||||
device->ExtraData = data;
|
||||
|
||||
data->context = ppa_context_new(ppa_threaded_mainloop_get_api(data->loop), data->context_name);
|
||||
if(!data->context)
|
||||
{
|
||||
AL_PRINT("pa_context_new() failed: %s\n",
|
||||
ppa_strerror(ppa_context_errno(data->context)));
|
||||
|
||||
ppa_threaded_mainloop_unlock(data->loop);
|
||||
goto out;
|
||||
}
|
||||
|
||||
ppa_context_set_state_callback(data->context, context_state_callback, device);
|
||||
|
||||
if(ppa_context_connect(data->context, NULL, PA_CONTEXT_NOAUTOSPAWN, NULL) < 0)
|
||||
{
|
||||
AL_PRINT("Context did not connect: %s\n",
|
||||
ppa_strerror(ppa_context_errno(data->context)));
|
||||
|
||||
ppa_context_unref(data->context);
|
||||
data->context = NULL;
|
||||
|
||||
ppa_threaded_mainloop_unlock(data->loop);
|
||||
goto out;
|
||||
}
|
||||
|
||||
while((state=ppa_context_get_state(data->context)) != PA_CONTEXT_READY)
|
||||
{
|
||||
if(!PA_CONTEXT_IS_GOOD(state))
|
||||
{
|
||||
AL_PRINT("Context did not get ready: %s\n",
|
||||
ppa_strerror(ppa_context_errno(data->context)));
|
||||
|
||||
ppa_context_unref(data->context);
|
||||
data->context = NULL;
|
||||
|
||||
ppa_threaded_mainloop_unlock(data->loop);
|
||||
goto out;
|
||||
}
|
||||
|
||||
ppa_threaded_mainloop_wait(data->loop);
|
||||
ppa_threaded_mainloop_accept(data->loop);
|
||||
}
|
||||
ppa_context_set_state_callback(data->context, context_state_callback2, device);
|
||||
|
||||
device->szDeviceName = strdup(device_name);
|
||||
|
||||
ppa_threaded_mainloop_unlock(data->loop);
|
||||
return ALC_TRUE;
|
||||
|
||||
out:
|
||||
if(data->loop)
|
||||
{
|
||||
ppa_threaded_mainloop_stop(data->loop);
|
||||
ppa_threaded_mainloop_free(data->loop);
|
||||
}
|
||||
|
||||
device->ExtraData = NULL;
|
||||
ppa_xfree(data);
|
||||
return ALC_FALSE;
|
||||
} //}}}
|
||||
|
||||
static void pulse_close(ALCdevice *device) //{{{
|
||||
{
|
||||
pulse_data *data = device->ExtraData;
|
||||
|
||||
ppa_threaded_mainloop_lock(data->loop);
|
||||
|
||||
if(data->stream)
|
||||
{
|
||||
ppa_stream_disconnect(data->stream);
|
||||
ppa_stream_unref(data->stream);
|
||||
}
|
||||
|
||||
ppa_context_disconnect(data->context);
|
||||
ppa_context_unref(data->context);
|
||||
|
||||
ppa_threaded_mainloop_unlock(data->loop);
|
||||
|
||||
ppa_threaded_mainloop_stop(data->loop);
|
||||
ppa_threaded_mainloop_free(data->loop);
|
||||
|
||||
DestroyRingBuffer(data->ring);
|
||||
|
||||
device->ExtraData = NULL;
|
||||
ppa_xfree(data);
|
||||
} //}}}
|
||||
//}}}
|
||||
|
||||
// OpenAL {{{
|
||||
static ALCboolean pulse_open_playback(ALCdevice *device, const ALCchar *device_name) //{{{
|
||||
{
|
||||
if(!device_name)
|
||||
device_name = pulse_device;
|
||||
else if(strcmp(device_name, pulse_device) != 0)
|
||||
return ALC_FALSE;
|
||||
|
||||
pulse_load();
|
||||
if(!pa_handle)
|
||||
return ALC_FALSE;
|
||||
|
||||
if(pulse_open(device, device_name) != ALC_FALSE)
|
||||
return ALC_TRUE;
|
||||
|
||||
pulse_unload();
|
||||
return ALC_FALSE;
|
||||
} //}}}
|
||||
|
||||
static void pulse_close_playback(ALCdevice *device) //{{{
|
||||
{
|
||||
pulse_close(device);
|
||||
pulse_unload();
|
||||
} //}}}
|
||||
|
||||
static ALCboolean pulse_reset_playback(ALCdevice *device) //{{{
|
||||
{
|
||||
pulse_data *data = device->ExtraData;
|
||||
pa_stream_state_t state;
|
||||
pa_channel_map chanmap;
|
||||
|
||||
ppa_threaded_mainloop_lock(data->loop);
|
||||
|
||||
data->frame_size = aluBytesFromFormat(device->Format) *
|
||||
aluChannelsFromFormat(device->Format);
|
||||
data->attr.minreq = data->frame_size * device->UpdateSize;
|
||||
data->attr.prebuf = -1;
|
||||
data->attr.maxlength = -1;
|
||||
data->attr.fragsize = -1;
|
||||
data->attr.tlength = data->attr.minreq * device->NumUpdates;
|
||||
data->stream_name = "Playback Stream";
|
||||
|
||||
switch(aluBytesFromFormat(device->Format))
|
||||
{
|
||||
case 1:
|
||||
data->spec.format = PA_SAMPLE_U8;
|
||||
break;
|
||||
case 2:
|
||||
data->spec.format = PA_SAMPLE_S16NE;
|
||||
break;
|
||||
case 4:
|
||||
data->spec.format = PA_SAMPLE_FLOAT32NE;
|
||||
break;
|
||||
default:
|
||||
AL_PRINT("Unknown format: 0x%x\n", device->Format);
|
||||
ppa_threaded_mainloop_unlock(data->loop);
|
||||
return ALC_FALSE;
|
||||
}
|
||||
data->spec.rate = device->Frequency;
|
||||
data->spec.channels = aluChannelsFromFormat(device->Format);
|
||||
|
||||
if(ppa_sample_spec_valid(&data->spec) == 0)
|
||||
{
|
||||
AL_PRINT("Invalid sample format\n");
|
||||
ppa_threaded_mainloop_unlock(data->loop);
|
||||
return ALC_FALSE;
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
if(!ppa_channel_map_init_auto(&chanmap, data->spec.channels, PA_CHANNEL_MAP_WAVEEX))
|
||||
{
|
||||
AL_PRINT("Couldn't build map for channel count (%d)!", data->spec.channels);
|
||||
ppa_threaded_mainloop_unlock(data->loop);
|
||||
return ALC_FALSE;
|
||||
}
|
||||
#else
|
||||
switch(data->spec.channels)
|
||||
{
|
||||
case 1:
|
||||
ppa_channel_map_parse(&chanmap, "mono");
|
||||
break;
|
||||
case 2:
|
||||
ppa_channel_map_parse(&chanmap, "front-left,front-right");
|
||||
break;
|
||||
case 4:
|
||||
ppa_channel_map_parse(&chanmap, "front-left,front-right,rear-left,rear-right");
|
||||
break;
|
||||
case 6:
|
||||
ppa_channel_map_parse(&chanmap, "front-left,front-right,rear-left,rear-right,front-center,lfe");
|
||||
break;
|
||||
case 7:
|
||||
ppa_channel_map_parse(&chanmap, "front-left,front-right,front-center,lfe,rear-center,side-left,side-right");
|
||||
break;
|
||||
case 8:
|
||||
ppa_channel_map_parse(&chanmap, "front-left,front-right,rear-left,rear-right,front-center,lfe,side-left,side-right");
|
||||
break;
|
||||
default:
|
||||
AL_PRINT("Got unhandled channel count (%d)!", data->spec.channels);
|
||||
ppa_threaded_mainloop_unlock(data->loop);
|
||||
return ALC_FALSE;
|
||||
}
|
||||
#endif
|
||||
|
||||
data->stream = ppa_stream_new(data->context, data->stream_name, &data->spec, &chanmap);
|
||||
if(!data->stream)
|
||||
{
|
||||
AL_PRINT("pa_stream_new() failed: %s\n",
|
||||
ppa_strerror(ppa_context_errno(data->context)));
|
||||
|
||||
ppa_threaded_mainloop_unlock(data->loop);
|
||||
return ALC_FALSE;
|
||||
}
|
||||
|
||||
ppa_stream_set_state_callback(data->stream, stream_state_callback, device);
|
||||
ppa_stream_set_write_callback(data->stream, stream_write_callback, device);
|
||||
|
||||
if(ppa_stream_connect_playback(data->stream, NULL, &data->attr, PA_STREAM_ADJUST_LATENCY, NULL, NULL) < 0)
|
||||
{
|
||||
AL_PRINT("Stream did not connect: %s\n",
|
||||
ppa_strerror(ppa_context_errno(data->context)));
|
||||
|
||||
ppa_stream_unref(data->stream);
|
||||
data->stream = NULL;
|
||||
|
||||
ppa_threaded_mainloop_unlock(data->loop);
|
||||
return ALC_FALSE;
|
||||
}
|
||||
|
||||
while((state=ppa_stream_get_state(data->stream)) != PA_STREAM_READY)
|
||||
{
|
||||
if(!PA_STREAM_IS_GOOD(state))
|
||||
{
|
||||
AL_PRINT("Stream did not get ready: %s\n",
|
||||
ppa_strerror(ppa_context_errno(data->context)));
|
||||
|
||||
ppa_stream_unref(data->stream);
|
||||
data->stream = NULL;
|
||||
|
||||
ppa_threaded_mainloop_unlock(data->loop);
|
||||
return ALC_FALSE;
|
||||
}
|
||||
|
||||
ppa_threaded_mainloop_wait(data->loop);
|
||||
ppa_threaded_mainloop_accept(data->loop);
|
||||
}
|
||||
ppa_stream_set_state_callback(data->stream, stream_state_callback2, device);
|
||||
|
||||
stream_buffer_attr_callback(data->stream, device);
|
||||
ppa_stream_set_buffer_attr_callback(data->stream, stream_buffer_attr_callback, device);
|
||||
|
||||
ppa_threaded_mainloop_unlock(data->loop);
|
||||
return ALC_TRUE;
|
||||
} //}}}
|
||||
|
||||
static void pulse_stop_playback(ALCdevice *device) //{{{
|
||||
{
|
||||
pulse_data *data = device->ExtraData;
|
||||
|
||||
if(!data->stream)
|
||||
return;
|
||||
|
||||
ppa_threaded_mainloop_lock(data->loop);
|
||||
|
||||
ppa_stream_disconnect(data->stream);
|
||||
ppa_stream_unref(data->stream);
|
||||
data->stream = NULL;
|
||||
|
||||
ppa_threaded_mainloop_unlock(data->loop);
|
||||
} //}}}
|
||||
|
||||
|
||||
static ALCboolean pulse_open_capture(ALCdevice *device, const ALCchar *device_name) //{{{
|
||||
{
|
||||
pulse_data *data;
|
||||
pa_stream_state_t state;
|
||||
|
||||
if(!device_name)
|
||||
device_name = pulse_capture_device;
|
||||
else if(strcmp(device_name, pulse_capture_device) != 0)
|
||||
return ALC_FALSE;
|
||||
|
||||
pulse_load();
|
||||
if(!pa_handle)
|
||||
return ALC_FALSE;
|
||||
|
||||
if(pulse_open(device, device_name) == ALC_FALSE)
|
||||
{
|
||||
pulse_unload();
|
||||
return ALC_FALSE;
|
||||
}
|
||||
|
||||
data = device->ExtraData;
|
||||
ppa_threaded_mainloop_lock(data->loop);
|
||||
|
||||
data->samples = device->UpdateSize * device->NumUpdates;
|
||||
data->frame_size = aluBytesFromFormat(device->Format) *
|
||||
aluChannelsFromFormat(device->Format);
|
||||
|
||||
if(!(data->ring = CreateRingBuffer(data->frame_size, data->samples)))
|
||||
{
|
||||
ppa_threaded_mainloop_unlock(data->loop);
|
||||
pulse_close(device);
|
||||
pulse_unload();
|
||||
return ALC_FALSE;
|
||||
}
|
||||
|
||||
data->attr.minreq = -1;
|
||||
data->attr.prebuf = -1;
|
||||
data->attr.maxlength = -1;
|
||||
data->attr.tlength = -1;
|
||||
data->attr.fragsize = data->frame_size * data->samples / 2;
|
||||
data->stream_name = "Capture Stream";
|
||||
|
||||
data->spec.rate = device->Frequency;
|
||||
data->spec.channels = aluChannelsFromFormat(device->Format);
|
||||
|
||||
switch(aluBytesFromFormat(device->Format))
|
||||
{
|
||||
case 1:
|
||||
data->spec.format = PA_SAMPLE_U8;
|
||||
break;
|
||||
case 2:
|
||||
data->spec.format = PA_SAMPLE_S16NE;
|
||||
break;
|
||||
case 4:
|
||||
data->spec.format = PA_SAMPLE_FLOAT32NE;
|
||||
break;
|
||||
default:
|
||||
AL_PRINT("Unknown format: 0x%x\n", device->Format);
|
||||
ppa_threaded_mainloop_unlock(data->loop);
|
||||
pulse_close(device);
|
||||
pulse_unload();
|
||||
return ALC_FALSE;
|
||||
}
|
||||
|
||||
if(ppa_sample_spec_valid(&data->spec) == 0)
|
||||
{
|
||||
AL_PRINT("Invalid sample format\n");
|
||||
ppa_threaded_mainloop_unlock(data->loop);
|
||||
pulse_close(device);
|
||||
pulse_unload();
|
||||
return ALC_FALSE;
|
||||
}
|
||||
|
||||
data->stream = ppa_stream_new(data->context, data->stream_name, &data->spec, NULL);
|
||||
if(!data->stream)
|
||||
{
|
||||
AL_PRINT("pa_stream_new() failed: %s\n",
|
||||
ppa_strerror(ppa_context_errno(data->context)));
|
||||
|
||||
ppa_threaded_mainloop_unlock(data->loop);
|
||||
pulse_close(device);
|
||||
pulse_unload();
|
||||
return ALC_FALSE;
|
||||
}
|
||||
|
||||
ppa_stream_set_state_callback(data->stream, stream_state_callback, device);
|
||||
|
||||
if(ppa_stream_connect_record(data->stream, NULL, &data->attr, PA_STREAM_ADJUST_LATENCY) < 0)
|
||||
{
|
||||
AL_PRINT("Stream did not connect: %s\n",
|
||||
ppa_strerror(ppa_context_errno(data->context)));
|
||||
|
||||
ppa_stream_unref(data->stream);
|
||||
ppa_threaded_mainloop_unlock(data->loop);
|
||||
|
||||
data->stream = NULL;
|
||||
pulse_close(device);
|
||||
pulse_unload();
|
||||
return ALC_FALSE;
|
||||
}
|
||||
|
||||
while((state=ppa_stream_get_state(data->stream)) != PA_STREAM_READY)
|
||||
{
|
||||
if(!PA_STREAM_IS_GOOD(state))
|
||||
{
|
||||
AL_PRINT("Stream did not get ready: %s\n",
|
||||
ppa_strerror(ppa_context_errno(data->context)));
|
||||
|
||||
ppa_stream_unref(data->stream);
|
||||
ppa_threaded_mainloop_unlock(data->loop);
|
||||
|
||||
data->stream = NULL;
|
||||
pulse_close(device);
|
||||
pulse_unload();
|
||||
return ALC_FALSE;
|
||||
}
|
||||
|
||||
ppa_threaded_mainloop_wait(data->loop);
|
||||
ppa_threaded_mainloop_accept(data->loop);
|
||||
}
|
||||
ppa_stream_set_state_callback(data->stream, stream_state_callback2, device);
|
||||
|
||||
ppa_threaded_mainloop_unlock(data->loop);
|
||||
return ALC_TRUE;
|
||||
} //}}}
|
||||
|
||||
static void pulse_close_capture(ALCdevice *device) //{{{
|
||||
{
|
||||
pulse_close(device);
|
||||
pulse_unload();
|
||||
} //}}}
|
||||
|
||||
static void pulse_start_capture(ALCdevice *device) //{{{
|
||||
{
|
||||
pulse_data *data = device->ExtraData;
|
||||
|
||||
ppa_threaded_mainloop_lock(data->loop);
|
||||
ppa_stream_set_read_callback(data->stream, stream_read_callback, device);
|
||||
ppa_threaded_mainloop_unlock(data->loop);
|
||||
} //}}}
|
||||
|
||||
static void pulse_stop_capture(ALCdevice *device) //{{{
|
||||
{
|
||||
pulse_data *data = device->ExtraData;
|
||||
|
||||
ppa_threaded_mainloop_lock(data->loop);
|
||||
ppa_stream_set_read_callback(data->stream, NULL, NULL);
|
||||
ppa_threaded_mainloop_unlock(data->loop);
|
||||
} //}}}
|
||||
|
||||
static void pulse_capture_samples(ALCdevice *device, ALCvoid *buffer, ALCuint samples) //{{{
|
||||
{
|
||||
pulse_data *data = device->ExtraData;
|
||||
ALCuint available = RingBufferSize(data->ring);
|
||||
|
||||
if(available < samples)
|
||||
alcSetError(ALC_INVALID_VALUE);
|
||||
else
|
||||
ReadRingBuffer(data->ring, buffer, samples);
|
||||
} //}}}
|
||||
|
||||
static ALCuint pulse_available_samples(ALCdevice *device) //{{{
|
||||
{
|
||||
pulse_data *data = device->ExtraData;
|
||||
return RingBufferSize(data->ring);
|
||||
} //}}}
|
||||
|
||||
BackendFuncs pulse_funcs = { //{{{
|
||||
pulse_open_playback,
|
||||
pulse_close_playback,
|
||||
pulse_reset_playback,
|
||||
pulse_stop_playback,
|
||||
pulse_open_capture,
|
||||
pulse_close_capture,
|
||||
pulse_start_capture,
|
||||
pulse_stop_capture,
|
||||
pulse_capture_samples,
|
||||
pulse_available_samples
|
||||
}; //}}}
|
||||
|
||||
void alc_pulse_init(BackendFuncs *func_list) //{{{
|
||||
{
|
||||
*func_list = pulse_funcs;
|
||||
} //}}}
|
||||
|
||||
void alc_pulse_deinit(void) //{{{
|
||||
{
|
||||
} //}}}
|
||||
|
||||
void alc_pulse_probe(int type) //{{{
|
||||
{
|
||||
pulse_load();
|
||||
if(!pa_handle) return;
|
||||
|
||||
if(type == DEVICE_PROBE)
|
||||
AppendDeviceList(pulse_device);
|
||||
else if(type == ALL_DEVICE_PROBE)
|
||||
AppendAllDeviceList(pulse_device);
|
||||
else if(type == CAPTURE_DEVICE_PROBE)
|
||||
AppendCaptureDeviceList(pulse_capture_device);
|
||||
|
||||
pulse_unload();
|
||||
} //}}}
|
||||
//}}}
|
||||
+292
@@ -0,0 +1,292 @@
|
||||
/**
|
||||
* OpenAL cross platform audio library
|
||||
* Copyright (C) 1999-2007 by authors.
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* 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
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
* Or go to http://www.gnu.org/copyleft/lgpl.html
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <memory.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <math.h>
|
||||
#include "alMain.h"
|
||||
#include "AL/al.h"
|
||||
#include "AL/alc.h"
|
||||
|
||||
#include <sys/audioio.h>
|
||||
|
||||
|
||||
static const ALCchar solaris_device[] = "Solaris Software";
|
||||
|
||||
typedef struct {
|
||||
int fd;
|
||||
volatile int killNow;
|
||||
ALvoid *thread;
|
||||
|
||||
ALubyte *mix_data;
|
||||
int data_size;
|
||||
} solaris_data;
|
||||
|
||||
|
||||
static ALuint SolarisProc(ALvoid *ptr)
|
||||
{
|
||||
ALCdevice *pDevice = (ALCdevice*)ptr;
|
||||
solaris_data *data = (solaris_data*)pDevice->ExtraData;
|
||||
int remaining = 0;
|
||||
ALint frameSize;
|
||||
int wrote;
|
||||
|
||||
frameSize = aluChannelsFromFormat(pDevice->Format) *
|
||||
aluBytesFromFormat(pDevice->Format);
|
||||
|
||||
while(!data->killNow && pDevice->Connected)
|
||||
{
|
||||
ALint len = data->data_size;
|
||||
ALubyte *WritePtr = data->mix_data;
|
||||
|
||||
aluMixData(pDevice, WritePtr, len/frameSize);
|
||||
while(len > 0 && !data->killNow)
|
||||
{
|
||||
wrote = write(data->fd, WritePtr, len);
|
||||
if(wrote < 0)
|
||||
{
|
||||
if(errno != EAGAIN && errno != EWOULDBLOCK && errno != EINTR)
|
||||
{
|
||||
AL_PRINT("write failed: %s\n", strerror(errno));
|
||||
aluHandleDisconnect(pDevice);
|
||||
len = 0;
|
||||
}
|
||||
else
|
||||
Sleep(1);
|
||||
continue;
|
||||
}
|
||||
|
||||
len -= wrote;
|
||||
WritePtr += wrote;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static ALCboolean solaris_open_playback(ALCdevice *device, const ALCchar *deviceName)
|
||||
{
|
||||
char driver[64];
|
||||
solaris_data *data;
|
||||
|
||||
strncpy(driver, GetConfigValue("solaris", "device", "/dev/audio"), sizeof(driver)-1);
|
||||
driver[sizeof(driver)-1] = 0;
|
||||
if(!deviceName)
|
||||
deviceName = solaris_device;
|
||||
else if(strcmp(deviceName, solaris_device) != 0)
|
||||
return ALC_FALSE;
|
||||
|
||||
data = (solaris_data*)calloc(1, sizeof(solaris_data));
|
||||
data->killNow = 0;
|
||||
|
||||
data->fd = open(driver, O_WRONLY);
|
||||
if(data->fd == -1)
|
||||
{
|
||||
free(data);
|
||||
AL_PRINT("Could not open %s: %s\n", driver, strerror(errno));
|
||||
return ALC_FALSE;
|
||||
}
|
||||
|
||||
device->szDeviceName = strdup(deviceName);
|
||||
device->ExtraData = data;
|
||||
return ALC_TRUE;
|
||||
}
|
||||
|
||||
static void solaris_close_playback(ALCdevice *device)
|
||||
{
|
||||
solaris_data *data = (solaris_data*)device->ExtraData;
|
||||
|
||||
close(data->fd);
|
||||
free(data);
|
||||
device->ExtraData = NULL;
|
||||
}
|
||||
|
||||
static ALCboolean solaris_reset_playback(ALCdevice *device)
|
||||
{
|
||||
solaris_data *data = (solaris_data*)device->ExtraData;
|
||||
audio_info_t info;
|
||||
ALuint frameSize;
|
||||
int numChannels;
|
||||
|
||||
AUDIO_INITINFO(&info);
|
||||
|
||||
switch(aluBytesFromFormat(device->Format))
|
||||
{
|
||||
case 1:
|
||||
info.play.precision = 8;
|
||||
info.play.encoding = AUDIO_ENCODING_LINEAR8;
|
||||
break;
|
||||
case 4:
|
||||
switch(numChannels)
|
||||
{
|
||||
case 1: device->Format = AL_FORMAT_MONO16; break;
|
||||
case 2: device->Format = AL_FORMAT_STEREO16; break;
|
||||
case 4: device->Format = AL_FORMAT_QUAD16; break;
|
||||
case 6: device->Format = AL_FORMAT_51CHN16; break;
|
||||
case 7: device->Format = AL_FORMAT_61CHN16; break;
|
||||
case 8: device->Format = AL_FORMAT_71CHN16; break;
|
||||
}
|
||||
/* fall-through */
|
||||
case 2:
|
||||
info.play.precision = 16;
|
||||
info.play.encoding = AUDIO_ENCODING_LINEAR;
|
||||
break;
|
||||
default:
|
||||
AL_PRINT("Unknown format: 0x%x\n", device->Format);
|
||||
return ALC_FALSE;
|
||||
}
|
||||
|
||||
numChannels = aluChannelsFromFormat(device->Format);
|
||||
info.play.sample_rate = device->Frequency;
|
||||
info.play.channels = numChannels;
|
||||
|
||||
frameSize = numChannels * aluBytesFromFormat(device->Format);
|
||||
info.play.buffer_size = device->UpdateSize*device->NumUpdates * frameSize;
|
||||
|
||||
if(ioctl(data->fd, AUDIO_SETINFO, &info) < 0)
|
||||
{
|
||||
AL_PRINT("ioctl failed: %s\n", strerror(errno));
|
||||
return ALC_FALSE;
|
||||
}
|
||||
|
||||
if(aluChannelsFromFormat(device->Format) != info.play.channels)
|
||||
{
|
||||
AL_PRINT("Could not set %d channels, got %d instead\n", aluChannelsFromFormat(device->Format), info.play.channels);
|
||||
return ALC_FALSE;
|
||||
}
|
||||
|
||||
if(!((info.play.precision == 8 && aluBytesFromFormat(device->Format) == 1) ||
|
||||
(info.play.precision == 16 && aluBytesFromFormat(device->Format) == 2)))
|
||||
{
|
||||
AL_PRINT("Could not set %d-bit output, got %d\n", aluBytesFromFormat(device->Format)*8, info.play.precision);
|
||||
return ALC_FALSE;
|
||||
}
|
||||
|
||||
device->Frequency = info.play.sample_rate;
|
||||
device->UpdateSize = (info.play.buffer_size/device->NumUpdates) + 1;
|
||||
|
||||
data->data_size = device->UpdateSize * frameSize;
|
||||
data->mix_data = calloc(1, data->data_size);
|
||||
|
||||
data->thread = StartThread(SolarisProc, device);
|
||||
if(data->thread == NULL)
|
||||
{
|
||||
free(data->mix_data);
|
||||
data->mix_data = NULL;
|
||||
return ALC_FALSE;
|
||||
}
|
||||
|
||||
return ALC_TRUE;
|
||||
}
|
||||
|
||||
static void solaris_stop_playback(ALCdevice *device)
|
||||
{
|
||||
solaris_data *data = (solaris_data*)device->ExtraData;
|
||||
|
||||
if(!data->thread)
|
||||
return;
|
||||
|
||||
data->killNow = 1;
|
||||
StopThread(data->thread);
|
||||
data->thread = NULL;
|
||||
|
||||
free(data->mix_data);
|
||||
data->mix_data = NULL;
|
||||
}
|
||||
|
||||
|
||||
static ALCboolean solaris_open_capture(ALCdevice *device, const ALCchar *deviceName, ALCuint frequency, ALCenum format, ALCsizei SampleSize)
|
||||
{
|
||||
(void)device;
|
||||
(void)deviceName;
|
||||
(void)frequency;
|
||||
(void)format;
|
||||
(void)SampleSize;
|
||||
return ALC_FALSE;
|
||||
}
|
||||
|
||||
static void solaris_close_capture(ALCdevice *device)
|
||||
{
|
||||
(void)device;
|
||||
}
|
||||
|
||||
static void solaris_start_capture(ALCdevice *pDevice)
|
||||
{
|
||||
(void)pDevice;
|
||||
}
|
||||
|
||||
static void solaris_stop_capture(ALCdevice *pDevice)
|
||||
{
|
||||
(void)pDevice;
|
||||
}
|
||||
|
||||
static void solaris_capture_samples(ALCdevice *pDevice, ALCvoid *pBuffer, ALCuint lSamples)
|
||||
{
|
||||
(void)pDevice;
|
||||
(void)pBuffer;
|
||||
(void)lSamples;
|
||||
}
|
||||
|
||||
static ALCuint solaris_available_samples(ALCdevice *pDevice)
|
||||
{
|
||||
(void)pDevice;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
BackendFuncs solaris_funcs = {
|
||||
solaris_open_playback,
|
||||
solaris_close_playback,
|
||||
solaris_reset_playback,
|
||||
solaris_stop_playback,
|
||||
solaris_open_capture,
|
||||
solaris_close_capture,
|
||||
solaris_start_capture,
|
||||
solaris_stop_capture,
|
||||
solaris_capture_samples,
|
||||
solaris_available_samples
|
||||
};
|
||||
|
||||
void alc_solaris_init(BackendFuncs *func_list)
|
||||
{
|
||||
*func_list = solaris_funcs;
|
||||
}
|
||||
|
||||
void alc_solaris_deinit(void)
|
||||
{
|
||||
}
|
||||
|
||||
void alc_solaris_probe(ALCboolean capture)
|
||||
{
|
||||
if(type == DEVICE_PROBE)
|
||||
AppendDeviceList(solaris_device);
|
||||
else if(type == ALL_DEVICE_PROBE)
|
||||
AppendAllDeviceList(solaris_device);
|
||||
}
|
||||
+347
@@ -0,0 +1,347 @@
|
||||
/**
|
||||
* OpenAL cross platform audio library
|
||||
* Copyright (C) 1999-2007 by authors.
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* 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
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
* Or go to http://www.gnu.org/copyleft/lgpl.html
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <memory.h>
|
||||
#include "alMain.h"
|
||||
#include "AL/al.h"
|
||||
#include "AL/alc.h"
|
||||
|
||||
|
||||
typedef struct {
|
||||
FILE *f;
|
||||
long DataStart;
|
||||
|
||||
ALvoid *buffer;
|
||||
ALuint size;
|
||||
|
||||
volatile int killNow;
|
||||
ALvoid *thread;
|
||||
} wave_data;
|
||||
|
||||
|
||||
static const ALCchar waveDevice[] = "Wave File Writer";
|
||||
|
||||
|
||||
static ALuint WaveProc(ALvoid *ptr)
|
||||
{
|
||||
ALCdevice *pDevice = (ALCdevice*)ptr;
|
||||
wave_data *data = (wave_data*)pDevice->ExtraData;
|
||||
ALuint frameSize;
|
||||
ALuint now, last;
|
||||
size_t fs;
|
||||
ALuint avail;
|
||||
union {
|
||||
short s;
|
||||
char b[sizeof(short)];
|
||||
} uSB;
|
||||
|
||||
uSB.s = 1;
|
||||
frameSize = aluBytesFromFormat(pDevice->Format) *
|
||||
aluChannelsFromFormat(pDevice->Format);
|
||||
|
||||
last = timeGetTime();
|
||||
while(!data->killNow && pDevice->Connected)
|
||||
{
|
||||
now = timeGetTime();
|
||||
|
||||
avail = (now-last) * pDevice->Frequency / 1000;
|
||||
if(avail < pDevice->UpdateSize)
|
||||
{
|
||||
Sleep(1);
|
||||
continue;
|
||||
}
|
||||
|
||||
while(avail >= pDevice->UpdateSize)
|
||||
{
|
||||
aluMixData(pDevice, data->buffer, pDevice->UpdateSize);
|
||||
|
||||
if(uSB.b[0] != 1 && aluBytesFromFormat(pDevice->Format) > 1)
|
||||
{
|
||||
ALubyte *bytes = data->buffer;
|
||||
ALuint i;
|
||||
|
||||
for(i = 0;i < data->size;i++)
|
||||
fputc(bytes[i^1], data->f);
|
||||
}
|
||||
else
|
||||
fs = fwrite(data->buffer, frameSize, pDevice->UpdateSize,
|
||||
data->f);
|
||||
if(ferror(data->f))
|
||||
{
|
||||
AL_PRINT("Error writing to file\n");
|
||||
aluHandleDisconnect(pDevice);
|
||||
break;
|
||||
}
|
||||
|
||||
avail -= pDevice->UpdateSize;
|
||||
}
|
||||
last = now;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static ALCboolean wave_open_playback(ALCdevice *device, const ALCchar *deviceName)
|
||||
{
|
||||
wave_data *data;
|
||||
const char *fname;
|
||||
|
||||
fname = GetConfigValue("wave", "file", "");
|
||||
if(!fname[0])
|
||||
return ALC_FALSE;
|
||||
|
||||
if(!deviceName)
|
||||
deviceName = waveDevice;
|
||||
else if(strcmp(deviceName, waveDevice) != 0)
|
||||
return ALC_FALSE;
|
||||
|
||||
data = (wave_data*)calloc(1, sizeof(wave_data));
|
||||
|
||||
data->f = fopen(fname, "wb");
|
||||
if(!data->f)
|
||||
{
|
||||
free(data);
|
||||
AL_PRINT("Could not open file '%s': %s\n", fname, strerror(errno));
|
||||
return ALC_FALSE;
|
||||
}
|
||||
|
||||
device->szDeviceName = strdup(deviceName);
|
||||
device->ExtraData = data;
|
||||
return ALC_TRUE;
|
||||
}
|
||||
|
||||
static void wave_close_playback(ALCdevice *device)
|
||||
{
|
||||
wave_data *data = (wave_data*)device->ExtraData;
|
||||
|
||||
fclose(data->f);
|
||||
free(data);
|
||||
device->ExtraData = NULL;
|
||||
}
|
||||
|
||||
static ALCboolean wave_reset_playback(ALCdevice *device)
|
||||
{
|
||||
wave_data *data = (wave_data*)device->ExtraData;
|
||||
ALuint channels, bits, i;
|
||||
|
||||
fseek(data->f, 0, SEEK_SET);
|
||||
clearerr(data->f);
|
||||
|
||||
bits = aluBytesFromFormat(device->Format) * 8;
|
||||
channels = aluChannelsFromFormat(device->Format);
|
||||
switch(bits)
|
||||
{
|
||||
case 8:
|
||||
case 16:
|
||||
case 32:
|
||||
if(channels == 0)
|
||||
{
|
||||
AL_PRINT("Unknown format?! %x\n", device->Format);
|
||||
return ALC_FALSE;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
AL_PRINT("Unknown format?! %x\n", device->Format);
|
||||
return ALC_FALSE;
|
||||
}
|
||||
|
||||
fprintf(data->f, "RIFF");
|
||||
fputc(0, data->f); // 'RIFF' header len; filled in at close
|
||||
fputc(0, data->f);
|
||||
fputc(0, data->f);
|
||||
fputc(0, data->f);
|
||||
|
||||
fprintf(data->f, "WAVE");
|
||||
|
||||
fprintf(data->f, "fmt ");
|
||||
fputc(16, data->f); // 'fmt ' header len; 16 bytes for PCM
|
||||
fputc(0, data->f);
|
||||
fputc(0, data->f);
|
||||
fputc(0, data->f);
|
||||
// 16-bit val, format type id (PCM: 1)
|
||||
fputc(1, data->f);
|
||||
fputc(0, data->f);
|
||||
// 16-bit val, channel count
|
||||
fputc(channels&0xff, data->f);
|
||||
fputc((channels>>8)&0xff, data->f);
|
||||
// 32-bit val, frequency
|
||||
fputc(device->Frequency&0xff, data->f);
|
||||
fputc((device->Frequency>>8)&0xff, data->f);
|
||||
fputc((device->Frequency>>16)&0xff, data->f);
|
||||
fputc((device->Frequency>>24)&0xff, data->f);
|
||||
// 32-bit val, bytes per second
|
||||
i = device->Frequency * channels * bits / 8;
|
||||
fputc(i&0xff, data->f);
|
||||
fputc((i>>8)&0xff, data->f);
|
||||
fputc((i>>16)&0xff, data->f);
|
||||
fputc((i>>24)&0xff, data->f);
|
||||
// 16-bit val, frame size
|
||||
i = channels * bits / 8;
|
||||
fputc(i&0xff, data->f);
|
||||
fputc((i>>8)&0xff, data->f);
|
||||
// 16-bit val, bits per sample
|
||||
fputc(bits&0xff, data->f);
|
||||
fputc((bits>>8)&0xff, data->f);
|
||||
|
||||
fprintf(data->f, "data");
|
||||
fputc(0, data->f); // 'data' header len; filled in at close
|
||||
fputc(0, data->f);
|
||||
fputc(0, data->f);
|
||||
fputc(0, data->f);
|
||||
|
||||
if(ferror(data->f))
|
||||
{
|
||||
AL_PRINT("Error writing header: %s\n", strerror(errno));
|
||||
return ALC_FALSE;
|
||||
}
|
||||
|
||||
data->DataStart = ftell(data->f);
|
||||
|
||||
data->size = device->UpdateSize * channels * bits / 8;
|
||||
data->buffer = malloc(data->size);
|
||||
if(!data->buffer)
|
||||
{
|
||||
AL_PRINT("buffer malloc failed\n");
|
||||
return ALC_FALSE;
|
||||
}
|
||||
|
||||
data->thread = StartThread(WaveProc, device);
|
||||
if(data->thread == NULL)
|
||||
{
|
||||
free(data->buffer);
|
||||
data->buffer = NULL;
|
||||
return ALC_FALSE;
|
||||
}
|
||||
|
||||
return ALC_TRUE;
|
||||
}
|
||||
|
||||
static void wave_stop_playback(ALCdevice *device)
|
||||
{
|
||||
wave_data *data = (wave_data*)device->ExtraData;
|
||||
ALuint dataLen;
|
||||
long size;
|
||||
|
||||
if(!data->thread)
|
||||
return;
|
||||
|
||||
data->killNow = 1;
|
||||
StopThread(data->thread);
|
||||
data->thread = NULL;
|
||||
|
||||
free(data->buffer);
|
||||
data->buffer = NULL;
|
||||
|
||||
size = ftell(data->f);
|
||||
if(size > 0)
|
||||
{
|
||||
dataLen = size - data->DataStart;
|
||||
if(fseek(data->f, data->DataStart-4, SEEK_SET) == 0)
|
||||
{
|
||||
fputc(dataLen&0xff, data->f); // 'data' header len
|
||||
fputc((dataLen>>8)&0xff, data->f);
|
||||
fputc((dataLen>>16)&0xff, data->f);
|
||||
fputc((dataLen>>24)&0xff, data->f);
|
||||
}
|
||||
if(fseek(data->f, 4, SEEK_SET) == 0)
|
||||
{
|
||||
size -= 8;
|
||||
fputc(size&0xff, data->f); // 'WAVE' header len
|
||||
fputc((size>>8)&0xff, data->f);
|
||||
fputc((size>>16)&0xff, data->f);
|
||||
fputc((size>>24)&0xff, data->f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static ALCboolean wave_open_capture(ALCdevice *pDevice, const ALCchar *deviceName)
|
||||
{
|
||||
(void)pDevice;
|
||||
(void)deviceName;
|
||||
return ALC_FALSE;
|
||||
}
|
||||
|
||||
static void wave_close_capture(ALCdevice *pDevice)
|
||||
{
|
||||
(void)pDevice;
|
||||
}
|
||||
|
||||
static void wave_start_capture(ALCdevice *pDevice)
|
||||
{
|
||||
(void)pDevice;
|
||||
}
|
||||
|
||||
static void wave_stop_capture(ALCdevice *pDevice)
|
||||
{
|
||||
(void)pDevice;
|
||||
}
|
||||
|
||||
static void wave_capture_samples(ALCdevice *pDevice, ALCvoid *pBuffer, ALCuint lSamples)
|
||||
{
|
||||
(void)pDevice;
|
||||
(void)pBuffer;
|
||||
(void)lSamples;
|
||||
}
|
||||
|
||||
static ALCuint wave_available_samples(ALCdevice *pDevice)
|
||||
{
|
||||
(void)pDevice;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
BackendFuncs wave_funcs = {
|
||||
wave_open_playback,
|
||||
wave_close_playback,
|
||||
wave_reset_playback,
|
||||
wave_stop_playback,
|
||||
wave_open_capture,
|
||||
wave_close_capture,
|
||||
wave_start_capture,
|
||||
wave_stop_capture,
|
||||
wave_capture_samples,
|
||||
wave_available_samples
|
||||
};
|
||||
|
||||
void alc_wave_init(BackendFuncs *func_list)
|
||||
{
|
||||
*func_list = wave_funcs;
|
||||
}
|
||||
|
||||
void alc_wave_deinit(void)
|
||||
{
|
||||
}
|
||||
|
||||
void alc_wave_probe(int type)
|
||||
{
|
||||
if(*(GetConfigValue("wave", "file", "")) == 0)
|
||||
return;
|
||||
|
||||
if(type == DEVICE_PROBE)
|
||||
AppendDeviceList(waveDevice);
|
||||
else if(type == ALL_DEVICE_PROBE)
|
||||
AppendAllDeviceList(waveDevice);
|
||||
}
|
||||
+84
-34
@@ -18,6 +18,9 @@
|
||||
* Or go to http://www.gnu.org/copyleft/lgpl.html
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#define _WIN32_WINNT 0x0500
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <memory.h>
|
||||
@@ -47,7 +50,8 @@ typedef struct {
|
||||
} WinMMData;
|
||||
|
||||
|
||||
static ALCchar *CaptureDeviceList[16];
|
||||
static ALCchar **CaptureDeviceList;
|
||||
static ALuint NumCaptureDevices;
|
||||
|
||||
/*
|
||||
WaveInProc
|
||||
@@ -63,7 +67,7 @@ static void CALLBACK WaveInProc(HWAVEIN hDevice,UINT uMsg,DWORD_PTR dwInstance,D
|
||||
(void)hDevice;
|
||||
(void)dwParam2;
|
||||
|
||||
if ((uMsg==WIM_DATA) && (pDevice))
|
||||
if ((uMsg==WIM_DATA))
|
||||
{
|
||||
// Decrement number of buffers in use
|
||||
pData->lWaveInBuffersCommitted--;
|
||||
@@ -172,20 +176,18 @@ static void WinMMClosePlayback(ALCdevice *device)
|
||||
}
|
||||
|
||||
|
||||
static ALCboolean WinMMOpenCapture(ALCdevice *pDevice, const ALCchar *deviceName, ALCuint frequency, ALCenum format, ALCsizei SampleSize)
|
||||
static ALCboolean WinMMOpenCapture(ALCdevice *pDevice, const ALCchar *deviceName)
|
||||
{
|
||||
WAVEFORMATEX wfexCaptureFormat;
|
||||
WinMMData *pData = NULL;
|
||||
ALint lDeviceID = 0;
|
||||
ALint lBufferSize;
|
||||
ALint i;
|
||||
|
||||
(void)format;
|
||||
ALuint i;
|
||||
|
||||
// Find the Device ID matching the deviceName if valid
|
||||
if (deviceName)
|
||||
{
|
||||
for(i = 0;CaptureDeviceList[i];i++)
|
||||
for(i = 0;i < NumCaptureDevices;i++)
|
||||
{
|
||||
if (!strcmp(deviceName, CaptureDeviceList[i]))
|
||||
{
|
||||
@@ -193,26 +195,26 @@ static ALCboolean WinMMOpenCapture(ALCdevice *pDevice, const ALCchar *deviceName
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!CaptureDeviceList[i])
|
||||
if(i == NumCaptureDevices)
|
||||
return ALC_FALSE;
|
||||
}
|
||||
pDevice->szDeviceName = CaptureDeviceList[lDeviceID];
|
||||
|
||||
pData = calloc(1, sizeof(*pData));
|
||||
if(!pData)
|
||||
{
|
||||
SetALCError(ALC_OUT_OF_MEMORY);
|
||||
alcSetError(ALC_OUT_OF_MEMORY);
|
||||
return ALC_FALSE;
|
||||
}
|
||||
|
||||
memset(&wfexCaptureFormat, 0, sizeof(WAVEFORMATEX));
|
||||
wfexCaptureFormat.wFormatTag = WAVE_FORMAT_PCM;
|
||||
wfexCaptureFormat.nChannels = pDevice->Channels;
|
||||
wfexCaptureFormat.wBitsPerSample = pDevice->FrameSize / pDevice->Channels * 8;
|
||||
wfexCaptureFormat.nBlockAlign = pDevice->FrameSize;
|
||||
wfexCaptureFormat.nSamplesPerSec = frequency;
|
||||
wfexCaptureFormat.nChannels = aluChannelsFromFormat(pDevice->Format);
|
||||
wfexCaptureFormat.wBitsPerSample = aluBytesFromFormat(pDevice->Format) * 8;
|
||||
wfexCaptureFormat.nBlockAlign = wfexCaptureFormat.wBitsPerSample *
|
||||
wfexCaptureFormat.nChannels / 8;
|
||||
wfexCaptureFormat.nSamplesPerSec = pDevice->Frequency;
|
||||
wfexCaptureFormat.nAvgBytesPerSec = wfexCaptureFormat.nSamplesPerSec *
|
||||
pDevice->FrameSize;
|
||||
wfexCaptureFormat.nBlockAlign;
|
||||
wfexCaptureFormat.cbSize = 0;
|
||||
|
||||
if (waveInOpen(&pData->hWaveInHandle, lDeviceID, &wfexCaptureFormat, (DWORD_PTR)&WaveInProc, (DWORD_PTR)pDevice, CALLBACK_FUNCTION) != MMSYSERR_NOERROR)
|
||||
@@ -226,12 +228,9 @@ static ALCboolean WinMMOpenCapture(ALCdevice *pDevice, const ALCchar *deviceName
|
||||
if (pData->hWaveInThreadEvent == NULL)
|
||||
goto failure;
|
||||
|
||||
pData->hWaveInThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)CaptureThreadProc, (LPVOID)pDevice, 0, &pData->ulWaveInThreadID);
|
||||
if (pData->hWaveInThread == NULL)
|
||||
goto failure;
|
||||
|
||||
// Allocate circular memory buffer for the captured audio
|
||||
pData->ulCapturedDataSize = SampleSize * wfexCaptureFormat.nBlockAlign;
|
||||
pData->ulCapturedDataSize = pDevice->UpdateSize*pDevice->NumUpdates *
|
||||
wfexCaptureFormat.nBlockAlign;
|
||||
|
||||
// Make sure circular buffer is at least 100ms in size (and an exact multiple of
|
||||
// the block alignment
|
||||
@@ -264,17 +263,36 @@ static ALCboolean WinMMOpenCapture(ALCdevice *pDevice, const ALCchar *deviceName
|
||||
pData->ulWriteCapturedDataPos = 0;
|
||||
|
||||
pDevice->ExtraData = pData;
|
||||
|
||||
pData->hWaveInThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)CaptureThreadProc, (LPVOID)pDevice, 0, &pData->ulWaveInThreadID);
|
||||
if (pData->hWaveInThread == NULL)
|
||||
goto failure;
|
||||
|
||||
pDevice->szDeviceName = strdup(CaptureDeviceList[lDeviceID]);
|
||||
return ALC_TRUE;
|
||||
|
||||
failure:
|
||||
if (pData->hWaveInThreadEvent)
|
||||
CloseHandle(pData->hWaveInThreadEvent);
|
||||
for (i=0;i<4;i++)
|
||||
{
|
||||
if(pData->WaveInBuffer[i].lpData)
|
||||
{
|
||||
waveInUnprepareHeader(pData->hWaveInHandle, &pData->WaveInBuffer[i], sizeof(WAVEHDR));
|
||||
free(pData->WaveInBuffer[i].lpData);
|
||||
}
|
||||
}
|
||||
|
||||
free(pData->pCapturedSampleData);
|
||||
if(pData->hWaveInHandle)
|
||||
waveInClose(pData->hWaveInHandle);
|
||||
if(pData->hWaveInThread)
|
||||
CloseHandle(pData->hWaveInThread);
|
||||
if (pData->hWaveInHdrEvent)
|
||||
CloseHandle(pData->hWaveInHdrEvent);
|
||||
if (pData->hWaveInHandle)
|
||||
waveInClose(pData->hWaveInHandle);
|
||||
if (pData->hWaveInThreadEvent)
|
||||
CloseHandle(pData->hWaveInThreadEvent);
|
||||
|
||||
free(pData);
|
||||
pDevice->ExtraData = NULL;
|
||||
return ALC_FALSE;
|
||||
}
|
||||
|
||||
@@ -346,16 +364,20 @@ static void WinMMCaptureSamples(ALCdevice *pDevice, ALCvoid *pBuffer, ALCuint lS
|
||||
ALuint ulBytes, ulBytesToCopy;
|
||||
ALuint ulCapturedSamples;
|
||||
ALuint ulReadOffset;
|
||||
ALuint frameSize = aluBytesFromFormat(pDevice->Format) *
|
||||
aluChannelsFromFormat(pDevice->Format);
|
||||
|
||||
// Check that we have the requested numbers of Samples
|
||||
ulCapturedSamples = (pData->ulWriteCapturedDataPos - pData->ulReadCapturedDataPos) / pDevice->FrameSize;
|
||||
ulCapturedSamples = (pData->ulWriteCapturedDataPos -
|
||||
pData->ulReadCapturedDataPos) /
|
||||
frameSize;
|
||||
if(ulSamples > ulCapturedSamples)
|
||||
{
|
||||
SetALCError(ALC_INVALID_VALUE);
|
||||
alcSetError(ALC_INVALID_VALUE);
|
||||
return;
|
||||
}
|
||||
|
||||
ulBytes = ulSamples * pDevice->FrameSize;
|
||||
ulBytes = ulSamples * frameSize;
|
||||
|
||||
// Get Read Offset
|
||||
ulReadOffset = (pData->ulReadCapturedDataPos % pData->ulCapturedDataSize);
|
||||
@@ -384,13 +406,16 @@ static ALCuint WinMMAvailableSamples(ALCdevice *pDevice)
|
||||
{
|
||||
WinMMData *pData = (WinMMData*)pDevice->ExtraData;
|
||||
ALCuint lCapturedBytes = (pData->ulWriteCapturedDataPos - pData->ulReadCapturedDataPos);
|
||||
return lCapturedBytes / pDevice->FrameSize;
|
||||
return lCapturedBytes / (aluBytesFromFormat(pDevice->Format) *
|
||||
aluChannelsFromFormat(pDevice->Format));
|
||||
}
|
||||
|
||||
|
||||
BackendFuncs WinMMFuncs = {
|
||||
WinMMOpenPlayback,
|
||||
WinMMClosePlayback,
|
||||
NULL,
|
||||
NULL,
|
||||
WinMMOpenCapture,
|
||||
WinMMCloseCapture,
|
||||
WinMMStartCapture,
|
||||
@@ -401,20 +426,45 @@ BackendFuncs WinMMFuncs = {
|
||||
|
||||
void alcWinMMInit(BackendFuncs *FuncList)
|
||||
{
|
||||
ALint lNumDevs;
|
||||
ALint lLoop;
|
||||
|
||||
*FuncList = WinMMFuncs;
|
||||
}
|
||||
|
||||
lNumDevs = waveInGetNumDevs();
|
||||
for (lLoop = 0; lLoop < lNumDevs; lLoop++)
|
||||
void alcWinMMDeinit()
|
||||
{
|
||||
ALuint lLoop;
|
||||
|
||||
for(lLoop = 0; lLoop < NumCaptureDevices; lLoop++)
|
||||
free(CaptureDeviceList[lLoop]);
|
||||
free(CaptureDeviceList);
|
||||
CaptureDeviceList = NULL;
|
||||
|
||||
NumCaptureDevices = 0;
|
||||
}
|
||||
|
||||
void alcWinMMProbe(int type)
|
||||
{
|
||||
ALuint lLoop;
|
||||
|
||||
if(type != CAPTURE_DEVICE_PROBE)
|
||||
return;
|
||||
|
||||
for(lLoop = 0; lLoop < NumCaptureDevices; lLoop++)
|
||||
free(CaptureDeviceList[lLoop]);
|
||||
|
||||
NumCaptureDevices = waveInGetNumDevs();
|
||||
CaptureDeviceList = realloc(CaptureDeviceList, sizeof(ALCchar*) * NumCaptureDevices);
|
||||
for(lLoop = 0; lLoop < NumCaptureDevices; lLoop++)
|
||||
{
|
||||
WAVEINCAPS WaveInCaps;
|
||||
|
||||
if(waveInGetDevCaps(lLoop, &WaveInCaps, sizeof(WAVEINCAPS)) == MMSYSERR_NOERROR)
|
||||
{
|
||||
char name[128];
|
||||
snprintf(name, sizeof(name), "WaveIn on %s", WaveInCaps.szPname);
|
||||
CaptureDeviceList[lLoop] = AppendCaptureDeviceList(name);
|
||||
AppendCaptureDeviceList(name);
|
||||
CaptureDeviceList[lLoop] = strdup(name);
|
||||
}
|
||||
else
|
||||
CaptureDeviceList[lLoop] = strdup("");
|
||||
}
|
||||
}
|
||||
|
||||
+304
-91
@@ -1,44 +1,59 @@
|
||||
# CMake build file list for OpenAL
|
||||
|
||||
CMAKE_MINIMUM_REQUIRED(VERSION 2.4)
|
||||
|
||||
IF(COMMAND CMAKE_POLICY)
|
||||
CMAKE_POLICY(SET CMP0003 NEW)
|
||||
ENDIF(COMMAND CMAKE_POLICY)
|
||||
|
||||
INCLUDE(CheckFunctionExists)
|
||||
INCLUDE(CheckLibraryExists)
|
||||
INCLUDE(CheckIncludeFile)
|
||||
INCLUDE(CheckIncludeFiles)
|
||||
INCLUDE(CheckSymbolExists)
|
||||
INCLUDE(CheckCCompilerFlag)
|
||||
INCLUDE(CheckCSourceCompiles)
|
||||
INCLUDE(CheckTypeSize)
|
||||
|
||||
|
||||
PROJECT(OpenAL)
|
||||
PROJECT(OpenAL C)
|
||||
|
||||
|
||||
SET(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS TRUE)
|
||||
|
||||
|
||||
OPTION(ALSA "ALSA backend" ON)
|
||||
OPTION(OSS "OSS backend" ON)
|
||||
OPTION(DSOUND "DirectSound backend" ON)
|
||||
OPTION(WINMM "Windows Multimedia backend" ON)
|
||||
OPTION(ALSA "Check for ALSA backend" ON)
|
||||
OPTION(OSS "Check for OSS backend" ON)
|
||||
OPTION(SOLARIS "Check for Solaris backend" ON)
|
||||
OPTION(DSOUND "Check for DirectSound backend" ON)
|
||||
OPTION(WINMM "Check for Windows Multimedia backend" ON)
|
||||
OPTION(PORTAUDIO "Check for PortAudio backend" ON)
|
||||
OPTION(PULSEAUDIO "Check for PulseAudio backend" ON)
|
||||
|
||||
OPTION(DLOPEN "Use the dlopen API for loading optional libs" ON)
|
||||
OPTION(DLOPEN "Check for the dlopen API for loading optional libs" ON)
|
||||
|
||||
OPTION(DEBUG "Build lib in debug mode" OFF)
|
||||
OPTION(NODEBUG "Disable all debug info for optimizations" OFF)
|
||||
OPTION(WERROR "Treat compile warnings as errors" OFF)
|
||||
OPTION(WERROR "Treat compile warnings as errors" OFF)
|
||||
|
||||
OPTION(EXAMPLES "Build example programs" ON)
|
||||
|
||||
OPTION(ALSOFT_CONFIG "Install alsoft.conf configuration file" OFF)
|
||||
|
||||
|
||||
SET(LIB_MAJOR_VERSION "1")
|
||||
SET(LIB_MINOR_VERSION "0")
|
||||
SET(LIB_BUILD_VERSION "38")
|
||||
SET(LIB_VERSION "${LIB_MAJOR_VERSION}.${LIB_MINOR_VERSION}.${LIB_BUILD_VERSION}")
|
||||
|
||||
|
||||
IF("${WIN32}")
|
||||
SET(LIBNAME openal32)
|
||||
IF(WIN32)
|
||||
SET(LIBNAME OpenAL32)
|
||||
ADD_DEFINITIONS("-D_WIN32")
|
||||
ELSE()
|
||||
SET(LIBNAME openal)
|
||||
ENDIF()
|
||||
|
||||
SET(LIB_MAJOR_VERSION "1")
|
||||
SET(LIB_MINOR_VERSION "10")
|
||||
SET(LIB_BUILD_VERSION "622")
|
||||
SET(LIB_VERSION "${LIB_MAJOR_VERSION}.${LIB_MINOR_VERSION}.${LIB_BUILD_VERSION}")
|
||||
IF(NOT DEFINED LIB_INSTALL_DIR)
|
||||
SET(LIB_INSTALL_DIR "lib${LIB_SUFFIX}")
|
||||
ENDIF(NOT DEFINED LIB_INSTALL_DIR)
|
||||
|
||||
|
||||
CHECK_TYPE_SIZE("long" SIZEOF_LONG)
|
||||
CHECK_TYPE_SIZE("long long" SIZEOF_LONG_LONG)
|
||||
@@ -48,14 +63,41 @@ CHECK_TYPE_SIZE("void*" SIZEOF_VOIDP)
|
||||
|
||||
# Add definitions, compiler switches, etc.
|
||||
INCLUDE_DIRECTORIES(OpenAL32/Include include "${OpenAL_BINARY_DIR}")
|
||||
SET(EXTRA_LIBS m ${EXTRA_LIBS})
|
||||
|
||||
IF("${MSVC}")
|
||||
IF(NOT CMAKE_BUILD_TYPE)
|
||||
SET(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING
|
||||
"Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel."
|
||||
FORCE)
|
||||
ENDIF()
|
||||
IF(NOT CMAKE_DEBUG_POSTFIX)
|
||||
SET(CMAKE_DEBUG_POSTFIX "" CACHE STRING
|
||||
"Library postfix for debug builds. Normally left blank."
|
||||
FORCE)
|
||||
ENDIF()
|
||||
|
||||
IF(NOT DXSDK_DIR)
|
||||
STRING(REGEX REPLACE "\\\\" "/" DXSDK_DIR "$ENV{DXSDK_DIR}")
|
||||
ELSE()
|
||||
STRING(REGEX REPLACE "\\\\" "/" DXSDK_DIR "${DXSDK_DIR}")
|
||||
ENDIF()
|
||||
IF(DXSDK_DIR)
|
||||
MESSAGE(STATUS "Using DirectX SDK directory: ${DXSDK_DIR}")
|
||||
SET(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} "${DXSDK_DIR}/Include")
|
||||
INCLUDE_DIRECTORIES("${DXSDK_DIR}/Include")
|
||||
LINK_DIRECTORIES("${DXSDK_DIR}/Lib")
|
||||
ENDIF()
|
||||
|
||||
IF(MSVC)
|
||||
# ???
|
||||
SET(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -D_DEBUG")
|
||||
SET(CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL} -DNDEBUG")
|
||||
SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -DNDEBUG")
|
||||
SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -D_DEBUG")
|
||||
ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS)
|
||||
ELSE()
|
||||
ADD_DEFINITIONS(-Wall)
|
||||
CHECK_C_COMPILER_FLAG(-Wextra HAVE_W_EXTRA)
|
||||
IF("${HAVE_W_EXTRA}")
|
||||
IF(HAVE_W_EXTRA)
|
||||
ADD_DEFINITIONS(-Wextra)
|
||||
ENDIF()
|
||||
|
||||
@@ -63,96 +105,166 @@ ELSE()
|
||||
ADD_DEFINITIONS(-Werror)
|
||||
ENDIF()
|
||||
|
||||
IF(DEBUG)
|
||||
ADD_DEFINITIONS(-g3)
|
||||
ELSEIF(NODEBUG)
|
||||
ADD_DEFINITIONS(-O2 -funroll-loops -fomit-frame-pointer)
|
||||
ELSE()
|
||||
ADD_DEFINITIONS(-g -O2 -funroll-loops)
|
||||
ENDIF()
|
||||
|
||||
# The mixer doesn't like GCC's strict aliasing optimizations. Make sure
|
||||
# it's turned off
|
||||
CHECK_C_COMPILER_FLAG(-fstrict-aliasing HAVE_STRICT_ALIASING)
|
||||
IF("${HAVE_STRICT_ALIASING}")
|
||||
ADD_DEFINITIONS(-fno-strict-aliasing)
|
||||
ENDIF()
|
||||
SET(CMAKE_C_FLAGS_RELWITHDEBINFO "-g -O2 -funroll-loops -D_DEBUG" CACHE STRING
|
||||
"Flags used by the compiler during Release with Debug Info builds."
|
||||
FORCE)
|
||||
SET(CMAKE_C_FLAGS_MINSIZEREL "-Os -DNDEBUG" CACHE STRING
|
||||
"Flags used by the compiler during release minsize builds."
|
||||
FORCE)
|
||||
SET(CMAKE_C_FLAGS_RELEASE "-O2 -funroll-loops -fomit-frame-pointer -DNDEBUG" CACHE STRING
|
||||
"Flags used by the compiler during release builds"
|
||||
FORCE)
|
||||
SET(CMAKE_C_FLAGS_DEBUG "-g3 -D_DEBUG" CACHE STRING
|
||||
"Flags used by the compiler during debug builds."
|
||||
FORCE)
|
||||
|
||||
# Set visibility options if available
|
||||
IF(NOT "${WIN32}")
|
||||
IF(NOT WIN32)
|
||||
CHECK_C_SOURCE_COMPILES("int foo() __attribute__((destructor));
|
||||
int main() {return 0;}" HAVE_GCC_DESTRUCTOR)
|
||||
|
||||
CHECK_C_COMPILER_FLAG(-fvisibility=hidden HAVE_VISIBILITY_SWITCH)
|
||||
IF("${HAVE_VISIBILITY_SWITCH}")
|
||||
IF(HAVE_VISIBILITY_SWITCH)
|
||||
CHECK_C_SOURCE_COMPILES("int foo() __attribute__((visibility(\"default\")));
|
||||
int main() {return 0;}" HAVE_GCC_VISIBILITY)
|
||||
IF("${HAVE_GCC_VISIBILITY}")
|
||||
IF(HAVE_GCC_VISIBILITY)
|
||||
ADD_DEFINITIONS(-fvisibility=hidden -DHAVE_GCC_VISIBILITY)
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
|
||||
IF(DEBUG)
|
||||
ADD_DEFINITIONS(-D_DEBUG)
|
||||
ELSEIF(NODEBUG)
|
||||
ADD_DEFINITIONS(-DNDEBUG)
|
||||
ENDIF()
|
||||
CHECK_INCLUDE_FILE(fenv.h HAVE_FENV_H)
|
||||
CHECK_INCLUDE_FILE(float.h HAVE_FLOAT_H)
|
||||
|
||||
CHECK_LIBRARY_EXISTS(m sqrtf "" HAVE_SQRTF)
|
||||
CHECK_LIBRARY_EXISTS(m acosf "" HAVE_ACOSF)
|
||||
CHECK_LIBRARY_EXISTS(m atanf "" HAVE_ATANF)
|
||||
CHECK_LIBRARY_EXISTS(m fabsf "" HAVE_FABSF)
|
||||
IF(HAVE_FENV_H)
|
||||
CHECK_LIBRARY_EXISTS(m fesetround "" HAVE_FESETROUND)
|
||||
ENDIF()
|
||||
IF(HAVE_SQRTF OR HAVE_ACOSF OR HAVE_ATANF OR HAVE_FABSF OR HAVE_FESETROUND)
|
||||
SET(EXTRA_LIBS m ${EXTRA_LIBS})
|
||||
ENDIF()
|
||||
CHECK_FUNCTION_EXISTS(strtof HAVE_STRTOF)
|
||||
CHECK_FUNCTION_EXISTS(_controlfp HAVE__CONTROLFP)
|
||||
|
||||
CHECK_FUNCTION_EXISTS(strcasecmp HAVE_STRCASECMP)
|
||||
IF(NOT "${HAVE_STRCASECMP}")
|
||||
IF(NOT HAVE_STRCASECMP)
|
||||
CHECK_FUNCTION_EXISTS(_stricmp HAVE__STRICMP)
|
||||
IF(NOT "${HAVE__STRICMP}")
|
||||
IF(NOT HAVE__STRICMP)
|
||||
MESSAGE(FATAL_ERROR "No case-insensitive compare function found, please report!")
|
||||
ENDIF()
|
||||
|
||||
ADD_DEFINITIONS(-Dstrcasecmp=_stricmp)
|
||||
ENDIF()
|
||||
|
||||
CHECK_FUNCTION_EXISTS(strncasecmp HAVE_STRNCASECMP)
|
||||
IF(NOT HAVE_STRNCASECMP)
|
||||
CHECK_FUNCTION_EXISTS(_strnicmp HAVE__STRNICMP)
|
||||
IF(NOT HAVE__STRNICMP)
|
||||
MESSAGE(FATAL_ERROR "No case-insensitive size-limitted compare function found, please report!")
|
||||
ENDIF()
|
||||
|
||||
ADD_DEFINITIONS(-Dstrncasecmp=_strnicmp)
|
||||
ENDIF()
|
||||
|
||||
CHECK_FUNCTION_EXISTS(snprintf HAVE_SNPRINTF)
|
||||
IF(NOT HAVE_SNPRINTF)
|
||||
CHECK_FUNCTION_EXISTS(_snprintf HAVE__SNPRINTF)
|
||||
IF(NOT HAVE__SNPRINTF)
|
||||
MESSAGE(FATAL_ERROR "No snprintf function found, please report!")
|
||||
ENDIF()
|
||||
|
||||
ADD_DEFINITIONS(-Dsnprintf=_snprintf)
|
||||
ENDIF()
|
||||
|
||||
CHECK_FUNCTION_EXISTS(vsnprintf HAVE_VSNPRINTF)
|
||||
IF(NOT HAVE_VSNPRINTF)
|
||||
CHECK_FUNCTION_EXISTS(_vsnprintf HAVE__VSNPRINTF)
|
||||
IF(NOT HAVE__VSNPRINTF)
|
||||
MESSAGE(FATAL_ERROR "No vsnprintf function found, please report!")
|
||||
ENDIF()
|
||||
|
||||
ADD_DEFINITIONS(-Dvsnprintf=_vsnprintf)
|
||||
ENDIF()
|
||||
|
||||
CHECK_SYMBOL_EXISTS(isnan math.h HAVE_ISNAN)
|
||||
IF(NOT HAVE_ISNAN)
|
||||
CHECK_FUNCTION_EXISTS(_isnan HAVE__ISNAN)
|
||||
IF(NOT HAVE__ISNAN)
|
||||
MESSAGE(FATAL_ERROR "No isnan function found, please report!")
|
||||
ENDIF()
|
||||
|
||||
ADD_DEFINITIONS(-Disnan=_isnan)
|
||||
ENDIF()
|
||||
|
||||
|
||||
# Check for the dlopen API (for dynamicly loading backend libs)
|
||||
IF(DLOPEN)
|
||||
CHECK_INCLUDE_FILE(dlfcn.h HAVE_DLFCN_H)
|
||||
IF("${HAVE_DLFCN_H}")
|
||||
IF(HAVE_DLFCN_H)
|
||||
CHECK_LIBRARY_EXISTS(dl dlopen "" HAVE_LIBDL)
|
||||
IF("${HAVE_LIBDL}")
|
||||
IF(HAVE_LIBDL)
|
||||
SET(EXTRA_LIBS dl ${EXTRA_LIBS})
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
|
||||
# Check if we have Windows headers
|
||||
CHECK_INCLUDE_FILE(windows.h HAVE_WINDOWS_H)
|
||||
IF(NOT "${HAVE_WINDOWS_H}")
|
||||
CHECK_INCLUDE_FILE(windows.h HAVE_WINDOWS_H -D_WIN32_WINNT=0x0500)
|
||||
IF(NOT HAVE_WINDOWS_H)
|
||||
CHECK_FUNCTION_EXISTS(gettimeofday HAVE_GETTIMEOFDAY)
|
||||
IF(NOT HAVE_GETTIMEOFDAY)
|
||||
MESSAGE(FATAL_ERROR "No timing function found!")
|
||||
ENDIF()
|
||||
|
||||
CHECK_FUNCTION_EXISTS(nanosleep HAVE_NANOSLEEP)
|
||||
IF(NOT HAVE_NANOSLEEP)
|
||||
MESSAGE(FATAL_ERROR "No sleep function found!")
|
||||
ENDIF()
|
||||
|
||||
CHECK_C_COMPILER_FLAG(-pthread HAVE_PTHREAD)
|
||||
IF(HAVE_PTHREAD)
|
||||
ADD_DEFINITIONS(-pthread)
|
||||
SET(EXTRA_LIBS ${EXTRA_LIBS} -pthread)
|
||||
ENDIF()
|
||||
|
||||
# We need pthreads outside of Windows
|
||||
CHECK_INCLUDE_FILE(pthread.h HAVE_PTHREAD_H)
|
||||
IF(NOT "${HAVE_PTHREAD_H}")
|
||||
IF(NOT HAVE_PTHREAD_H)
|
||||
MESSAGE(FATAL_ERROR "PThreads is required for non-Windows builds!")
|
||||
ENDIF()
|
||||
# Some systems need pthread_np.h to get recursive mutexes
|
||||
CHECK_INCLUDE_FILES("pthread.h;pthread_np.h" HAVE_PTHREAD_NP_H)
|
||||
|
||||
# _GNU_SOURCE is needed on some systems for extra attributes, and
|
||||
# _REENTRANT is needed for libc thread-safety
|
||||
ADD_DEFINITIONS(-D_GNU_SOURCE=1 -D_REENTRANT)
|
||||
ADD_DEFINITIONS(-D_GNU_SOURCE=1)
|
||||
CHECK_LIBRARY_EXISTS(pthread pthread_create "" HAVE_LIBPTHREAD)
|
||||
IF("${HAVE_LIBPTHREAD}")
|
||||
IF(HAVE_LIBPTHREAD)
|
||||
SET(EXTRA_LIBS pthread ${EXTRA_LIBS})
|
||||
ENDIF()
|
||||
|
||||
CHECK_LIBRARY_EXISTS(rt clock_gettime "" HAVE_LIBRT)
|
||||
IF(HAVE_LIBRT)
|
||||
SET(EXTRA_LIBS rt ${EXTRA_LIBS})
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
|
||||
# Check for a 64-bit type
|
||||
CHECK_INCLUDE_FILE(stdint.h HAVE_STDINT_H)
|
||||
IF(NOT "${HAVE_STDINT_H}")
|
||||
IF("${HAVE_WINDOWS_H}")
|
||||
CHECK_C_SOURCE_COMPILES("\#include <windows.h>
|
||||
IF(NOT HAVE_STDINT_H)
|
||||
IF(HAVE_WINDOWS_H)
|
||||
CHECK_C_SOURCE_COMPILES("\#define _WIN32_WINNT 0x0500
|
||||
\#include <windows.h>
|
||||
__int64 foo;
|
||||
int main() {return 0;}" HAVE___INT64)
|
||||
ENDIF()
|
||||
IF(NOT "${HAVE___INT64}")
|
||||
IF(NOT "${SIZEOF_LONG}" MATCHES "8")
|
||||
IF(NOT "${SIZEOF_LONG_LONG}" MATCHES "8")
|
||||
IF(NOT HAVE___INT64)
|
||||
IF(NOT SIZEOF_LONG MATCHES "8")
|
||||
IF(NOT SIZEOF_LONG_LONG MATCHES "8")
|
||||
MESSAGE(FATAL_ERROR "No 64-bit types found, please report!")
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
@@ -160,19 +272,27 @@ IF(NOT "${HAVE_STDINT_H}")
|
||||
ENDIF()
|
||||
|
||||
|
||||
SET(OPENAL_OBJS OpenAL32/alBuffer.c
|
||||
SET(OPENAL_OBJS OpenAL32/alAuxEffectSlot.c
|
||||
OpenAL32/alBuffer.c
|
||||
OpenAL32/alDatabuffer.c
|
||||
OpenAL32/alEffect.c
|
||||
OpenAL32/alError.c
|
||||
OpenAL32/alExtension.c
|
||||
OpenAL32/alFilter.c
|
||||
OpenAL32/alListener.c
|
||||
OpenAL32/alSource.c
|
||||
OpenAL32/alState.c
|
||||
OpenAL32/alThunk.c
|
||||
OpenAL32/OpenAL32.c
|
||||
)
|
||||
SET(ALC_OBJS Alc/ALc.c
|
||||
Alc/ALu.c
|
||||
Alc/alcConfig.c
|
||||
Alc/alcEcho.c
|
||||
Alc/alcReverb.c
|
||||
Alc/alcRing.c
|
||||
Alc/alcThread.c
|
||||
Alc/bs2b.c
|
||||
Alc/wave.c
|
||||
)
|
||||
|
||||
SET(BACKENDS "")
|
||||
@@ -180,15 +300,15 @@ SET(BACKENDS "")
|
||||
# Check ALSA backend
|
||||
IF(ALSA)
|
||||
CHECK_INCLUDE_FILE(alsa/asoundlib.h HAVE_ALSA_ASOUNDLIB_H)
|
||||
IF("${HAVE_ALSA_ASOUNDLIB_H}")
|
||||
IF(HAVE_ALSA_ASOUNDLIB_H)
|
||||
CHECK_LIBRARY_EXISTS(asound snd_pcm_open "" HAVE_LIBASOUND)
|
||||
IF("${HAVE_DLFCN_H}" OR "${HAVE_LIBASOUND}")
|
||||
IF(HAVE_DLFCN_H OR HAVE_LIBASOUND)
|
||||
SET(HAVE_ALSA 1)
|
||||
SET(ALC_OBJS ${ALC_OBJS} Alc/alsa.c)
|
||||
IF("${HAVE_DLFCN_H}")
|
||||
SET(BACKENDS ${BACKENDS} ALSA)
|
||||
IF(HAVE_DLFCN_H)
|
||||
SET(BACKENDS "${BACKENDS} ALSA,")
|
||||
ELSE()
|
||||
SET(BACKENDS ${BACKENDS} ALSA\(linked\))
|
||||
SET(BACKENDS "${BACKENDS} ALSA \(linked\),")
|
||||
SET(EXTRA_LIBS asound ${EXTRA_LIBS})
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
@@ -198,79 +318,172 @@ ENDIF()
|
||||
# Check OSS backend
|
||||
IF(OSS)
|
||||
CHECK_INCLUDE_FILE(sys/soundcard.h HAVE_SYS_SOUNDCARD_H)
|
||||
IF("${HAVE_SYS_SOUNDCARD_H}")
|
||||
IF(HAVE_SYS_SOUNDCARD_H)
|
||||
SET(HAVE_OSS 1)
|
||||
SET(ALC_OBJS ${ALC_OBJS} Alc/oss.c)
|
||||
SET(BACKENDS ${BACKENDS} OSS)
|
||||
SET(BACKENDS "${BACKENDS} OSS,")
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
|
||||
# Check Solaris backend
|
||||
IF(SOLARIS)
|
||||
CHECK_INCLUDE_FILE(sys/audioio.h HAVE_SYS_AUDIOIO_H)
|
||||
IF(HAVE_SYS_AUDIOIO_H)
|
||||
SET(HAVE_SOLARIS 1)
|
||||
SET(ALC_OBJS ${ALC_OBJS} Alc/solaris.c)
|
||||
SET(BACKENDS "${BACKENDS} Solaris,")
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
|
||||
# Check DSound/MMSystem backend
|
||||
IF("${HAVE_WINDOWS_H}")
|
||||
SET(CMAKE_REQUIRED_LIBRARIES ole32)
|
||||
CHECK_C_SOURCE_COMPILES("int main() {return 0;}" HAVE_LIBOLE32)
|
||||
SET(CMAKE_REQUIRED_LIBRARIES "")
|
||||
# CHECK_LIBRARY_EXISTS(ole32 CoInitialize "" HAVE_LIBOLE32)
|
||||
IF("${HAVE_LIBOLE32}")
|
||||
SET(EXTRA_LIBS ole32 ${EXTRA_LIBS})
|
||||
ENDIF()
|
||||
|
||||
IF(DSOUND)
|
||||
CHECK_INCLUDE_FILE(dsound.h HAVE_DSOUND_H)
|
||||
IF("${HAVE_DSOUND_H}")
|
||||
IF(DSOUND)
|
||||
CHECK_INCLUDE_FILE(dsound.h HAVE_DSOUND_H)
|
||||
IF(HAVE_DSOUND_H)
|
||||
CHECK_LIBRARY_EXISTS(dsound DirectSoundCreate "" HAVE_LIBDSOUND)
|
||||
IF(HAVE_LIBDSOUND OR WIN32)
|
||||
SET(HAVE_DSOUND 1)
|
||||
SET(ALC_OBJS ${ALC_OBJS} Alc/dsound.c)
|
||||
SET(BACKENDS ${BACKENDS} DirectSound)
|
||||
|
||||
CHECK_LIBRARY_EXISTS(dxguid IID_IDirectSound "" HAVE_LIBDXGUID)
|
||||
IF("${HAVE_LIBDXGUID}")
|
||||
SET(EXTRA_LIBS dxguid ${EXTRA_LIBS})
|
||||
IF(WIN32)
|
||||
SET(BACKENDS "${BACKENDS} DirectSound,")
|
||||
ELSE()
|
||||
SET(BACKENDS "${BACKENDS} DirectSound \(linked\),")
|
||||
SET(EXTRA_LIBS dsound ${EXTRA_LIBS})
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
IF(HAVE_WINDOWS_H)
|
||||
IF(WINMM)
|
||||
CHECK_INCLUDE_FILES("windows.h;mmsystem.h" HAVE_MMSYSTEM_H)
|
||||
IF("${HAVE_MMSYSTEM_H}")
|
||||
CHECK_INCLUDE_FILES("windows.h;mmsystem.h" HAVE_MMSYSTEM_H -D_WIN32_WINNT=0x0500)
|
||||
IF(HAVE_MMSYSTEM_H)
|
||||
SET(HAVE_WINMM 1)
|
||||
SET(ALC_OBJS ${ALC_OBJS} Alc/winmm.c)
|
||||
SET(BACKENDS ${BACKENDS} WinMM)
|
||||
SET(BACKENDS "${BACKENDS} WinMM,")
|
||||
|
||||
SET(CMAKE_REQUIRED_LIBRARIES winmm)
|
||||
CHECK_C_SOURCE_COMPILES("int main() {return 0;}" HAVE_LIBWINMM)
|
||||
SET(CMAKE_REQUIRED_LIBRARIES "")
|
||||
# CHECK_LIBRARY_EXISTS(winmm waveInOpen "" HAVE_LIBWINMM)
|
||||
IF("${HAVE_LIBWINMM}")
|
||||
IF(HAVE_LIBWINMM)
|
||||
SET(EXTRA_LIBS winmm ${EXTRA_LIBS})
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
|
||||
# Check PortAudio backend
|
||||
IF(PORTAUDIO)
|
||||
CHECK_INCLUDE_FILE(portaudio.h HAVE_PORTAUDIO_H)
|
||||
IF(HAVE_PORTAUDIO_H)
|
||||
CHECK_LIBRARY_EXISTS(portaudio Pa_Initialize "" HAVE_LIBPORTAUDIO)
|
||||
IF(HAVE_LIBPORTAUDIO)
|
||||
SET(HAVE_PORTAUDIO 1)
|
||||
SET(ALC_OBJS ${ALC_OBJS} Alc/portaudio.c)
|
||||
IF(HAVE_DLFCN_H)
|
||||
SET(BACKENDS "${BACKENDS} PortAudio,")
|
||||
ELSE()
|
||||
SET(BACKENDS "${BACKENDS} PortAudio \(linked\),")
|
||||
SET(EXTRA_LIBS portaudio ${EXTRA_LIBS})
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
|
||||
# Check PortAudio backend
|
||||
IF(PULSEAUDIO)
|
||||
CHECK_INCLUDE_FILE(pulse/pulseaudio.h HAVE_PULSE_PULSEAUDIO_H)
|
||||
IF(HAVE_PULSE_PULSEAUDIO_H)
|
||||
CHECK_LIBRARY_EXISTS(pulse pa_context_new "" HAVE_LIBPULSE)
|
||||
IF(HAVE_LIBPULSE)
|
||||
SET(HAVE_PULSEAUDIO 1)
|
||||
SET(ALC_OBJS ${ALC_OBJS} Alc/pulseaudio.c)
|
||||
IF(HAVE_DLFCN_H)
|
||||
SET(BACKENDS "${BACKENDS} PulseAudio,")
|
||||
ELSE()
|
||||
SET(BACKENDS "${BACKENDS} PulseAudio \(linked\),")
|
||||
SET(EXTRA_LIBS pulse ${EXTRA_LIBS})
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
|
||||
# This is always available
|
||||
SET(BACKENDS "${BACKENDS} WaveFile")
|
||||
|
||||
# Needed for openal.pc.in
|
||||
SET(prefix ${CMAKE_INSTALL_PREFIX})
|
||||
SET(exec_prefix "\${prefix}")
|
||||
SET(libdir "\${exec_prefix}/${LIB_INSTALL_DIR}")
|
||||
SET(bindir "\${exec_prefix}/bin")
|
||||
SET(includedir "\${prefix}/include")
|
||||
SET(PACKAGE_VERSION "${LIB_VERSION}")
|
||||
|
||||
# End configuration
|
||||
CONFIGURE_FILE(
|
||||
"${OpenAL_SOURCE_DIR}/config.h.in"
|
||||
"${OpenAL_BINARY_DIR}/config.h")
|
||||
CONFIGURE_FILE(
|
||||
"${OpenAL_SOURCE_DIR}/admin/pkgconfig/openal.pc.in"
|
||||
"${OpenAL_BINARY_DIR}/admin/pkgconfig/openal.pc"
|
||||
@ONLY)
|
||||
|
||||
ADD_DEFINITIONS(-DAL_BUILD_LIBRARY)
|
||||
|
||||
# Build a shared library
|
||||
ADD_LIBRARY(${LIBNAME} SHARED ${OPENAL_OBJS} ${ALC_OBJS})
|
||||
SET_TARGET_PROPERTIES(${LIBNAME} PROPERTIES VERSION ${LIB_VERSION} SOVERSION ${LIB_MAJOR_VERSION})
|
||||
# Build a library
|
||||
IF(NOT LIBTYPE)
|
||||
SET(LIBTYPE SHARED)
|
||||
ENDIF()
|
||||
ADD_LIBRARY(${LIBNAME} ${LIBTYPE} ${OPENAL_OBJS} ${ALC_OBJS})
|
||||
SET_TARGET_PROPERTIES(${LIBNAME} PROPERTIES VERSION ${LIB_VERSION}
|
||||
SOVERSION ${LIB_MAJOR_VERSION})
|
||||
IF(WIN32)
|
||||
SET_TARGET_PROPERTIES(${LIBNAME} PROPERTIES PREFIX "")
|
||||
ENDIF()
|
||||
|
||||
TARGET_LINK_LIBRARIES(${LIBNAME} ${EXTRA_LIBS})
|
||||
|
||||
# Add an install target here
|
||||
INSTALL(TARGETS ${LIBNAME}
|
||||
RUNTIME DESTINATION bin
|
||||
LIBRARY DESTINATION lib
|
||||
ARCHIVE DESTINATION lib
|
||||
LIBRARY DESTINATION ${LIB_INSTALL_DIR}
|
||||
ARCHIVE DESTINATION ${LIB_INSTALL_DIR}
|
||||
)
|
||||
INSTALL(FILES include/AL/al.h
|
||||
include/AL/alc.h
|
||||
include/AL/alext.h
|
||||
DESTINATION include/AL
|
||||
)
|
||||
INSTALL(FILES "${OpenAL_BINARY_DIR}/admin/pkgconfig/openal.pc"
|
||||
DESTINATION "${LIB_INSTALL_DIR}/pkgconfig")
|
||||
|
||||
# Install alsoft.conf configuration file
|
||||
IF(ALSOFT_CONFIG)
|
||||
INSTALL(FILES alsoftrc.sample
|
||||
DESTINATION /etc/openal
|
||||
RENAME alsoft.conf
|
||||
)
|
||||
ENDIF()
|
||||
|
||||
IF(EXAMPLES)
|
||||
ADD_EXECUTABLE(openal-info examples/openal-info.c)
|
||||
TARGET_LINK_LIBRARIES(openal-info ${LIBNAME})
|
||||
INSTALL(TARGETS openal-info
|
||||
RUNTIME DESTINATION bin
|
||||
LIBRARY DESTINATION ${LIB_INSTALL_DIR}
|
||||
ARCHIVE DESTINATION ${LIB_INSTALL_DIR}
|
||||
)
|
||||
ENDIF()
|
||||
|
||||
MESSAGE(STATUS "")
|
||||
MESSAGE(STATUS "Building OpenAL with support for the following backends:")
|
||||
MESSAGE(STATUS " ${BACKENDS}")
|
||||
MESSAGE(STATUS "")
|
||||
|
||||
IF(WIN32)
|
||||
IF(NOT HAVE_DSOUND)
|
||||
MESSAGE(STATUS "WARNING: Building the Windows version without DirectSound output")
|
||||
MESSAGE(STATUS " This is probably NOT what you want!")
|
||||
MESSAGE(STATUS "")
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
#ifndef _AL_AUXEFFECTSLOT_H_
|
||||
#define _AL_AUXEFFECTSLOT_H_
|
||||
|
||||
#include "AL/al.h"
|
||||
#include "alEffect.h"
|
||||
#include "alFilter.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define AL_EFFECTSLOT_EFFECT 0x0001
|
||||
#define AL_EFFECTSLOT_GAIN 0x0002
|
||||
#define AL_EFFECTSLOT_AUXILIARY_SEND_AUTO 0x0003
|
||||
|
||||
#define AL_EFFECTSLOT_NULL 0x0000
|
||||
|
||||
typedef struct ALeffectState ALeffectState;
|
||||
|
||||
typedef struct ALeffectslot
|
||||
{
|
||||
ALeffect effect;
|
||||
|
||||
ALfloat Gain;
|
||||
ALboolean AuxSendAuto;
|
||||
|
||||
ALeffectState *EffectState;
|
||||
|
||||
ALfloat WetBuffer[BUFFERSIZE];
|
||||
|
||||
ALuint refcount;
|
||||
|
||||
// Index to itself
|
||||
ALuint effectslot;
|
||||
|
||||
struct ALeffectslot *next;
|
||||
} ALeffectslot;
|
||||
|
||||
ALvoid AL_APIENTRY alGenAuxiliaryEffectSlots(ALsizei n, ALuint *effectslots);
|
||||
ALvoid AL_APIENTRY alDeleteAuxiliaryEffectSlots(ALsizei n, ALuint *effectslots);
|
||||
ALboolean AL_APIENTRY alIsAuxiliaryEffectSlot(ALuint effectslot);
|
||||
|
||||
ALvoid AL_APIENTRY alAuxiliaryEffectSloti(ALuint effectslot, ALenum param, ALint iValue);
|
||||
ALvoid AL_APIENTRY alAuxiliaryEffectSlotiv(ALuint effectslot, ALenum param, ALint *piValues);
|
||||
ALvoid AL_APIENTRY alAuxiliaryEffectSlotf(ALuint effectslot, ALenum param, ALfloat flValue);
|
||||
ALvoid AL_APIENTRY alAuxiliaryEffectSlotfv(ALuint effectslot, ALenum param, ALfloat *pflValues);
|
||||
|
||||
ALvoid AL_APIENTRY alGetAuxiliaryEffectSloti(ALuint effectslot, ALenum param, ALint *piValue);
|
||||
ALvoid AL_APIENTRY alGetAuxiliaryEffectSlotiv(ALuint effectslot, ALenum param, ALint *piValues);
|
||||
ALvoid AL_APIENTRY alGetAuxiliaryEffectSlotf(ALuint effectslot, ALenum param, ALfloat *pflValue);
|
||||
ALvoid AL_APIENTRY alGetAuxiliaryEffectSlotfv(ALuint effectslot, ALenum param, ALfloat *pflValues);
|
||||
|
||||
ALvoid ReleaseALAuxiliaryEffectSlots(ALCcontext *Context);
|
||||
|
||||
|
||||
struct ALeffectState {
|
||||
ALvoid (*Destroy)(ALeffectState *State);
|
||||
ALboolean (*DeviceUpdate)(ALeffectState *State, ALCdevice *Device);
|
||||
ALvoid (*Update)(ALeffectState *State, ALCcontext *Context, const ALeffect *Effect);
|
||||
ALvoid (*Process)(ALeffectState *State, const ALeffectslot *Slot, ALuint SamplesToDo, const ALfloat *SamplesIn, ALfloat (*SamplesOut)[OUTPUTCHANNELS]);
|
||||
};
|
||||
|
||||
ALeffectState *NoneCreate(void);
|
||||
ALeffectState *EAXVerbCreate(void);
|
||||
ALeffectState *VerbCreate(void);
|
||||
ALeffectState *EchoCreate(void);
|
||||
|
||||
#define ALEffect_Destroy(a) ((a)->Destroy((a)))
|
||||
#define ALEffect_DeviceUpdate(a,b) ((a)->DeviceUpdate((a),(b)))
|
||||
#define ALEffect_Update(a,b,c) ((a)->Update((a),(b),(c)))
|
||||
#define ALEffect_Process(a,b,c,d,e) ((a)->Process((a),(b),(c),(d),(e)))
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -7,23 +7,28 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define UNUSED 0
|
||||
#define PENDING 1
|
||||
#define PROCESSED 2
|
||||
#define BUFFER_PADDING 2
|
||||
|
||||
typedef struct ALbuffer_struct
|
||||
typedef struct ALbuffer
|
||||
{
|
||||
ALenum format;
|
||||
ALenum eOriginalFormat;
|
||||
ALshort *data;
|
||||
ALsizei size;
|
||||
|
||||
ALenum format;
|
||||
ALenum eOriginalFormat;
|
||||
ALsizei frequency;
|
||||
ALenum state;
|
||||
|
||||
ALuint refcount; // Number of sources using this buffer (deletion can only occur when this is 0)
|
||||
struct ALbuffer_struct *next;
|
||||
|
||||
// Index to itself
|
||||
ALuint buffer;
|
||||
|
||||
struct ALbuffer *next;
|
||||
} ALbuffer;
|
||||
|
||||
ALvoid ReleaseALBuffers(ALvoid);
|
||||
ALvoid ALAPIENTRY alBufferSubDataEXT(ALuint buffer,ALenum format,const ALvoid *data,ALsizei offset,ALsizei length);
|
||||
|
||||
ALvoid ReleaseALBuffers(ALCdevice *device);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
#ifndef _AL_DATABUFFER_H_
|
||||
#define _AL_DATABUFFER_H_
|
||||
|
||||
#include "AL/al.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define UNMAPPED 0
|
||||
#define MAPPED 1
|
||||
|
||||
typedef struct ALdatabuffer
|
||||
{
|
||||
ALubyte *data;
|
||||
ALuint size;
|
||||
ALenum state;
|
||||
|
||||
ALenum usage;
|
||||
|
||||
/* Index to self */
|
||||
ALuint databuffer;
|
||||
|
||||
struct ALdatabuffer *next;
|
||||
} ALdatabuffer;
|
||||
|
||||
ALvoid ALAPIENTRY alGenDatabuffersEXT(ALsizei n,ALuint *puiBuffers);
|
||||
ALvoid ALAPIENTRY alDeleteDatabuffersEXT(ALsizei n, const ALuint *puiBuffers);
|
||||
ALboolean ALAPIENTRY alIsDatabufferEXT(ALuint uiBuffer);
|
||||
|
||||
ALvoid ALAPIENTRY alDatabufferDataEXT(ALuint buffer,const ALvoid *data,ALsizei size,ALenum usage);
|
||||
ALvoid ALAPIENTRY alDatabufferSubDataEXT(ALuint buffer, ALuint start, ALsizei length, const ALvoid *data);
|
||||
ALvoid ALAPIENTRY alGetDatabufferSubDataEXT(ALuint buffer, ALuint start, ALsizei length, ALvoid *data);
|
||||
|
||||
ALvoid ALAPIENTRY alDatabufferfEXT(ALuint buffer, ALenum eParam, ALfloat flValue);
|
||||
ALvoid ALAPIENTRY alDatabufferfvEXT(ALuint buffer, ALenum eParam, const ALfloat* flValues);
|
||||
ALvoid ALAPIENTRY alDatabufferiEXT(ALuint buffer, ALenum eParam, ALint lValue);
|
||||
ALvoid ALAPIENTRY alDatabufferivEXT(ALuint buffer, ALenum eParam, const ALint* plValues);
|
||||
ALvoid ALAPIENTRY alGetDatabufferfEXT(ALuint buffer, ALenum eParam, ALfloat *pflValue);
|
||||
ALvoid ALAPIENTRY alGetDatabufferfvEXT(ALuint buffer, ALenum eParam, ALfloat* pflValues);
|
||||
ALvoid ALAPIENTRY alGetDatabufferiEXT(ALuint buffer, ALenum eParam, ALint *plValue);
|
||||
ALvoid ALAPIENTRY alGetDatabufferivEXT(ALuint buffer, ALenum eParam, ALint* plValues);
|
||||
|
||||
ALvoid ALAPIENTRY alSelectDatabufferEXT(ALenum target, ALuint uiBuffer);
|
||||
|
||||
ALvoid* ALAPIENTRY alMapDatabufferEXT(ALuint uiBuffer, ALuint start, ALsizei length, ALenum access);
|
||||
ALvoid ALAPIENTRY alUnmapDatabufferEXT(ALuint uiBuffer);
|
||||
|
||||
ALvoid ReleaseALDatabuffers(ALCdevice *device);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,274 @@
|
||||
// NOTE: The effect structure is getting too large, it may be a good idea to
|
||||
// start using a union or another form of unified storage.
|
||||
#ifndef _AL_EFFECT_H_
|
||||
#define _AL_EFFECT_H_
|
||||
|
||||
#include "AL/al.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define AL_EFFECT_TYPE 0x8001
|
||||
|
||||
#define AL_EFFECT_NULL 0x0000
|
||||
#define AL_EFFECT_REVERB 0x0001
|
||||
#define AL_EFFECT_CHORUS 0x0002
|
||||
#define AL_EFFECT_DISTORTION 0x0003
|
||||
#define AL_EFFECT_ECHO 0x0004
|
||||
#define AL_EFFECT_FLANGER 0x0005
|
||||
#define AL_EFFECT_FREQUENCY_SHIFTER 0x0006
|
||||
#define AL_EFFECT_VOCAL_MORPHER 0x0007
|
||||
#define AL_EFFECT_PITCH_SHIFTER 0x0008
|
||||
#define AL_EFFECT_RING_MODULATOR 0x0009
|
||||
#define AL_EFFECT_AUTOWAH 0x000A
|
||||
#define AL_EFFECT_COMPRESSOR 0x000B
|
||||
#define AL_EFFECT_EQUALIZER 0x000C
|
||||
#define AL_EFFECT_EAXREVERB 0x8000
|
||||
|
||||
#define AL_REVERB_DENSITY 0x0001
|
||||
#define AL_REVERB_DIFFUSION 0x0002
|
||||
#define AL_REVERB_GAIN 0x0003
|
||||
#define AL_REVERB_GAINHF 0x0004
|
||||
#define AL_REVERB_DECAY_TIME 0x0005
|
||||
#define AL_REVERB_DECAY_HFRATIO 0x0006
|
||||
#define AL_REVERB_REFLECTIONS_GAIN 0x0007
|
||||
#define AL_REVERB_REFLECTIONS_DELAY 0x0008
|
||||
#define AL_REVERB_LATE_REVERB_GAIN 0x0009
|
||||
#define AL_REVERB_LATE_REVERB_DELAY 0x000A
|
||||
#define AL_REVERB_AIR_ABSORPTION_GAINHF 0x000B
|
||||
#define AL_REVERB_ROOM_ROLLOFF_FACTOR 0x000C
|
||||
#define AL_REVERB_DECAY_HFLIMIT 0x000D
|
||||
|
||||
#define AL_REVERB_MIN_DENSITY (0.0f)
|
||||
#define AL_REVERB_MAX_DENSITY (1.0f)
|
||||
#define AL_REVERB_DEFAULT_DENSITY (1.0f)
|
||||
#define AL_REVERB_MIN_DIFFUSION (0.0f)
|
||||
#define AL_REVERB_MAX_DIFFUSION (1.0f)
|
||||
#define AL_REVERB_DEFAULT_DIFFUSION (1.0f)
|
||||
#define AL_REVERB_MIN_GAIN (0.0f)
|
||||
#define AL_REVERB_MAX_GAIN (1.0f)
|
||||
#define AL_REVERB_DEFAULT_GAIN (0.32f)
|
||||
#define AL_REVERB_MIN_GAINHF (0.0f)
|
||||
#define AL_REVERB_MAX_GAINHF (1.0f)
|
||||
#define AL_REVERB_DEFAULT_GAINHF (0.89f)
|
||||
#define AL_REVERB_MIN_DECAY_TIME (0.1f)
|
||||
#define AL_REVERB_MAX_DECAY_TIME (20.0f)
|
||||
#define AL_REVERB_DEFAULT_DECAY_TIME (1.49f)
|
||||
#define AL_REVERB_MIN_DECAY_HFRATIO (0.1f)
|
||||
#define AL_REVERB_MAX_DECAY_HFRATIO (2.0f)
|
||||
#define AL_REVERB_DEFAULT_DECAY_HFRATIO (0.83f)
|
||||
#define AL_REVERB_MIN_REFLECTIONS_GAIN (0.0f)
|
||||
#define AL_REVERB_MAX_REFLECTIONS_GAIN (3.16f)
|
||||
#define AL_REVERB_DEFAULT_REFLECTIONS_GAIN (0.05f)
|
||||
#define AL_REVERB_MIN_REFLECTIONS_DELAY (0.0f)
|
||||
#define AL_REVERB_MAX_REFLECTIONS_DELAY (0.3f)
|
||||
#define AL_REVERB_DEFAULT_REFLECTIONS_DELAY (0.007f)
|
||||
#define AL_REVERB_MIN_LATE_REVERB_GAIN (0.0f)
|
||||
#define AL_REVERB_MAX_LATE_REVERB_GAIN (10.0f)
|
||||
#define AL_REVERB_DEFAULT_LATE_REVERB_GAIN (1.26f)
|
||||
#define AL_REVERB_MIN_LATE_REVERB_DELAY (0.0f)
|
||||
#define AL_REVERB_MAX_LATE_REVERB_DELAY (0.1f)
|
||||
#define AL_REVERB_DEFAULT_LATE_REVERB_DELAY (0.011f)
|
||||
#define AL_REVERB_MIN_AIR_ABSORPTION_GAINHF (0.892f)
|
||||
#define AL_REVERB_MAX_AIR_ABSORPTION_GAINHF (1.0f)
|
||||
#define AL_REVERB_DEFAULT_AIR_ABSORPTION_GAINHF (0.994f)
|
||||
#define AL_REVERB_MIN_ROOM_ROLLOFF_FACTOR (0.0f)
|
||||
#define AL_REVERB_MAX_ROOM_ROLLOFF_FACTOR (10.0f)
|
||||
#define AL_REVERB_DEFAULT_ROOM_ROLLOFF_FACTOR (0.0f)
|
||||
#define AL_REVERB_MIN_DECAY_HFLIMIT (AL_FALSE)
|
||||
#define AL_REVERB_MAX_DECAY_HFLIMIT (AL_TRUE)
|
||||
#define AL_REVERB_DEFAULT_DECAY_HFLIMIT (AL_TRUE)
|
||||
|
||||
#define AL_ECHO_DELAY 0x0001
|
||||
#define AL_ECHO_LRDELAY 0x0002
|
||||
#define AL_ECHO_DAMPING 0x0003
|
||||
#define AL_ECHO_FEEDBACK 0x0004
|
||||
#define AL_ECHO_SPREAD 0x0005
|
||||
|
||||
#define AL_ECHO_MIN_DELAY (0.0f)
|
||||
#define AL_ECHO_MAX_DELAY (0.207f)
|
||||
#define AL_ECHO_DEFAULT_DELAY (0.1f)
|
||||
#define AL_ECHO_MIN_LRDELAY (0.0f)
|
||||
#define AL_ECHO_MAX_LRDELAY (0.404f)
|
||||
#define AL_ECHO_DEFAULT_LRDELAY (0.1f)
|
||||
#define AL_ECHO_MIN_DAMPING (0.0f)
|
||||
#define AL_ECHO_MAX_DAMPING (0.99f)
|
||||
#define AL_ECHO_DEFAULT_DAMPING (0.5f)
|
||||
#define AL_ECHO_MIN_FEEDBACK (0.0f)
|
||||
#define AL_ECHO_MAX_FEEDBACK (1.0f)
|
||||
#define AL_ECHO_DEFAULT_FEEDBACK (0.5f)
|
||||
#define AL_ECHO_MIN_SPREAD (-1.0f)
|
||||
#define AL_ECHO_MAX_SPREAD (1.0f)
|
||||
#define AL_ECHO_DEFAULT_SPREAD (-1.0f)
|
||||
|
||||
#define AL_EAXREVERB_DENSITY 0x0001
|
||||
#define AL_EAXREVERB_DIFFUSION 0x0002
|
||||
#define AL_EAXREVERB_GAIN 0x0003
|
||||
#define AL_EAXREVERB_GAINHF 0x0004
|
||||
#define AL_EAXREVERB_GAINLF 0x0005
|
||||
#define AL_EAXREVERB_DECAY_TIME 0x0006
|
||||
#define AL_EAXREVERB_DECAY_HFRATIO 0x0007
|
||||
#define AL_EAXREVERB_DECAY_LFRATIO 0x0008
|
||||
#define AL_EAXREVERB_REFLECTIONS_GAIN 0x0009
|
||||
#define AL_EAXREVERB_REFLECTIONS_DELAY 0x000A
|
||||
#define AL_EAXREVERB_REFLECTIONS_PAN 0x000B
|
||||
#define AL_EAXREVERB_LATE_REVERB_GAIN 0x000C
|
||||
#define AL_EAXREVERB_LATE_REVERB_DELAY 0x000D
|
||||
#define AL_EAXREVERB_LATE_REVERB_PAN 0x000E
|
||||
#define AL_EAXREVERB_ECHO_TIME 0x000F
|
||||
#define AL_EAXREVERB_ECHO_DEPTH 0x0010
|
||||
#define AL_EAXREVERB_MODULATION_TIME 0x0011
|
||||
#define AL_EAXREVERB_MODULATION_DEPTH 0x0012
|
||||
#define AL_EAXREVERB_AIR_ABSORPTION_GAINHF 0x0013
|
||||
#define AL_EAXREVERB_HFREFERENCE 0x0014
|
||||
#define AL_EAXREVERB_LFREFERENCE 0x0015
|
||||
#define AL_EAXREVERB_ROOM_ROLLOFF_FACTOR 0x0016
|
||||
#define AL_EAXREVERB_DECAY_HFLIMIT 0x0017
|
||||
|
||||
#define AL_EAXREVERB_MIN_DENSITY (0.0f)
|
||||
#define AL_EAXREVERB_MAX_DENSITY (1.0f)
|
||||
#define AL_EAXREVERB_DEFAULT_DENSITY (1.0f)
|
||||
#define AL_EAXREVERB_MIN_DIFFUSION (0.0f)
|
||||
#define AL_EAXREVERB_MAX_DIFFUSION (1.0f)
|
||||
#define AL_EAXREVERB_DEFAULT_DIFFUSION (1.0f)
|
||||
#define AL_EAXREVERB_MIN_GAIN (0.0f)
|
||||
#define AL_EAXREVERB_MAX_GAIN (1.0f)
|
||||
#define AL_EAXREVERB_DEFAULT_GAIN (0.32f)
|
||||
#define AL_EAXREVERB_MIN_GAINHF (0.0f)
|
||||
#define AL_EAXREVERB_MAX_GAINHF (1.0f)
|
||||
#define AL_EAXREVERB_DEFAULT_GAINHF (0.89f)
|
||||
#define AL_EAXREVERB_MIN_GAINLF (0.0f)
|
||||
#define AL_EAXREVERB_MAX_GAINLF (1.0f)
|
||||
#define AL_EAXREVERB_DEFAULT_GAINLF (1.0f)
|
||||
#define AL_EAXREVERB_MIN_DECAY_TIME (0.1f)
|
||||
#define AL_EAXREVERB_MAX_DECAY_TIME (20.0f)
|
||||
#define AL_EAXREVERB_DEFAULT_DECAY_TIME (1.49f)
|
||||
#define AL_EAXREVERB_MIN_DECAY_HFRATIO (0.1f)
|
||||
#define AL_EAXREVERB_MAX_DECAY_HFRATIO (2.0f)
|
||||
#define AL_EAXREVERB_DEFAULT_DECAY_HFRATIO (0.83f)
|
||||
#define AL_EAXREVERB_MIN_DECAY_LFRATIO (0.1f)
|
||||
#define AL_EAXREVERB_MAX_DECAY_LFRATIO (2.0f)
|
||||
#define AL_EAXREVERB_DEFAULT_DECAY_LFRATIO (1.0f)
|
||||
#define AL_EAXREVERB_MIN_REFLECTIONS_GAIN (0.0f)
|
||||
#define AL_EAXREVERB_MAX_REFLECTIONS_GAIN (3.16f)
|
||||
#define AL_EAXREVERB_DEFAULT_REFLECTIONS_GAIN (0.05f)
|
||||
#define AL_EAXREVERB_MIN_REFLECTIONS_DELAY (0.0f)
|
||||
#define AL_EAXREVERB_MAX_REFLECTIONS_DELAY (0.3f)
|
||||
#define AL_EAXREVERB_DEFAULT_REFLECTIONS_DELAY (0.007f)
|
||||
#define AL_EAXREVERB_DEFAULT_REFLECTIONS_PAN_XYZ (0.0f)
|
||||
#define AL_EAXREVERB_MIN_LATE_REVERB_GAIN (0.0f)
|
||||
#define AL_EAXREVERB_MAX_LATE_REVERB_GAIN (10.0f)
|
||||
#define AL_EAXREVERB_DEFAULT_LATE_REVERB_GAIN (1.26f)
|
||||
#define AL_EAXREVERB_MIN_LATE_REVERB_DELAY (0.0f)
|
||||
#define AL_EAXREVERB_MAX_LATE_REVERB_DELAY (0.1f)
|
||||
#define AL_EAXREVERB_DEFAULT_LATE_REVERB_DELAY (0.011f)
|
||||
#define AL_EAXREVERB_DEFAULT_LATE_REVERB_PAN_XYZ (0.0f)
|
||||
#define AL_EAXREVERB_MIN_ECHO_TIME (0.075f)
|
||||
#define AL_EAXREVERB_MAX_ECHO_TIME (0.25f)
|
||||
#define AL_EAXREVERB_DEFAULT_ECHO_TIME (0.25f)
|
||||
#define AL_EAXREVERB_MIN_ECHO_DEPTH (0.0f)
|
||||
#define AL_EAXREVERB_MAX_ECHO_DEPTH (1.0f)
|
||||
#define AL_EAXREVERB_DEFAULT_ECHO_DEPTH (0.0f)
|
||||
#define AL_EAXREVERB_MIN_MODULATION_TIME (0.04f)
|
||||
#define AL_EAXREVERB_MAX_MODULATION_TIME (4.0f)
|
||||
#define AL_EAXREVERB_DEFAULT_MODULATION_TIME (0.25f)
|
||||
#define AL_EAXREVERB_MIN_MODULATION_DEPTH (0.0f)
|
||||
#define AL_EAXREVERB_MAX_MODULATION_DEPTH (1.0f)
|
||||
#define AL_EAXREVERB_DEFAULT_MODULATION_DEPTH (0.0f)
|
||||
#define AL_EAXREVERB_MIN_AIR_ABSORPTION_GAINHF (0.892f)
|
||||
#define AL_EAXREVERB_MAX_AIR_ABSORPTION_GAINHF (1.0f)
|
||||
#define AL_EAXREVERB_DEFAULT_AIR_ABSORPTION_GAINHF (0.994f)
|
||||
#define AL_EAXREVERB_MIN_HFREFERENCE (1000.0f)
|
||||
#define AL_EAXREVERB_MAX_HFREFERENCE (20000.0f)
|
||||
#define AL_EAXREVERB_DEFAULT_HFREFERENCE (5000.0f)
|
||||
#define AL_EAXREVERB_MIN_LFREFERENCE (20.0f)
|
||||
#define AL_EAXREVERB_MAX_LFREFERENCE (1000.0f)
|
||||
#define AL_EAXREVERB_DEFAULT_LFREFERENCE (250.0f)
|
||||
#define AL_EAXREVERB_MIN_ROOM_ROLLOFF_FACTOR (0.0f)
|
||||
#define AL_EAXREVERB_MAX_ROOM_ROLLOFF_FACTOR (10.0f)
|
||||
#define AL_EAXREVERB_DEFAULT_ROOM_ROLLOFF_FACTOR (0.0f)
|
||||
#define AL_EAXREVERB_MIN_DECAY_HFLIMIT (AL_FALSE)
|
||||
#define AL_EAXREVERB_MAX_DECAY_HFLIMIT (AL_TRUE)
|
||||
#define AL_EAXREVERB_DEFAULT_DECAY_HFLIMIT (AL_TRUE)
|
||||
|
||||
enum {
|
||||
EAXREVERB = 0,
|
||||
REVERB,
|
||||
ECHO,
|
||||
|
||||
MAX_EFFECTS
|
||||
};
|
||||
extern ALboolean DisabledEffects[MAX_EFFECTS];
|
||||
|
||||
typedef struct ALeffect
|
||||
{
|
||||
// Effect type (AL_EFFECT_NULL, ...)
|
||||
ALenum type;
|
||||
|
||||
struct {
|
||||
// Shared Reverb Properties
|
||||
ALfloat Density;
|
||||
ALfloat Diffusion;
|
||||
ALfloat Gain;
|
||||
ALfloat GainHF;
|
||||
ALfloat DecayTime;
|
||||
ALfloat DecayHFRatio;
|
||||
ALfloat ReflectionsGain;
|
||||
ALfloat ReflectionsDelay;
|
||||
ALfloat LateReverbGain;
|
||||
ALfloat LateReverbDelay;
|
||||
ALfloat AirAbsorptionGainHF;
|
||||
ALfloat RoomRolloffFactor;
|
||||
ALboolean DecayHFLimit;
|
||||
|
||||
// Additional EAX Reverb Properties
|
||||
ALfloat GainLF;
|
||||
ALfloat DecayLFRatio;
|
||||
ALfloat ReflectionsPan[3];
|
||||
ALfloat LateReverbPan[3];
|
||||
ALfloat EchoTime;
|
||||
ALfloat EchoDepth;
|
||||
ALfloat ModulationTime;
|
||||
ALfloat ModulationDepth;
|
||||
ALfloat HFReference;
|
||||
ALfloat LFReference;
|
||||
} Reverb;
|
||||
|
||||
struct {
|
||||
ALfloat Delay;
|
||||
ALfloat LRDelay;
|
||||
|
||||
ALfloat Damping;
|
||||
ALfloat Feedback;
|
||||
|
||||
ALfloat Spread;
|
||||
} Echo;
|
||||
|
||||
// Index to itself
|
||||
ALuint effect;
|
||||
|
||||
struct ALeffect *next;
|
||||
} ALeffect;
|
||||
|
||||
ALvoid AL_APIENTRY alGenEffects(ALsizei n, ALuint *effects);
|
||||
ALvoid AL_APIENTRY alDeleteEffects(ALsizei n, ALuint *effects);
|
||||
ALboolean AL_APIENTRY alIsEffect(ALuint effect);
|
||||
|
||||
ALvoid AL_APIENTRY alEffecti(ALuint effect, ALenum param, ALint iValue);
|
||||
ALvoid AL_APIENTRY alEffectiv(ALuint effect, ALenum param, ALint *piValues);
|
||||
ALvoid AL_APIENTRY alEffectf(ALuint effect, ALenum param, ALfloat flValue);
|
||||
ALvoid AL_APIENTRY alEffectfv(ALuint effect, ALenum param, ALfloat *pflValues);
|
||||
|
||||
ALvoid AL_APIENTRY alGetEffecti(ALuint effect, ALenum param, ALint *piValue);
|
||||
ALvoid AL_APIENTRY alGetEffectiv(ALuint effect, ALenum param, ALint *piValues);
|
||||
ALvoid AL_APIENTRY alGetEffectf(ALuint effect, ALenum param, ALfloat *pflValue);
|
||||
ALvoid AL_APIENTRY alGetEffectfv(ALuint effect, ALenum param, ALfloat *pflValues);
|
||||
|
||||
ALvoid ReleaseALEffects(ALCdevice *device);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,98 @@
|
||||
#ifndef _AL_FILTER_H_
|
||||
#define _AL_FILTER_H_
|
||||
|
||||
#include "AL/al.h"
|
||||
#include "alu.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
ALfloat coeff;
|
||||
#ifndef _MSC_VER
|
||||
ALfloat history[0];
|
||||
#else
|
||||
ALfloat history[1];
|
||||
#endif
|
||||
} FILTER;
|
||||
|
||||
static __inline ALfloat lpFilter4P(FILTER *iir, ALuint offset, ALfloat input)
|
||||
{
|
||||
ALfloat *history = &iir->history[offset];
|
||||
ALfloat a = iir->coeff;
|
||||
ALfloat output = input;
|
||||
|
||||
output = output + (history[0]-output)*a;
|
||||
history[0] = output;
|
||||
output = output + (history[1]-output)*a;
|
||||
history[1] = output;
|
||||
output = output + (history[2]-output)*a;
|
||||
history[2] = output;
|
||||
output = output + (history[3]-output)*a;
|
||||
history[3] = output;
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
static __inline ALfloat lpFilter2P(FILTER *iir, ALuint offset, ALfloat input)
|
||||
{
|
||||
ALfloat *history = &iir->history[offset];
|
||||
ALfloat a = iir->coeff;
|
||||
ALfloat output = input;
|
||||
|
||||
output = output + (history[0]-output)*a;
|
||||
history[0] = output;
|
||||
output = output + (history[1]-output)*a;
|
||||
history[1] = output;
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
|
||||
#define AL_FILTER_TYPE 0x8001
|
||||
|
||||
#define AL_FILTER_NULL 0x0000
|
||||
#define AL_FILTER_LOWPASS 0x0001
|
||||
#define AL_FILTER_HIGHPASS 0x0002
|
||||
#define AL_FILTER_BANDPASS 0x0003
|
||||
|
||||
#define AL_LOWPASS_GAIN 0x0001
|
||||
#define AL_LOWPASS_GAINHF 0x0002
|
||||
|
||||
|
||||
typedef struct ALfilter
|
||||
{
|
||||
// Filter type (AL_FILTER_NULL, ...)
|
||||
ALenum type;
|
||||
|
||||
ALfloat Gain;
|
||||
ALfloat GainHF;
|
||||
|
||||
// Index to itself
|
||||
ALuint filter;
|
||||
|
||||
struct ALfilter *next;
|
||||
} ALfilter;
|
||||
|
||||
ALvoid AL_APIENTRY alGenFilters(ALsizei n, ALuint *filters);
|
||||
ALvoid AL_APIENTRY alDeleteFilters(ALsizei n, ALuint *filters);
|
||||
ALboolean AL_APIENTRY alIsFilter(ALuint filter);
|
||||
|
||||
ALvoid AL_APIENTRY alFilteri(ALuint filter, ALenum param, ALint iValue);
|
||||
ALvoid AL_APIENTRY alFilteriv(ALuint filter, ALenum param, ALint *piValues);
|
||||
ALvoid AL_APIENTRY alFilterf(ALuint filter, ALenum param, ALfloat flValue);
|
||||
ALvoid AL_APIENTRY alFilterfv(ALuint filter, ALenum param, ALfloat *pflValues);
|
||||
|
||||
ALvoid AL_APIENTRY alGetFilteri(ALuint filter, ALenum param, ALint *piValue);
|
||||
ALvoid AL_APIENTRY alGetFilteriv(ALuint filter, ALenum param, ALint *piValues);
|
||||
ALvoid AL_APIENTRY alGetFilterf(ALuint filter, ALenum param, ALfloat *pflValue);
|
||||
ALvoid AL_APIENTRY alGetFilterfv(ALuint filter, ALenum param, ALfloat *pflValues);
|
||||
|
||||
ALvoid ReleaseALFilters(ALCdevice *device);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -7,6 +7,8 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define AL_METERS_PER_UNIT 0x20004
|
||||
|
||||
typedef struct ALlistener_struct
|
||||
{
|
||||
ALfloat Position[3];
|
||||
@@ -14,6 +16,7 @@ typedef struct ALlistener_struct
|
||||
ALfloat Forward[3];
|
||||
ALfloat Up[3];
|
||||
ALfloat Gain;
|
||||
ALfloat MetersPerUnit;
|
||||
} ALlistener;
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
+200
-50
@@ -1,24 +1,51 @@
|
||||
#ifndef AL_MAIN_H
|
||||
#define AL_MAIN_H
|
||||
|
||||
#define AL_MAX_CHANNELS 4
|
||||
#define AL_MAX_SOURCES 32
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "alu.h"
|
||||
#ifdef HAVE_FENV_H
|
||||
#include <fenv.h>
|
||||
#endif
|
||||
|
||||
#include "AL/al.h"
|
||||
#include "AL/alc.h"
|
||||
#include "AL/alext.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
#ifndef _WIN32_WINNT
|
||||
#define _WIN32_WINNT 0x0500
|
||||
#endif
|
||||
#include <windows.h>
|
||||
//#define strcasecmp _stricmp
|
||||
|
||||
typedef DWORD tls_type;
|
||||
#define tls_create(x) (*(x) = TlsAlloc())
|
||||
#define tls_delete(x) TlsFree((x))
|
||||
#define tls_get(x) TlsGetValue((x))
|
||||
#define tls_set(x, a) TlsSetValue((x), (a))
|
||||
|
||||
#else
|
||||
|
||||
#include <unistd.h>
|
||||
#include <assert.h>
|
||||
#include <pthread.h>
|
||||
#ifdef HAVE_PTHREAD_NP_H
|
||||
#include <pthread_np.h>
|
||||
#endif
|
||||
#include <sys/time.h>
|
||||
#include <time.h>
|
||||
#include <errno.h>
|
||||
|
||||
#define IsBadWritePtr(a,b) (0)
|
||||
|
||||
typedef pthread_key_t tls_type;
|
||||
#define tls_create(x) pthread_key_create((x), NULL)
|
||||
#define tls_delete(x) pthread_key_delete((x))
|
||||
#define tls_get(x) pthread_getspecific((x))
|
||||
#define tls_set(x, a) pthread_setspecific((x), (a))
|
||||
|
||||
typedef pthread_mutex_t CRITICAL_SECTION;
|
||||
static inline void EnterCriticalSection(CRITICAL_SECTION *cs)
|
||||
{
|
||||
@@ -41,6 +68,10 @@ static inline void InitializeCriticalSection(CRITICAL_SECTION *cs)
|
||||
assert(ret == 0);
|
||||
|
||||
ret = pthread_mutexattr_settype(&attrib, PTHREAD_MUTEX_RECURSIVE);
|
||||
#ifdef HAVE_PTHREAD_NP_H
|
||||
if(ret != 0)
|
||||
ret = pthread_mutexattr_setkind_np(&attrib, PTHREAD_MUTEX_RECURSIVE);
|
||||
#endif
|
||||
assert(ret == 0);
|
||||
ret = pthread_mutex_init(cs, &attrib);
|
||||
assert(ret == 0);
|
||||
@@ -55,55 +86,94 @@ static inline void DeleteCriticalSection(CRITICAL_SECTION *cs)
|
||||
assert(ret == 0);
|
||||
}
|
||||
|
||||
/* NOTE: This wrapper isn't quite accurate as it returns an ALuint, as opposed
|
||||
* to the expected DWORD. Both are defined as unsigned 32-bit types, however.
|
||||
* Additionally, Win32 is supposed to measure the time since Windows started,
|
||||
* as opposed to the actual time. */
|
||||
static inline ALuint timeGetTime(void)
|
||||
{
|
||||
int ret;
|
||||
#ifdef _POSIX_TIMERS
|
||||
struct timespec ts;
|
||||
|
||||
ret = clock_gettime(CLOCK_REALTIME, &ts);
|
||||
assert(ret == 0);
|
||||
|
||||
return ts.tv_nsec/1000000 + ts.tv_sec*1000;
|
||||
#else
|
||||
struct timeval tv;
|
||||
|
||||
ret = gettimeofday(&tv, NULL);
|
||||
assert(ret == 0);
|
||||
|
||||
return tv.tv_usec/1000 + tv.tv_sec*1000;
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline void Sleep(ALuint t)
|
||||
{
|
||||
struct timespec tv, rem;
|
||||
tv.tv_nsec = (t*1000000)%1000000000;
|
||||
tv.tv_sec = t/1000;
|
||||
|
||||
while(nanosleep(&tv, &rem) == -1 && errno == EINTR)
|
||||
tv = rem;
|
||||
}
|
||||
#define min(x,y) (((x)<(y))?(x):(y))
|
||||
#define max(x,y) (((x)>(y))?(x):(y))
|
||||
#endif
|
||||
|
||||
#include "alBuffer.h"
|
||||
#include "alError.h"
|
||||
#include "alExtension.h"
|
||||
#include "alListener.h"
|
||||
#include "alSource.h"
|
||||
#include "alState.h"
|
||||
#include "alThunk.h"
|
||||
#include "alu.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern CRITICAL_SECTION g_mutex;
|
||||
static __inline void al_print(const char *fname, unsigned int line, const char *fmt, ...)
|
||||
{
|
||||
const char *fn;
|
||||
char str[256];
|
||||
int i;
|
||||
|
||||
extern char szDebug[256];
|
||||
fn = strrchr(fname, '/');
|
||||
if(!fn) fn = strrchr(fname, '\\');;
|
||||
if(!fn) fn = fname;
|
||||
else fn += 1;
|
||||
|
||||
#define AL_PRINT(...) do { \
|
||||
int _al_print_i; \
|
||||
char *_al_print_fn = strrchr(__FILE__, '/'); \
|
||||
if(!_al_print_fn) _al_print_fn = __FILE__; \
|
||||
else _al_print_fn += 1; \
|
||||
_al_print_i = snprintf(szDebug, sizeof(szDebug), "AL lib: %s:%d: ", _al_print_fn, __LINE__); \
|
||||
snprintf(szDebug+_al_print_i, sizeof(szDebug)-_al_print_i, __VA_ARGS__); \
|
||||
fprintf(stderr, "%s", szDebug); \
|
||||
} while(0)
|
||||
i = snprintf(str, sizeof(str), "AL lib: %s:%d: ", fn, line);
|
||||
if(i < (int)sizeof(str) && i > 0)
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
vsnprintf(str+i, sizeof(str)-i, fmt, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
str[sizeof(str)-1] = 0;
|
||||
|
||||
fprintf(stderr, "%s", str);
|
||||
}
|
||||
#define AL_PRINT(...) al_print(__FILE__, __LINE__, __VA_ARGS__)
|
||||
|
||||
#define AL_FORMAT_MONO_IMA4 0x1300
|
||||
#define AL_FORMAT_STEREO_IMA4 0x1301
|
||||
// These are from AL_EXT_MCFORMATS, which we don't support yet but the mixer
|
||||
// can use 4-channel formats
|
||||
#define AL_FORMAT_QUAD8 0x1204
|
||||
#define AL_FORMAT_QUAD16 0x1205
|
||||
|
||||
#define SWMIXER_OUTPUT_RATE 44100
|
||||
//#define OUTPUT_BUFFER_SIZE (32768*SWMIXER_OUTPUT_RATE/22050)
|
||||
|
||||
#define SPEEDOFSOUNDMETRESPERSEC (343.3f)
|
||||
#define AIRABSORBGAINDBHF (-0.05f)
|
||||
|
||||
#define LOWPASSFREQCUTOFF (5000)
|
||||
|
||||
#define QUADRANT_NUM 128
|
||||
#define LUT_NUM (4 * QUADRANT_NUM)
|
||||
|
||||
|
||||
typedef struct {
|
||||
ALCboolean (*OpenPlayback)(ALCdevice*, const ALCchar*);
|
||||
void (*ClosePlayback)(ALCdevice*);
|
||||
ALCboolean (*ResetPlayback)(ALCdevice*);
|
||||
void (*StopPlayback)(ALCdevice*);
|
||||
|
||||
ALCboolean (*OpenCapture)(ALCdevice*, const ALCchar*, ALCuint, ALCenum, ALCsizei);
|
||||
ALCboolean (*OpenCapture)(ALCdevice*, const ALCchar*);
|
||||
void (*CloseCapture)(ALCdevice*);
|
||||
void (*StartCapture)(ALCdevice*);
|
||||
void (*StopCapture)(ALCdevice*);
|
||||
@@ -111,38 +181,97 @@ typedef struct {
|
||||
ALCuint (*AvailableSamples)(ALCdevice*);
|
||||
} BackendFuncs;
|
||||
|
||||
enum {
|
||||
DEVICE_PROBE,
|
||||
ALL_DEVICE_PROBE,
|
||||
CAPTURE_DEVICE_PROBE
|
||||
};
|
||||
|
||||
void alc_alsa_init(BackendFuncs *func_list);
|
||||
void alc_alsa_deinit(void);
|
||||
void alc_alsa_probe(int type);
|
||||
void alc_oss_init(BackendFuncs *func_list);
|
||||
void alc_oss_deinit(void);
|
||||
void alc_oss_probe(int type);
|
||||
void alc_solaris_init(BackendFuncs *func_list);
|
||||
void alc_solaris_deinit(void);
|
||||
void alc_solarise_probe(int type);
|
||||
void alcDSoundInit(BackendFuncs *func_list);
|
||||
void alcDSoundDeinit(void);
|
||||
void alcDSoundProbe(int type);
|
||||
void alcWinMMInit(BackendFuncs *FuncList);
|
||||
void alcWinMMDeinit(void);
|
||||
void alcWinMMProbe(int type);
|
||||
void alc_pa_init(BackendFuncs *func_list);
|
||||
void alc_pa_deinit(void);
|
||||
void alc_pa_probe(int type);
|
||||
void alc_wave_init(BackendFuncs *func_list);
|
||||
void alc_wave_deinit(void);
|
||||
void alc_wave_probe(int type);
|
||||
void alc_pulse_init(BackendFuncs *func_list);
|
||||
void alc_pulse_deinit(void);
|
||||
void alc_pulse_probe(int type);
|
||||
|
||||
|
||||
struct ALCdevice_struct
|
||||
{
|
||||
ALboolean InUse;
|
||||
ALCboolean Connected;
|
||||
ALboolean IsCaptureDevice;
|
||||
|
||||
ALuint Frequency;
|
||||
ALuint UpdateFreq;
|
||||
ALuint FrameSize;
|
||||
ALuint Channels;
|
||||
ALuint UpdateSize;
|
||||
ALuint NumUpdates;
|
||||
ALenum Format;
|
||||
|
||||
ALCchar *szDeviceName;
|
||||
|
||||
// Maximum number of sources that can be created
|
||||
ALuint MaxNoOfSources;
|
||||
// Maximum number of slots that can be created
|
||||
ALuint AuxiliaryEffectSlotMax;
|
||||
|
||||
// Context created on this device
|
||||
ALCcontext *Context;
|
||||
ALint lNumMonoSources;
|
||||
ALint lNumStereoSources;
|
||||
ALuint NumAuxSends;
|
||||
|
||||
// Linked List of Buffers for this device
|
||||
struct ALbuffer *Buffers;
|
||||
ALuint BufferCount;
|
||||
|
||||
// Linked List of Effects for this device
|
||||
struct ALeffect *EffectList;
|
||||
ALuint EffectCount;
|
||||
|
||||
// Linked List of Filters for this device
|
||||
struct ALfilter *FilterList;
|
||||
ALuint FilterCount;
|
||||
|
||||
// Linked List of Databuffers for this device
|
||||
struct ALdatabuffer *Databuffers;
|
||||
ALuint DatabufferCount;
|
||||
|
||||
// Stereo-to-binaural filter
|
||||
struct bs2b *Bs2b;
|
||||
ALCint Bs2bLevel;
|
||||
|
||||
// Dry path buffer mix
|
||||
float DryBuffer[BUFFERSIZE][OUTPUTCHANNELS];
|
||||
|
||||
// Contexts created on this device
|
||||
ALCcontext **Contexts;
|
||||
ALuint NumContexts;
|
||||
|
||||
BackendFuncs *Funcs;
|
||||
void *ExtraData; // For the backend's use
|
||||
|
||||
ALCdevice *next;
|
||||
};
|
||||
|
||||
#define ALCdevice_OpenPlayback(a,b) ((a)->Funcs->OpenPlayback((a), (b)))
|
||||
#define ALCdevice_ClosePlayback(a) ((a)->Funcs->ClosePlayback((a)))
|
||||
#define ALCdevice_OpenCapture(a,b,c,d,e) ((a)->Funcs->OpenCapture((a), (b), (c), (d), (e)))
|
||||
#define ALCdevice_ResetPlayback(a) ((a)->Funcs->ResetPlayback((a)))
|
||||
#define ALCdevice_StopPlayback(a) ((a)->Funcs->StopPlayback((a)))
|
||||
#define ALCdevice_OpenCapture(a,b) ((a)->Funcs->OpenCapture((a), (b)))
|
||||
#define ALCdevice_CloseCapture(a) ((a)->Funcs->CloseCapture((a)))
|
||||
#define ALCdevice_StartCapture(a) ((a)->Funcs->StartCapture((a)))
|
||||
#define ALCdevice_StopCapture(a) ((a)->Funcs->StopCapture((a)))
|
||||
@@ -153,34 +282,42 @@ struct ALCcontext_struct
|
||||
{
|
||||
ALlistener Listener;
|
||||
|
||||
ALsource *Source;
|
||||
ALuint SourceCount;
|
||||
struct ALsource *Source;
|
||||
ALuint SourceCount;
|
||||
|
||||
struct ALeffectslot *AuxiliaryEffectSlot;
|
||||
ALuint AuxiliaryEffectSlotCount;
|
||||
|
||||
struct ALdatabuffer *SampleSource;
|
||||
struct ALdatabuffer *SampleSink;
|
||||
|
||||
ALenum LastError;
|
||||
ALboolean InUse;
|
||||
|
||||
ALuint Frequency;
|
||||
|
||||
ALenum DistanceModel;
|
||||
|
||||
ALfloat DopplerFactor;
|
||||
ALfloat DopplerVelocity;
|
||||
ALfloat flSpeedOfSound;
|
||||
|
||||
ALint lNumMonoSources;
|
||||
ALint lNumStereoSources;
|
||||
ALfloat PanningLUT[OUTPUTCHANNELS * LUT_NUM];
|
||||
ALint NumChan;
|
||||
|
||||
ALfloat ChannelMatrix[OUTPUTCHANNELS][OUTPUTCHANNELS];
|
||||
|
||||
ALCdevice *Device;
|
||||
ALCchar ExtensionList[1024];
|
||||
const ALCchar *ExtensionList;
|
||||
|
||||
ALCcontext *next;
|
||||
};
|
||||
|
||||
ALCchar *AppendDeviceList(char *name);
|
||||
ALCchar *AppendAllDeviceList(char *name);
|
||||
ALCchar *AppendCaptureDeviceList(char *name);
|
||||
ALCvoid ReleaseALC(ALCvoid);
|
||||
|
||||
ALCvoid SetALCError(ALenum errorCode);
|
||||
void AppendDeviceList(const ALCchar *name);
|
||||
void AppendAllDeviceList(const ALCchar *name);
|
||||
void AppendCaptureDeviceList(const ALCchar *name);
|
||||
|
||||
ALCvoid alcSetError(ALenum errorCode);
|
||||
|
||||
ALCvoid SuspendContext(ALCcontext *context);
|
||||
ALCvoid ProcessContext(ALCcontext *context);
|
||||
@@ -188,11 +325,24 @@ ALCvoid ProcessContext(ALCcontext *context);
|
||||
ALvoid *StartThread(ALuint (*func)(ALvoid*), ALvoid *ptr);
|
||||
ALuint StopThread(ALvoid *thread);
|
||||
|
||||
ALCcontext *GetContextSuspended(void);
|
||||
|
||||
typedef struct RingBuffer RingBuffer;
|
||||
RingBuffer *CreateRingBuffer(ALsizei frame_size, ALsizei length);
|
||||
void DestroyRingBuffer(RingBuffer *ring);
|
||||
ALsizei RingBufferSize(RingBuffer *ring);
|
||||
void WriteRingBuffer(RingBuffer *ring, const ALubyte *data, ALsizei len);
|
||||
void ReadRingBuffer(RingBuffer *ring, ALubyte *data, ALsizei len);
|
||||
|
||||
void ReadALConfig(void);
|
||||
void FreeALConfig(void);
|
||||
const char *GetConfigValue(const char *blockName, const char *keyName, const char *def);
|
||||
int GetConfigValueInt(const char *blockName, const char *keyName, int def);
|
||||
float GetConfigValueFloat(const char *blockName, const char *keyName, float def);
|
||||
int GetConfigValueBool(const char *blockName, const char *keyName, float def);
|
||||
|
||||
ALCboolean ALCAPIENTRY alcMakeCurrent(ALCcontext *context);
|
||||
ALCcontext* ALCAPIENTRY alcGetThreadContext(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
+59
-16
@@ -3,21 +3,32 @@
|
||||
|
||||
#define AL_NUM_SOURCE_PARAMS 128
|
||||
|
||||
#define MAX_SENDS 2
|
||||
|
||||
#include "alFilter.h"
|
||||
#include "alu.h"
|
||||
#include "AL/al.h"
|
||||
|
||||
#define AL_DIRECT_FILTER 0x20005
|
||||
#define AL_AUXILIARY_SEND_FILTER 0x20006
|
||||
#define AL_AIR_ABSORPTION_FACTOR 0x20007
|
||||
#define AL_ROOM_ROLLOFF_FACTOR 0x20008
|
||||
#define AL_CONE_OUTER_GAINHF 0x20009
|
||||
#define AL_DIRECT_FILTER_GAINHF_AUTO 0x2000A
|
||||
#define AL_AUXILIARY_SEND_FILTER_GAIN_AUTO 0x2000B
|
||||
#define AL_AUXILIARY_SEND_FILTER_GAINHF_AUTO 0x2000C
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct ALbufferlistitem
|
||||
{
|
||||
ALuint buffer;
|
||||
ALuint bufferstate;
|
||||
ALuint flag;
|
||||
struct ALbuffer *buffer;
|
||||
struct ALbufferlistitem *next;
|
||||
} ALbufferlistitem;
|
||||
|
||||
typedef struct ALsource_struct
|
||||
typedef struct ALsource
|
||||
{
|
||||
ALfloat flPitch;
|
||||
ALfloat flGain;
|
||||
@@ -34,26 +45,33 @@ typedef struct ALsource_struct
|
||||
ALfloat vOrientation[3];
|
||||
ALboolean bHeadRelative;
|
||||
ALboolean bLooping;
|
||||
ALenum DistanceModel;
|
||||
|
||||
ALuint ulBufferID;
|
||||
|
||||
ALboolean inuse;
|
||||
ALboolean play;
|
||||
ALenum state;
|
||||
ALuint position;
|
||||
ALuint position_fraction;
|
||||
|
||||
struct ALbuffer *Buffer;
|
||||
|
||||
struct ALbufferlistitem *queue; // Linked list of buffers in queue
|
||||
ALuint BuffersInQueue; // Number of buffers in queue
|
||||
ALuint BuffersProcessed; // Number of buffers already processed (played)
|
||||
ALuint BuffersPlayed; // Number of buffers played on this loop
|
||||
|
||||
ALuint TotalBufferDataSize; // Total amount of data contained in the buffers queued for this source
|
||||
ALuint BuffersPlayed; // Number of buffers played on this loop
|
||||
ALuint BufferPosition; // Read position in audio data of current buffer
|
||||
ALfilter DirectFilter;
|
||||
|
||||
// Index to itself
|
||||
ALuint source;
|
||||
struct {
|
||||
struct ALeffectslot *Slot;
|
||||
ALfilter WetFilter;
|
||||
} Send[MAX_SENDS];
|
||||
|
||||
ALint lBytesPlayed;
|
||||
ALboolean DryGainHFAuto;
|
||||
ALboolean WetGainAuto;
|
||||
ALboolean WetGainHFAuto;
|
||||
ALfloat OuterGainHF;
|
||||
|
||||
ALfloat AirAbsorptionFactor;
|
||||
ALfloat RoomRolloffFactor;
|
||||
ALfloat DopplerFactor;
|
||||
|
||||
ALint lOffset;
|
||||
ALint lOffsetType;
|
||||
@@ -61,9 +79,34 @@ typedef struct ALsource_struct
|
||||
// Source Type (Static, Streaming, or Undetermined)
|
||||
ALint lSourceType;
|
||||
|
||||
struct ALsource_struct *next;
|
||||
// Current gains, which are ramped while mixed
|
||||
ALfloat DryGains[OUTPUTCHANNELS];
|
||||
ALfloat WetGains[MAX_SENDS];
|
||||
ALboolean FirstStart;
|
||||
|
||||
// Current target parameters used for mixing
|
||||
struct {
|
||||
ALfloat DryGains[OUTPUTCHANNELS];
|
||||
ALfloat WetGains[MAX_SENDS];
|
||||
ALfloat Pitch;
|
||||
|
||||
struct {
|
||||
FILTER iirFilter;
|
||||
ALfloat history[2];
|
||||
} Send[MAX_SENDS];
|
||||
|
||||
FILTER iirFilter;
|
||||
ALfloat history[OUTPUTCHANNELS*2];
|
||||
} Params;
|
||||
|
||||
// Index to itself
|
||||
ALuint source;
|
||||
|
||||
struct ALsource *next;
|
||||
} ALsource;
|
||||
|
||||
ALvoid ReleaseALSources(ALCcontext *Context);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
+140
-9
@@ -1,22 +1,153 @@
|
||||
#ifndef _ALU_H_
|
||||
#define _ALU_H_
|
||||
|
||||
#define BUFFERSIZE 48000
|
||||
#define FRACTIONBITS 14
|
||||
#define FRACTIONMASK ((1L<<FRACTIONBITS)-1)
|
||||
#define MAX_PITCH 4
|
||||
#define OUTPUTCHANNELS 4
|
||||
|
||||
#include "AL/al.h"
|
||||
#include "AL/alc.h"
|
||||
#include "AL/alext.h"
|
||||
|
||||
#ifdef HAVE_FLOAT_H
|
||||
#include <float.h>
|
||||
#endif
|
||||
|
||||
#ifndef M_PI
|
||||
#define M_PI 3.14159265358979323846 /* pi */
|
||||
#define M_PI_2 1.57079632679489661923 /* pi/2 */
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SQRTF
|
||||
#define aluSqrt(x) ((ALfloat)sqrtf((float)(x)))
|
||||
#else
|
||||
#define aluSqrt(x) ((ALfloat)sqrt((double)(x)))
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_ACOSF
|
||||
#define aluAcos(x) ((ALfloat)acosf((float)(x)))
|
||||
#else
|
||||
#define aluAcos(x) ((ALfloat)acos((double)(x)))
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_ATANF
|
||||
#define aluAtan(x) ((ALfloat)atanf((float)(x)))
|
||||
#else
|
||||
#define aluAtan(x) ((ALfloat)atan((double)(x)))
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_FABSF
|
||||
#define aluFabs(x) ((ALfloat)fabsf((float)(x)))
|
||||
#else
|
||||
#define aluFabs(x) ((ALfloat)fabs((double)(x)))
|
||||
#endif
|
||||
|
||||
// fixes for mingw32.
|
||||
#if defined(max) && !defined(__max)
|
||||
#define __max max
|
||||
#endif
|
||||
#if defined(min) && !defined(__min)
|
||||
#define __min min
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
__inline ALuint aluBytesFromFormat(ALenum format);
|
||||
__inline ALuint aluChannelsFromFormat(ALenum format);
|
||||
ALvoid aluMixData(ALCcontext *context,ALvoid *buffer,ALsizei size,ALenum format);
|
||||
enum {
|
||||
FRONT_LEFT = 0,
|
||||
FRONT_RIGHT,
|
||||
FRONT_CENTER,
|
||||
SIDE_LEFT,
|
||||
SIDE_RIGHT,
|
||||
BACK_LEFT,
|
||||
BACK_RIGHT,
|
||||
BACK_CENTER,
|
||||
LFE,
|
||||
|
||||
OUTPUTCHANNELS
|
||||
};
|
||||
|
||||
#define BUFFERSIZE 24000
|
||||
|
||||
extern ALboolean DuplicateStereo;
|
||||
|
||||
/* NOTE: The AL_FORMAT_REAR* enums aren't handled here be cause they're
|
||||
* converted to AL_FORMAT_QUAD* when loaded */
|
||||
static __inline ALuint aluBytesFromFormat(ALenum format)
|
||||
{
|
||||
switch(format)
|
||||
{
|
||||
case AL_FORMAT_MONO8:
|
||||
case AL_FORMAT_STEREO8:
|
||||
case AL_FORMAT_QUAD8_LOKI:
|
||||
case AL_FORMAT_QUAD8:
|
||||
case AL_FORMAT_51CHN8:
|
||||
case AL_FORMAT_61CHN8:
|
||||
case AL_FORMAT_71CHN8:
|
||||
return 1;
|
||||
|
||||
case AL_FORMAT_MONO16:
|
||||
case AL_FORMAT_STEREO16:
|
||||
case AL_FORMAT_QUAD16_LOKI:
|
||||
case AL_FORMAT_QUAD16:
|
||||
case AL_FORMAT_51CHN16:
|
||||
case AL_FORMAT_61CHN16:
|
||||
case AL_FORMAT_71CHN16:
|
||||
return 2;
|
||||
|
||||
case AL_FORMAT_MONO_FLOAT32:
|
||||
case AL_FORMAT_STEREO_FLOAT32:
|
||||
case AL_FORMAT_QUAD32:
|
||||
case AL_FORMAT_51CHN32:
|
||||
case AL_FORMAT_61CHN32:
|
||||
case AL_FORMAT_71CHN32:
|
||||
return 4;
|
||||
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
static __inline ALuint aluChannelsFromFormat(ALenum format)
|
||||
{
|
||||
switch(format)
|
||||
{
|
||||
case AL_FORMAT_MONO8:
|
||||
case AL_FORMAT_MONO16:
|
||||
case AL_FORMAT_MONO_FLOAT32:
|
||||
return 1;
|
||||
|
||||
case AL_FORMAT_STEREO8:
|
||||
case AL_FORMAT_STEREO16:
|
||||
case AL_FORMAT_STEREO_FLOAT32:
|
||||
return 2;
|
||||
|
||||
case AL_FORMAT_QUAD8_LOKI:
|
||||
case AL_FORMAT_QUAD16_LOKI:
|
||||
case AL_FORMAT_QUAD8:
|
||||
case AL_FORMAT_QUAD16:
|
||||
case AL_FORMAT_QUAD32:
|
||||
return 4;
|
||||
|
||||
case AL_FORMAT_51CHN8:
|
||||
case AL_FORMAT_51CHN16:
|
||||
case AL_FORMAT_51CHN32:
|
||||
return 6;
|
||||
|
||||
case AL_FORMAT_61CHN8:
|
||||
case AL_FORMAT_61CHN16:
|
||||
case AL_FORMAT_61CHN32:
|
||||
return 7;
|
||||
|
||||
case AL_FORMAT_71CHN8:
|
||||
case AL_FORMAT_71CHN16:
|
||||
case AL_FORMAT_71CHN32:
|
||||
return 8;
|
||||
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
ALvoid aluInitPanning(ALCcontext *Context);
|
||||
ALvoid aluMixData(ALCdevice *device, ALvoid *buffer, ALsizei size);
|
||||
ALvoid aluHandleDisconnect(ALCdevice *device);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -0,0 +1,109 @@
|
||||
/*-
|
||||
* Copyright (c) 2005 Boris Mikhaylov
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* 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 AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef BS2B_H
|
||||
#define BS2B_H
|
||||
|
||||
/* Number of crossfeed levels */
|
||||
#define BS2B_CLEVELS 3
|
||||
|
||||
/* Normal crossfeed levels */
|
||||
#define BS2B_HIGH_CLEVEL 3
|
||||
#define BS2B_MIDDLE_CLEVEL 2
|
||||
#define BS2B_LOW_CLEVEL 1
|
||||
|
||||
/* Easy crossfeed levels */
|
||||
#define BS2B_HIGH_ECLEVEL BS2B_HIGH_CLEVEL + BS2B_CLEVELS
|
||||
#define BS2B_MIDDLE_ECLEVEL BS2B_MIDDLE_CLEVEL + BS2B_CLEVELS
|
||||
#define BS2B_LOW_ECLEVEL BS2B_LOW_CLEVEL + BS2B_CLEVELS
|
||||
|
||||
/* Default crossfeed levels */
|
||||
#define BS2B_DEFAULT_CLEVEL BS2B_HIGH_ECLEVEL
|
||||
/* Default sample rate (Hz) */
|
||||
#define BS2B_DEFAULT_SRATE 44100
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
struct bs2b {
|
||||
int level; /* Crossfeed level */
|
||||
int srate; /* Sample rate (Hz) */
|
||||
|
||||
/* Lowpass IIR filter coefficients */
|
||||
double a0_lo;
|
||||
double b1_lo;
|
||||
|
||||
/* Highboost IIR filter coefficients */
|
||||
double a0_hi;
|
||||
double a1_hi;
|
||||
double b1_hi;
|
||||
|
||||
/* Global gain against overloading */
|
||||
double gain;
|
||||
|
||||
/* Buffer of last filtered sample.
|
||||
* [0] - first channel, [1] - second channel
|
||||
*/
|
||||
struct t_last_sample {
|
||||
double asis[2];
|
||||
double lo[2];
|
||||
double hi[2];
|
||||
} last_sample;
|
||||
};
|
||||
|
||||
/* Clear buffers and set new coefficients with new crossfeed level value.
|
||||
* level - crossfeed level of *LEVEL values.
|
||||
*/
|
||||
void bs2b_set_level(struct bs2b *bs2b, int level);
|
||||
|
||||
/* Return current crossfeed level value */
|
||||
int bs2b_get_level(struct bs2b *bs2b);
|
||||
|
||||
/* Clear buffers and set new coefficients with new sample rate value.
|
||||
* srate - sample rate by Hz.
|
||||
*/
|
||||
void bs2b_set_srate(struct bs2b *bs2b, int srate);
|
||||
|
||||
/* Return current sample rate value */
|
||||
int bs2b_get_srate(struct bs2b *bs2b);
|
||||
|
||||
/* Clear buffer */
|
||||
void bs2b_clear(struct bs2b *bs2b);
|
||||
|
||||
/* Return 1 if buffer is clear */
|
||||
int bs2b_is_clear(struct bs2b *bs2b);
|
||||
|
||||
/* Crossfeeds one stereo sample that are pointed by sample.
|
||||
* [0] - first channel, [1] - second channel.
|
||||
* Returns crossfided samle by sample pointer.
|
||||
*/
|
||||
|
||||
/* sample poits to floats */
|
||||
void bs2b_cross_feed(struct bs2b *bs2b, float *sample);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* BS2B_H */
|
||||
@@ -1,63 +0,0 @@
|
||||
/**
|
||||
* OpenAL cross platform audio library
|
||||
* Copyright (C) 1999-2007 by authors.
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* 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
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
* Or go to http://www.gnu.org/copyleft/lgpl.html
|
||||
*/
|
||||
|
||||
#include "alMain.h"
|
||||
#include "alBuffer.h"
|
||||
#include "alThunk.h"
|
||||
|
||||
CRITICAL_SECTION g_mutex;
|
||||
|
||||
#ifdef _WIN32
|
||||
BOOL APIENTRY DllMain(HANDLE hModule,DWORD ul_reason_for_call,LPVOID lpReserved)
|
||||
{
|
||||
(void)lpReserved;
|
||||
|
||||
// Perform actions based on the reason for calling.
|
||||
switch(ul_reason_for_call)
|
||||
{
|
||||
case DLL_PROCESS_ATTACH:
|
||||
DisableThreadLibraryCalls(hModule);
|
||||
break;
|
||||
|
||||
case DLL_PROCESS_DETACH:
|
||||
ReleaseALBuffers();
|
||||
FreeALConfig();
|
||||
ALTHUNK_EXIT();
|
||||
DeleteCriticalSection(&g_mutex);
|
||||
break;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
#else
|
||||
#ifdef HAVE_GCC_DESTRUCTOR
|
||||
static void my_deinit() __attribute__((destructor));
|
||||
static void my_deinit()
|
||||
{
|
||||
static ALenum once = AL_FALSE;
|
||||
if(once) return;
|
||||
once = AL_TRUE;
|
||||
|
||||
ReleaseALBuffers();
|
||||
FreeALConfig();
|
||||
ALTHUNK_EXIT();
|
||||
DeleteCriticalSection(&g_mutex);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
@@ -0,0 +1,510 @@
|
||||
/**
|
||||
* OpenAL cross platform audio library
|
||||
* Copyright (C) 1999-2007 by authors.
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* 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
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
* Or go to http://www.gnu.org/copyleft/lgpl.html
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "AL/al.h"
|
||||
#include "AL/alc.h"
|
||||
#include "alMain.h"
|
||||
#include "alAuxEffectSlot.h"
|
||||
#include "alThunk.h"
|
||||
#include "alError.h"
|
||||
|
||||
|
||||
static ALvoid InitializeEffect(ALCcontext *Context, ALeffectslot *ALEffectSlot, ALeffect *effect);
|
||||
|
||||
|
||||
ALvoid AL_APIENTRY alGenAuxiliaryEffectSlots(ALsizei n, ALuint *effectslots)
|
||||
{
|
||||
ALCcontext *Context;
|
||||
ALsizei i, j;
|
||||
|
||||
Context = GetContextSuspended();
|
||||
if(!Context) return;
|
||||
|
||||
if (n > 0)
|
||||
{
|
||||
ALCdevice *Device = Context->Device;
|
||||
|
||||
if(Context->AuxiliaryEffectSlotCount+n <= Device->AuxiliaryEffectSlotMax)
|
||||
{
|
||||
// Check that enough memory has been allocted in the 'effectslots' array for n Effect Slots
|
||||
if (!IsBadWritePtr((void*)effectslots, n * sizeof(ALuint)))
|
||||
{
|
||||
ALeffectslot **list = &Context->AuxiliaryEffectSlot;
|
||||
while(*list)
|
||||
list = &(*list)->next;
|
||||
|
||||
i = 0;
|
||||
while(i < n)
|
||||
{
|
||||
*list = calloc(1, sizeof(ALeffectslot));
|
||||
if(!(*list) || !((*list)->EffectState=NoneCreate()))
|
||||
{
|
||||
// We must have run out or memory
|
||||
free(*list); *list = NULL;
|
||||
alDeleteAuxiliaryEffectSlots(i, effectslots);
|
||||
alSetError(AL_OUT_OF_MEMORY);
|
||||
break;
|
||||
}
|
||||
|
||||
(*list)->Gain = 1.0;
|
||||
(*list)->AuxSendAuto = AL_TRUE;
|
||||
for(j = 0;j < BUFFERSIZE;j++)
|
||||
(*list)->WetBuffer[j] = 0.0f;
|
||||
(*list)->refcount = 0;
|
||||
|
||||
effectslots[i] = (ALuint)ALTHUNK_ADDENTRY(*list);
|
||||
(*list)->effectslot = effectslots[i];
|
||||
|
||||
Context->AuxiliaryEffectSlotCount++;
|
||||
i++;
|
||||
|
||||
list = &(*list)->next;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
alSetError(AL_INVALID_OPERATION);
|
||||
}
|
||||
|
||||
ProcessContext(Context);
|
||||
}
|
||||
|
||||
ALvoid AL_APIENTRY alDeleteAuxiliaryEffectSlots(ALsizei n, ALuint *effectslots)
|
||||
{
|
||||
ALCcontext *Context;
|
||||
ALeffectslot *ALAuxiliaryEffectSlot;
|
||||
ALsizei i;
|
||||
|
||||
Context = GetContextSuspended();
|
||||
if(!Context) return;
|
||||
|
||||
if (n >= 0)
|
||||
{
|
||||
// Check that all effectslots are valid
|
||||
for (i = 0; i < n; i++)
|
||||
{
|
||||
if (!alIsAuxiliaryEffectSlot(effectslots[i]))
|
||||
{
|
||||
alSetError(AL_INVALID_NAME);
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
ALAuxiliaryEffectSlot = (ALeffectslot*)ALTHUNK_LOOKUPENTRY(effectslots[i]);
|
||||
if(ALAuxiliaryEffectSlot->refcount > 0)
|
||||
{
|
||||
alSetError(AL_INVALID_NAME);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (i == n)
|
||||
{
|
||||
// All effectslots are valid
|
||||
for (i = 0; i < n; i++)
|
||||
{
|
||||
// Recheck that the effectslot is valid, because there could be duplicated names
|
||||
if (alIsAuxiliaryEffectSlot(effectslots[i]))
|
||||
{
|
||||
ALeffectslot **list;
|
||||
|
||||
ALAuxiliaryEffectSlot = ((ALeffectslot*)ALTHUNK_LOOKUPENTRY(effectslots[i]));
|
||||
|
||||
// Remove Source from list of Sources
|
||||
list = &Context->AuxiliaryEffectSlot;
|
||||
while(*list && *list != ALAuxiliaryEffectSlot)
|
||||
list = &(*list)->next;
|
||||
|
||||
if(*list)
|
||||
*list = (*list)->next;
|
||||
ALTHUNK_REMOVEENTRY(ALAuxiliaryEffectSlot->effectslot);
|
||||
|
||||
if(ALAuxiliaryEffectSlot->EffectState)
|
||||
ALEffect_Destroy(ALAuxiliaryEffectSlot->EffectState);
|
||||
|
||||
memset(ALAuxiliaryEffectSlot, 0, sizeof(ALeffectslot));
|
||||
free(ALAuxiliaryEffectSlot);
|
||||
|
||||
Context->AuxiliaryEffectSlotCount--;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
alSetError(AL_INVALID_VALUE);
|
||||
|
||||
ProcessContext(Context);
|
||||
}
|
||||
|
||||
ALboolean AL_APIENTRY alIsAuxiliaryEffectSlot(ALuint effectslot)
|
||||
{
|
||||
ALCcontext *Context;
|
||||
ALeffectslot **list;
|
||||
|
||||
Context = GetContextSuspended();
|
||||
if(!Context) return AL_FALSE;
|
||||
|
||||
list = &Context->AuxiliaryEffectSlot;
|
||||
while(*list && (*list)->effectslot != effectslot)
|
||||
list = &(*list)->next;
|
||||
|
||||
ProcessContext(Context);
|
||||
|
||||
return (*list ? AL_TRUE : AL_FALSE);
|
||||
}
|
||||
|
||||
ALvoid AL_APIENTRY alAuxiliaryEffectSloti(ALuint effectslot, ALenum param, ALint iValue)
|
||||
{
|
||||
ALCcontext *Context;
|
||||
|
||||
Context = GetContextSuspended();
|
||||
if(!Context) return;
|
||||
|
||||
if (alIsAuxiliaryEffectSlot(effectslot))
|
||||
{
|
||||
ALeffectslot *ALEffectSlot = (ALeffectslot*)ALTHUNK_LOOKUPENTRY(effectslot);
|
||||
|
||||
switch(param)
|
||||
{
|
||||
case AL_EFFECTSLOT_EFFECT:
|
||||
if(alIsEffect(iValue))
|
||||
{
|
||||
ALeffect *effect = (ALeffect*)ALTHUNK_LOOKUPENTRY(iValue);
|
||||
InitializeEffect(Context, ALEffectSlot, effect);
|
||||
}
|
||||
else
|
||||
alSetError(AL_INVALID_VALUE);
|
||||
break;
|
||||
|
||||
case AL_EFFECTSLOT_AUXILIARY_SEND_AUTO:
|
||||
if(iValue == AL_TRUE || iValue == AL_FALSE)
|
||||
ALEffectSlot->AuxSendAuto = iValue;
|
||||
else
|
||||
alSetError(AL_INVALID_VALUE);
|
||||
break;
|
||||
|
||||
default:
|
||||
alSetError(AL_INVALID_ENUM);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
alSetError(AL_INVALID_NAME);
|
||||
|
||||
ProcessContext(Context);
|
||||
}
|
||||
|
||||
ALvoid AL_APIENTRY alAuxiliaryEffectSlotiv(ALuint effectslot, ALenum param, ALint *piValues)
|
||||
{
|
||||
ALCcontext *Context;
|
||||
|
||||
Context = GetContextSuspended();
|
||||
if(!Context) return;
|
||||
|
||||
if (alIsAuxiliaryEffectSlot(effectslot))
|
||||
{
|
||||
switch(param)
|
||||
{
|
||||
case AL_EFFECTSLOT_EFFECT:
|
||||
case AL_EFFECTSLOT_AUXILIARY_SEND_AUTO:
|
||||
alAuxiliaryEffectSloti(effectslot, param, piValues[0]);
|
||||
break;
|
||||
|
||||
default:
|
||||
alSetError(AL_INVALID_ENUM);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
alSetError(AL_INVALID_NAME);
|
||||
|
||||
ProcessContext(Context);
|
||||
}
|
||||
|
||||
ALvoid AL_APIENTRY alAuxiliaryEffectSlotf(ALuint effectslot, ALenum param, ALfloat flValue)
|
||||
{
|
||||
ALCcontext *Context;
|
||||
|
||||
Context = GetContextSuspended();
|
||||
if(!Context) return;
|
||||
|
||||
if (alIsAuxiliaryEffectSlot(effectslot))
|
||||
{
|
||||
ALeffectslot *ALEffectSlot = (ALeffectslot*)ALTHUNK_LOOKUPENTRY(effectslot);
|
||||
|
||||
switch(param)
|
||||
{
|
||||
case AL_EFFECTSLOT_GAIN:
|
||||
if(flValue >= 0.0f && flValue <= 1.0f)
|
||||
ALEffectSlot->Gain = flValue;
|
||||
else
|
||||
alSetError(AL_INVALID_VALUE);
|
||||
break;
|
||||
|
||||
default:
|
||||
alSetError(AL_INVALID_ENUM);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
alSetError(AL_INVALID_NAME);
|
||||
|
||||
ProcessContext(Context);
|
||||
}
|
||||
|
||||
ALvoid AL_APIENTRY alAuxiliaryEffectSlotfv(ALuint effectslot, ALenum param, ALfloat *pflValues)
|
||||
{
|
||||
ALCcontext *Context;
|
||||
|
||||
Context = GetContextSuspended();
|
||||
if(!Context) return;
|
||||
|
||||
if (alIsAuxiliaryEffectSlot(effectslot))
|
||||
{
|
||||
switch(param)
|
||||
{
|
||||
case AL_EFFECTSLOT_GAIN:
|
||||
alAuxiliaryEffectSlotf(effectslot, param, pflValues[0]);
|
||||
break;
|
||||
|
||||
default:
|
||||
alSetError(AL_INVALID_ENUM);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
alSetError(AL_INVALID_NAME);
|
||||
|
||||
ProcessContext(Context);
|
||||
}
|
||||
|
||||
ALvoid AL_APIENTRY alGetAuxiliaryEffectSloti(ALuint effectslot, ALenum param, ALint *piValue)
|
||||
{
|
||||
ALCcontext *Context;
|
||||
|
||||
Context = GetContextSuspended();
|
||||
if(!Context) return;
|
||||
|
||||
if (alIsAuxiliaryEffectSlot(effectslot))
|
||||
{
|
||||
ALeffectslot *ALEffectSlot = (ALeffectslot*)ALTHUNK_LOOKUPENTRY(effectslot);
|
||||
|
||||
switch(param)
|
||||
{
|
||||
case AL_EFFECTSLOT_EFFECT:
|
||||
*piValue = ALEffectSlot->effect.effect;
|
||||
break;
|
||||
|
||||
case AL_EFFECTSLOT_AUXILIARY_SEND_AUTO:
|
||||
*piValue = ALEffectSlot->AuxSendAuto;
|
||||
break;
|
||||
|
||||
default:
|
||||
alSetError(AL_INVALID_ENUM);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
alSetError(AL_INVALID_NAME);
|
||||
|
||||
ProcessContext(Context);
|
||||
}
|
||||
|
||||
ALvoid AL_APIENTRY alGetAuxiliaryEffectSlotiv(ALuint effectslot, ALenum param, ALint *piValues)
|
||||
{
|
||||
ALCcontext *Context;
|
||||
|
||||
Context = GetContextSuspended();
|
||||
if(!Context) return;
|
||||
|
||||
if (alIsAuxiliaryEffectSlot(effectslot))
|
||||
{
|
||||
switch(param)
|
||||
{
|
||||
case AL_EFFECTSLOT_EFFECT:
|
||||
case AL_EFFECTSLOT_AUXILIARY_SEND_AUTO:
|
||||
alGetAuxiliaryEffectSloti(effectslot, param, piValues);
|
||||
break;
|
||||
|
||||
default:
|
||||
alSetError(AL_INVALID_ENUM);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
alSetError(AL_INVALID_NAME);
|
||||
|
||||
ProcessContext(Context);
|
||||
}
|
||||
|
||||
ALvoid AL_APIENTRY alGetAuxiliaryEffectSlotf(ALuint effectslot, ALenum param, ALfloat *pflValue)
|
||||
{
|
||||
ALCcontext *Context;
|
||||
|
||||
Context = GetContextSuspended();
|
||||
if(!Context) return;
|
||||
|
||||
if (alIsAuxiliaryEffectSlot(effectslot))
|
||||
{
|
||||
ALeffectslot *ALEffectSlot = (ALeffectslot*)ALTHUNK_LOOKUPENTRY(effectslot);
|
||||
|
||||
switch(param)
|
||||
{
|
||||
case AL_EFFECTSLOT_GAIN:
|
||||
*pflValue = ALEffectSlot->Gain;
|
||||
break;
|
||||
|
||||
default:
|
||||
alSetError(AL_INVALID_ENUM);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
alSetError(AL_INVALID_NAME);
|
||||
|
||||
ProcessContext(Context);
|
||||
}
|
||||
|
||||
ALvoid AL_APIENTRY alGetAuxiliaryEffectSlotfv(ALuint effectslot, ALenum param, ALfloat *pflValues)
|
||||
{
|
||||
ALCcontext *Context;
|
||||
|
||||
Context = GetContextSuspended();
|
||||
if(!Context) return;
|
||||
|
||||
if (alIsAuxiliaryEffectSlot(effectslot))
|
||||
{
|
||||
switch(param)
|
||||
{
|
||||
case AL_EFFECTSLOT_GAIN:
|
||||
alGetAuxiliaryEffectSlotf(effectslot, param, pflValues);
|
||||
break;
|
||||
|
||||
default:
|
||||
alSetError(AL_INVALID_ENUM);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
alSetError(AL_INVALID_NAME);
|
||||
|
||||
ProcessContext(Context);
|
||||
}
|
||||
|
||||
|
||||
static ALvoid NoneDestroy(ALeffectState *State)
|
||||
{ free(State); }
|
||||
static ALboolean NoneDeviceUpdate(ALeffectState *State, ALCdevice *Device)
|
||||
{
|
||||
return AL_TRUE;
|
||||
(void)State;
|
||||
(void)Device;
|
||||
}
|
||||
static ALvoid NoneUpdate(ALeffectState *State, ALCcontext *Context, const ALeffect *Effect)
|
||||
{
|
||||
(void)State;
|
||||
(void)Context;
|
||||
(void)Effect;
|
||||
}
|
||||
static ALvoid NoneProcess(ALeffectState *State, const ALeffectslot *Slot, ALuint SamplesToDo, const ALfloat *SamplesIn, ALfloat (*SamplesOut)[OUTPUTCHANNELS])
|
||||
{
|
||||
(void)State;
|
||||
(void)Slot;
|
||||
(void)SamplesToDo;
|
||||
(void)SamplesIn;
|
||||
(void)SamplesOut;
|
||||
}
|
||||
ALeffectState *NoneCreate(void)
|
||||
{
|
||||
ALeffectState *state;
|
||||
|
||||
state = calloc(1, sizeof(*state));
|
||||
if(!state)
|
||||
{
|
||||
alSetError(AL_OUT_OF_MEMORY);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
state->Destroy = NoneDestroy;
|
||||
state->DeviceUpdate = NoneDeviceUpdate;
|
||||
state->Update = NoneUpdate;
|
||||
state->Process = NoneProcess;
|
||||
|
||||
return state;
|
||||
}
|
||||
|
||||
static ALvoid InitializeEffect(ALCcontext *Context, ALeffectslot *ALEffectSlot, ALeffect *effect)
|
||||
{
|
||||
if(ALEffectSlot->effect.type != (effect?effect->type:AL_EFFECT_NULL))
|
||||
{
|
||||
ALeffectState *NewState = NULL;
|
||||
if(!effect || effect->type == AL_EFFECT_NULL)
|
||||
NewState = NoneCreate();
|
||||
else if(effect->type == AL_EFFECT_EAXREVERB)
|
||||
NewState = EAXVerbCreate();
|
||||
else if(effect->type == AL_EFFECT_REVERB)
|
||||
NewState = VerbCreate();
|
||||
else if(effect->type == AL_EFFECT_ECHO)
|
||||
NewState = EchoCreate();
|
||||
/* No new state? An error occured.. */
|
||||
if(NewState == NULL ||
|
||||
ALEffect_DeviceUpdate(NewState, Context->Device) == AL_FALSE)
|
||||
{
|
||||
if(NewState)
|
||||
ALEffect_Destroy(NewState);
|
||||
return;
|
||||
}
|
||||
if(ALEffectSlot->EffectState)
|
||||
ALEffect_Destroy(ALEffectSlot->EffectState);
|
||||
ALEffectSlot->EffectState = NewState;
|
||||
}
|
||||
if(!effect)
|
||||
{
|
||||
memset(&ALEffectSlot->effect, 0, sizeof(ALEffectSlot->effect));
|
||||
return;
|
||||
}
|
||||
memcpy(&ALEffectSlot->effect, effect, sizeof(*effect));
|
||||
ALEffect_Update(ALEffectSlot->EffectState, Context, effect);
|
||||
}
|
||||
|
||||
|
||||
ALvoid ReleaseALAuxiliaryEffectSlots(ALCcontext *Context)
|
||||
{
|
||||
while(Context->AuxiliaryEffectSlot)
|
||||
{
|
||||
ALeffectslot *temp = Context->AuxiliaryEffectSlot;
|
||||
Context->AuxiliaryEffectSlot = Context->AuxiliaryEffectSlot->next;
|
||||
|
||||
// Release effectslot structure
|
||||
if(temp->EffectState)
|
||||
ALEffect_Destroy(temp->EffectState);
|
||||
ALTHUNK_REMOVEENTRY(temp->effectslot);
|
||||
|
||||
memset(temp, 0, sizeof(ALeffectslot));
|
||||
free(temp);
|
||||
}
|
||||
Context->AuxiliaryEffectSlotCount = 0;
|
||||
}
|
||||
+504
-331
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,639 @@
|
||||
/**
|
||||
* OpenAL cross platform audio library
|
||||
* Copyright (C) 1999-2007 by authors.
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* 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
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
* Or go to http://www.gnu.org/copyleft/lgpl.html
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
#include "alMain.h"
|
||||
#include "AL/al.h"
|
||||
#include "AL/alc.h"
|
||||
#include "AL/alext.h"
|
||||
#include "alError.h"
|
||||
#include "alDatabuffer.h"
|
||||
#include "alThunk.h"
|
||||
|
||||
|
||||
/*
|
||||
* alGenDatabuffersEXT(ALsizei n, ALuint *puiBuffers)
|
||||
*
|
||||
* Generates n AL Databuffers, and stores the Databuffers Names in the array pointed to by puiBuffers
|
||||
*/
|
||||
ALvoid ALAPIENTRY alGenDatabuffersEXT(ALsizei n,ALuint *puiBuffers)
|
||||
{
|
||||
ALCcontext *Context;
|
||||
ALsizei i=0;
|
||||
|
||||
Context = GetContextSuspended();
|
||||
if(!Context) return;
|
||||
|
||||
/* Check that we are actually generation some Databuffers */
|
||||
if(n > 0)
|
||||
{
|
||||
ALCdevice *device = Context->Device;
|
||||
|
||||
/* Check the pointer is valid (and points to enough memory to store
|
||||
* Databuffer Names) */
|
||||
if(!IsBadWritePtr((void*)puiBuffers, n * sizeof(ALuint)))
|
||||
{
|
||||
ALdatabuffer **list = &device->Databuffers;
|
||||
while(*list)
|
||||
list = &(*list)->next;
|
||||
|
||||
/* Create all the new Databuffers */
|
||||
while(i < n)
|
||||
{
|
||||
*list = calloc(1, sizeof(ALdatabuffer));
|
||||
if(!(*list))
|
||||
{
|
||||
alDeleteDatabuffersEXT(i, puiBuffers);
|
||||
alSetError(AL_OUT_OF_MEMORY);
|
||||
break;
|
||||
}
|
||||
|
||||
puiBuffers[i] = (ALuint)ALTHUNK_ADDENTRY(*list);
|
||||
(*list)->databuffer = puiBuffers[i];
|
||||
(*list)->state = UNMAPPED;
|
||||
device->DatabufferCount++;
|
||||
i++;
|
||||
|
||||
list = &(*list)->next;
|
||||
}
|
||||
}
|
||||
else
|
||||
alSetError(AL_INVALID_VALUE);
|
||||
}
|
||||
|
||||
ProcessContext(Context);
|
||||
}
|
||||
|
||||
/*
|
||||
* alDatabeleteBuffersEXT(ALsizei n, ALuint *puiBuffers)
|
||||
*
|
||||
* Deletes the n AL Databuffers pointed to by puiBuffers
|
||||
*/
|
||||
ALvoid ALAPIENTRY alDeleteDatabuffersEXT(ALsizei n, const ALuint *puiBuffers)
|
||||
{
|
||||
ALCcontext *Context;
|
||||
ALdatabuffer *ALBuf;
|
||||
ALsizei i;
|
||||
ALboolean bFailed = AL_FALSE;
|
||||
|
||||
Context = GetContextSuspended();
|
||||
if(!Context) return;
|
||||
|
||||
/* Check we are actually Deleting some Databuffers */
|
||||
if(n >= 0)
|
||||
{
|
||||
ALCdevice *device = Context->Device;
|
||||
|
||||
/* Check that all the databuffers are valid and can actually be
|
||||
* deleted */
|
||||
for(i = 0;i < n;i++)
|
||||
{
|
||||
/* Check for valid Buffer ID (can be NULL buffer) */
|
||||
if(alIsDatabufferEXT(puiBuffers[i]))
|
||||
{
|
||||
/* If not the NULL buffer, check that it's unmapped */
|
||||
ALBuf = ((ALdatabuffer *)ALTHUNK_LOOKUPENTRY(puiBuffers[i]));
|
||||
if(ALBuf)
|
||||
{
|
||||
if(ALBuf->state != UNMAPPED)
|
||||
{
|
||||
/* Databuffer still in use, cannot be deleted */
|
||||
alSetError(AL_INVALID_OPERATION);
|
||||
bFailed = AL_TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Invalid Databuffer */
|
||||
alSetError(AL_INVALID_NAME);
|
||||
bFailed = AL_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
/* If all the Databuffers were valid (and unmapped), then we can
|
||||
* delete them */
|
||||
if(!bFailed)
|
||||
{
|
||||
for(i = 0;i < n;i++)
|
||||
{
|
||||
if(puiBuffers[i] && alIsDatabufferEXT(puiBuffers[i]))
|
||||
{
|
||||
ALdatabuffer **list = &device->Databuffers;
|
||||
|
||||
ALBuf = (ALdatabuffer*)ALTHUNK_LOOKUPENTRY(puiBuffers[i]);
|
||||
while(*list && *list != ALBuf)
|
||||
list = &(*list)->next;
|
||||
|
||||
if(*list)
|
||||
*list = (*list)->next;
|
||||
|
||||
if(ALBuf == Context->SampleSource)
|
||||
Context->SampleSource = NULL;
|
||||
if(ALBuf == Context->SampleSink)
|
||||
Context->SampleSink = NULL;
|
||||
|
||||
// Release the memory used to store audio data
|
||||
free(ALBuf->data);
|
||||
|
||||
// Release buffer structure
|
||||
ALTHUNK_REMOVEENTRY(puiBuffers[i]);
|
||||
memset(ALBuf, 0, sizeof(ALdatabuffer));
|
||||
device->DatabufferCount--;
|
||||
free(ALBuf);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
alSetError(AL_INVALID_VALUE);
|
||||
|
||||
ProcessContext(Context);
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* alIsDatabufferEXT(ALuint uiBuffer)
|
||||
*
|
||||
* Checks if ulBuffer is a valid Databuffer Name
|
||||
*/
|
||||
ALboolean ALAPIENTRY alIsDatabufferEXT(ALuint uiBuffer)
|
||||
{
|
||||
ALCcontext *Context;
|
||||
ALdatabuffer *ALBuf;
|
||||
|
||||
Context = GetContextSuspended();
|
||||
if(!Context) return AL_FALSE;
|
||||
|
||||
/* Check through list of generated databuffers for uiBuffer */
|
||||
ALBuf = Context->Device->Databuffers;
|
||||
while(ALBuf && ALBuf->databuffer != uiBuffer)
|
||||
ALBuf = ALBuf->next;
|
||||
|
||||
ProcessContext(Context);
|
||||
|
||||
return ((ALBuf || !uiBuffer) ? AL_TRUE : AL_FALSE);
|
||||
}
|
||||
|
||||
/*
|
||||
* alDatabufferDataEXT(ALuint buffer,ALvoid *data,ALsizei size,ALenum usage)
|
||||
*
|
||||
* Fill databuffer with data
|
||||
*/
|
||||
ALvoid ALAPIENTRY alDatabufferDataEXT(ALuint buffer,const ALvoid *data,ALsizei size,ALenum usage)
|
||||
{
|
||||
ALCcontext *Context;
|
||||
ALdatabuffer *ALBuf;
|
||||
ALvoid *temp;
|
||||
|
||||
Context = GetContextSuspended();
|
||||
if(!Context) return;
|
||||
|
||||
if(alIsDatabufferEXT(buffer) && buffer != 0)
|
||||
{
|
||||
ALBuf = (ALdatabuffer*)ALTHUNK_LOOKUPENTRY(buffer);
|
||||
if(ALBuf->state == UNMAPPED)
|
||||
{
|
||||
if(usage == AL_STREAM_WRITE_EXT || usage == AL_STREAM_READ_EXT ||
|
||||
usage == AL_STREAM_COPY_EXT || usage == AL_STATIC_WRITE_EXT ||
|
||||
usage == AL_STATIC_READ_EXT || usage == AL_STATIC_COPY_EXT ||
|
||||
usage == AL_DYNAMIC_WRITE_EXT || usage == AL_DYNAMIC_READ_EXT ||
|
||||
usage == AL_DYNAMIC_COPY_EXT)
|
||||
{
|
||||
/* (Re)allocate data */
|
||||
temp = realloc(ALBuf->data, size);
|
||||
if(temp)
|
||||
{
|
||||
ALBuf->data = temp;
|
||||
ALBuf->size = size;
|
||||
ALBuf->usage = usage;
|
||||
if(data)
|
||||
memcpy(ALBuf->data, data, size);
|
||||
}
|
||||
else
|
||||
alSetError(AL_OUT_OF_MEMORY);
|
||||
}
|
||||
else
|
||||
alSetError(AL_INVALID_ENUM);
|
||||
}
|
||||
else
|
||||
alSetError(AL_INVALID_OPERATION);
|
||||
}
|
||||
else
|
||||
alSetError(AL_INVALID_NAME);
|
||||
|
||||
ProcessContext(Context);
|
||||
}
|
||||
|
||||
ALvoid ALAPIENTRY alDatabufferSubDataEXT(ALuint uiBuffer, ALuint start, ALsizei length, const ALvoid *data)
|
||||
{
|
||||
ALCcontext *pContext;
|
||||
ALdatabuffer *pBuffer;
|
||||
|
||||
pContext = GetContextSuspended();
|
||||
if(!pContext) return;
|
||||
|
||||
if(alIsDatabufferEXT(uiBuffer) && uiBuffer != 0)
|
||||
{
|
||||
pBuffer = (ALdatabuffer*)ALTHUNK_LOOKUPENTRY(uiBuffer);
|
||||
|
||||
if(length >= 0 && start+length <= pBuffer->size)
|
||||
{
|
||||
if(pBuffer->state == UNMAPPED)
|
||||
memcpy(pBuffer->data+start, data, length);
|
||||
else
|
||||
alSetError(AL_INVALID_OPERATION);
|
||||
}
|
||||
else
|
||||
alSetError(AL_INVALID_VALUE);
|
||||
}
|
||||
else
|
||||
alSetError(AL_INVALID_NAME);
|
||||
|
||||
ProcessContext(pContext);
|
||||
}
|
||||
|
||||
ALvoid ALAPIENTRY alGetDatabufferSubDataEXT(ALuint uiBuffer, ALuint start, ALsizei length, ALvoid *data)
|
||||
{
|
||||
ALCcontext *pContext;
|
||||
ALdatabuffer *pBuffer;
|
||||
|
||||
pContext = GetContextSuspended();
|
||||
if(!pContext) return;
|
||||
|
||||
if(alIsDatabufferEXT(uiBuffer) && uiBuffer != 0)
|
||||
{
|
||||
pBuffer = (ALdatabuffer*)ALTHUNK_LOOKUPENTRY(uiBuffer);
|
||||
|
||||
if(length >= 0 && start+length <= pBuffer->size)
|
||||
{
|
||||
if(pBuffer->state == UNMAPPED)
|
||||
memcpy(data, pBuffer->data+start, length);
|
||||
else
|
||||
alSetError(AL_INVALID_OPERATION);
|
||||
}
|
||||
else
|
||||
alSetError(AL_INVALID_VALUE);
|
||||
}
|
||||
else
|
||||
alSetError(AL_INVALID_NAME);
|
||||
|
||||
ProcessContext(pContext);
|
||||
}
|
||||
|
||||
|
||||
ALvoid ALAPIENTRY alDatabufferfEXT(ALuint buffer, ALenum eParam, ALfloat flValue)
|
||||
{
|
||||
ALCcontext *pContext;
|
||||
|
||||
(void)flValue;
|
||||
|
||||
pContext = GetContextSuspended();
|
||||
if(!pContext) return;
|
||||
|
||||
if(alIsDatabufferEXT(buffer) && buffer != 0)
|
||||
{
|
||||
switch(eParam)
|
||||
{
|
||||
default:
|
||||
alSetError(AL_INVALID_ENUM);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
alSetError(AL_INVALID_NAME);
|
||||
|
||||
ProcessContext(pContext);
|
||||
}
|
||||
|
||||
ALvoid ALAPIENTRY alDatabufferfvEXT(ALuint buffer, ALenum eParam, const ALfloat* flValues)
|
||||
{
|
||||
ALCcontext *pContext;
|
||||
|
||||
(void)flValues;
|
||||
|
||||
pContext = GetContextSuspended();
|
||||
if(!pContext) return;
|
||||
|
||||
if(alIsDatabufferEXT(buffer) && buffer != 0)
|
||||
{
|
||||
switch(eParam)
|
||||
{
|
||||
default:
|
||||
alSetError(AL_INVALID_ENUM);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
alSetError(AL_INVALID_NAME);
|
||||
|
||||
ProcessContext(pContext);
|
||||
}
|
||||
|
||||
|
||||
ALvoid ALAPIENTRY alDatabufferiEXT(ALuint buffer, ALenum eParam, ALint lValue)
|
||||
{
|
||||
ALCcontext *pContext;
|
||||
|
||||
(void)lValue;
|
||||
|
||||
pContext = GetContextSuspended();
|
||||
if(!pContext) return;
|
||||
|
||||
if(alIsDatabufferEXT(buffer) && buffer != 0)
|
||||
{
|
||||
switch(eParam)
|
||||
{
|
||||
default:
|
||||
alSetError(AL_INVALID_ENUM);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
alSetError(AL_INVALID_NAME);
|
||||
|
||||
ProcessContext(pContext);
|
||||
}
|
||||
|
||||
ALvoid ALAPIENTRY alDatabufferivEXT(ALuint buffer, ALenum eParam, const ALint* plValues)
|
||||
{
|
||||
ALCcontext *pContext;
|
||||
|
||||
(void)plValues;
|
||||
|
||||
pContext = GetContextSuspended();
|
||||
if(!pContext) return;
|
||||
|
||||
if(alIsDatabufferEXT(buffer) && buffer != 0)
|
||||
{
|
||||
switch(eParam)
|
||||
{
|
||||
default:
|
||||
alSetError(AL_INVALID_ENUM);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
alSetError(AL_INVALID_NAME);
|
||||
|
||||
ProcessContext(pContext);
|
||||
}
|
||||
|
||||
|
||||
ALvoid ALAPIENTRY alGetDatabufferfEXT(ALuint buffer, ALenum eParam, ALfloat *pflValue)
|
||||
{
|
||||
ALCcontext *pContext;
|
||||
|
||||
pContext = GetContextSuspended();
|
||||
if(!pContext) return;
|
||||
|
||||
if(pflValue)
|
||||
{
|
||||
if(alIsDatabufferEXT(buffer) && buffer != 0)
|
||||
{
|
||||
switch(eParam)
|
||||
{
|
||||
default:
|
||||
alSetError(AL_INVALID_ENUM);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
alSetError(AL_INVALID_NAME);
|
||||
}
|
||||
else
|
||||
alSetError(AL_INVALID_VALUE);
|
||||
|
||||
ProcessContext(pContext);
|
||||
}
|
||||
|
||||
ALvoid ALAPIENTRY alGetDatabufferfvEXT(ALuint buffer, ALenum eParam, ALfloat* pflValues)
|
||||
{
|
||||
ALCcontext *pContext;
|
||||
|
||||
pContext = GetContextSuspended();
|
||||
if(!pContext) return;
|
||||
|
||||
if(pflValues)
|
||||
{
|
||||
if(alIsDatabufferEXT(buffer) && buffer != 0)
|
||||
{
|
||||
switch(eParam)
|
||||
{
|
||||
default:
|
||||
alSetError(AL_INVALID_ENUM);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
alSetError(AL_INVALID_NAME);
|
||||
}
|
||||
else
|
||||
alSetError(AL_INVALID_VALUE);
|
||||
|
||||
ProcessContext(pContext);
|
||||
}
|
||||
|
||||
ALvoid ALAPIENTRY alGetDatabufferiEXT(ALuint buffer, ALenum eParam, ALint *plValue)
|
||||
{
|
||||
ALCcontext *pContext;
|
||||
ALdatabuffer *pBuffer;
|
||||
|
||||
pContext = GetContextSuspended();
|
||||
if(!pContext) return;
|
||||
|
||||
if(plValue)
|
||||
{
|
||||
if(alIsDatabufferEXT(buffer) && buffer != 0)
|
||||
{
|
||||
pBuffer = (ALdatabuffer*)ALTHUNK_LOOKUPENTRY(buffer);
|
||||
|
||||
switch(eParam)
|
||||
{
|
||||
case AL_SIZE:
|
||||
*plValue = pBuffer->size;
|
||||
break;
|
||||
|
||||
default:
|
||||
alSetError(AL_INVALID_ENUM);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
alSetError(AL_INVALID_NAME);
|
||||
}
|
||||
else
|
||||
alSetError(AL_INVALID_VALUE);
|
||||
|
||||
ProcessContext(pContext);
|
||||
}
|
||||
|
||||
ALvoid ALAPIENTRY alGetDatabufferivEXT(ALuint buffer, ALenum eParam, ALint* plValues)
|
||||
{
|
||||
ALCcontext *pContext;
|
||||
|
||||
pContext = GetContextSuspended();
|
||||
if(!pContext) return;
|
||||
|
||||
if(plValues)
|
||||
{
|
||||
if(alIsDatabufferEXT(buffer) && buffer != 0)
|
||||
{
|
||||
switch (eParam)
|
||||
{
|
||||
case AL_SIZE:
|
||||
alGetBufferi(buffer, eParam, plValues);
|
||||
break;
|
||||
|
||||
default:
|
||||
alSetError(AL_INVALID_ENUM);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
alSetError(AL_INVALID_NAME);
|
||||
}
|
||||
else
|
||||
alSetError(AL_INVALID_VALUE);
|
||||
|
||||
ProcessContext(pContext);
|
||||
}
|
||||
|
||||
|
||||
ALvoid ALAPIENTRY alSelectDatabufferEXT(ALenum target, ALuint uiBuffer)
|
||||
{
|
||||
ALCcontext *pContext;
|
||||
ALdatabuffer *pBuffer;
|
||||
|
||||
pContext = GetContextSuspended();
|
||||
if(!pContext) return;
|
||||
|
||||
if(alIsDatabufferEXT(uiBuffer))
|
||||
{
|
||||
pBuffer = (ALdatabuffer*)(uiBuffer ? ALTHUNK_LOOKUPENTRY(uiBuffer) : NULL);
|
||||
if(target == AL_SAMPLE_SOURCE_EXT)
|
||||
pContext->SampleSource = pBuffer;
|
||||
else if(target == AL_SAMPLE_SINK_EXT)
|
||||
pContext->SampleSink = pBuffer;
|
||||
else
|
||||
alSetError(AL_INVALID_VALUE);
|
||||
}
|
||||
else
|
||||
alSetError(AL_INVALID_NAME);
|
||||
|
||||
ProcessContext(pContext);
|
||||
}
|
||||
|
||||
|
||||
ALvoid* ALAPIENTRY alMapDatabufferEXT(ALuint uiBuffer, ALuint start, ALsizei length, ALenum access)
|
||||
{
|
||||
ALCcontext *pContext;
|
||||
ALdatabuffer *pBuffer;
|
||||
ALvoid *ret = NULL;
|
||||
|
||||
pContext = GetContextSuspended();
|
||||
if(!pContext) return NULL;
|
||||
|
||||
if(alIsDatabufferEXT(uiBuffer) && uiBuffer != 0)
|
||||
{
|
||||
pBuffer = (ALdatabuffer*)ALTHUNK_LOOKUPENTRY(uiBuffer);
|
||||
|
||||
if(length >= 0 && start+length <= pBuffer->size)
|
||||
{
|
||||
if(access == AL_READ_ONLY_EXT || access == AL_WRITE_ONLY_EXT ||
|
||||
access == AL_READ_WRITE_EXT)
|
||||
{
|
||||
if(pBuffer->state == UNMAPPED)
|
||||
{
|
||||
ret = pBuffer->data + start;
|
||||
pBuffer->state = MAPPED;
|
||||
}
|
||||
else
|
||||
alSetError(AL_INVALID_OPERATION);
|
||||
}
|
||||
else
|
||||
alSetError(AL_INVALID_ENUM);
|
||||
}
|
||||
else
|
||||
alSetError(AL_INVALID_VALUE);
|
||||
}
|
||||
else
|
||||
alSetError(AL_INVALID_NAME);
|
||||
|
||||
ProcessContext(pContext);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
ALvoid ALAPIENTRY alUnmapDatabufferEXT(ALuint uiBuffer)
|
||||
{
|
||||
ALCcontext *pContext;
|
||||
ALdatabuffer *pBuffer;
|
||||
|
||||
pContext = GetContextSuspended();
|
||||
if(!pContext) return;
|
||||
|
||||
if(alIsDatabufferEXT(uiBuffer) && uiBuffer != 0)
|
||||
{
|
||||
pBuffer = (ALdatabuffer*)ALTHUNK_LOOKUPENTRY(uiBuffer);
|
||||
|
||||
if(pBuffer->state == MAPPED)
|
||||
pBuffer->state = UNMAPPED;
|
||||
else
|
||||
alSetError(AL_INVALID_OPERATION);
|
||||
}
|
||||
else
|
||||
alSetError(AL_INVALID_NAME);
|
||||
|
||||
ProcessContext(pContext);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* ReleaseALDatabuffers()
|
||||
*
|
||||
* INTERNAL FN : Called by DLLMain on exit to destroy any buffers that still exist
|
||||
*/
|
||||
ALvoid ReleaseALDatabuffers(ALCdevice *device)
|
||||
{
|
||||
ALdatabuffer *ALBuffer;
|
||||
ALdatabuffer *ALBufferTemp;
|
||||
|
||||
ALBuffer = device->Databuffers;
|
||||
while(ALBuffer)
|
||||
{
|
||||
// Release sample data
|
||||
free(ALBuffer->data);
|
||||
|
||||
// Release Buffer structure
|
||||
ALBufferTemp = ALBuffer;
|
||||
ALBuffer = ALBuffer->next;
|
||||
memset(ALBufferTemp, 0, sizeof(ALdatabuffer));
|
||||
free(ALBufferTemp);
|
||||
}
|
||||
device->Databuffers = NULL;
|
||||
device->DatabufferCount = 0;
|
||||
}
|
||||
+1228
File diff suppressed because it is too large
Load Diff
+18
-21
@@ -18,40 +18,37 @@
|
||||
* Or go to http://www.gnu.org/copyleft/lgpl.html
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "alMain.h"
|
||||
#include "AL/alc.h"
|
||||
#include "alError.h"
|
||||
|
||||
ALAPI ALenum ALAPIENTRY alGetError(ALvoid)
|
||||
{
|
||||
ALCcontext *Context;
|
||||
ALenum errorCode;
|
||||
ALCcontext *Context;
|
||||
ALenum errorCode;
|
||||
|
||||
Context = alcGetCurrentContext();
|
||||
SuspendContext(Context);
|
||||
Context = GetContextSuspended();
|
||||
if(!Context) return AL_INVALID_OPERATION;
|
||||
|
||||
if (Context)
|
||||
{
|
||||
errorCode = Context->LastError;
|
||||
Context->LastError = AL_NO_ERROR;
|
||||
}
|
||||
else
|
||||
errorCode = AL_INVALID_OPERATION;
|
||||
errorCode = Context->LastError;
|
||||
Context->LastError = AL_NO_ERROR;
|
||||
|
||||
ProcessContext(Context);
|
||||
ProcessContext(Context);
|
||||
|
||||
return errorCode;
|
||||
return errorCode;
|
||||
}
|
||||
|
||||
ALvoid alSetError(ALenum errorCode)
|
||||
{
|
||||
ALCcontext *Context;
|
||||
ALCcontext *Context;
|
||||
|
||||
Context=alcGetCurrentContext();
|
||||
SuspendContext(Context);
|
||||
|
||||
if (Context && Context->LastError == AL_NO_ERROR)
|
||||
Context->LastError = errorCode;
|
||||
|
||||
ProcessContext(Context);
|
||||
Context = GetContextSuspended();
|
||||
if(Context)
|
||||
{
|
||||
if(Context->LastError == AL_NO_ERROR)
|
||||
Context->LastError = errorCode;
|
||||
ProcessContext(Context);
|
||||
}
|
||||
}
|
||||
|
||||
+155
-26
@@ -18,12 +18,20 @@
|
||||
* Or go to http://www.gnu.org/copyleft/lgpl.html
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include "alExtension.h"
|
||||
#include "alError.h"
|
||||
#include "alMain.h"
|
||||
#include "alFilter.h"
|
||||
#include "alEffect.h"
|
||||
#include "alAuxEffectSlot.h"
|
||||
#include "alDatabuffer.h"
|
||||
#include "alSource.h"
|
||||
#include "alBuffer.h"
|
||||
#include "AL/al.h"
|
||||
#include "AL/alc.h"
|
||||
|
||||
@@ -101,6 +109,63 @@ static ALfunction function[]= {
|
||||
{ "alDopplerVelocity", (ALvoid *) alDopplerVelocity },
|
||||
{ "alSpeedOfSound", (ALvoid *) alSpeedOfSound },
|
||||
{ "alDistanceModel", (ALvoid *) alDistanceModel },
|
||||
|
||||
{ "alGenFilters", (ALvoid *) alGenFilters },
|
||||
{ "alDeleteFilters", (ALvoid *) alDeleteFilters },
|
||||
{ "alIsFilter", (ALvoid *) alIsFilter },
|
||||
{ "alFilteri", (ALvoid *) alFilteri },
|
||||
{ "alFilteriv", (ALvoid *) alFilteriv },
|
||||
{ "alFilterf", (ALvoid *) alFilterf },
|
||||
{ "alFilterfv", (ALvoid *) alFilterfv },
|
||||
{ "alGetFilteri", (ALvoid *) alGetFilteri },
|
||||
{ "alGetFilteriv", (ALvoid *) alGetFilteriv },
|
||||
{ "alGetFilterf", (ALvoid *) alGetFilterf },
|
||||
{ "alGetFilterfv", (ALvoid *) alGetFilterfv },
|
||||
|
||||
{ "alGenEffects", (ALvoid *) alGenEffects },
|
||||
{ "alDeleteEffects", (ALvoid *) alDeleteEffects },
|
||||
{ "alIsEffect", (ALvoid *) alIsEffect },
|
||||
{ "alEffecti", (ALvoid *) alEffecti },
|
||||
{ "alEffectiv", (ALvoid *) alEffectiv },
|
||||
{ "alEffectf", (ALvoid *) alEffectf },
|
||||
{ "alEffectfv", (ALvoid *) alEffectfv },
|
||||
{ "alGetEffecti", (ALvoid *) alGetEffecti },
|
||||
{ "alGetEffectiv", (ALvoid *) alGetEffectiv },
|
||||
{ "alGetEffectf", (ALvoid *) alGetEffectf },
|
||||
{ "alGetEffectfv", (ALvoid *) alGetEffectfv },
|
||||
|
||||
{ "alGenAuxiliaryEffectSlots", (ALvoid *) alGenAuxiliaryEffectSlots },
|
||||
{ "alDeleteAuxiliaryEffectSlots",(ALvoid *) alDeleteAuxiliaryEffectSlots},
|
||||
{ "alIsAuxiliaryEffectSlot", (ALvoid *) alIsAuxiliaryEffectSlot },
|
||||
{ "alAuxiliaryEffectSloti", (ALvoid *) alAuxiliaryEffectSloti },
|
||||
{ "alAuxiliaryEffectSlotiv", (ALvoid *) alAuxiliaryEffectSlotiv },
|
||||
{ "alAuxiliaryEffectSlotf", (ALvoid *) alAuxiliaryEffectSlotf },
|
||||
{ "alAuxiliaryEffectSlotfv", (ALvoid *) alAuxiliaryEffectSlotfv },
|
||||
{ "alGetAuxiliaryEffectSloti", (ALvoid *) alGetAuxiliaryEffectSloti },
|
||||
{ "alGetAuxiliaryEffectSlotiv", (ALvoid *) alGetAuxiliaryEffectSlotiv},
|
||||
{ "alGetAuxiliaryEffectSlotf", (ALvoid *) alGetAuxiliaryEffectSlotf },
|
||||
{ "alGetAuxiliaryEffectSlotfv", (ALvoid *) alGetAuxiliaryEffectSlotfv},
|
||||
|
||||
{ "alBufferSubDataEXT", (ALvoid *) alBufferSubDataEXT },
|
||||
|
||||
{ "alGenDatabuffersEXT", (ALvoid *) alGenDatabuffersEXT },
|
||||
{ "alDeleteDatabuffersEXT", (ALvoid *) alDeleteDatabuffersEXT },
|
||||
{ "alIsDatabufferEXT", (ALvoid *) alIsDatabufferEXT },
|
||||
{ "alDatabufferDataEXT", (ALvoid *) alDatabufferDataEXT },
|
||||
{ "alDatabufferSubDataEXT", (ALvoid *) alDatabufferSubDataEXT },
|
||||
{ "alGetDatabufferSubDataEXT", (ALvoid *) alGetDatabufferSubDataEXT },
|
||||
{ "alDatabufferfEXT", (ALvoid *) alDatabufferfEXT },
|
||||
{ "alDatabufferfvEXT", (ALvoid *) alDatabufferfvEXT },
|
||||
{ "alDatabufferiEXT", (ALvoid *) alDatabufferiEXT },
|
||||
{ "alDatabufferivEXT", (ALvoid *) alDatabufferivEXT },
|
||||
{ "alGetDatabufferfEXT", (ALvoid *) alGetDatabufferfEXT },
|
||||
{ "alGetDatabufferfvEXT", (ALvoid *) alGetDatabufferfvEXT },
|
||||
{ "alGetDatabufferiEXT", (ALvoid *) alGetDatabufferiEXT },
|
||||
{ "alGetDatabufferivEXT", (ALvoid *) alGetDatabufferivEXT },
|
||||
{ "alSelectDatabufferEXT", (ALvoid *) alSelectDatabufferEXT },
|
||||
{ "alMapDatabufferEXT", (ALvoid *) alMapDatabufferEXT },
|
||||
{ "alUnmapDatabufferEXT", (ALvoid *) alUnmapDatabufferEXT },
|
||||
|
||||
{ NULL, (ALvoid *) NULL } };
|
||||
|
||||
static ALenums enumeration[]={
|
||||
@@ -135,6 +200,18 @@ static ALenums enumeration[]={
|
||||
{ (ALchar *)"AL_STATIC", AL_STATIC },
|
||||
{ (ALchar *)"AL_STREAMING", AL_STREAMING },
|
||||
{ (ALchar *)"AL_UNDETERMINED", AL_UNDETERMINED },
|
||||
{ (ALchar *)"AL_METERS_PER_UNIT", AL_METERS_PER_UNIT },
|
||||
|
||||
// Source EFX Properties
|
||||
{ (ALchar *)"AL_DIRECT_FILTER", AL_DIRECT_FILTER },
|
||||
{ (ALchar *)"AL_AUXILIARY_SEND_FILTER", AL_AUXILIARY_SEND_FILTER },
|
||||
{ (ALchar *)"AL_AIR_ABSORPTION_FACTOR", AL_AIR_ABSORPTION_FACTOR },
|
||||
{ (ALchar *)"AL_ROOM_ROLLOFF_FACTOR", AL_ROOM_ROLLOFF_FACTOR },
|
||||
{ (ALchar *)"AL_CONE_OUTER_GAINHF", AL_CONE_OUTER_GAINHF },
|
||||
{ (ALchar *)"AL_DIRECT_FILTER_GAINHF_AUTO", AL_DIRECT_FILTER_GAINHF_AUTO },
|
||||
{ (ALchar *)"AL_AUXILIARY_SEND_FILTER_GAIN_AUTO", AL_AUXILIARY_SEND_FILTER_GAIN_AUTO },
|
||||
{ (ALchar *)"AL_AUXILIARY_SEND_FILTER_GAINHF_AUTO", AL_AUXILIARY_SEND_FILTER_GAINHF_AUTO},
|
||||
|
||||
|
||||
// Source State information
|
||||
{ (ALchar *)"AL_SOURCE_STATE", AL_SOURCE_STATE },
|
||||
@@ -150,12 +227,29 @@ static ALenums enumeration[]={
|
||||
// Buffer Formats
|
||||
{ (ALchar *)"AL_FORMAT_MONO8", AL_FORMAT_MONO8 },
|
||||
{ (ALchar *)"AL_FORMAT_MONO16", AL_FORMAT_MONO16 },
|
||||
{ (ALchar *)"AL_FORMAT_MONO_FLOAT32", AL_FORMAT_MONO_FLOAT32 },
|
||||
{ (ALchar *)"AL_FORMAT_STEREO8", AL_FORMAT_STEREO8 },
|
||||
{ (ALchar *)"AL_FORMAT_STEREO16", AL_FORMAT_STEREO16 },
|
||||
{ (ALchar *)"AL_FORMAT_STEREO_FLOAT32", AL_FORMAT_STEREO_FLOAT32 },
|
||||
{ (ALchar *)"AL_FORMAT_MONO_IMA4", AL_FORMAT_MONO_IMA4 },
|
||||
{ (ALchar *)"AL_FORMAT_STEREO_IMA4", AL_FORMAT_STEREO_IMA4 },
|
||||
{ (ALchar *)"AL_FORMAT_QUAD8_LOKI", AL_FORMAT_QUAD8_LOKI },
|
||||
{ (ALchar *)"AL_FORMAT_QUAD16_LOKI", AL_FORMAT_QUAD16_LOKI },
|
||||
{ (ALchar *)"AL_FORMAT_QUAD8", AL_FORMAT_QUAD8 },
|
||||
{ (ALchar *)"AL_FORMAT_QUAD16", AL_FORMAT_QUAD16 },
|
||||
{ (ALchar *)"AL_FORMAT_QUAD32", AL_FORMAT_QUAD32 },
|
||||
{ (ALchar *)"AL_FORMAT_51CHN8", AL_FORMAT_51CHN8 },
|
||||
{ (ALchar *)"AL_FORMAT_51CHN16", AL_FORMAT_51CHN16 },
|
||||
{ (ALchar *)"AL_FORMAT_51CHN32", AL_FORMAT_51CHN32 },
|
||||
{ (ALchar *)"AL_FORMAT_61CHN8", AL_FORMAT_61CHN8 },
|
||||
{ (ALchar *)"AL_FORMAT_61CHN16", AL_FORMAT_61CHN16 },
|
||||
{ (ALchar *)"AL_FORMAT_61CHN32", AL_FORMAT_61CHN32 },
|
||||
{ (ALchar *)"AL_FORMAT_71CHN8", AL_FORMAT_71CHN8 },
|
||||
{ (ALchar *)"AL_FORMAT_71CHN16", AL_FORMAT_71CHN16 },
|
||||
{ (ALchar *)"AL_FORMAT_71CHN32", AL_FORMAT_71CHN32 },
|
||||
{ (ALchar *)"AL_FORMAT_REAR8", AL_FORMAT_REAR8 },
|
||||
{ (ALchar *)"AL_FORMAT_REAR16", AL_FORMAT_REAR16 },
|
||||
{ (ALchar *)"AL_FORMAT_REAR32", AL_FORMAT_REAR32 },
|
||||
|
||||
// Buffer attributes
|
||||
{ (ALchar *)"AL_FREQUENCY", AL_FREQUENCY },
|
||||
@@ -196,8 +290,52 @@ static ALenums enumeration[]={
|
||||
{ (ALchar *)"AL_EXPONENT_DISTANCE", AL_EXPONENT_DISTANCE },
|
||||
{ (ALchar *)"AL_EXPONENT_DISTANCE_CLAMPED", AL_EXPONENT_DISTANCE_CLAMPED },
|
||||
|
||||
// Filter types
|
||||
{ (ALchar *)"AL_FILTER_TYPE", AL_FILTER_TYPE },
|
||||
{ (ALchar *)"AL_FILTER_NULL", AL_FILTER_NULL },
|
||||
{ (ALchar *)"AL_FILTER_LOWPASS", AL_FILTER_LOWPASS },
|
||||
{ (ALchar *)"AL_FILTER_HIGHPASS", AL_FILTER_HIGHPASS },
|
||||
{ (ALchar *)"AL_FILTER_BANDPASS", AL_FILTER_BANDPASS },
|
||||
|
||||
// Filter params
|
||||
{ (ALchar *)"AL_LOWPASS_GAIN", AL_LOWPASS_GAIN },
|
||||
{ (ALchar *)"AL_LOWPASS_GAINHF", AL_LOWPASS_GAINHF },
|
||||
|
||||
// Effect types
|
||||
{ (ALchar *)"AL_EFFECT_TYPE", AL_EFFECT_TYPE },
|
||||
{ (ALchar *)"AL_EFFECT_NULL", AL_EFFECT_NULL },
|
||||
{ (ALchar *)"AL_EFFECT_REVERB", AL_EFFECT_REVERB },
|
||||
{ (ALchar *)"AL_EFFECT_CHORUS", AL_EFFECT_CHORUS },
|
||||
{ (ALchar *)"AL_EFFECT_DISTORTION", AL_EFFECT_DISTORTION },
|
||||
{ (ALchar *)"AL_EFFECT_ECHO", AL_EFFECT_ECHO },
|
||||
{ (ALchar *)"AL_EFFECT_FLANGER", AL_EFFECT_FLANGER },
|
||||
{ (ALchar *)"AL_EFFECT_FREQUENCY_SHIFTER", AL_EFFECT_FREQUENCY_SHIFTER },
|
||||
{ (ALchar *)"AL_EFFECT_VOCAL_MORPHER", AL_EFFECT_VOCAL_MORPHER },
|
||||
{ (ALchar *)"AL_EFFECT_PITCH_SHIFTER", AL_EFFECT_PITCH_SHIFTER },
|
||||
{ (ALchar *)"AL_EFFECT_RING_MODULATOR", AL_EFFECT_RING_MODULATOR },
|
||||
{ (ALchar *)"AL_EFFECT_AUTOWAH", AL_EFFECT_AUTOWAH },
|
||||
{ (ALchar *)"AL_EFFECT_COMPRESSOR", AL_EFFECT_COMPRESSOR },
|
||||
{ (ALchar *)"AL_EFFECT_EQUALIZER", AL_EFFECT_EQUALIZER },
|
||||
|
||||
// Reverb params
|
||||
{ (ALchar *)"AL_REVERB_DENSITY", AL_REVERB_DENSITY },
|
||||
{ (ALchar *)"AL_REVERB_DIFFUSION", AL_REVERB_DIFFUSION },
|
||||
{ (ALchar *)"AL_REVERB_GAIN", AL_REVERB_GAIN },
|
||||
{ (ALchar *)"AL_REVERB_GAINHF", AL_REVERB_GAINHF },
|
||||
{ (ALchar *)"AL_REVERB_DECAY_TIME", AL_REVERB_DECAY_TIME },
|
||||
{ (ALchar *)"AL_REVERB_DECAY_HFRATIO", AL_REVERB_DECAY_HFRATIO },
|
||||
{ (ALchar *)"AL_REVERB_REFLECTIONS_GAIN", AL_REVERB_REFLECTIONS_GAIN },
|
||||
{ (ALchar *)"AL_REVERB_REFLECTIONS_DELAY", AL_REVERB_REFLECTIONS_DELAY },
|
||||
{ (ALchar *)"AL_REVERB_LATE_REVERB_GAIN", AL_REVERB_LATE_REVERB_GAIN },
|
||||
{ (ALchar *)"AL_REVERB_LATE_REVERB_DELAY", AL_REVERB_LATE_REVERB_DELAY },
|
||||
{ (ALchar *)"AL_REVERB_AIR_ABSORPTION_GAINHF", AL_REVERB_AIR_ABSORPTION_GAINHF },
|
||||
{ (ALchar *)"AL_REVERB_ROOM_ROLLOFF_FACTOR", AL_REVERB_ROOM_ROLLOFF_FACTOR },
|
||||
{ (ALchar *)"AL_REVERB_DECAY_HFLIMIT", AL_REVERB_DECAY_HFLIMIT },
|
||||
|
||||
|
||||
// Default
|
||||
{ (ALchar *)NULL, (ALenum ) 0 } };
|
||||
{ (ALchar *)NULL, (ALenum)0 }
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -205,7 +343,8 @@ ALAPI ALboolean ALAPIENTRY alIsExtensionPresent(const ALchar *extName)
|
||||
{
|
||||
ALboolean bIsSupported = AL_FALSE;
|
||||
ALCcontext *pContext;
|
||||
char *ptr, *ext;
|
||||
const char *ptr;
|
||||
size_t len;
|
||||
|
||||
if (!extName)
|
||||
{
|
||||
@@ -213,39 +352,29 @@ ALAPI ALboolean ALAPIENTRY alIsExtensionPresent(const ALchar *extName)
|
||||
return AL_FALSE;
|
||||
}
|
||||
|
||||
pContext = alcGetCurrentContext();
|
||||
if(!pContext)
|
||||
{
|
||||
alSetError(AL_INVALID_OPERATION);
|
||||
return AL_FALSE;
|
||||
}
|
||||
|
||||
ext = strdup(extName);
|
||||
ptr = ext;
|
||||
do {
|
||||
*ptr = (char)toupper(*ptr);
|
||||
} while(*(ptr++));
|
||||
|
||||
SuspendContext(pContext);
|
||||
pContext = GetContextSuspended();
|
||||
if(!pContext) return AL_FALSE;
|
||||
|
||||
len = strlen(extName);
|
||||
ptr = pContext->ExtensionList;
|
||||
while((ptr=strstr(ptr, ext)) != NULL)
|
||||
while(ptr && *ptr)
|
||||
{
|
||||
if(ptr == pContext->ExtensionList || ptr[-1] == ' ')
|
||||
if(strncasecmp(ptr, extName, len) == 0 &&
|
||||
(ptr[len] == '\0' || isspace(ptr[len])))
|
||||
{
|
||||
char e = ptr[strlen(ext)];
|
||||
if(e == ' ' || e == 0)
|
||||
{
|
||||
bIsSupported = AL_TRUE;
|
||||
break;
|
||||
}
|
||||
bIsSupported = AL_TRUE;
|
||||
break;
|
||||
}
|
||||
if((ptr=strchr(ptr, ' ')) != NULL)
|
||||
{
|
||||
do {
|
||||
++ptr;
|
||||
} while(isspace(*ptr));
|
||||
}
|
||||
ptr++;
|
||||
}
|
||||
|
||||
ProcessContext(pContext);
|
||||
|
||||
free(ext);
|
||||
return bIsSupported;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,425 @@
|
||||
/**
|
||||
* OpenAL cross platform audio library
|
||||
* Copyright (C) 1999-2007 by authors.
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* 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
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
* Or go to http://www.gnu.org/copyleft/lgpl.html
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "AL/al.h"
|
||||
#include "AL/alc.h"
|
||||
#include "alMain.h"
|
||||
#include "alFilter.h"
|
||||
#include "alThunk.h"
|
||||
#include "alError.h"
|
||||
|
||||
|
||||
static void InitFilterParams(ALfilter *filter, ALenum type);
|
||||
|
||||
|
||||
ALvoid AL_APIENTRY alGenFilters(ALsizei n, ALuint *filters)
|
||||
{
|
||||
ALCcontext *Context;
|
||||
ALsizei i;
|
||||
|
||||
Context = GetContextSuspended();
|
||||
if(!Context) return;
|
||||
|
||||
if (n > 0)
|
||||
{
|
||||
ALCdevice *device = Context->Device;
|
||||
|
||||
// Check that enough memory has been allocted in the 'filters' array for n Filters
|
||||
if (!IsBadWritePtr((void*)filters, n * sizeof(ALuint)))
|
||||
{
|
||||
ALfilter **list = &device->FilterList;
|
||||
while(*list)
|
||||
list = &(*list)->next;
|
||||
|
||||
i = 0;
|
||||
while(i < n)
|
||||
{
|
||||
*list = calloc(1, sizeof(ALfilter));
|
||||
if(!(*list))
|
||||
{
|
||||
// We must have run out or memory
|
||||
alDeleteFilters(i, filters);
|
||||
alSetError(AL_OUT_OF_MEMORY);
|
||||
break;
|
||||
}
|
||||
|
||||
filters[i] = (ALuint)ALTHUNK_ADDENTRY(*list);
|
||||
(*list)->filter = filters[i];
|
||||
|
||||
InitFilterParams(*list, AL_FILTER_NULL);
|
||||
device->FilterCount++;
|
||||
i++;
|
||||
|
||||
list = &(*list)->next;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ProcessContext(Context);
|
||||
}
|
||||
|
||||
ALvoid AL_APIENTRY alDeleteFilters(ALsizei n, ALuint *filters)
|
||||
{
|
||||
ALCcontext *Context;
|
||||
ALfilter *ALFilter;
|
||||
ALsizei i;
|
||||
|
||||
Context = GetContextSuspended();
|
||||
if(!Context) return;
|
||||
|
||||
if (n >= 0)
|
||||
{
|
||||
ALCdevice *device = Context->Device;
|
||||
|
||||
// Check that all filters are valid
|
||||
for (i = 0; i < n; i++)
|
||||
{
|
||||
if (!alIsFilter(filters[i]))
|
||||
{
|
||||
alSetError(AL_INVALID_NAME);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (i == n)
|
||||
{
|
||||
// All filters are valid
|
||||
for (i = 0; i < n; i++)
|
||||
{
|
||||
// Recheck that the filter is valid, because there could be duplicated names
|
||||
if (filters[i] && alIsFilter(filters[i]))
|
||||
{
|
||||
ALfilter **list;
|
||||
|
||||
ALFilter = ((ALfilter*)ALTHUNK_LOOKUPENTRY(filters[i]));
|
||||
|
||||
// Remove Source from list of Sources
|
||||
list = &device->FilterList;
|
||||
while(*list && *list != ALFilter)
|
||||
list = &(*list)->next;
|
||||
|
||||
if(*list)
|
||||
*list = (*list)->next;
|
||||
ALTHUNK_REMOVEENTRY(ALFilter->filter);
|
||||
|
||||
memset(ALFilter, 0, sizeof(ALfilter));
|
||||
free(ALFilter);
|
||||
|
||||
device->FilterCount--;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
alSetError(AL_INVALID_VALUE);
|
||||
|
||||
ProcessContext(Context);
|
||||
}
|
||||
|
||||
ALboolean AL_APIENTRY alIsFilter(ALuint filter)
|
||||
{
|
||||
ALCcontext *Context;
|
||||
ALfilter *list;
|
||||
|
||||
Context = GetContextSuspended();
|
||||
if(!Context) return AL_FALSE;
|
||||
|
||||
list = Context->Device->FilterList;
|
||||
while(list && list->filter != filter)
|
||||
list = list->next;
|
||||
|
||||
ProcessContext(Context);
|
||||
|
||||
return ((list || !filter) ? AL_TRUE : AL_FALSE);
|
||||
}
|
||||
|
||||
ALvoid AL_APIENTRY alFilteri(ALuint filter, ALenum param, ALint iValue)
|
||||
{
|
||||
ALCcontext *Context;
|
||||
|
||||
Context = GetContextSuspended();
|
||||
if(!Context) return;
|
||||
|
||||
if (filter && alIsFilter(filter))
|
||||
{
|
||||
ALfilter *ALFilter = (ALfilter*)ALTHUNK_LOOKUPENTRY(filter);
|
||||
|
||||
switch(param)
|
||||
{
|
||||
case AL_FILTER_TYPE:
|
||||
if(iValue == AL_FILTER_NULL ||
|
||||
iValue == AL_FILTER_LOWPASS)
|
||||
InitFilterParams(ALFilter, iValue);
|
||||
else
|
||||
alSetError(AL_INVALID_VALUE);
|
||||
break;
|
||||
|
||||
default:
|
||||
alSetError(AL_INVALID_ENUM);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
alSetError(AL_INVALID_NAME);
|
||||
|
||||
ProcessContext(Context);
|
||||
}
|
||||
|
||||
ALvoid AL_APIENTRY alFilteriv(ALuint filter, ALenum param, ALint *piValues)
|
||||
{
|
||||
ALCcontext *Context;
|
||||
|
||||
Context = GetContextSuspended();
|
||||
if(!Context) return;
|
||||
|
||||
if (filter && alIsFilter(filter))
|
||||
{
|
||||
switch(param)
|
||||
{
|
||||
case AL_FILTER_TYPE:
|
||||
alFilteri(filter, param, piValues[0]);
|
||||
break;
|
||||
|
||||
default:
|
||||
alSetError(AL_INVALID_ENUM);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
alSetError(AL_INVALID_NAME);
|
||||
|
||||
ProcessContext(Context);
|
||||
}
|
||||
|
||||
ALvoid AL_APIENTRY alFilterf(ALuint filter, ALenum param, ALfloat flValue)
|
||||
{
|
||||
ALCcontext *Context;
|
||||
|
||||
Context = GetContextSuspended();
|
||||
if(!Context) return;
|
||||
|
||||
if (filter && alIsFilter(filter))
|
||||
{
|
||||
ALfilter *ALFilter = (ALfilter*)ALTHUNK_LOOKUPENTRY(filter);
|
||||
|
||||
switch(ALFilter->type)
|
||||
{
|
||||
case AL_FILTER_LOWPASS:
|
||||
switch(param)
|
||||
{
|
||||
case AL_LOWPASS_GAIN:
|
||||
if(flValue >= 0.0f && flValue <= 1.0f)
|
||||
ALFilter->Gain = flValue;
|
||||
else
|
||||
alSetError(AL_INVALID_VALUE);
|
||||
break;
|
||||
|
||||
case AL_LOWPASS_GAINHF:
|
||||
if(flValue >= 0.0f && flValue <= 1.0f)
|
||||
ALFilter->GainHF = flValue;
|
||||
else
|
||||
alSetError(AL_INVALID_VALUE);
|
||||
break;
|
||||
|
||||
default:
|
||||
alSetError(AL_INVALID_ENUM);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
alSetError(AL_INVALID_ENUM);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
alSetError(AL_INVALID_NAME);
|
||||
|
||||
ProcessContext(Context);
|
||||
}
|
||||
|
||||
ALvoid AL_APIENTRY alFilterfv(ALuint filter, ALenum param, ALfloat *pflValues)
|
||||
{
|
||||
ALCcontext *Context;
|
||||
|
||||
Context = GetContextSuspended();
|
||||
if(!Context) return;
|
||||
|
||||
if (filter && alIsFilter(filter))
|
||||
{
|
||||
switch(param)
|
||||
{
|
||||
default:
|
||||
alFilterf(filter, param, pflValues[0]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
alSetError(AL_INVALID_NAME);
|
||||
|
||||
ProcessContext(Context);
|
||||
}
|
||||
|
||||
ALvoid AL_APIENTRY alGetFilteri(ALuint filter, ALenum param, ALint *piValue)
|
||||
{
|
||||
ALCcontext *Context;
|
||||
|
||||
Context = GetContextSuspended();
|
||||
if(!Context) return;
|
||||
|
||||
if (filter && alIsFilter(filter))
|
||||
{
|
||||
ALfilter *ALFilter = (ALfilter*)ALTHUNK_LOOKUPENTRY(filter);
|
||||
|
||||
switch(param)
|
||||
{
|
||||
case AL_FILTER_TYPE:
|
||||
*piValue = ALFilter->type;
|
||||
break;
|
||||
|
||||
default:
|
||||
alSetError(AL_INVALID_ENUM);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
alSetError(AL_INVALID_NAME);
|
||||
|
||||
ProcessContext(Context);
|
||||
}
|
||||
|
||||
ALvoid AL_APIENTRY alGetFilteriv(ALuint filter, ALenum param, ALint *piValues)
|
||||
{
|
||||
ALCcontext *Context;
|
||||
|
||||
Context = GetContextSuspended();
|
||||
if(!Context) return;
|
||||
|
||||
if (filter && alIsFilter(filter))
|
||||
{
|
||||
switch(param)
|
||||
{
|
||||
case AL_FILTER_TYPE:
|
||||
alGetFilteri(filter, param, piValues);
|
||||
break;
|
||||
|
||||
default:
|
||||
alSetError(AL_INVALID_ENUM);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
alSetError(AL_INVALID_NAME);
|
||||
|
||||
ProcessContext(Context);
|
||||
}
|
||||
|
||||
ALvoid AL_APIENTRY alGetFilterf(ALuint filter, ALenum param, ALfloat *pflValue)
|
||||
{
|
||||
ALCcontext *Context;
|
||||
|
||||
Context = GetContextSuspended();
|
||||
if(!Context) return;
|
||||
|
||||
if (filter && alIsFilter(filter))
|
||||
{
|
||||
ALfilter *ALFilter = (ALfilter*)ALTHUNK_LOOKUPENTRY(filter);
|
||||
|
||||
switch(ALFilter->type)
|
||||
{
|
||||
case AL_FILTER_LOWPASS:
|
||||
switch(param)
|
||||
{
|
||||
case AL_LOWPASS_GAIN:
|
||||
*pflValue = ALFilter->Gain;
|
||||
break;
|
||||
|
||||
case AL_LOWPASS_GAINHF:
|
||||
*pflValue = ALFilter->GainHF;
|
||||
break;
|
||||
|
||||
default:
|
||||
alSetError(AL_INVALID_ENUM);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
alSetError(AL_INVALID_ENUM);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
alSetError(AL_INVALID_NAME);
|
||||
|
||||
ProcessContext(Context);
|
||||
}
|
||||
|
||||
ALvoid AL_APIENTRY alGetFilterfv(ALuint filter, ALenum param, ALfloat *pflValues)
|
||||
{
|
||||
ALCcontext *Context;
|
||||
|
||||
Context = GetContextSuspended();
|
||||
if(!Context) return;
|
||||
|
||||
if (filter && alIsFilter(filter))
|
||||
{
|
||||
switch(param)
|
||||
{
|
||||
default:
|
||||
alGetFilterf(filter, param, pflValues);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
alSetError(AL_INVALID_NAME);
|
||||
|
||||
ProcessContext(Context);
|
||||
}
|
||||
|
||||
|
||||
ALvoid ReleaseALFilters(ALCdevice *device)
|
||||
{
|
||||
ALfilter *list = device->FilterList;
|
||||
while(list)
|
||||
{
|
||||
ALfilter *temp = list;
|
||||
list = list->next;
|
||||
|
||||
// Release filter structure
|
||||
memset(temp, 0, sizeof(ALfilter));
|
||||
free(temp);
|
||||
}
|
||||
device->FilterList = NULL;
|
||||
device->FilterCount = 0;
|
||||
}
|
||||
|
||||
|
||||
static void InitFilterParams(ALfilter *filter, ALenum type)
|
||||
{
|
||||
filter->type = type;
|
||||
|
||||
filter->Gain = 1.0;
|
||||
filter->GainHF = 1.0;
|
||||
}
|
||||
+102
-162
@@ -18,6 +18,8 @@
|
||||
* Or go to http://www.gnu.org/copyleft/lgpl.html
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "alMain.h"
|
||||
#include "AL/alc.h"
|
||||
#include "alError.h"
|
||||
@@ -27,31 +29,31 @@ ALAPI ALvoid ALAPIENTRY alListenerf(ALenum eParam, ALfloat flValue)
|
||||
{
|
||||
ALCcontext *pContext;
|
||||
|
||||
pContext = alcGetCurrentContext();
|
||||
if (pContext)
|
||||
{
|
||||
SuspendContext(pContext);
|
||||
pContext = GetContextSuspended();
|
||||
if(!pContext) return;
|
||||
|
||||
switch (eParam)
|
||||
{
|
||||
switch(eParam)
|
||||
{
|
||||
case AL_GAIN:
|
||||
if (flValue >= 0.0f)
|
||||
if(flValue >= 0.0f)
|
||||
pContext->Listener.Gain = flValue;
|
||||
else
|
||||
alSetError(AL_INVALID_VALUE);
|
||||
break;
|
||||
|
||||
case AL_METERS_PER_UNIT:
|
||||
if(flValue > 0.0f)
|
||||
pContext->Listener.MetersPerUnit = flValue;
|
||||
else
|
||||
alSetError(AL_INVALID_VALUE);
|
||||
break;
|
||||
|
||||
default:
|
||||
alSetError(AL_INVALID_ENUM);
|
||||
break;
|
||||
}
|
||||
|
||||
ProcessContext(pContext);
|
||||
}
|
||||
else
|
||||
alSetError(AL_INVALID_OPERATION);
|
||||
|
||||
return;
|
||||
ProcessContext(pContext);
|
||||
}
|
||||
|
||||
|
||||
@@ -59,13 +61,11 @@ ALAPI ALvoid ALAPIENTRY alListener3f(ALenum eParam, ALfloat flValue1, ALfloat fl
|
||||
{
|
||||
ALCcontext *pContext;
|
||||
|
||||
pContext = alcGetCurrentContext();
|
||||
if (pContext)
|
||||
{
|
||||
SuspendContext(pContext);
|
||||
pContext = GetContextSuspended();
|
||||
if(!pContext) return;
|
||||
|
||||
switch(eParam)
|
||||
{
|
||||
switch(eParam)
|
||||
{
|
||||
case AL_POSITION:
|
||||
pContext->Listener.Position[0] = flValue1;
|
||||
pContext->Listener.Position[1] = flValue2;
|
||||
@@ -81,14 +81,9 @@ ALAPI ALvoid ALAPIENTRY alListener3f(ALenum eParam, ALfloat flValue1, ALfloat fl
|
||||
default:
|
||||
alSetError(AL_INVALID_ENUM);
|
||||
break;
|
||||
}
|
||||
|
||||
ProcessContext(pContext);
|
||||
}
|
||||
else
|
||||
alSetError(AL_INVALID_OPERATION);
|
||||
|
||||
return;
|
||||
ProcessContext(pContext);
|
||||
}
|
||||
|
||||
|
||||
@@ -96,22 +91,27 @@ ALAPI ALvoid ALAPIENTRY alListenerfv(ALenum eParam, const ALfloat *pflValues)
|
||||
{
|
||||
ALCcontext *pContext;
|
||||
|
||||
pContext = alcGetCurrentContext();
|
||||
if (pContext)
|
||||
{
|
||||
SuspendContext(pContext);
|
||||
pContext = GetContextSuspended();
|
||||
if(!pContext) return;
|
||||
|
||||
if (pflValues)
|
||||
if(pflValues)
|
||||
{
|
||||
switch(eParam)
|
||||
{
|
||||
switch (eParam)
|
||||
{
|
||||
case AL_GAIN:
|
||||
if (pflValues[0] >= 0.0f)
|
||||
if(pflValues[0] >= 0.0f)
|
||||
pContext->Listener.Gain = pflValues[0];
|
||||
else
|
||||
alSetError(AL_INVALID_VALUE);
|
||||
break;
|
||||
|
||||
case AL_METERS_PER_UNIT:
|
||||
if(pflValues[0] > 0.0f)
|
||||
pContext->Listener.MetersPerUnit = pflValues[0];
|
||||
else
|
||||
alSetError(AL_INVALID_VALUE);
|
||||
break;
|
||||
|
||||
case AL_POSITION:
|
||||
pContext->Listener.Position[0] = pflValues[0];
|
||||
pContext->Listener.Position[1] = pflValues[1];
|
||||
@@ -137,17 +137,12 @@ ALAPI ALvoid ALAPIENTRY alListenerfv(ALenum eParam, const ALfloat *pflValues)
|
||||
default:
|
||||
alSetError(AL_INVALID_ENUM);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
alSetError(AL_INVALID_VALUE);
|
||||
|
||||
ProcessContext(pContext);
|
||||
}
|
||||
else
|
||||
alSetError(AL_INVALID_OPERATION);
|
||||
alSetError(AL_INVALID_VALUE);
|
||||
|
||||
return;
|
||||
ProcessContext(pContext);
|
||||
}
|
||||
|
||||
|
||||
@@ -157,24 +152,17 @@ ALAPI ALvoid ALAPIENTRY alListeneri(ALenum eParam, ALint lValue)
|
||||
|
||||
(void)lValue;
|
||||
|
||||
pContext = alcGetCurrentContext();
|
||||
if (pContext)
|
||||
{
|
||||
SuspendContext(pContext);
|
||||
pContext = GetContextSuspended();
|
||||
if(!pContext) return;
|
||||
|
||||
switch (eParam)
|
||||
{
|
||||
switch(eParam)
|
||||
{
|
||||
default:
|
||||
alSetError(AL_INVALID_ENUM);
|
||||
break;
|
||||
}
|
||||
|
||||
ProcessContext(pContext);
|
||||
}
|
||||
else
|
||||
alSetError(AL_INVALID_OPERATION);
|
||||
|
||||
return;
|
||||
ProcessContext(pContext);
|
||||
}
|
||||
|
||||
|
||||
@@ -182,13 +170,11 @@ ALAPI void ALAPIENTRY alListener3i(ALenum eParam, ALint lValue1, ALint lValue2,
|
||||
{
|
||||
ALCcontext *pContext;
|
||||
|
||||
pContext = alcGetCurrentContext();
|
||||
if (pContext)
|
||||
{
|
||||
SuspendContext(pContext);
|
||||
pContext = GetContextSuspended();
|
||||
if(!pContext) return;
|
||||
|
||||
switch(eParam)
|
||||
{
|
||||
switch(eParam)
|
||||
{
|
||||
case AL_POSITION:
|
||||
case AL_VELOCITY:
|
||||
alListener3f(eParam, (ALfloat)lValue1, (ALfloat)lValue2, (ALfloat)lValue3);
|
||||
@@ -197,14 +183,9 @@ ALAPI void ALAPIENTRY alListener3i(ALenum eParam, ALint lValue1, ALint lValue2,
|
||||
default:
|
||||
alSetError(AL_INVALID_ENUM);
|
||||
break;
|
||||
}
|
||||
|
||||
ProcessContext(pContext);
|
||||
}
|
||||
else
|
||||
alSetError(AL_INVALID_OPERATION);
|
||||
|
||||
return;
|
||||
ProcessContext(pContext);
|
||||
}
|
||||
|
||||
|
||||
@@ -213,15 +194,13 @@ ALAPI void ALAPIENTRY alListeneriv( ALenum eParam, const ALint* plValues )
|
||||
ALCcontext *pContext;
|
||||
ALfloat flValues[6];
|
||||
|
||||
pContext = alcGetCurrentContext();
|
||||
if (pContext)
|
||||
{
|
||||
SuspendContext(pContext);
|
||||
pContext = GetContextSuspended();
|
||||
if(!pContext) return;
|
||||
|
||||
if (plValues)
|
||||
if(plValues)
|
||||
{
|
||||
switch(eParam)
|
||||
{
|
||||
switch (eParam)
|
||||
{
|
||||
case AL_POSITION:
|
||||
case AL_VELOCITY:
|
||||
flValues[0] = (ALfloat)plValues[0];
|
||||
@@ -243,17 +222,12 @@ ALAPI void ALAPIENTRY alListeneriv( ALenum eParam, const ALint* plValues )
|
||||
default:
|
||||
alSetError(AL_INVALID_ENUM);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
alSetError(AL_INVALID_VALUE);
|
||||
|
||||
ProcessContext(pContext);
|
||||
}
|
||||
else
|
||||
alSetError(AL_INVALID_OPERATION);
|
||||
alSetError(AL_INVALID_VALUE);
|
||||
|
||||
return;
|
||||
ProcessContext(pContext);
|
||||
}
|
||||
|
||||
|
||||
@@ -261,33 +235,30 @@ ALAPI ALvoid ALAPIENTRY alGetListenerf(ALenum eParam, ALfloat *pflValue)
|
||||
{
|
||||
ALCcontext *pContext;
|
||||
|
||||
pContext = alcGetCurrentContext();
|
||||
if (pContext)
|
||||
{
|
||||
SuspendContext(pContext);
|
||||
pContext = GetContextSuspended();
|
||||
if(!pContext) return;
|
||||
|
||||
if (pflValue)
|
||||
if(pflValue)
|
||||
{
|
||||
switch(eParam)
|
||||
{
|
||||
switch (eParam)
|
||||
{
|
||||
case AL_GAIN:
|
||||
*pflValue = pContext->Listener.Gain;
|
||||
break;
|
||||
|
||||
case AL_METERS_PER_UNIT:
|
||||
*pflValue = pContext->Listener.MetersPerUnit;
|
||||
break;
|
||||
|
||||
default:
|
||||
alSetError(AL_INVALID_ENUM);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
alSetError(AL_INVALID_VALUE);
|
||||
|
||||
ProcessContext(pContext);
|
||||
}
|
||||
else
|
||||
alSetError(AL_INVALID_OPERATION);
|
||||
alSetError(AL_INVALID_VALUE);
|
||||
|
||||
return;
|
||||
ProcessContext(pContext);
|
||||
}
|
||||
|
||||
|
||||
@@ -295,15 +266,13 @@ ALAPI ALvoid ALAPIENTRY alGetListener3f(ALenum eParam, ALfloat *pflValue1, ALflo
|
||||
{
|
||||
ALCcontext *pContext;
|
||||
|
||||
pContext = alcGetCurrentContext();
|
||||
if (pContext)
|
||||
{
|
||||
SuspendContext(pContext);
|
||||
pContext = GetContextSuspended();
|
||||
if(!pContext) return;
|
||||
|
||||
if ((pflValue1) && (pflValue2) && (pflValue3))
|
||||
if(pflValue1 && pflValue2 && pflValue3)
|
||||
{
|
||||
switch(eParam)
|
||||
{
|
||||
switch (eParam)
|
||||
{
|
||||
case AL_POSITION:
|
||||
*pflValue1 = pContext->Listener.Position[0];
|
||||
*pflValue2 = pContext->Listener.Position[1];
|
||||
@@ -319,17 +288,12 @@ ALAPI ALvoid ALAPIENTRY alGetListener3f(ALenum eParam, ALfloat *pflValue1, ALflo
|
||||
default:
|
||||
alSetError(AL_INVALID_ENUM);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
alSetError(AL_INVALID_VALUE);
|
||||
|
||||
ProcessContext(pContext);
|
||||
}
|
||||
else
|
||||
alSetError(AL_INVALID_OPERATION);
|
||||
alSetError(AL_INVALID_VALUE);
|
||||
|
||||
return;
|
||||
ProcessContext(pContext);
|
||||
}
|
||||
|
||||
|
||||
@@ -337,19 +301,21 @@ ALAPI ALvoid ALAPIENTRY alGetListenerfv(ALenum eParam, ALfloat *pflValues)
|
||||
{
|
||||
ALCcontext *pContext;
|
||||
|
||||
pContext = alcGetCurrentContext();
|
||||
if (pContext)
|
||||
{
|
||||
SuspendContext(pContext);
|
||||
pContext = GetContextSuspended();
|
||||
if(!pContext) return;
|
||||
|
||||
if (pflValues)
|
||||
if(pflValues)
|
||||
{
|
||||
switch(eParam)
|
||||
{
|
||||
switch (eParam)
|
||||
{
|
||||
case AL_GAIN:
|
||||
pflValues[0] = pContext->Listener.Gain;
|
||||
break;
|
||||
|
||||
case AL_METERS_PER_UNIT:
|
||||
pflValues[0] = pContext->Listener.MetersPerUnit;
|
||||
break;
|
||||
|
||||
case AL_POSITION:
|
||||
pflValues[0] = pContext->Listener.Position[0];
|
||||
pflValues[1] = pContext->Listener.Position[1];
|
||||
@@ -375,17 +341,12 @@ ALAPI ALvoid ALAPIENTRY alGetListenerfv(ALenum eParam, ALfloat *pflValues)
|
||||
default:
|
||||
alSetError(AL_INVALID_ENUM);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
alSetError(AL_INVALID_VALUE);
|
||||
|
||||
ProcessContext(pContext);
|
||||
}
|
||||
else
|
||||
alSetError(AL_INVALID_OPERATION);
|
||||
alSetError(AL_INVALID_VALUE);
|
||||
|
||||
return;
|
||||
ProcessContext(pContext);
|
||||
}
|
||||
|
||||
|
||||
@@ -393,29 +354,22 @@ ALAPI ALvoid ALAPIENTRY alGetListeneri(ALenum eParam, ALint *plValue)
|
||||
{
|
||||
ALCcontext *pContext;
|
||||
|
||||
pContext = alcGetCurrentContext();
|
||||
if (pContext)
|
||||
{
|
||||
SuspendContext(pContext);
|
||||
pContext = GetContextSuspended();
|
||||
if(!pContext) return;
|
||||
|
||||
if (plValue)
|
||||
if(plValue)
|
||||
{
|
||||
switch(eParam)
|
||||
{
|
||||
switch (eParam)
|
||||
{
|
||||
default:
|
||||
alSetError(AL_INVALID_ENUM);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
alSetError(AL_INVALID_VALUE);
|
||||
|
||||
ProcessContext(pContext);
|
||||
}
|
||||
else
|
||||
alSetError(AL_INVALID_OPERATION);
|
||||
alSetError(AL_INVALID_VALUE);
|
||||
|
||||
return;
|
||||
ProcessContext(pContext);
|
||||
}
|
||||
|
||||
|
||||
@@ -423,15 +377,13 @@ ALAPI void ALAPIENTRY alGetListener3i(ALenum eParam, ALint *plValue1, ALint *plV
|
||||
{
|
||||
ALCcontext *pContext;
|
||||
|
||||
pContext = alcGetCurrentContext();
|
||||
if (pContext)
|
||||
{
|
||||
SuspendContext(pContext);
|
||||
pContext = GetContextSuspended();
|
||||
if(!pContext) return;
|
||||
|
||||
if ((plValue1) && (plValue2) && (plValue3))
|
||||
if(plValue1 && plValue2 && plValue3)
|
||||
{
|
||||
switch (eParam)
|
||||
{
|
||||
switch (eParam)
|
||||
{
|
||||
case AL_POSITION:
|
||||
*plValue1 = (ALint)pContext->Listener.Position[0];
|
||||
*plValue2 = (ALint)pContext->Listener.Position[1];
|
||||
@@ -447,17 +399,12 @@ ALAPI void ALAPIENTRY alGetListener3i(ALenum eParam, ALint *plValue1, ALint *plV
|
||||
default:
|
||||
alSetError(AL_INVALID_ENUM);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
alSetError(AL_INVALID_VALUE);
|
||||
|
||||
ProcessContext(pContext);
|
||||
}
|
||||
else
|
||||
alSetError(AL_INVALID_OPERATION);
|
||||
alSetError(AL_INVALID_VALUE);
|
||||
|
||||
return;
|
||||
ProcessContext(pContext);
|
||||
}
|
||||
|
||||
|
||||
@@ -465,15 +412,13 @@ ALAPI void ALAPIENTRY alGetListeneriv(ALenum eParam, ALint* plValues)
|
||||
{
|
||||
ALCcontext *pContext;
|
||||
|
||||
pContext = alcGetCurrentContext();
|
||||
if (pContext)
|
||||
{
|
||||
SuspendContext(pContext);
|
||||
pContext = GetContextSuspended();
|
||||
if(!pContext) return;
|
||||
|
||||
if (plValues)
|
||||
if(plValues)
|
||||
{
|
||||
switch(eParam)
|
||||
{
|
||||
switch (eParam)
|
||||
{
|
||||
case AL_POSITION:
|
||||
plValues[0] = (ALint)pContext->Listener.Position[0];
|
||||
plValues[1] = (ALint)pContext->Listener.Position[1];
|
||||
@@ -499,15 +444,10 @@ ALAPI void ALAPIENTRY alGetListeneriv(ALenum eParam, ALint* plValues)
|
||||
default:
|
||||
alSetError(AL_INVALID_ENUM);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
alSetError(AL_INVALID_VALUE);
|
||||
|
||||
ProcessContext(pContext);
|
||||
}
|
||||
else
|
||||
alSetError(AL_INVALID_OPERATION);
|
||||
alSetError(AL_INVALID_VALUE);
|
||||
|
||||
return;
|
||||
ProcessContext(pContext);
|
||||
}
|
||||
|
||||
+921
-921
File diff suppressed because it is too large
Load Diff
+276
-381
@@ -18,14 +18,19 @@
|
||||
* Or go to http://www.gnu.org/copyleft/lgpl.html
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "alMain.h"
|
||||
#include "AL/alc.h"
|
||||
#include "AL/alext.h"
|
||||
#include "alError.h"
|
||||
#include "alSource.h"
|
||||
#include "alState.h"
|
||||
#include "alDatabuffer.h"
|
||||
|
||||
static const ALchar alVendor[] = "OpenAL Community";
|
||||
static const ALchar alVersion[] = "1.1";
|
||||
static const ALchar alVersion[] = "1.1 ALSOFT "ALSOFT_VERSION;
|
||||
static const ALchar alRenderer[] = "OpenAL Soft";
|
||||
|
||||
// Error Messages
|
||||
@@ -40,50 +45,34 @@ ALAPI ALvoid ALAPIENTRY alEnable(ALenum capability)
|
||||
{
|
||||
ALCcontext *Context;
|
||||
|
||||
Context=alcGetCurrentContext();
|
||||
if (Context)
|
||||
{
|
||||
SuspendContext(Context);
|
||||
Context = GetContextSuspended();
|
||||
if(!Context) return;
|
||||
|
||||
switch (capability)
|
||||
{
|
||||
default:
|
||||
alSetError(AL_INVALID_ENUM);
|
||||
break;
|
||||
}
|
||||
|
||||
ProcessContext(Context);
|
||||
}
|
||||
else
|
||||
switch(capability)
|
||||
{
|
||||
// Invalid Context
|
||||
alSetError(AL_INVALID_OPERATION);
|
||||
default:
|
||||
alSetError(AL_INVALID_ENUM);
|
||||
break;
|
||||
}
|
||||
|
||||
ProcessContext(Context);
|
||||
}
|
||||
|
||||
ALAPI ALvoid ALAPIENTRY alDisable(ALenum capability)
|
||||
{
|
||||
ALCcontext *Context;
|
||||
|
||||
Context=alcGetCurrentContext();
|
||||
if (Context)
|
||||
{
|
||||
SuspendContext(Context);
|
||||
Context = GetContextSuspended();
|
||||
if(!Context) return;
|
||||
|
||||
switch (capability)
|
||||
{
|
||||
default:
|
||||
alSetError(AL_INVALID_ENUM);
|
||||
break;
|
||||
}
|
||||
|
||||
ProcessContext(Context);
|
||||
}
|
||||
else
|
||||
switch(capability)
|
||||
{
|
||||
// Invalid Context
|
||||
alSetError(AL_INVALID_OPERATION);
|
||||
default:
|
||||
alSetError(AL_INVALID_ENUM);
|
||||
break;
|
||||
}
|
||||
|
||||
ProcessContext(Context);
|
||||
}
|
||||
|
||||
ALAPI ALboolean ALAPIENTRY alIsEnabled(ALenum capability)
|
||||
@@ -91,26 +80,18 @@ ALAPI ALboolean ALAPIENTRY alIsEnabled(ALenum capability)
|
||||
ALCcontext *Context;
|
||||
ALboolean value=AL_FALSE;
|
||||
|
||||
Context=alcGetCurrentContext();
|
||||
if (Context)
|
||||
{
|
||||
SuspendContext(Context);
|
||||
Context = GetContextSuspended();
|
||||
if(!Context) return AL_FALSE;
|
||||
|
||||
switch (capability)
|
||||
{
|
||||
default:
|
||||
alSetError(AL_INVALID_ENUM);
|
||||
break;
|
||||
}
|
||||
|
||||
ProcessContext(Context);
|
||||
}
|
||||
else
|
||||
switch(capability)
|
||||
{
|
||||
// Invalid Context
|
||||
alSetError(AL_INVALID_OPERATION);
|
||||
default:
|
||||
alSetError(AL_INVALID_ENUM);
|
||||
break;
|
||||
}
|
||||
|
||||
ProcessContext(Context);
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
@@ -119,46 +100,38 @@ ALAPI ALboolean ALAPIENTRY alGetBoolean(ALenum pname)
|
||||
ALCcontext *Context;
|
||||
ALboolean value=AL_FALSE;
|
||||
|
||||
Context=alcGetCurrentContext();
|
||||
if (Context)
|
||||
Context = GetContextSuspended();
|
||||
if(!Context) return AL_FALSE;
|
||||
|
||||
switch(pname)
|
||||
{
|
||||
SuspendContext(Context);
|
||||
case AL_DOPPLER_FACTOR:
|
||||
if(Context->DopplerFactor != 0.0f)
|
||||
value = AL_TRUE;
|
||||
break;
|
||||
|
||||
switch (pname)
|
||||
{
|
||||
case AL_DOPPLER_FACTOR:
|
||||
if (Context->DopplerFactor != 0.0f)
|
||||
value = AL_TRUE;
|
||||
break;
|
||||
case AL_DOPPLER_VELOCITY:
|
||||
if(Context->DopplerVelocity != 0.0f)
|
||||
value = AL_TRUE;
|
||||
break;
|
||||
|
||||
case AL_DOPPLER_VELOCITY:
|
||||
if (Context->DopplerVelocity != 0.0f)
|
||||
value = AL_TRUE;
|
||||
break;
|
||||
case AL_DISTANCE_MODEL:
|
||||
if(Context->DistanceModel == AL_INVERSE_DISTANCE_CLAMPED)
|
||||
value = AL_TRUE;
|
||||
break;
|
||||
|
||||
case AL_DISTANCE_MODEL:
|
||||
if (Context->DistanceModel == AL_INVERSE_DISTANCE_CLAMPED)
|
||||
value = AL_TRUE;
|
||||
break;
|
||||
case AL_SPEED_OF_SOUND:
|
||||
if(Context->flSpeedOfSound != 0.0f)
|
||||
value = AL_TRUE;
|
||||
break;
|
||||
|
||||
case AL_SPEED_OF_SOUND:
|
||||
if (Context->flSpeedOfSound != 0.0f)
|
||||
value = AL_TRUE;
|
||||
break;
|
||||
|
||||
default:
|
||||
alSetError(AL_INVALID_ENUM);
|
||||
break;
|
||||
}
|
||||
|
||||
ProcessContext(Context);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Invalid Context
|
||||
alSetError(AL_INVALID_OPERATION);
|
||||
default:
|
||||
alSetError(AL_INVALID_ENUM);
|
||||
break;
|
||||
}
|
||||
|
||||
ProcessContext(Context);
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
@@ -167,42 +140,34 @@ ALAPI ALdouble ALAPIENTRY alGetDouble(ALenum pname)
|
||||
ALCcontext *Context;
|
||||
ALdouble value = 0.0;
|
||||
|
||||
Context=alcGetCurrentContext();
|
||||
if (Context)
|
||||
Context = GetContextSuspended();
|
||||
if(!Context) return 0.0;
|
||||
|
||||
switch(pname)
|
||||
{
|
||||
SuspendContext(Context);
|
||||
case AL_DOPPLER_FACTOR:
|
||||
value = (double)Context->DopplerFactor;
|
||||
break;
|
||||
|
||||
switch (pname)
|
||||
{
|
||||
case AL_DOPPLER_FACTOR:
|
||||
value = (double)Context->DopplerFactor;
|
||||
break;
|
||||
case AL_DOPPLER_VELOCITY:
|
||||
value = (double)Context->DopplerVelocity;
|
||||
break;
|
||||
|
||||
case AL_DOPPLER_VELOCITY:
|
||||
value = (double)Context->DopplerVelocity;
|
||||
break;
|
||||
case AL_DISTANCE_MODEL:
|
||||
value = (double)Context->DistanceModel;
|
||||
break;
|
||||
|
||||
case AL_DISTANCE_MODEL:
|
||||
value = (double)Context->DistanceModel;
|
||||
break;
|
||||
case AL_SPEED_OF_SOUND:
|
||||
value = (double)Context->flSpeedOfSound;
|
||||
break;
|
||||
|
||||
case AL_SPEED_OF_SOUND:
|
||||
value = (double)Context->flSpeedOfSound;
|
||||
break;
|
||||
|
||||
default:
|
||||
alSetError(AL_INVALID_ENUM);
|
||||
break;
|
||||
}
|
||||
|
||||
ProcessContext(Context);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Invalid Context
|
||||
alSetError(AL_INVALID_OPERATION);
|
||||
default:
|
||||
alSetError(AL_INVALID_ENUM);
|
||||
break;
|
||||
}
|
||||
|
||||
ProcessContext(Context);
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
@@ -211,42 +176,34 @@ ALAPI ALfloat ALAPIENTRY alGetFloat(ALenum pname)
|
||||
ALCcontext *Context;
|
||||
ALfloat value = 0.0f;
|
||||
|
||||
Context=alcGetCurrentContext();
|
||||
if (Context)
|
||||
Context = GetContextSuspended();
|
||||
if(!Context) return 0.0f;
|
||||
|
||||
switch(pname)
|
||||
{
|
||||
SuspendContext(Context);
|
||||
case AL_DOPPLER_FACTOR:
|
||||
value = Context->DopplerFactor;
|
||||
break;
|
||||
|
||||
switch (pname)
|
||||
{
|
||||
case AL_DOPPLER_FACTOR:
|
||||
value = Context->DopplerFactor;
|
||||
break;
|
||||
case AL_DOPPLER_VELOCITY:
|
||||
value = Context->DopplerVelocity;
|
||||
break;
|
||||
|
||||
case AL_DOPPLER_VELOCITY:
|
||||
value = Context->DopplerVelocity;
|
||||
break;
|
||||
case AL_DISTANCE_MODEL:
|
||||
value = (float)Context->DistanceModel;
|
||||
break;
|
||||
|
||||
case AL_DISTANCE_MODEL:
|
||||
value = (float)Context->DistanceModel;
|
||||
break;
|
||||
case AL_SPEED_OF_SOUND:
|
||||
value = Context->flSpeedOfSound;
|
||||
break;
|
||||
|
||||
case AL_SPEED_OF_SOUND:
|
||||
value = Context->flSpeedOfSound;
|
||||
break;
|
||||
|
||||
default:
|
||||
alSetError(AL_INVALID_ENUM);
|
||||
break;
|
||||
}
|
||||
|
||||
ProcessContext(Context);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Invalid Context
|
||||
alSetError(AL_INVALID_OPERATION);
|
||||
default:
|
||||
alSetError(AL_INVALID_ENUM);
|
||||
break;
|
||||
}
|
||||
|
||||
ProcessContext(Context);
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
@@ -255,42 +212,48 @@ ALAPI ALint ALAPIENTRY alGetInteger(ALenum pname)
|
||||
ALCcontext *Context;
|
||||
ALint value = 0;
|
||||
|
||||
Context=alcGetCurrentContext();
|
||||
if (Context)
|
||||
Context = GetContextSuspended();
|
||||
if(!Context) return 0;
|
||||
|
||||
switch(pname)
|
||||
{
|
||||
SuspendContext(Context);
|
||||
case AL_DOPPLER_FACTOR:
|
||||
value = (ALint)Context->DopplerFactor;
|
||||
break;
|
||||
|
||||
switch (pname)
|
||||
{
|
||||
case AL_DOPPLER_FACTOR:
|
||||
value = (ALint)Context->DopplerFactor;
|
||||
break;
|
||||
case AL_DOPPLER_VELOCITY:
|
||||
value = (ALint)Context->DopplerVelocity;
|
||||
break;
|
||||
|
||||
case AL_DOPPLER_VELOCITY:
|
||||
value = (ALint)Context->DopplerVelocity;
|
||||
break;
|
||||
case AL_DISTANCE_MODEL:
|
||||
value = (ALint)Context->DistanceModel;
|
||||
break;
|
||||
|
||||
case AL_DISTANCE_MODEL:
|
||||
value = (ALint)Context->DistanceModel;
|
||||
break;
|
||||
case AL_SPEED_OF_SOUND:
|
||||
value = (ALint)Context->flSpeedOfSound;
|
||||
break;
|
||||
|
||||
case AL_SPEED_OF_SOUND:
|
||||
value = (ALint)Context->flSpeedOfSound;
|
||||
break;
|
||||
case AL_SAMPLE_SOURCE_EXT:
|
||||
if(Context->SampleSource)
|
||||
value = (ALint)Context->SampleSource->databuffer;
|
||||
else
|
||||
value = 0;
|
||||
break;
|
||||
|
||||
default:
|
||||
alSetError(AL_INVALID_ENUM);
|
||||
break;
|
||||
}
|
||||
case AL_SAMPLE_SINK_EXT:
|
||||
if(Context->SampleSink)
|
||||
value = (ALint)Context->SampleSink->databuffer;
|
||||
else
|
||||
value = 0;
|
||||
break;
|
||||
|
||||
ProcessContext(Context);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Invalid Context
|
||||
alSetError(AL_INVALID_OPERATION);
|
||||
default:
|
||||
alSetError(AL_INVALID_ENUM);
|
||||
break;
|
||||
}
|
||||
|
||||
ProcessContext(Context);
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
@@ -298,204 +261,178 @@ ALAPI ALvoid ALAPIENTRY alGetBooleanv(ALenum pname,ALboolean *data)
|
||||
{
|
||||
ALCcontext *Context;
|
||||
|
||||
Context=alcGetCurrentContext();
|
||||
if (Context)
|
||||
Context = GetContextSuspended();
|
||||
if(!Context) return;
|
||||
|
||||
if(data)
|
||||
{
|
||||
SuspendContext(Context);
|
||||
|
||||
if (data)
|
||||
switch(pname)
|
||||
{
|
||||
switch (pname)
|
||||
{
|
||||
case AL_DOPPLER_FACTOR:
|
||||
*data = (ALboolean)((Context->DopplerFactor != 0.0f) ? AL_TRUE : AL_FALSE);
|
||||
break;
|
||||
case AL_DOPPLER_FACTOR:
|
||||
*data = (ALboolean)((Context->DopplerFactor != 0.0f) ? AL_TRUE : AL_FALSE);
|
||||
break;
|
||||
|
||||
case AL_DOPPLER_VELOCITY:
|
||||
*data = (ALboolean)((Context->DopplerVelocity != 0.0f) ? AL_TRUE : AL_FALSE);
|
||||
break;
|
||||
case AL_DOPPLER_VELOCITY:
|
||||
*data = (ALboolean)((Context->DopplerVelocity != 0.0f) ? AL_TRUE : AL_FALSE);
|
||||
break;
|
||||
|
||||
case AL_DISTANCE_MODEL:
|
||||
*data = (ALboolean)((Context->DistanceModel == AL_INVERSE_DISTANCE_CLAMPED) ? AL_TRUE : AL_FALSE);
|
||||
break;
|
||||
case AL_DISTANCE_MODEL:
|
||||
*data = (ALboolean)((Context->DistanceModel == AL_INVERSE_DISTANCE_CLAMPED) ? AL_TRUE : AL_FALSE);
|
||||
break;
|
||||
|
||||
case AL_SPEED_OF_SOUND:
|
||||
*data = (ALboolean)((Context->flSpeedOfSound != 0.0f) ? AL_TRUE : AL_FALSE);
|
||||
break;
|
||||
case AL_SPEED_OF_SOUND:
|
||||
*data = (ALboolean)((Context->flSpeedOfSound != 0.0f) ? AL_TRUE : AL_FALSE);
|
||||
break;
|
||||
|
||||
default:
|
||||
alSetError(AL_INVALID_ENUM);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
alSetError(AL_INVALID_ENUM);
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
// data is a NULL pointer
|
||||
alSetError(AL_INVALID_VALUE);
|
||||
}
|
||||
|
||||
ProcessContext(Context);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Invalid Context
|
||||
alSetError(AL_INVALID_OPERATION);
|
||||
// data is a NULL pointer
|
||||
alSetError(AL_INVALID_VALUE);
|
||||
}
|
||||
|
||||
return;
|
||||
ProcessContext(Context);
|
||||
}
|
||||
|
||||
ALAPI ALvoid ALAPIENTRY alGetDoublev(ALenum pname,ALdouble *data)
|
||||
{
|
||||
ALCcontext *Context;
|
||||
|
||||
Context=alcGetCurrentContext();
|
||||
if (Context)
|
||||
Context = GetContextSuspended();
|
||||
if(!Context) return;
|
||||
|
||||
if(data)
|
||||
{
|
||||
SuspendContext(Context);
|
||||
|
||||
if (data)
|
||||
switch(pname)
|
||||
{
|
||||
switch (pname)
|
||||
{
|
||||
case AL_DOPPLER_FACTOR:
|
||||
*data = (double)Context->DopplerFactor;
|
||||
break;
|
||||
case AL_DOPPLER_FACTOR:
|
||||
*data = (double)Context->DopplerFactor;
|
||||
break;
|
||||
|
||||
case AL_DOPPLER_VELOCITY:
|
||||
*data = (double)Context->DopplerVelocity;
|
||||
break;
|
||||
case AL_DOPPLER_VELOCITY:
|
||||
*data = (double)Context->DopplerVelocity;
|
||||
break;
|
||||
|
||||
case AL_DISTANCE_MODEL:
|
||||
*data = (double)Context->DistanceModel;
|
||||
break;
|
||||
case AL_DISTANCE_MODEL:
|
||||
*data = (double)Context->DistanceModel;
|
||||
break;
|
||||
|
||||
case AL_SPEED_OF_SOUND:
|
||||
*data = (double)Context->flSpeedOfSound;
|
||||
break;
|
||||
case AL_SPEED_OF_SOUND:
|
||||
*data = (double)Context->flSpeedOfSound;
|
||||
break;
|
||||
|
||||
default:
|
||||
alSetError(AL_INVALID_ENUM);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
alSetError(AL_INVALID_ENUM);
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
// data is a NULL pointer
|
||||
alSetError(AL_INVALID_VALUE);
|
||||
}
|
||||
|
||||
ProcessContext(Context);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Invalid Context
|
||||
alSetError(AL_INVALID_OPERATION);
|
||||
// data is a NULL pointer
|
||||
alSetError(AL_INVALID_VALUE);
|
||||
}
|
||||
|
||||
return;
|
||||
ProcessContext(Context);
|
||||
}
|
||||
|
||||
ALAPI ALvoid ALAPIENTRY alGetFloatv(ALenum pname,ALfloat *data)
|
||||
{
|
||||
ALCcontext *Context;
|
||||
|
||||
Context=alcGetCurrentContext();
|
||||
if (Context)
|
||||
Context = GetContextSuspended();
|
||||
if(!Context) return;
|
||||
|
||||
if(data)
|
||||
{
|
||||
SuspendContext(Context);
|
||||
|
||||
if (data)
|
||||
switch(pname)
|
||||
{
|
||||
switch (pname)
|
||||
{
|
||||
case AL_DOPPLER_FACTOR:
|
||||
*data = Context->DopplerFactor;
|
||||
break;
|
||||
case AL_DOPPLER_FACTOR:
|
||||
*data = Context->DopplerFactor;
|
||||
break;
|
||||
|
||||
case AL_DOPPLER_VELOCITY:
|
||||
*data = Context->DopplerVelocity;
|
||||
break;
|
||||
case AL_DOPPLER_VELOCITY:
|
||||
*data = Context->DopplerVelocity;
|
||||
break;
|
||||
|
||||
case AL_DISTANCE_MODEL:
|
||||
*data = (float)Context->DistanceModel;
|
||||
break;
|
||||
case AL_DISTANCE_MODEL:
|
||||
*data = (float)Context->DistanceModel;
|
||||
break;
|
||||
|
||||
case AL_SPEED_OF_SOUND:
|
||||
*data = Context->flSpeedOfSound;
|
||||
break;
|
||||
case AL_SPEED_OF_SOUND:
|
||||
*data = Context->flSpeedOfSound;
|
||||
break;
|
||||
|
||||
default:
|
||||
alSetError(AL_INVALID_ENUM);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
alSetError(AL_INVALID_ENUM);
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
// data is a NULL pointer
|
||||
alSetError(AL_INVALID_VALUE);
|
||||
}
|
||||
|
||||
ProcessContext(Context);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Invalid Context
|
||||
alSetError(AL_INVALID_OPERATION);
|
||||
// data is a NULL pointer
|
||||
alSetError(AL_INVALID_VALUE);
|
||||
}
|
||||
|
||||
return;
|
||||
ProcessContext(Context);
|
||||
}
|
||||
|
||||
ALAPI ALvoid ALAPIENTRY alGetIntegerv(ALenum pname,ALint *data)
|
||||
{
|
||||
ALCcontext *Context;
|
||||
|
||||
Context=alcGetCurrentContext();
|
||||
if (Context)
|
||||
Context = GetContextSuspended();
|
||||
if(!Context) return;
|
||||
|
||||
if(data)
|
||||
{
|
||||
SuspendContext(Context);
|
||||
|
||||
if (data)
|
||||
switch(pname)
|
||||
{
|
||||
switch (pname)
|
||||
{
|
||||
case AL_DOPPLER_FACTOR:
|
||||
*data = (ALint)Context->DopplerFactor;
|
||||
break;
|
||||
case AL_DOPPLER_FACTOR:
|
||||
*data = (ALint)Context->DopplerFactor;
|
||||
break;
|
||||
|
||||
case AL_DOPPLER_VELOCITY:
|
||||
*data = (ALint)Context->DopplerVelocity;
|
||||
break;
|
||||
case AL_DOPPLER_VELOCITY:
|
||||
*data = (ALint)Context->DopplerVelocity;
|
||||
break;
|
||||
|
||||
case AL_DISTANCE_MODEL:
|
||||
*data = (ALint)Context->DistanceModel;
|
||||
break;
|
||||
case AL_DISTANCE_MODEL:
|
||||
*data = (ALint)Context->DistanceModel;
|
||||
break;
|
||||
|
||||
case AL_SPEED_OF_SOUND:
|
||||
*data = (ALint)Context->flSpeedOfSound;
|
||||
break;
|
||||
case AL_SPEED_OF_SOUND:
|
||||
*data = (ALint)Context->flSpeedOfSound;
|
||||
break;
|
||||
|
||||
default:
|
||||
alSetError(AL_INVALID_ENUM);
|
||||
break;
|
||||
}
|
||||
case AL_SAMPLE_SOURCE_EXT:
|
||||
if(Context->SampleSource)
|
||||
*data = (ALint)Context->SampleSource->databuffer;
|
||||
else
|
||||
*data = 0;
|
||||
break;
|
||||
|
||||
case AL_SAMPLE_SINK_EXT:
|
||||
if(Context->SampleSink)
|
||||
*data = (ALint)Context->SampleSink->databuffer;
|
||||
else
|
||||
*data = 0;
|
||||
break;
|
||||
|
||||
default:
|
||||
alSetError(AL_INVALID_ENUM);
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
// data is a NULL pointer
|
||||
alSetError(AL_INVALID_VALUE);
|
||||
}
|
||||
|
||||
ProcessContext(Context);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Invalid Context
|
||||
alSetError(AL_INVALID_OPERATION);
|
||||
// data is a NULL pointer
|
||||
alSetError(AL_INVALID_VALUE);
|
||||
}
|
||||
|
||||
return;
|
||||
ProcessContext(Context);
|
||||
}
|
||||
|
||||
ALAPI const ALchar* ALAPIENTRY alGetString(ALenum pname)
|
||||
@@ -503,14 +440,8 @@ ALAPI const ALchar* ALAPIENTRY alGetString(ALenum pname)
|
||||
const ALchar *value;
|
||||
ALCcontext *pContext;
|
||||
|
||||
pContext = alcGetCurrentContext();
|
||||
if(!pContext)
|
||||
{
|
||||
alSetError(AL_INVALID_OPERATION);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
SuspendContext(pContext);
|
||||
pContext = GetContextSuspended();
|
||||
if(!pContext) return NULL;
|
||||
|
||||
switch(pname)
|
||||
{
|
||||
@@ -569,109 +500,73 @@ ALAPI ALvoid ALAPIENTRY alDopplerFactor(ALfloat value)
|
||||
{
|
||||
ALCcontext *Context;
|
||||
|
||||
Context=alcGetCurrentContext();
|
||||
if (Context)
|
||||
{
|
||||
SuspendContext(Context);
|
||||
Context = GetContextSuspended();
|
||||
if(!Context) return;
|
||||
|
||||
if (value>=0.0f)
|
||||
Context->DopplerFactor = value;
|
||||
else
|
||||
alSetError(AL_INVALID_VALUE);
|
||||
|
||||
ProcessContext(Context);
|
||||
}
|
||||
if(value >= 0.0f)
|
||||
Context->DopplerFactor = value;
|
||||
else
|
||||
{
|
||||
// Invalid Context
|
||||
alSetError(AL_INVALID_OPERATION);
|
||||
}
|
||||
alSetError(AL_INVALID_VALUE);
|
||||
|
||||
return;
|
||||
ProcessContext(Context);
|
||||
}
|
||||
|
||||
ALAPI ALvoid ALAPIENTRY alDopplerVelocity(ALfloat value)
|
||||
{
|
||||
ALCcontext *Context;
|
||||
|
||||
Context=alcGetCurrentContext();
|
||||
if (Context)
|
||||
{
|
||||
SuspendContext(Context);
|
||||
Context = GetContextSuspended();
|
||||
if(!Context) return;
|
||||
|
||||
if (value>0.0f)
|
||||
Context->DopplerVelocity=value;
|
||||
else
|
||||
alSetError(AL_INVALID_VALUE);
|
||||
|
||||
ProcessContext(Context);
|
||||
}
|
||||
if(value > 0.0f)
|
||||
Context->DopplerVelocity=value;
|
||||
else
|
||||
{
|
||||
// Invalid Context
|
||||
alSetError(AL_INVALID_OPERATION);
|
||||
}
|
||||
alSetError(AL_INVALID_VALUE);
|
||||
|
||||
return;
|
||||
ProcessContext(Context);
|
||||
}
|
||||
|
||||
ALAPI ALvoid ALAPIENTRY alSpeedOfSound(ALfloat flSpeedOfSound)
|
||||
{
|
||||
ALCcontext *pContext;
|
||||
|
||||
pContext = alcGetCurrentContext();
|
||||
if (pContext)
|
||||
{
|
||||
SuspendContext(pContext);
|
||||
pContext = GetContextSuspended();
|
||||
if(!pContext) return;
|
||||
|
||||
if (flSpeedOfSound > 0.0f)
|
||||
pContext->flSpeedOfSound = flSpeedOfSound;
|
||||
else
|
||||
alSetError(AL_INVALID_VALUE);
|
||||
|
||||
ProcessContext(pContext);
|
||||
}
|
||||
if(flSpeedOfSound > 0.0f)
|
||||
pContext->flSpeedOfSound = flSpeedOfSound;
|
||||
else
|
||||
{
|
||||
alSetError(AL_INVALID_OPERATION);
|
||||
}
|
||||
alSetError(AL_INVALID_VALUE);
|
||||
|
||||
return;
|
||||
ProcessContext(pContext);
|
||||
}
|
||||
|
||||
ALAPI ALvoid ALAPIENTRY alDistanceModel(ALenum value)
|
||||
{
|
||||
ALCcontext *Context;
|
||||
ALsource *Source;
|
||||
|
||||
Context=alcGetCurrentContext();
|
||||
if (Context)
|
||||
Context = GetContextSuspended();
|
||||
if(!Context) return;
|
||||
|
||||
switch(value)
|
||||
{
|
||||
SuspendContext(Context);
|
||||
case AL_NONE:
|
||||
case AL_INVERSE_DISTANCE:
|
||||
case AL_INVERSE_DISTANCE_CLAMPED:
|
||||
case AL_LINEAR_DISTANCE:
|
||||
case AL_LINEAR_DISTANCE_CLAMPED:
|
||||
case AL_EXPONENT_DISTANCE:
|
||||
case AL_EXPONENT_DISTANCE_CLAMPED:
|
||||
Context->DistanceModel = value;
|
||||
for(Source = Context->Source;Source != NULL;Source = Source->next)
|
||||
Source->DistanceModel = value;
|
||||
break;
|
||||
|
||||
switch (value)
|
||||
{
|
||||
case AL_NONE:
|
||||
case AL_INVERSE_DISTANCE:
|
||||
case AL_INVERSE_DISTANCE_CLAMPED:
|
||||
case AL_LINEAR_DISTANCE:
|
||||
case AL_LINEAR_DISTANCE_CLAMPED:
|
||||
case AL_EXPONENT_DISTANCE:
|
||||
case AL_EXPONENT_DISTANCE_CLAMPED:
|
||||
Context->DistanceModel = value;
|
||||
break;
|
||||
|
||||
default:
|
||||
alSetError(AL_INVALID_VALUE);
|
||||
break;
|
||||
}
|
||||
|
||||
ProcessContext(Context);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Invalid Context
|
||||
alSetError(AL_INVALID_OPERATION);
|
||||
default:
|
||||
alSetError(AL_INVALID_VALUE);
|
||||
break;
|
||||
}
|
||||
|
||||
return;
|
||||
ProcessContext(Context);
|
||||
}
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
* Or go to http://www.gnu.org/copyleft/lgpl.html
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "alMain.h"
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
# Cross-compiling requires CMake 2.6 or newer. To cross-compile, first modify
|
||||
# this file to set the proper settings and paths. Then use it from build/ like:
|
||||
# cmake .. -DCMAKE_TOOLCHAIN_FILE=../XCompile.txt \
|
||||
# -DCMAKE_INSTALL_PREFIX=/usr/mingw32/mingw
|
||||
# If you already have a toolchain file setup, you may use that instead of this
|
||||
# file.
|
||||
|
||||
# the name of the target operating system
|
||||
SET(CMAKE_SYSTEM_NAME Windows)
|
||||
|
||||
# which compilers to use for C and C++
|
||||
SET(CMAKE_C_COMPILER mingw32-gcc)
|
||||
SET(CMAKE_CXX_COMPILER mingw32-g++)
|
||||
|
||||
# here is the target environment located
|
||||
SET(CMAKE_FIND_ROOT_PATH /usr/mingw32/mingw)
|
||||
|
||||
# adjust the default behaviour of the FIND_XXX() commands:
|
||||
# search headers and libraries in the target environment, search
|
||||
# programs in the host environment
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
||||
@@ -0,0 +1,11 @@
|
||||
prefix=@prefix@
|
||||
exec_prefix=@exec_prefix@
|
||||
libdir=@libdir@
|
||||
includedir=@includedir@
|
||||
|
||||
Name: OpenAL
|
||||
Description: OpenAL is a cross-platform 3D audio API
|
||||
Requires: @PKG_CONFIG_REQUIRES@
|
||||
Version: @PACKAGE_VERSION@
|
||||
Libs: -L${libdir} -l@LIBNAME@ @PKG_CONFIG_LIBS@
|
||||
Cflags: -I${includedir}
|
||||
+213
@@ -0,0 +1,213 @@
|
||||
# OpenAL config file. Options that are not under a block or are under the
|
||||
# [general] block are for general, non-backend-specific options. Blocks may
|
||||
# appear multiple times, and duplicated options will take the last value
|
||||
# specified.
|
||||
# The system-wide settings can be put in /etc/openal/alsoft.conf and user-
|
||||
# specific override settings in ~/.alsoftrc.
|
||||
# For Windows, these settings should go into %AppData%\alsoft.ini
|
||||
# The environment variable ALSOFT_CONF can be used to specify another config
|
||||
# override
|
||||
|
||||
# Option and block names are case-insenstive. The supplied values are only
|
||||
# hints and may not be honored (though generally it'll try to get as close as
|
||||
# possible). Note: options that are left unset may default to app- or system-
|
||||
# specified values. These are the current available settings:
|
||||
|
||||
## format:
|
||||
# Sets the output format. Can be one of:
|
||||
# AL_FORMAT_MONO8 (8-bit mono)
|
||||
# AL_FORMAT_STEREO8 (8-bit stereo)
|
||||
# AL_FORMAT_QUAD8 (8-bit 4-channel)
|
||||
# AL_FORMAT_51CHN8 (8-bit 5.1 output)
|
||||
# AL_FORMAT_61CHN8 (8-bit 6.1 output)
|
||||
# AL_FORMAT_71CHN8 (8-bit 7.1 output)
|
||||
# AL_FORMAT_MONO16 (16-bit mono)
|
||||
# AL_FORMAT_STEREO16 (16-bit stereo)
|
||||
# AL_FORMAT_QUAD16 (16-bit 4-channel)
|
||||
# AL_FORMAT_51CHN16 (16-bit 5.1 output)
|
||||
# AL_FORMAT_61CHN16 (16-bit 6.1 output)
|
||||
# AL_FORMAT_71CHN16 (16-bit 7.1 output)
|
||||
# AL_FORMAT_MONO32 (32-bit float mono)
|
||||
# AL_FORMAT_STEREO32 (32-bit float stereo)
|
||||
# AL_FORMAT_QUAD32 (32-bit float 4-channel)
|
||||
# AL_FORMAT_51CHN32 (32-bit float 5.1 output)
|
||||
# AL_FORMAT_61CHN32 (32-bit float 6.1 output)
|
||||
# AL_FORMAT_71CHN32 (32-bit float 7.1 output)
|
||||
#format = AL_FORMAT_STEREO16
|
||||
|
||||
## cf_level:
|
||||
# Sets the crossfeed level for stereo output. Valid values are:
|
||||
# 0 - No crossfeed
|
||||
# 1 - Low crossfeed
|
||||
# 2 - Middle crossfeed
|
||||
# 3 - High crossfeed (virtual speakers are closer to itself)
|
||||
# 4 - Low easy crossfeed
|
||||
# 5 - Middle easy crossfeed
|
||||
# 6 - High easy crossfeed
|
||||
# Users of headphones may want to try various settings. Has no effect on non-
|
||||
# stereo modes.
|
||||
#cf_level = 0
|
||||
|
||||
## frequency:
|
||||
# Sets the output frequency.
|
||||
#frequency = 44100
|
||||
|
||||
## period_size:
|
||||
# Sets the update period size, in frames. This is the number of frames needed
|
||||
# for each mixing update. If the deprecated 'refresh' option is specified and
|
||||
# this isn't, the value will be calculated as size = refresh/periods.
|
||||
#period_size = 1024
|
||||
|
||||
## periods:
|
||||
# Sets the number of update periods. Higher values create a larger mix ahead,
|
||||
# which helps protect against skips when the CPU is under load, but increases
|
||||
# the delay between a sound getting mixed and being heard.
|
||||
#periods = 4
|
||||
|
||||
## sources:
|
||||
# Sets the maximum number of allocatable sources. Lower values may help for
|
||||
# systems with apps that try to play more sounds than the CPU can handle.
|
||||
#sources = 256
|
||||
|
||||
## stereodup:
|
||||
# Sets whether to duplicate stereo sounds on the rear and side speakers for 4+
|
||||
# channel output. This can make stereo sources substantially louder than mono
|
||||
# or even 4+ channel sources, but provides a "fuller" playback quality. True,
|
||||
# yes, on, and non-0 values will duplicate stereo sources. 0 and anything else
|
||||
# will cause stereo sounds to only play out the front speakers.
|
||||
#stereodup = false
|
||||
|
||||
## drivers:
|
||||
# Sets the backend driver list order, comma-seperated. Unknown backends and
|
||||
# duplicated names are ignored, and unlisted backends won't be considered for
|
||||
# use. An empty list means the default.
|
||||
#drivers = alsa,oss,solaris,dsound,winmm,port,pulse,wave
|
||||
|
||||
## excludefx:
|
||||
# Sets which effects to exclude, preventing apps from using them. This can
|
||||
# help for apps that try to use effects which are too CPU intensive for the
|
||||
# system to handle. Available effects are: eaxreverb,reverb,echo
|
||||
#excludefx =
|
||||
|
||||
## slots:
|
||||
# Sets the maximum number of Auxiliary Effect Slots an app can create. A slot
|
||||
# can use a non-negligible amount of CPU time if an effect is set on it even
|
||||
# if no sources are feeding it, so this may help when apps use more than the
|
||||
# system can handle.
|
||||
#slots = 4
|
||||
|
||||
## sends:
|
||||
# Sets the maximum number of auxiliary sends per source. The total number of
|
||||
# sends possible is defined at compile time and thus can not be increased
|
||||
# beyond the default (2).
|
||||
#sends = 2
|
||||
|
||||
## layout_STEREO:
|
||||
# Sets the speaker layout when using stereo output. Values are specified in
|
||||
# degrees, where 0 is straight in front, negative goes left, and positive goes
|
||||
# right. The values must define a circular pattern, starting with the back-
|
||||
# left at the most negative, around the front to back-center. Unspecified
|
||||
# speakers will remain at their default position. Available speakers are
|
||||
# front-left(fl) and front-right(fr).
|
||||
#layout_STEREO = fl=-90, fr=90
|
||||
|
||||
## laytout_QUAD:
|
||||
# Sets the speaker layout when using quadriphonic output. Available speakers
|
||||
# are back-left(bl), front-left(fl), front-right(fr), and back-right(br).
|
||||
#layout_QUAD = bl=-135, fl=-45, fr=45, br=135
|
||||
|
||||
## layout_51CHN:
|
||||
# Sets the speaker layout when using 5.1 output. Available speakers are back-
|
||||
# left(bl), front-left(fl), front-center(fc), front-right(fr), and back-
|
||||
# right(br).
|
||||
#layout_51CHN = bl=-110, fl=-30, fc=0, fr=30, br=110
|
||||
|
||||
## layout_61CHN:
|
||||
# Sets the speaker layout when using 6.1 output. Available speakers are side-
|
||||
# left(sl), front-left(fl), front-center(fc), front-right(fr), side-right(sr),
|
||||
# and back-center(bc).
|
||||
#layout_61CHN = sl=-90, fl=-30, fc=0, fr=30, sr=90, bc=180
|
||||
|
||||
## layout_71CHN:
|
||||
# Sets the speaker layout when using 7.1 output. Available speakers are back-
|
||||
# left(bl), side-left(sl), front-left(fl), front-center(fc), front-right(fr),
|
||||
# side-right(sr), and back-right(br).
|
||||
#layout_71CHN = bl=-150, sl=-90, fl=-30, fc=0, fr=30, sr=90, br=150
|
||||
|
||||
##
|
||||
## ALSA backend stuff
|
||||
##
|
||||
[alsa]
|
||||
|
||||
## device:
|
||||
# Sets the device name for the default playback device.
|
||||
#device = default
|
||||
|
||||
## capture:
|
||||
# Sets the device name for the default capture device.
|
||||
#capture = default
|
||||
|
||||
## mmap:
|
||||
# Sets whether to try using mmap mode (helps reduce latencies and CPU
|
||||
# consumption). If mmap isn't available, it will automatically fall back to
|
||||
# non-mmap mode. True, yes, on, and non-0 values will attempt to use mmap. 0
|
||||
# and anything else will force mmap off.
|
||||
#mmap = true
|
||||
|
||||
##
|
||||
## OSS backend stuff
|
||||
##
|
||||
[oss]
|
||||
|
||||
## device:
|
||||
# Sets the device name for OSS output.
|
||||
#device = /dev/dsp
|
||||
|
||||
## capture:
|
||||
# Sets the device name for OSS capture.
|
||||
#capture = /dev/dsp
|
||||
|
||||
##
|
||||
## Solaris backend stuff
|
||||
##
|
||||
[solaris]
|
||||
|
||||
## device:
|
||||
# Sets the device name for Solaris output.
|
||||
#device = /dev/audio
|
||||
|
||||
##
|
||||
## DirectSound backend stuff
|
||||
##
|
||||
[dsound]
|
||||
|
||||
##
|
||||
## Windows Multimedia backend stuff
|
||||
##
|
||||
[winmm]
|
||||
|
||||
##
|
||||
## PortAudio backend stuff
|
||||
##
|
||||
[port]
|
||||
|
||||
## device:
|
||||
# Sets the device index for output. Negative values will use the default as
|
||||
# given by PortAudio itself.
|
||||
#device = -1
|
||||
|
||||
##
|
||||
## PulseAudio backend stuff
|
||||
##
|
||||
[pulse]
|
||||
|
||||
##
|
||||
## Wave File Writer stuff
|
||||
##
|
||||
[wave]
|
||||
|
||||
## file:
|
||||
# Sets the filename of the wave file to write to. An empty name prevents the
|
||||
# backend from opening, even when explicitly requested.
|
||||
# THIS WILL OVERWRITE EXISTING FILES WITHOUT QUESTION!
|
||||
#file =
|
||||
+36
@@ -1,24 +1,45 @@
|
||||
#ifndef CONFIG_H
|
||||
#define CONFIG_H
|
||||
|
||||
/* Define to the library version */
|
||||
#define ALSOFT_VERSION "${LIB_VERSION}"
|
||||
|
||||
/* Define if we have the ALSA backend */
|
||||
#cmakedefine HAVE_ALSA
|
||||
|
||||
/* Define if we have the OSS backend */
|
||||
#cmakedefine HAVE_OSS
|
||||
|
||||
/* Define if we have the Solaris backend */
|
||||
#cmakedefine HAVE_SOLARIS
|
||||
|
||||
/* Define if we have the DSound backend */
|
||||
#cmakedefine HAVE_DSOUND
|
||||
|
||||
/* Define if we have the Windows Multimedia backend */
|
||||
#cmakedefine HAVE_WINMM
|
||||
|
||||
/* Define if we have the PortAudio backend */
|
||||
#cmakedefine HAVE_PORTAUDIO
|
||||
|
||||
/* Define if we have the PulseAudio backend */
|
||||
#cmakedefine HAVE_PULSEAUDIO
|
||||
|
||||
/* Define if we have dlfcn.h */
|
||||
#cmakedefine HAVE_DLFCN_H
|
||||
|
||||
/* Define if we have the sqrtf function */
|
||||
#cmakedefine HAVE_SQRTF
|
||||
|
||||
/* Define if we have the acosf function */
|
||||
#cmakedefine HAVE_ACOSF
|
||||
|
||||
/* Define if we have the atanf function */
|
||||
#cmakedefine HAVE_ATANF
|
||||
|
||||
/* Define if we have the fabsf function */
|
||||
#cmakedefine HAVE_FABSF
|
||||
|
||||
/* Define if we have the strtof function */
|
||||
#cmakedefine HAVE_STRTOF
|
||||
|
||||
@@ -43,4 +64,19 @@
|
||||
/* Define if we have GCC's destructor attribute */
|
||||
#cmakedefine HAVE_GCC_DESTRUCTOR
|
||||
|
||||
/* Define if we have pthread_np.h */
|
||||
#cmakedefine HAVE_PTHREAD_NP_H
|
||||
|
||||
/* Define if we have float.h */
|
||||
#cmakedefine HAVE_FLOAT_H
|
||||
|
||||
/* Define if we have fenv.h */
|
||||
#cmakedefine HAVE_FENV_H
|
||||
|
||||
/* Define if we have fesetround() */
|
||||
#cmakedefine HAVE_FESETROUND
|
||||
|
||||
/* Define if we have _controlfp() */
|
||||
#cmakedefine HAVE__CONTROLFP
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,294 @@
|
||||
/*
|
||||
* openal-info: Display information about ALC and AL.
|
||||
*
|
||||
* Idea based on glxinfo for OpenGL.
|
||||
* Initial OpenAL version by Erik Hofman <erik@ehofman.com>.
|
||||
* Further hacked by Sven Panne <sven.panne@aedion.de>.
|
||||
* More work (clean up) by Chris Robinson <chris.kcat@gmail.com>.
|
||||
*
|
||||
*/
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "AL/alc.h"
|
||||
#include "AL/al.h"
|
||||
#include "AL/alext.h"
|
||||
|
||||
#ifndef ALC_EXT_EFX
|
||||
#define AL_FILTER_TYPE 0x8001
|
||||
#define AL_EFFECT_TYPE 0x8001
|
||||
#define AL_FILTER_NULL 0x0000
|
||||
#define AL_FILTER_LOWPASS 0x0001
|
||||
#define AL_FILTER_HIGHPASS 0x0002
|
||||
#define AL_FILTER_BANDPASS 0x0003
|
||||
#define AL_EFFECT_NULL 0x0000
|
||||
#define AL_EFFECT_EAXREVERB 0x8000
|
||||
#define AL_EFFECT_REVERB 0x0001
|
||||
#define AL_EFFECT_CHORUS 0x0002
|
||||
#define AL_EFFECT_DISTORTION 0x0003
|
||||
#define AL_EFFECT_ECHO 0x0004
|
||||
#define AL_EFFECT_FLANGER 0x0005
|
||||
#define AL_EFFECT_FREQUENCY_SHIFTER 0x0006
|
||||
#define AL_EFFECT_VOCAL_MORPHER 0x0007
|
||||
#define AL_EFFECT_PITCH_SHIFTER 0x0008
|
||||
#define AL_EFFECT_RING_MODULATOR 0x0009
|
||||
#define AL_EFFECT_AUTOWAH 0x000A
|
||||
#define AL_EFFECT_COMPRESSOR 0x000B
|
||||
#define AL_EFFECT_EQUALIZER 0x000C
|
||||
#define ALC_EFX_MAJOR_VERSION 0x20001
|
||||
#define ALC_EFX_MINOR_VERSION 0x20002
|
||||
#define ALC_MAX_AUXILIARY_SENDS 0x20003
|
||||
#endif
|
||||
ALvoid (AL_APIENTRY *p_alGenFilters)(ALsizei,ALuint*);
|
||||
ALvoid (AL_APIENTRY *p_alDeleteFilters)(ALsizei,ALuint*);
|
||||
ALvoid (AL_APIENTRY *p_alFilteri)(ALuint,ALenum,ALint);
|
||||
ALvoid (AL_APIENTRY *p_alGenEffects)(ALsizei,ALuint*);
|
||||
ALvoid (AL_APIENTRY *p_alDeleteEffects)(ALsizei,ALuint*);
|
||||
ALvoid (AL_APIENTRY *p_alEffecti)(ALuint,ALenum,ALint);
|
||||
|
||||
static const int indentation = 4;
|
||||
static const int maxmimumWidth = 79;
|
||||
|
||||
static void printChar(int c, int *width)
|
||||
{
|
||||
putchar(c);
|
||||
*width = ((c == '\n') ? 0 : ((*width) + 1));
|
||||
}
|
||||
|
||||
static void indent(int *width)
|
||||
{
|
||||
int i;
|
||||
for(i = 0; i < indentation; i++)
|
||||
printChar(' ', width);
|
||||
}
|
||||
|
||||
static void printExtensions(const char *header, char separator, const char *extensions)
|
||||
{
|
||||
int width = 0, start = 0, end = 0;
|
||||
|
||||
printf("%s:\n", header);
|
||||
if(extensions == NULL || extensions[0] == '\0')
|
||||
return;
|
||||
|
||||
indent(&width);
|
||||
while (1)
|
||||
{
|
||||
if(extensions[end] == separator || extensions[end] == '\0')
|
||||
{
|
||||
if(width + end - start + 2 > maxmimumWidth)
|
||||
{
|
||||
printChar('\n', &width);
|
||||
indent(&width);
|
||||
}
|
||||
while(start < end)
|
||||
{
|
||||
printChar(extensions[start], &width);
|
||||
start++;
|
||||
}
|
||||
if(extensions[end] == '\0')
|
||||
break;
|
||||
start++;
|
||||
end++;
|
||||
if(extensions[end] == '\0')
|
||||
break;
|
||||
printChar(',', &width);
|
||||
printChar(' ', &width);
|
||||
}
|
||||
end++;
|
||||
}
|
||||
printChar('\n', &width);
|
||||
}
|
||||
|
||||
static void die(const char *kind, const char *description)
|
||||
{
|
||||
fprintf(stderr, "%s error %s occured\n", kind, description);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
static void checkForErrors(void)
|
||||
{
|
||||
{
|
||||
ALCdevice *device = alcGetContextsDevice(alcGetCurrentContext());
|
||||
ALCenum error = alcGetError(device);
|
||||
if(error != ALC_NO_ERROR)
|
||||
die("ALC", (const char*)alcGetString(device, error));
|
||||
}
|
||||
{
|
||||
ALenum error = alGetError();
|
||||
if(error != AL_NO_ERROR)
|
||||
die("AL", (const char*)alGetString(error));
|
||||
}
|
||||
}
|
||||
|
||||
static void printDevices(ALCenum which, const char *kind)
|
||||
{
|
||||
const char *s = alcGetString(NULL, which);
|
||||
checkForErrors();
|
||||
|
||||
printf("Available %sdevices:\n", kind);
|
||||
while(*s != '\0')
|
||||
{
|
||||
printf(" %s\n", s);
|
||||
while(*s++ != '\0')
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
static void printALCInfo (void)
|
||||
{
|
||||
ALCint major, minor;
|
||||
ALCdevice *device;
|
||||
|
||||
if(alcIsExtensionPresent(NULL, (const ALCchar*)"ALC_ENUMERATION_EXT") == AL_TRUE)
|
||||
{
|
||||
if(alcIsExtensionPresent(NULL, (const ALCchar*)"ALC_ENUMERATE_ALL_EXT") == AL_TRUE)
|
||||
printDevices(ALC_ALL_DEVICES_SPECIFIER, "playback ");
|
||||
else
|
||||
printDevices(ALC_DEVICE_SPECIFIER, "playback ");
|
||||
printDevices(ALC_CAPTURE_DEVICE_SPECIFIER, "capture ");
|
||||
}
|
||||
else
|
||||
printf("No device enumeration available\n");
|
||||
|
||||
device = alcGetContextsDevice(alcGetCurrentContext());
|
||||
checkForErrors();
|
||||
|
||||
printf("Default device: %s\n",
|
||||
alcGetString(device, ALC_DEFAULT_DEVICE_SPECIFIER));
|
||||
|
||||
printf("Default capture device: %s\n",
|
||||
alcGetString(device, ALC_CAPTURE_DEFAULT_DEVICE_SPECIFIER));
|
||||
|
||||
alcGetIntegerv(device, ALC_MAJOR_VERSION, 1, &major);
|
||||
alcGetIntegerv(device, ALC_MINOR_VERSION, 1, &minor);
|
||||
checkForErrors();
|
||||
printf("ALC version: %d.%d\n", (int)major, (int)minor);
|
||||
|
||||
printExtensions("ALC extensions", ' ',
|
||||
alcGetString(device, ALC_EXTENSIONS));
|
||||
checkForErrors();
|
||||
}
|
||||
|
||||
static void printALInfo(void)
|
||||
{
|
||||
printf("OpenAL vendor string: %s\n", alGetString(AL_VENDOR));
|
||||
printf("OpenAL renderer string: %s\n", alGetString(AL_RENDERER));
|
||||
printf("OpenAL version string: %s\n", alGetString(AL_VERSION));
|
||||
printExtensions("OpenAL extensions", ' ', alGetString(AL_EXTENSIONS));
|
||||
checkForErrors();
|
||||
}
|
||||
|
||||
static void printEFXInfo(void)
|
||||
{
|
||||
ALCint major, minor, sends;
|
||||
ALCdevice *device;
|
||||
ALuint obj;
|
||||
int i;
|
||||
const struct {
|
||||
ALenum type;
|
||||
const char *name;
|
||||
} effects[] = {
|
||||
{ AL_EFFECT_EAXREVERB, "EAX Reverb" },
|
||||
{ AL_EFFECT_REVERB, "Reverb" },
|
||||
{ AL_EFFECT_CHORUS, "Chorus" },
|
||||
{ AL_EFFECT_DISTORTION, "Distortion" },
|
||||
{ AL_EFFECT_ECHO, "Echo" },
|
||||
{ AL_EFFECT_FLANGER, "Flanger" },
|
||||
{ AL_EFFECT_FREQUENCY_SHIFTER, "Frequency Shifter" },
|
||||
{ AL_EFFECT_VOCAL_MORPHER, "Vocal Morpher" },
|
||||
{ AL_EFFECT_PITCH_SHIFTER, "Pitch Shifter" },
|
||||
{ AL_EFFECT_RING_MODULATOR, "Ring Modulator" },
|
||||
{ AL_EFFECT_AUTOWAH, "Autowah" },
|
||||
{ AL_EFFECT_COMPRESSOR, "Compressor" },
|
||||
{ AL_EFFECT_EQUALIZER, "Equalizer" },
|
||||
{ AL_EFFECT_NULL, NULL }
|
||||
};
|
||||
const struct {
|
||||
ALenum type;
|
||||
const char *name;
|
||||
} filters[] = {
|
||||
{ AL_FILTER_LOWPASS, "Low-pass" },
|
||||
{ AL_FILTER_HIGHPASS, "High-pass" },
|
||||
{ AL_FILTER_BANDPASS, "Band-pass" },
|
||||
{ AL_FILTER_NULL, NULL }
|
||||
};
|
||||
|
||||
device = alcGetContextsDevice(alcGetCurrentContext());
|
||||
|
||||
if(alcIsExtensionPresent(device, (const ALCchar*)"ALC_EXT_EFX") == AL_FALSE)
|
||||
{
|
||||
printf("EFX not available\n");
|
||||
return;
|
||||
}
|
||||
|
||||
alcGetIntegerv(device, ALC_EFX_MAJOR_VERSION, 1, &major);
|
||||
alcGetIntegerv(device, ALC_EFX_MINOR_VERSION, 1, &minor);
|
||||
checkForErrors();
|
||||
printf("EFX version: %d.%d\n", (int)major, (int)minor);
|
||||
|
||||
alcGetIntegerv(device, ALC_MAX_AUXILIARY_SENDS, 1, &sends);
|
||||
checkForErrors();
|
||||
printf("Max auxiliary sends: %d\n", (int)sends);
|
||||
|
||||
p_alGenFilters = alGetProcAddress("alGenFilters");
|
||||
p_alDeleteFilters = alGetProcAddress("alDeleteFilters");
|
||||
p_alFilteri = alGetProcAddress("alFilteri");
|
||||
p_alGenEffects = alGetProcAddress("alGenEffects");
|
||||
p_alDeleteEffects = alGetProcAddress("alDeleteEffects");
|
||||
p_alEffecti = alGetProcAddress("alEffecti");
|
||||
checkForErrors();
|
||||
if(!p_alGenEffects || !p_alDeleteEffects || !p_alEffecti ||
|
||||
!p_alGenFilters || !p_alDeleteFilters || !p_alFilteri)
|
||||
{
|
||||
printf("Missing EFX functions!\n");
|
||||
return;
|
||||
}
|
||||
|
||||
p_alGenFilters(1, &obj);
|
||||
checkForErrors();
|
||||
printf("Available filters:\n");
|
||||
for(i = 0;filters[i].type != AL_FILTER_NULL;i++)
|
||||
{
|
||||
p_alFilteri(obj, AL_FILTER_TYPE, filters[i].type);
|
||||
if(alGetError() == AL_NO_ERROR)
|
||||
printf(" %s\n", filters[i].name);
|
||||
}
|
||||
p_alDeleteFilters(1, &obj);
|
||||
checkForErrors();
|
||||
|
||||
p_alGenEffects(1, &obj);
|
||||
checkForErrors();
|
||||
printf("Available effects:\n");
|
||||
for(i = 0;effects[i].type != AL_EFFECT_NULL;i++)
|
||||
{
|
||||
p_alEffecti(obj, AL_EFFECT_TYPE, effects[i].type);
|
||||
if(alGetError() == AL_NO_ERROR)
|
||||
printf(" %s\n", effects[i].name);
|
||||
}
|
||||
p_alDeleteEffects(1, &obj);
|
||||
checkForErrors();
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
ALCdevice *device = alcOpenDevice(NULL);
|
||||
ALCcontext *context = alcCreateContext(device, NULL);
|
||||
alcMakeContextCurrent(context);
|
||||
checkForErrors();
|
||||
|
||||
printALCInfo();
|
||||
printALInfo();
|
||||
printEFXInfo();
|
||||
checkForErrors();
|
||||
|
||||
alcMakeContextCurrent(NULL);
|
||||
alcDestroyContext(context);
|
||||
alcCloseDevice(device);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
@@ -166,11 +166,6 @@ typedef void ALCvoid;
|
||||
#define ALC_ATTRIBUTES_SIZE 0x1002
|
||||
#define ALC_ALL_ATTRIBUTES 0x1003
|
||||
|
||||
/**
|
||||
* ALC_ENUMERATE_ALL_EXT enums
|
||||
*/
|
||||
#define ALC_DEFAULT_ALL_DEVICES_SPECIFIER 0x1012
|
||||
#define ALC_ALL_DEVICES_SPECIFIER 0x1013
|
||||
|
||||
/**
|
||||
* Capture extension
|
||||
|
||||
@@ -0,0 +1,157 @@
|
||||
/**
|
||||
* OpenAL cross platform audio library
|
||||
* Copyright (C) 2008 by authors.
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* 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
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
* Or go to http://www.gnu.org/copyleft/lgpl.html
|
||||
*/
|
||||
|
||||
#ifndef AL_ALEXT_H
|
||||
#define AL_ALEXT_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef AL_LOKI_IMA_ADPCM_format
|
||||
#define AL_LOKI_IMA_ADPCM_format 1
|
||||
#define AL_FORMAT_IMA_ADPCM_MONO16_EXT 0x10000
|
||||
#define AL_FORMAT_IMA_ADPCM_STEREO16_EXT 0x10001
|
||||
#endif
|
||||
|
||||
#ifndef AL_LOKI_WAVE_format
|
||||
#define AL_LOKI_WAVE_format 1
|
||||
#define AL_FORMAT_WAVE_EXT 0x10002
|
||||
#endif
|
||||
|
||||
#ifndef AL_EXT_vorbis
|
||||
#define AL_EXT_vorbis 1
|
||||
#define AL_FORMAT_VORBIS_EXT 0x10003
|
||||
#endif
|
||||
|
||||
#ifndef AL_LOKI_quadriphonic
|
||||
#define AL_LOKI_quadriphonic 1
|
||||
#define AL_FORMAT_QUAD8_LOKI 0x10004
|
||||
#define AL_FORMAT_QUAD16_LOKI 0x10005
|
||||
#endif
|
||||
|
||||
#ifndef AL_EXT_float32
|
||||
#define AL_EXT_float32 1
|
||||
#define AL_FORMAT_MONO_FLOAT32 0x10010
|
||||
#define AL_FORMAT_STEREO_FLOAT32 0x10011
|
||||
#endif
|
||||
|
||||
#ifndef ALC_LOKI_audio_channel
|
||||
#define ALC_LOKI_audio_channel 1
|
||||
#define ALC_CHAN_MAIN_LOKI 0x500001
|
||||
#define ALC_CHAN_PCM_LOKI 0x500002
|
||||
#define ALC_CHAN_CD_LOKI 0x500003
|
||||
#endif
|
||||
|
||||
#ifndef ALC_ENUMERATE_ALL_EXT
|
||||
#define ALC_ENUMERATE_ALL_EXT 1
|
||||
#define ALC_DEFAULT_ALL_DEVICES_SPECIFIER 0x1012
|
||||
#define ALC_ALL_DEVICES_SPECIFIER 0x1013
|
||||
#endif
|
||||
|
||||
#ifndef AL_EXT_MCFORMATS
|
||||
#define AL_EXT_MCFORMATS 1
|
||||
#define AL_FORMAT_QUAD8 0x1204
|
||||
#define AL_FORMAT_QUAD16 0x1205
|
||||
#define AL_FORMAT_QUAD32 0x1206
|
||||
#define AL_FORMAT_REAR8 0x1207
|
||||
#define AL_FORMAT_REAR16 0x1208
|
||||
#define AL_FORMAT_REAR32 0x1209
|
||||
#define AL_FORMAT_51CHN8 0x120A
|
||||
#define AL_FORMAT_51CHN16 0x120B
|
||||
#define AL_FORMAT_51CHN32 0x120C
|
||||
#define AL_FORMAT_61CHN8 0x120D
|
||||
#define AL_FORMAT_61CHN16 0x120E
|
||||
#define AL_FORMAT_61CHN32 0x120F
|
||||
#define AL_FORMAT_71CHN8 0x1210
|
||||
#define AL_FORMAT_71CHN16 0x1211
|
||||
#define AL_FORMAT_71CHN32 0x1212
|
||||
#endif
|
||||
|
||||
#ifndef AL_EXT_IMA4
|
||||
#define AL_EXT_IMA4 1
|
||||
#define AL_FORMAT_MONO_IMA4 0x1300
|
||||
#define AL_FORMAT_STEREO_IMA4 0x1301
|
||||
#endif
|
||||
|
||||
#ifndef AL_EXT_buffer_sub_data
|
||||
#define AL_EXT_buffer_sub_data 1
|
||||
#define AL_BYTE_RW_OFFSETS_EXT 0x1031
|
||||
#define AL_SAMPLE_RW_OFFSETS_EXT 0x1032
|
||||
#define AL_SEC_RW_OFFSETS_EXT 0x1033
|
||||
typedef ALvoid (AL_APIENTRY*PFNALBUFFERSUBDATAEXTPROC)(ALuint,ALenum,const ALvoid*,ALsizei,ALsizei);
|
||||
#endif
|
||||
|
||||
#ifndef AL_EXT_BUFFER_DATA_STATIC
|
||||
#define AL_EXT_BUFFER_DATA_STATIC 1
|
||||
typedef ALvoid (AL_APIENTRY*PFNALBUFFERDATASTATICPROC)(const ALint,ALenum,ALvoid*,ALsizei,ALsizei);
|
||||
#endif
|
||||
|
||||
#ifndef AL_EXT_sample_buffer_object
|
||||
#define AL_EXT_sample_buffer_object 1
|
||||
#define AL_SAMPLE_SOURCE_EXT 0x1040
|
||||
#define AL_SAMPLE_SINK_EXT 0x1041
|
||||
#define AL_READ_ONLY_EXT 0x1042
|
||||
#define AL_WRITE_ONLY_EXT 0x1043
|
||||
#define AL_READ_WRITE_EXT 0x1044
|
||||
#define AL_STREAM_WRITE_EXT 0x1045
|
||||
#define AL_STREAM_READ_EXT 0x1046
|
||||
#define AL_STREAM_COPY_EXT 0x1047
|
||||
#define AL_STATIC_WRITE_EXT 0x1048
|
||||
#define AL_STATIC_READ_EXT 0x1049
|
||||
#define AL_STATIC_COPY_EXT 0x104A
|
||||
#define AL_DYNAMIC_WRITE_EXT 0x104B
|
||||
#define AL_DYNAMIC_READ_EXT 0x104C
|
||||
#define AL_DYNAMIC_COPY_EXT 0x104D
|
||||
typedef ALvoid (AL_APIENTRY*PFNALGENDATABUFFERSEXTPROC)(ALsizei n,ALuint *puiBuffers);
|
||||
typedef ALvoid (AL_APIENTRY*PFNALDELETEDATABUFFERSEXTPROC)(ALsizei n, const ALuint *puiBuffers);
|
||||
typedef ALboolean (AL_APIENTRY*PFNALISDATABUFFEREXTPROC)(ALuint uiBuffer);
|
||||
typedef ALvoid (AL_APIENTRY*PFNALDATABUFFERDATAEXTPROC)(ALuint buffer,const ALvoid *data,ALsizei size,ALenum usage);
|
||||
typedef ALvoid (AL_APIENTRY*PFNALDATABUFFERSUBDATAEXTPROC)(ALuint buffer, ALuint start, ALsizei length, const ALvoid *);
|
||||
typedef ALvoid (AL_APIENTRY*PFNALGETDATABUFFERSUBDATAEXTPROC)(ALuint buffer, ALuint start, ALsizei length, ALvoid *);
|
||||
typedef ALvoid (AL_APIENTRY*PFNALDATABUFFERFEXTPROC)(ALuint buffer, ALenum eParam, ALfloat flValue);
|
||||
typedef ALvoid (AL_APIENTRY*PFNALDATABUFFERFVEXTPROC)(ALuint buffer, ALenum eParam, const ALfloat* flValues);
|
||||
typedef ALvoid (AL_APIENTRY*PFNALDATABUFFERIEXTPROC)(ALuint buffer, ALenum eParam, ALint lValue);
|
||||
typedef ALvoid (AL_APIENTRY*PFNALDATABUFFERIVEXTPROC)(ALuint buffer, ALenum eParam, const ALint* plValues);
|
||||
typedef ALvoid (AL_APIENTRY*PFNALGETDATABUFFERFEXTPROC)(ALuint buffer, ALenum eParam, ALfloat *pflValue);
|
||||
typedef ALvoid (AL_APIENTRY*PFNALGETDATABUFFERFVEXTPROC)(ALuint buffer, ALenum eParam, ALfloat* pflValues);
|
||||
typedef ALvoid (AL_APIENTRY*PFNALGETDATABUFFERIEXTPROC)(ALuint buffer, ALenum eParam, ALint *plValue);
|
||||
typedef ALvoid (AL_APIENTRY*PFNALGETDATABUFFERIVEXTPROC)(ALuint buffer, ALenum eParam, ALint* plValues);
|
||||
typedef ALvoid (AL_APIENTRY*PFNALSELECTDATABUFFEREXTPROC)(ALenum target, ALuint uiBuffer);
|
||||
typedef ALvoid* (AL_APIENTRY*PFNALMAPDATABUFFEREXTPROC)(ALuint uiBuffer, ALuint start, ALsizei length, ALenum access);
|
||||
typedef ALvoid (AL_APIENTRY*PFNALUNMAPDATABUFFEREXTPROC)(ALuint uiBuffer);
|
||||
#endif
|
||||
|
||||
#ifndef ALC_EXT_disconnect
|
||||
#define ALC_EXT_disconnect 1
|
||||
#define ALC_CONNECTED 0x313
|
||||
#endif
|
||||
|
||||
#ifndef ALC_EXT_thread_local_context
|
||||
#define ALC_EXT_thread_local_context 1
|
||||
typedef ALCboolean (ALCAPIENTRY*PFNALCMAKECURRENTPROC)(ALCcontext *context);
|
||||
typedef ALCcontext* (ALCAPIENTRY*PFNALCGETTHREADCONTEXTPROC)(void);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -1,50 +0,0 @@
|
||||
# OpenAL config file. Options that are not under a block or are under the
|
||||
# [general] block are for general, non-backend-specific options. Blocks may
|
||||
# appear multiple times, and duplicated options will take the last value
|
||||
# specified. The system-wide settings can be put in /etc/openal/config and
|
||||
# user-specific override settings in ~/.openalrc
|
||||
|
||||
# Option and block names are case-insenstive. The supplied values are only
|
||||
# hints and may not be honored (though generally it'll try to get as close as
|
||||
# possible). These are the current available settings:
|
||||
|
||||
format = AL_FORMAT_STEREO16 # Sets the output format. Can be one of:
|
||||
# AL_FORMAT_MONO8 (8-bit mono)
|
||||
# AL_FORMAT_STEREO8 (8-bit stereo)
|
||||
# AL_FORMAT_QUAD8 (8-bit 4-channel)
|
||||
# AL_FORMAT_MONO16 (16-bit mono)
|
||||
# AL_FORMAT_STEREO16 (16-bit stereo)
|
||||
# AL_FORMAT_QUAD16 (16-bit 4-channel)
|
||||
# Default is AL_FORMAT_STEREO16
|
||||
|
||||
frequency = 44100 # Sets the output frequency. Default is 44100
|
||||
|
||||
refresh = 0 # Sets the number of frames-per-update. Default is calculated as
|
||||
# 8192*frequency/22050. Note that the actual granularity may or
|
||||
# may not be less than this.
|
||||
|
||||
drivers = # Sets the backend driver list order, comma-seperated. Unknown
|
||||
# backends and duplicated names are ignored, and unlisted backends
|
||||
# won't be considered for use. An empty list means the default.
|
||||
# Default is:
|
||||
# alsa,oss,dsound,winmm
|
||||
|
||||
[alsa] # ALSA backend stuff
|
||||
device = default # Sets the device name for the default playback device.
|
||||
# Default is default
|
||||
|
||||
periods = 4 # Sets the number of update buffers. Default is 4
|
||||
|
||||
capture = default # Sets the device name for the default capture device.
|
||||
# Default is default
|
||||
|
||||
[oss] # OSS backend stuff
|
||||
device = /dev/dsp # Sets the device name for OSS output. Default is /dev/dsp
|
||||
|
||||
periods = 4 # Sets the number of update buffers. Default is 4
|
||||
|
||||
[dsound] # DirectSound backend stuff
|
||||
# Nothing yet...
|
||||
|
||||
[winmm] # Windows Multimedia backend stuff
|
||||
# Nothing yet...
|
||||
Reference in New Issue
Block a user