Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d1d6257731 | ||
|
|
ba9b2f1e49 | ||
|
|
7b4ccb3e9f | ||
|
|
4195a345a5 | ||
|
|
004bc95263 | ||
|
|
24fc176dfb | ||
|
|
056901b2be | ||
|
|
20991a95b8 | ||
|
|
31adc87bde | ||
|
|
2d4e8b623d | ||
|
|
bc1dce5d5b | ||
|
|
0fad73862c | ||
|
|
49690dd54b | ||
|
|
c9204fe3a5 | ||
|
|
24e7fac50b | ||
|
|
554c65e466 | ||
|
|
8128b7c8e2 | ||
|
|
0c9b655477 | ||
|
|
9fb949b49a | ||
|
|
909b8f89d8 | ||
|
|
77bac5b550 | ||
|
|
64067a9b7c | ||
|
|
62acd315ad | ||
|
|
c55b242b4e | ||
|
|
1e46bda0f8 | ||
|
|
16723d4bb1 | ||
|
|
4c3f95708f | ||
|
|
9a88b118b4 | ||
|
|
785eacf4f3 | ||
|
|
5722f93a74 | ||
|
|
bf13bd0d47 | ||
|
|
dd973da108 | ||
|
|
cbda46370c | ||
|
|
a4cdf1a727 | ||
|
|
e420464ba6 | ||
|
|
6fc0fe4426 | ||
|
|
671df54e4d | ||
|
|
81f3b3aafe | ||
|
|
796d5266f1 | ||
|
|
7c804cd796 | ||
|
|
ea442fa047 | ||
|
|
0915a8497b | ||
|
|
8135838018 | ||
|
|
f54ae2031e | ||
|
|
453ea2cb6c | ||
|
|
9fee7077d4 | ||
|
|
30fd858e5e | ||
|
|
9acea8759b | ||
|
|
31a4547187 | ||
|
|
994459e4ce | ||
|
|
a1f949d3b8 | ||
|
|
459b40cc4b | ||
|
|
9628edede0 | ||
|
|
bd5a02d080 | ||
|
|
2a80680d95 | ||
|
|
8e87ddd7fe | ||
|
|
e4a1086cfb | ||
|
|
12b4f177ec | ||
|
|
6a73fcc9ed | ||
|
|
2dd8982f73 | ||
|
|
6eccd4a573 | ||
|
|
27bc881cd8 | ||
|
|
b0c1455aa4 | ||
|
|
e2d90b383b | ||
|
|
c19f634e6c | ||
|
|
82e81421d7 | ||
|
|
0d05038790 | ||
|
|
38636345b1 | ||
|
|
9604c45e24 | ||
|
|
e69d1f2780 | ||
|
|
e9af0592d9 | ||
|
|
ce60c1adf7 | ||
|
|
35f43dfacb | ||
|
|
b7e179f6d3 | ||
|
|
3909e4cdfc | ||
|
|
3e90a5fe81 | ||
|
|
27ccad541a | ||
|
|
bf611ff0f6 | ||
|
|
0c877d2fdc | ||
|
|
8368ead1fa | ||
|
|
d22d24a6d5 | ||
|
|
fb84c6974d | ||
|
|
92ded6c6fd | ||
|
|
3d03298e86 | ||
|
|
c1002f6a28 | ||
|
|
861c126b08 | ||
|
|
8fda7247ff | ||
|
|
172ce98433 | ||
|
|
481d15ae60 | ||
|
|
0b5af5639b | ||
|
|
0015afd059 | ||
|
|
d0cd7fa31b | ||
|
|
a655432bbe | ||
|
|
09f0f68959 | ||
|
|
dac5b598f5 | ||
|
|
cb8b0cc329 | ||
|
|
029e31f1c5 | ||
|
|
efb9943637 | ||
|
|
243a2976a8 | ||
|
|
c725f39bae | ||
|
|
1f38c2107d | ||
|
|
2f4bd58f4a | ||
|
|
fa315705be | ||
|
|
2c3f4850b8 | ||
|
|
13ade4f1bc | ||
|
|
9163bdc38a | ||
|
|
d5f29a3c36 | ||
|
|
de0523ba7b | ||
|
|
ad072b17ce | ||
|
|
2059ba2c40 | ||
|
|
492e3deb95 | ||
|
|
fb185e4e79 | ||
|
|
dcffeaccf1 | ||
|
|
b5d0195023 | ||
|
|
b47bf06f97 | ||
|
|
9b3daa4974 | ||
|
|
4c1deb680d | ||
|
|
97d50538cd | ||
|
|
1f62f38106 | ||
|
|
d85753b79e | ||
|
|
50c379e2d8 | ||
|
|
d9f8b9f7b2 | ||
|
|
d804e7b903 | ||
|
|
7df475f860 | ||
|
|
aa587580c8 | ||
|
|
4d43a0c997 | ||
|
|
b637d6366c | ||
|
|
05444e8135 | ||
|
|
190dea149a | ||
|
|
8d4a179c14 | ||
|
|
ce8524cb47 | ||
|
|
504286b006 | ||
|
|
fb8285c7a7 | ||
|
|
7dff6a2842 | ||
|
|
0710ced079 | ||
|
|
6d9cb89333 | ||
|
|
940007cbf9 | ||
|
|
bbb65ed84b | ||
|
|
30074f8440 | ||
|
|
a042dcc700 | ||
|
|
3973a953df | ||
|
|
082c23515f | ||
|
|
6bec6ac558 | ||
|
|
946bd52a1d | ||
|
|
25497226cf | ||
|
|
f9ba1a3ddf | ||
|
|
b0381d27eb | ||
|
|
3e1aed8f40 | ||
|
|
ff520054c8 | ||
|
|
1a6f3c56ea | ||
|
|
af958221a1 | ||
|
|
2037426a65 | ||
|
|
e8960c69e9 | ||
|
|
23a5329690 | ||
|
|
eac0665b8d | ||
|
|
3de6c9aa42 | ||
|
|
8673343957 | ||
|
|
d1119cc069 | ||
|
|
ad25de5903 | ||
|
|
f8b09658f4 | ||
|
|
d5274d9298 | ||
|
|
5afa68835a | ||
|
|
5360baa49e | ||
|
|
fccc3d3894 | ||
|
|
7fa06e46c4 | ||
|
|
0afb1acab3 | ||
|
|
05b6646d7a | ||
|
|
35296c1f33 | ||
|
|
3ae726e8dd | ||
|
|
c188240ab9 | ||
|
|
099fdde7a4 | ||
|
|
cbc951d491 | ||
|
|
fc7212b214 | ||
|
|
f2187de8bb | ||
|
|
31c29495ca | ||
|
|
a191712169 | ||
|
|
517a35da94 | ||
|
|
821e8fb9d0 | ||
|
|
4b81398b4e | ||
|
|
d1cbff37be | ||
|
|
aa5f04c7a0 | ||
|
|
e15526153e | ||
|
|
48b103cad7 | ||
|
|
7f313afd08 | ||
|
|
7558d1ed7b | ||
|
|
0563eb914f | ||
|
|
abbb43759a | ||
|
|
6205d87a7f | ||
|
|
491958a724 | ||
|
|
808653a9b6 | ||
|
|
d2013b3f50 | ||
|
|
5790bbba61 | ||
|
|
f1a2610c4f | ||
|
|
2da533bec3 | ||
|
|
127da1613f | ||
|
|
c01935986c | ||
|
|
0a0bb9059f | ||
|
|
1f7c099dc0 | ||
|
|
78bfee53dd | ||
|
|
cd24fdcd5a | ||
|
|
47f2f554a3 | ||
|
|
a0519f1d18 | ||
|
|
4cc1861378 | ||
|
|
6154c1d06d | ||
|
|
32cd85bc7e | ||
|
|
3394d37b4e | ||
|
|
d2baaaa7df | ||
|
|
fc9eef3b81 | ||
|
|
58d45f7b3e | ||
|
|
8a9cde4999 | ||
|
|
3925dff2e6 | ||
|
|
f1909bc231 | ||
|
|
5dd5dc66c1 | ||
|
|
00135a87f0 | ||
|
|
687b552db1 | ||
|
|
2c7db48195 | ||
|
|
7137afeb2c | ||
|
|
ad80cc4eee | ||
|
|
f36c17d715 | ||
|
|
04af005c35 | ||
|
|
74c11f0c84 | ||
|
|
e798cf1ff6 | ||
|
|
cab942acae | ||
|
|
c7985fe5f7 | ||
|
|
29226e6a99 | ||
|
|
d0fd68f6df | ||
|
|
8d0a6cd035 | ||
|
|
f24ba544cd | ||
|
|
000285ee8e | ||
|
|
67a4892ee3 | ||
|
|
e1993d5ad2 | ||
|
|
0607dcebff | ||
|
|
3d12312806 | ||
|
|
a6521f3941 | ||
|
|
475fe453cc | ||
|
|
3da91a673a | ||
|
|
47e6ef0bdf | ||
|
|
6d36c432ab | ||
|
|
45ae0716be | ||
|
|
c5c7b239b6 | ||
|
|
c2d0d7818f | ||
|
|
0d7d935e88 | ||
|
|
3d66a5d14e | ||
|
|
c138505813 | ||
|
|
663415b914 | ||
|
|
c569d4f6ed | ||
|
|
e6058d3dc3 | ||
|
|
c1a96de41c | ||
|
|
18fe6e6dc8 | ||
|
|
aaa64b879e | ||
|
|
159eb3f962 | ||
|
|
9db50c6760 | ||
|
|
970606e491 | ||
|
|
7d7ea72854 | ||
|
|
0262295c4b | ||
|
|
48ed48f7b8 | ||
|
|
94c062d0d2 | ||
|
|
04934e86dd | ||
|
|
ff1eaea3e7 | ||
|
|
9a240dc82e | ||
|
|
a7cf091519 | ||
|
|
a2e7642d3c | ||
|
|
565efeeada | ||
|
|
c46106d633 | ||
|
|
63204eda5d | ||
|
|
791228f2ab | ||
|
|
19b0b1df51 | ||
|
|
30bbcd6452 | ||
|
|
832cb56f2d | ||
|
|
68c6da69f7 | ||
|
|
f626bef7c8 | ||
|
|
81746a1798 | ||
|
|
01c418f9df | ||
|
|
3b6c7275bc | ||
|
|
6562d4a562 | ||
|
|
17507b5935 | ||
|
|
57e691b901 | ||
|
|
344d44681e | ||
|
|
03d311823d | ||
|
|
9cb7646071 | ||
|
|
42a0f4d87b | ||
|
|
69cc002c92 | ||
|
|
b325ed1105 | ||
|
|
30f18b8dc7 | ||
|
|
e1d414c992 | ||
|
|
7f3cf75c5a | ||
|
|
ece794d905 | ||
|
|
3fa76c84be | ||
|
|
66d93c711b | ||
|
|
03a81a9d85 | ||
|
|
e2c0e7f5c2 | ||
|
|
8bf34950c1 | ||
|
|
2b990ac810 | ||
|
|
005f03d99f | ||
|
|
6ff1cd5502 | ||
|
|
9fc74d5acd | ||
|
|
2b07d3eb47 | ||
|
|
73e0d545ce | ||
|
|
50d43a1db4 | ||
|
|
318e9801f2 | ||
|
|
ea1caa474a | ||
|
|
7023c383b2 | ||
|
|
2bee47fd27 | ||
|
|
c8e0e35709 | ||
|
|
9afd62bfcd | ||
|
|
eec844a06e | ||
|
|
50bb209a80 | ||
|
|
41f2c653e2 | ||
|
|
85498a0797 | ||
|
|
b250c19a38 | ||
|
|
69ba4f776f | ||
|
|
4c111fbcde | ||
|
|
12eb8b2de8 | ||
|
|
44376d2d9b | ||
|
|
b8bcf0f466 | ||
|
|
1fe64c61be | ||
|
|
772961f0ce | ||
|
|
5bc9b273b3 | ||
|
|
0425741754 | ||
|
|
19c1a208ec | ||
|
|
422ed42817 | ||
|
|
fa2fdaab0a | ||
|
|
b7d614aa0d | ||
|
|
dab2e909af | ||
|
|
06df54a111 | ||
|
|
ef918b239e | ||
|
|
00b7fb3023 | ||
|
|
4f103b2093 | ||
|
|
2e401201ad | ||
|
|
b2e8d5749b | ||
|
|
52af1f72e2 | ||
|
|
c9d1aa1d3c | ||
|
|
718807b78b | ||
|
|
d2efa56d48 | ||
|
|
01a2af6c7c | ||
|
|
b38094ad91 | ||
|
|
9817473163 | ||
|
|
c5a4fd9bee | ||
|
|
d5df90a295 | ||
|
|
3245b7f275 | ||
|
|
59eb489425 | ||
|
|
4fd0cd4a73 | ||
|
|
6df3fa2ec1 | ||
|
|
1a8b06f67e | ||
|
|
92d06f43fa | ||
|
|
23f3b99003 | ||
|
|
b86a59aa4f | ||
|
|
368431f57c | ||
|
|
94147762fc | ||
|
|
e10727baa7 | ||
|
|
a6fb80baa4 | ||
|
|
f9a2fc592f | ||
|
|
76e4374d06 | ||
|
|
7e285a6f71 | ||
|
|
516e7d19da | ||
|
|
58caf577f1 | ||
|
|
76fcef618b | ||
|
|
74c862c68e | ||
|
|
9f858cc759 | ||
|
|
ca77bcd543 | ||
|
|
e086d40486 | ||
|
|
eda518f558 | ||
|
|
e76ec2c963 | ||
|
|
a3195381d1 | ||
|
|
8ff2058681 | ||
|
|
0ec35fa111 | ||
|
|
25fe9e89e7 | ||
|
|
0e0f07bbef | ||
|
|
c7a39b8521 | ||
|
|
5a89150a46 | ||
|
|
85450d06a1 | ||
|
|
70df1608d6 | ||
|
|
e24e0ccd68 | ||
|
|
514f5d760e | ||
|
|
05be95c8ce | ||
|
|
6b22b21651 | ||
|
|
07c546b2b4 | ||
|
|
bf0b178e71 | ||
|
|
883d311413 | ||
|
|
c7d82dd25c | ||
|
|
cf3b34f17a | ||
|
|
a790009a63 | ||
|
|
542d88472f | ||
|
|
9f43778eb2 | ||
|
|
0f3dedebb4 | ||
|
|
70d46a9fb8 | ||
|
|
c362c3d7ae | ||
|
|
07b8abbd62 | ||
|
|
d5981924fe | ||
|
|
62b386c2fd | ||
|
|
fad254562b | ||
|
|
d32c4c75ef | ||
|
|
624c9e46ce | ||
|
|
f0feea5591 | ||
|
|
def87f1e5f | ||
|
|
b726fefe5d | ||
|
|
49a41bf4df | ||
|
|
384b13c5fd | ||
|
|
977869a804 | ||
|
|
7c4fe02d01 | ||
|
|
b7398cbdd8 | ||
|
|
9774be0d15 | ||
|
|
a33a44cf4e | ||
|
|
273607c1c6 | ||
|
|
fee45c0170 | ||
|
|
9a6ec9de2f | ||
|
|
4682b0147e | ||
|
|
479eb93d9e | ||
|
|
9d9f863f55 | ||
|
|
dd0c85679b | ||
|
|
4efadb2808 | ||
|
|
cf5b117553 | ||
|
|
434512827f | ||
|
|
03bbaad686 | ||
|
|
3dc0f2ecf0 | ||
|
|
eeb5f98758 | ||
|
|
caa497ee8a | ||
|
|
930f841589 | ||
|
|
8baf773d0e | ||
|
|
11888a9270 | ||
|
|
76e50f6a3d | ||
|
|
7d5282ea5d | ||
|
|
f757163058 | ||
|
|
ac64ce71d6 | ||
|
|
16cd20c46f | ||
|
|
8f7b12d9ae | ||
|
|
66f8e45311 | ||
|
|
0ff3ffb2be | ||
|
|
d91434756b | ||
|
|
03013e0fd7 | ||
|
|
62f261a7b8 | ||
|
|
c3f2ef5491 | ||
|
|
67caea357c | ||
|
|
b1893d2084 | ||
|
|
46cee66563 | ||
|
|
0062c98dff | ||
|
|
6bbb1e4cf9 | ||
|
|
1356755ad4 | ||
|
|
2dc18a2f82 | ||
|
|
a7f51f8fd4 | ||
|
|
5a7c22a1ac | ||
|
|
617aff6cda | ||
|
|
b984ec52aa | ||
|
|
9693e0f57a | ||
|
|
647b360a0a | ||
|
|
68ac45e487 | ||
|
|
9e10cd9fa1 | ||
|
|
b2a3e877c0 | ||
|
|
5f89ba707d | ||
|
|
cfa4952f7c | ||
|
|
945df57357 | ||
|
|
fb193713a3 | ||
|
|
27dc834f37 | ||
|
|
3f73d63523 | ||
|
|
4c43c30421 | ||
|
|
7438f208c3 | ||
|
|
017f3d0674 | ||
|
|
2cf9ee989c | ||
|
|
66ed50aa00 | ||
|
|
179d7317e7 | ||
|
|
3108a3a001 | ||
|
|
8f7cf9443f | ||
|
|
e3db686e87 | ||
|
|
db1fc3628f | ||
|
|
3ad03f6673 | ||
|
|
f00edfd9c5 | ||
|
|
e6a395c297 | ||
|
|
be49da72ea | ||
|
|
46f59f25c2 | ||
|
|
0ca8b290a4 | ||
|
|
5a18c5ea91 | ||
|
|
a9833a71ce | ||
|
|
350d902799 | ||
|
|
e187de7eed | ||
|
|
49d94853b5 | ||
|
|
163c6ad862 | ||
|
|
4058b418bf | ||
|
|
4e358a9636 | ||
|
|
9d4aff8ac7 | ||
|
|
e162a5bf04 | ||
|
|
8d415b2e01 | ||
|
|
d634394da6 | ||
|
|
609de236a9 | ||
|
|
3f0d831af0 | ||
|
|
587bb5e811 | ||
|
|
c2220c526d | ||
|
|
b58e4abc01 | ||
|
|
3fb161ecd2 | ||
|
|
1d2d649281 | ||
|
|
8e8b420c9d | ||
|
|
9de8730dc9 | ||
|
|
30a6106477 | ||
|
|
f1e767b6a2 | ||
|
|
8581835161 | ||
|
|
cdeb0e4c72 | ||
|
|
8fd63c8f0c | ||
|
|
b92fd602ce | ||
|
|
7984d25ceb | ||
|
|
2b6241a09a | ||
|
|
93f748e77f | ||
|
|
7c6d7017bd | ||
|
|
344b65c4db | ||
|
|
03cf69f0a8 | ||
|
|
05e39ec513 | ||
|
|
7aba3a5d96 | ||
|
|
acd5816a6d | ||
|
|
8737732035 | ||
|
|
67aab3a9f6 | ||
|
|
8eb7cb28f9 | ||
|
|
3dec68ba47 | ||
|
|
d5b8d77a17 | ||
|
|
a1315c7644 | ||
|
|
532f05b83d | ||
|
|
5b7d0fbab3 | ||
|
|
ec567d8a77 | ||
|
|
33489feca8 | ||
|
|
ce82d88215 | ||
|
|
d1ad0815fe | ||
|
|
fc3f1e7c54 | ||
|
|
466658ee7e | ||
|
|
cf18922d19 | ||
|
|
3c081dfd93 | ||
|
|
a135c9cffc | ||
|
|
f891b24cb5 | ||
|
|
70aa3b04f8 | ||
|
|
c24921d56b | ||
|
|
aaec2aba38 | ||
|
|
3b95dd47d5 | ||
|
|
555ecbb70e | ||
|
|
919707efb7 | ||
|
|
c1de8cdc38 | ||
|
|
0cc440f291 | ||
|
|
0524907c18 | ||
|
|
c971fefd41 | ||
|
|
9ed289ef90 | ||
|
|
f3a003e550 | ||
|
|
48c2e9d67d | ||
|
|
0ffaf653a2 | ||
|
|
76d1b430b0 | ||
|
|
ec27d573f4 | ||
|
|
72d3c5ef00 | ||
|
|
81109dcbb6 | ||
|
|
fa510bd00c | ||
|
|
c21c26472c | ||
|
|
d6e7190836 | ||
|
|
d1a46c2c32 | ||
|
|
a02f3a5dd4 | ||
|
|
17b4fb02b3 | ||
|
|
252dcdcc99 | ||
|
|
97fc4f4a85 | ||
|
|
ad6e7c31df | ||
|
|
bf6b981367 | ||
|
|
72ded5ccef | ||
|
|
0344abd67a | ||
|
|
56fefde7e2 | ||
|
|
955c6843b6 | ||
|
|
d1528e51d5 | ||
|
|
53c720d412 | ||
|
|
878f12885b | ||
|
|
0a1a5707bf | ||
|
|
dd08018e9e | ||
|
|
56d04c6570 | ||
|
|
96eb480299 | ||
|
|
14bb3d06a2 | ||
|
|
1a1ac76d2a | ||
|
|
d93a9be656 | ||
|
|
dda16ee1fb | ||
|
|
78112c8582 | ||
|
|
ff778f6d68 | ||
|
|
cee9aeaf6b | ||
|
|
eb66038d4f | ||
|
|
1ee8ce75f1 | ||
|
|
0121d00478 | ||
|
|
e157d005ba | ||
|
|
251107076b | ||
|
|
750c29766f | ||
|
|
b0b67cdf5d | ||
|
|
50f8548b2f | ||
|
|
0ab6031d76 | ||
|
|
667b968939 | ||
|
|
e1128c8b28 | ||
|
|
e3de309804 | ||
|
|
9ca312b4b1 | ||
|
|
d27d91715f | ||
|
|
0eb45343ca | ||
|
|
7e7ef2f01d | ||
|
|
76bfd5b4a2 | ||
|
|
8d414e2fe7 | ||
|
|
2483dab54d | ||
|
|
3a7a2385df | ||
|
|
3274fabeb3 | ||
|
|
e0f8d79772 | ||
|
|
da496ae2fe | ||
|
|
184426175f | ||
|
|
1f9c4f19cf | ||
|
|
8b291aff96 | ||
|
|
8d004f07a4 | ||
|
|
14a2993796 | ||
|
|
3804376ccc | ||
|
|
bddd1e9e3b | ||
|
|
9e7069fde2 | ||
|
|
94b6a1054e | ||
|
|
d714c8380a | ||
|
|
b7ba2e2c57 | ||
|
|
52de5ea6ad | ||
|
|
78caf6ae86 | ||
|
|
46c499d02a | ||
|
|
dbbde6161d | ||
|
|
a62dcdd5f4 | ||
|
|
f7124be091 | ||
|
|
6499224888 | ||
|
|
252d5b319a | ||
|
|
280251656c | ||
|
|
aa796c23db | ||
|
|
0a41c6f0ec | ||
|
|
66aa54d319 | ||
|
|
288eaacd85 | ||
|
|
ecb776f88e | ||
|
|
1c593f1497 | ||
|
|
b4804a4b26 | ||
|
|
5015759334 | ||
|
|
3c292395ca | ||
|
|
8e654d3f78 | ||
|
|
0e245b3752 | ||
|
|
6fb926a560 | ||
|
|
8f33c65fe0 | ||
|
|
beae60bcd5 | ||
|
|
29e42b78c0 | ||
|
|
54fbda2ba4 | ||
|
|
e694d67366 | ||
|
|
6890de958d | ||
|
|
c855ab5624 | ||
|
|
3ccac74de2 | ||
|
|
ee283843fa | ||
|
|
291f301c10 | ||
|
|
e448e10fd7 | ||
|
|
e72ca08554 | ||
|
|
e87f705497 | ||
|
|
93db4233af | ||
|
|
fe993a6712 | ||
|
|
69bc7e34b9 | ||
|
|
a9ed9e329c | ||
|
|
8a21cb1cd3 | ||
|
|
bd87598af9 | ||
|
|
f4d62da8f0 | ||
|
|
ae7212963e | ||
|
|
24f34c9e8e | ||
|
|
98c4ab6d13 | ||
|
|
4a07205963 | ||
|
|
7c5f41ff5f | ||
|
|
a2a2cdb5bc | ||
|
|
41bf41e416 | ||
|
|
ebb43f5176 | ||
|
|
aff6e8e8da | ||
|
|
1b7e8ff6c5 | ||
|
|
739452361f | ||
|
|
ee63c9c210 | ||
|
|
b4491c00c4 | ||
|
|
12cd48a8a9 | ||
|
|
31316e9ca0 | ||
|
|
853fe788f8 | ||
|
|
1dd7b7bddc | ||
|
|
15ef9f9ee6 | ||
|
|
ad2ab5893e | ||
|
|
144571da9b | ||
|
|
8aa8417aa3 | ||
|
|
1fa674c109 | ||
|
|
710872bc22 | ||
|
|
1ff32236fa | ||
|
|
2a7811176c | ||
|
|
2e5df94f0f | ||
|
|
0c494c238a | ||
|
|
375886c777 | ||
|
|
0aa548457f | ||
|
|
e0cb65e8ac | ||
|
|
6875e6a779 | ||
|
|
ac5538c7df | ||
|
|
0ae8aebb89 | ||
|
|
361040f9d9 | ||
|
|
d2281935b3 | ||
|
|
0a6c334b59 | ||
|
|
38b747bb67 | ||
|
|
993bee38ca | ||
|
|
0b87bf9b72 | ||
|
|
456366b63b | ||
|
|
ec356d3efe | ||
|
|
5786d07450 | ||
|
|
8d8a2045bd | ||
|
|
0e9cfa6b64 | ||
|
|
d47dff3faa | ||
|
|
b81d9c79a8 | ||
|
|
57831d52dc | ||
|
|
b14c9eb748 | ||
|
|
cb1c072534 | ||
|
|
c17ff1703a | ||
|
|
65ad85790a | ||
|
|
17cd6798a6 | ||
|
|
d8d4e18835 | ||
|
|
009dfbe3b6 | ||
|
|
2ed9370bd6 | ||
|
|
e0c005cb75 | ||
|
|
4d6c1be7b6 |
No files matched your search
@@ -15,6 +15,7 @@
|
||||
/tags
|
||||
/TAGS
|
||||
/video/out/x11_icon.inc
|
||||
/video/out/opengl/nnedi3_weights.inc
|
||||
/demux/ebml_defs.c
|
||||
/demux/ebml_types.h
|
||||
/sub/osd_font.h
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
Reporting bugs
|
||||
==============
|
||||
|
||||
- State your platform and mpv version.
|
||||
- Make sure you're actually using the latest mpv release. Linux distributions
|
||||
in particular love redistributing ancient and unmaintained mpv releases.
|
||||
- Attach a log file made with ``-v`` or ``--log-file=output.txt``.
|
||||
- Avoid attaching text files packed in archive files (zip/rar/...), unless
|
||||
explicitly asked so. There are better means, such as using http://sprunge.us
|
||||
- If you think this is file specific, upload a sample file and link it.
|
||||
- Don't report multiple unrelated/barely related bugs in one issue.
|
||||
- Read: https://mpv.io/bug-reports/
|
||||
|
||||
Asking questions
|
||||
================
|
||||
|
||||
Preferably, asking questions should be done via IRC (#mpv on irc.freenode.net),
|
||||
but asking questions by opening a github issue is also barely tolerated.
|
||||
|
||||
When asking on IRC (#mpv on irc.freenode.net), don't ask to ask, just state
|
||||
your problem. Stay long enough until someone gets a chance to reply. Sometimes
|
||||
it can take hours.
|
||||
|
||||
Sending patches
|
||||
===============
|
||||
|
||||
See: https://github.com/mpv-player/mpv/blob/master/DOCS/contribute.md
|
||||
|
||||
In particular, be aware that all changes to GPL code must come with the
|
||||
implicit agreement that they might be LGPLv2.1+ relicensed at a later point.
|
||||
@@ -12,6 +12,9 @@ the code to LGPLv2.1+ at a later point without asking the contributor. (This
|
||||
is a safeguard for making potential relicensing of the project to LGPLv2.1+
|
||||
easier.) Using a more liberal license compatible to LGPLv2.1+ is also ok.
|
||||
|
||||
Some GPLv3 or LGPLv3 code in mpv can be enabled by building with --enable-gpl3,
|
||||
and in this case, the resulting binaries must be distributed under GPLv3.
|
||||
|
||||
For information about authors and contributors, consult the git log, which
|
||||
contains the complete SVN and CVS history as well.
|
||||
|
||||
|
||||
@@ -32,7 +32,12 @@ API changes
|
||||
|
||||
::
|
||||
|
||||
--- mpv 0.12.0 ---
|
||||
1.20 - deprecate "GL_MP_D3D_interfaces"/"glMPGetD3DInterface", and introduce
|
||||
"GL_MP_MPGetNativeDisplay"/"glMPGetNativeDisplay" (this is a
|
||||
backwards-compatible rename)
|
||||
--- mpv 0.11.0 ---
|
||||
--- mpv 0.10.0 ---
|
||||
1.19 - add "GL_MP_D3D_interfaces" pseudo extension to make it possible to
|
||||
use DXVA2 in OpenGL fullscreen mode in some situations
|
||||
- mpv_request_log_messages() now accepts "terminal-default" as parameter
|
||||
|
||||
@@ -1,35 +1,114 @@
|
||||
Client API examples
|
||||
===================
|
||||
# Client API examples
|
||||
|
||||
All these examples use the mpv client API through libmpv.
|
||||
|
||||
cocoa
|
||||
-----
|
||||
## Where are the docs?
|
||||
|
||||
The libmpv C API is documented directly in the header files (on normal Unix
|
||||
systems, this is in `/usr/include/mpv/client.h`.
|
||||
|
||||
libmpv merely gives you access to mpv's command interface, which is documented
|
||||
here:
|
||||
* Options (`mpv_set_option()` and friends): http://mpv.io/manual/master/#options
|
||||
* Commands (`mpv_command()` and friends): http://mpv.io/manual/master/#list-of-input-commands
|
||||
* Properties (`mpv_set_property()` and friends): http://mpv.io/manual/master/#properties
|
||||
|
||||
Essentially everything is done with them, including loading a file, retrieving
|
||||
playback progress, and so on.
|
||||
|
||||
## Methods of embedding the video window
|
||||
|
||||
All of these examples concentrate on how to integrate mpv's video renderers
|
||||
with your own GUI. This is generally the hardest part. libmpv enforces a
|
||||
somewhat efficient video output method, rather than e.g. returning a RGBA
|
||||
surface in memory for each frame. The latter would be prohibitively inefficient,
|
||||
because it would require conversion on the CPU. The goal is also not requiring
|
||||
the API users to reinvent their own video rendering/scaling/presentation
|
||||
mechanisms.
|
||||
|
||||
There are currently 2 methods of embedding video.
|
||||
|
||||
### Native window embedding
|
||||
|
||||
This uses the platform's native method of nesting multiple windows. For example,
|
||||
Linux/X11 can nest a window from a completely different process. The nested
|
||||
window can redraw contents on its own, and receive user input if the user
|
||||
interacts with this window.
|
||||
|
||||
libmpv lets you specify a parent window for its own video window via the `wid`
|
||||
option. Then libmpv will create its window with your window as parent, and
|
||||
render its video inside of it.
|
||||
|
||||
This method is highly OS-dependent. Some behavior is OS-specific. There are
|
||||
problems with focusing on X11 (the ancient X11 focus policy mismatches with
|
||||
that of modern UI toolkits - it's normally worked around, but this is not
|
||||
easily possible with raw window embedding). It seems to have stability problems
|
||||
on OSX when using the Qt toolkit.
|
||||
|
||||
### OpenGL embedding
|
||||
|
||||
This method lets you use libmpv's OpenGL renderer directly. You create an
|
||||
OpenGL context, and then use `mpv_opengl_cb_draw()` to render the video on
|
||||
each frame.
|
||||
|
||||
This is more complicated, because libmpv will work directly on your own OpenGL
|
||||
state. It's also not possible to have mpv automatically receive user input.
|
||||
You will have to simulate this with the `mouse`/`keypress`/`keydown`/`keyup`
|
||||
commands.
|
||||
|
||||
You also get much more flexibility. For example, you can actually render your
|
||||
own OSD on top of the video, something that is not possible with raw window
|
||||
embedding.
|
||||
|
||||
### Which one to use?
|
||||
|
||||
Due to the various platform-specific behavior and problems (in particular on
|
||||
OSX), OpenGL embedding is recommended. If you're not comfortable with requiring
|
||||
OpenGL, or want to support "direct" video output such as vdpau (which might
|
||||
win when it comes to performance and energy-saving), you should probably
|
||||
support both methods if possible.
|
||||
|
||||
## List of examples
|
||||
|
||||
### simple
|
||||
|
||||
Very primitive terminal-only example. Shows some most basic API usage.
|
||||
|
||||
### cocoa
|
||||
|
||||
Shows how to embed the mpv video window in Objective-C/Cocoa.
|
||||
|
||||
qt
|
||||
--
|
||||
### cocoa-openglcb
|
||||
|
||||
Similar to the cocoa sample, but shows how to integrate mpv's OpenGL renderer
|
||||
using libmpv's opengl-cb API. Since it does not require complicated interaction
|
||||
with Cocoa elements from different libraries, it's more robust.
|
||||
|
||||
### qt
|
||||
|
||||
Shows how to embed the mpv video window in Qt (using normal desktop widgets).
|
||||
|
||||
qml
|
||||
---
|
||||
### qt_opengl
|
||||
|
||||
Shows how to use mpv's OpenGL video renderer in QtQuick2 with QML.
|
||||
Shows how to use mpv's OpenGL video renderer in Qt. This uses the opengl-cb API
|
||||
for video. Since it does not rely on embedding "foreign" native Windows, it's
|
||||
usually more robust, potentially faster, and it's easier to control how your
|
||||
GUI interacts with the video. You can do your own OpenGL rendering on top of
|
||||
the video as well.
|
||||
|
||||
qml_direct
|
||||
----------
|
||||
### qml
|
||||
|
||||
Shows how to use mpv's OpenGL video renderer in QtQuick2 with QML. Uses the
|
||||
opengl-cb API for video. Since the video is a normal QML element, it's trivial
|
||||
to create OSD overlays with QML-native graphical elements as well.
|
||||
|
||||
### qml_direct
|
||||
|
||||
Alternative example, which typically avoids a FBO indirection. Might be
|
||||
slightly faster, but is less flexible and harder to use.
|
||||
slightly faster, but is less flexible and harder to use. In particular, the
|
||||
video is not a normal QML element. Uses the opengl-cb API for video.
|
||||
|
||||
sdl
|
||||
---
|
||||
### sdl
|
||||
|
||||
Show how to embed the mpv OpenGL renderer in SDL.
|
||||
|
||||
simple
|
||||
------
|
||||
|
||||
Very primitive terminal-only example. Shows some most basic API usage.
|
||||
Show how to embed the mpv OpenGL renderer in SDL. Uses the opengl-cb API for
|
||||
video.
|
||||
@@ -50,7 +50,7 @@ Item {
|
||||
text: "Make video look like on a Smart TV"
|
||||
onClicked: {
|
||||
if (checkbox.checked) {
|
||||
renderer.command(["vo_cmdline", "scale=sharpen3:scale-param1=5.0"])
|
||||
renderer.command(["vo_cmdline", "sharpen=5.0"])
|
||||
} else {
|
||||
renderer.command(["vo_cmdline", ""])
|
||||
}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
#include <QApplication>
|
||||
#include "mainwindow.h"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication a(argc, argv);
|
||||
// Qt sets the locale in the QApplication constructor, but libmpv requires
|
||||
// the LC_NUMERIC category to be set to "C", so change it back.
|
||||
setlocale(LC_NUMERIC, "C");
|
||||
MainWindow w;
|
||||
w.show();
|
||||
return a.exec();
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
#include "mainwindow.h"
|
||||
#include "mpvwidget.h"
|
||||
#include <QPushButton>
|
||||
#include <QSlider>
|
||||
#include <QLayout>
|
||||
#include <QFileDialog>
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent) : QWidget(parent)
|
||||
{
|
||||
m_mpv = new MpvWidget(this);
|
||||
m_slider = new QSlider();
|
||||
m_slider->setOrientation(Qt::Horizontal);
|
||||
m_openBtn = new QPushButton("Open");
|
||||
m_playBtn = new QPushButton("Pause");
|
||||
QHBoxLayout *hb = new QHBoxLayout();
|
||||
hb->addWidget(m_openBtn);
|
||||
hb->addWidget(m_playBtn);
|
||||
QVBoxLayout *vl = new QVBoxLayout();
|
||||
vl->addWidget(m_mpv);
|
||||
vl->addWidget(m_slider);
|
||||
vl->addLayout(hb);
|
||||
setLayout(vl);
|
||||
connect(m_slider, SIGNAL(sliderMoved(int)), SLOT(seek(int)));
|
||||
connect(m_openBtn, SIGNAL(clicked()), SLOT(openMedia()));
|
||||
connect(m_playBtn, SIGNAL(clicked()), SLOT(pauseResume()));
|
||||
connect(m_mpv, SIGNAL(positionChanged(int)), m_slider, SLOT(setValue(int)));
|
||||
connect(m_mpv, SIGNAL(durationChanged(int)), this, SLOT(setSliderRange(int)));
|
||||
}
|
||||
|
||||
void MainWindow::openMedia()
|
||||
{
|
||||
QString file = QFileDialog::getOpenFileName(0, "Open a video");
|
||||
if (file.isEmpty())
|
||||
return;
|
||||
m_mpv->command(QStringList() << "loadfile" << file);
|
||||
}
|
||||
|
||||
void MainWindow::seek(int pos)
|
||||
{
|
||||
m_mpv->command(QVariantList() << "seek" << pos << "absolute");
|
||||
}
|
||||
|
||||
void MainWindow::pauseResume()
|
||||
{
|
||||
const bool paused = m_mpv->getProperty("pause").toBool();
|
||||
m_mpv->setProperty("pause", !paused);
|
||||
}
|
||||
|
||||
void MainWindow::setSliderRange(int duration)
|
||||
{
|
||||
m_slider->setRange(0, duration);
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
#ifndef MainWindow_H
|
||||
#define MainWindow_H
|
||||
|
||||
#include <QtWidgets/QWidget>
|
||||
|
||||
class MpvWidget;
|
||||
class QSlider;
|
||||
class QPushButton;
|
||||
class MainWindow : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit MainWindow(QWidget *parent = 0);
|
||||
public Q_SLOTS:
|
||||
void openMedia();
|
||||
void seek(int pos);
|
||||
void pauseResume();
|
||||
private Q_SLOTS:
|
||||
void setSliderRange(int duration);
|
||||
private:
|
||||
MpvWidget *m_mpv;
|
||||
QSlider *m_slider;
|
||||
QPushButton *m_openBtn;
|
||||
QPushButton *m_playBtn;
|
||||
};
|
||||
|
||||
#endif // MainWindow_H
|
||||
@@ -0,0 +1,129 @@
|
||||
#include "mpvwidget.h"
|
||||
#include <stdexcept>
|
||||
#include <QtGui/QOpenGLContext>
|
||||
#include <QtCore/QMetaObject>
|
||||
|
||||
static void wakeup(void *ctx)
|
||||
{
|
||||
QMetaObject::invokeMethod((MpvWidget*)ctx, "on_mpv_events", Qt::QueuedConnection);
|
||||
}
|
||||
|
||||
static void *get_proc_address(void *ctx, const char *name) {
|
||||
Q_UNUSED(ctx);
|
||||
QOpenGLContext *glctx = QOpenGLContext::currentContext();
|
||||
if (!glctx)
|
||||
return NULL;
|
||||
return (void *)glctx->getProcAddress(QByteArray(name));
|
||||
}
|
||||
|
||||
MpvWidget::MpvWidget(QWidget *parent, Qt::WindowFlags f)
|
||||
: QOpenGLWidget(parent, f)
|
||||
{
|
||||
mpv = mpv::qt::Handle::FromRawHandle(mpv_create());
|
||||
if (!mpv)
|
||||
throw std::runtime_error("could not create mpv context");
|
||||
|
||||
mpv_set_option_string(mpv, "terminal", "yes");
|
||||
mpv_set_option_string(mpv, "msg-level", "all=v");
|
||||
if (mpv_initialize(mpv) < 0)
|
||||
throw std::runtime_error("could not initialize mpv context");
|
||||
|
||||
// Make use of the MPV_SUB_API_OPENGL_CB API.
|
||||
mpv::qt::set_option_variant(mpv, "vo", "opengl-cb");
|
||||
|
||||
// Request hw decoding, just for testing.
|
||||
mpv::qt::set_option_variant(mpv, "hwdec", "auto");
|
||||
|
||||
mpv_gl = (mpv_opengl_cb_context *)mpv_get_sub_api(mpv, MPV_SUB_API_OPENGL_CB);
|
||||
if (!mpv_gl)
|
||||
throw std::runtime_error("OpenGL not compiled in");
|
||||
mpv_opengl_cb_set_update_callback(mpv_gl, MpvWidget::on_update, (void *)this);
|
||||
connect(this, SIGNAL(frameSwapped()), SLOT(swapped()));
|
||||
|
||||
mpv_observe_property(mpv, 0, "duration", MPV_FORMAT_DOUBLE);
|
||||
mpv_observe_property(mpv, 0, "time-pos", MPV_FORMAT_DOUBLE);
|
||||
mpv_set_wakeup_callback(mpv, wakeup, this);
|
||||
}
|
||||
|
||||
MpvWidget::~MpvWidget()
|
||||
{
|
||||
makeCurrent();
|
||||
if (mpv_gl)
|
||||
mpv_opengl_cb_set_update_callback(mpv_gl, NULL, NULL);
|
||||
// Until this call is done, we need to make sure the player remains
|
||||
// alive. This is done implicitly with the mpv::qt::Handle instance
|
||||
// in this class.
|
||||
mpv_opengl_cb_uninit_gl(mpv_gl);
|
||||
}
|
||||
|
||||
void MpvWidget::command(const QVariant& params)
|
||||
{
|
||||
mpv::qt::command_variant(mpv, params);
|
||||
}
|
||||
|
||||
void MpvWidget::setProperty(const QString& name, const QVariant& value)
|
||||
{
|
||||
mpv::qt::set_property_variant(mpv, name, value);
|
||||
}
|
||||
|
||||
QVariant MpvWidget::getProperty(const QString &name) const
|
||||
{
|
||||
return mpv::qt::get_property_variant(mpv, name);
|
||||
}
|
||||
|
||||
void MpvWidget::initializeGL()
|
||||
{
|
||||
int r = mpv_opengl_cb_init_gl(mpv_gl, NULL, get_proc_address, NULL);
|
||||
if (r < 0)
|
||||
throw std::runtime_error("could not initialize OpenGL");
|
||||
}
|
||||
|
||||
void MpvWidget::paintGL()
|
||||
{
|
||||
mpv_opengl_cb_draw(mpv_gl, defaultFramebufferObject(), width(), -height());
|
||||
}
|
||||
|
||||
void MpvWidget::swapped()
|
||||
{
|
||||
mpv_opengl_cb_report_flip(mpv_gl, 0);
|
||||
}
|
||||
|
||||
void MpvWidget::on_mpv_events()
|
||||
{
|
||||
// Process all events, until the event queue is empty.
|
||||
while (mpv) {
|
||||
mpv_event *event = mpv_wait_event(mpv, 0);
|
||||
if (event->event_id == MPV_EVENT_NONE) {
|
||||
break;
|
||||
}
|
||||
handle_mpv_event(event);
|
||||
}
|
||||
}
|
||||
|
||||
void MpvWidget::handle_mpv_event(mpv_event *event)
|
||||
{
|
||||
switch (event->event_id) {
|
||||
case MPV_EVENT_PROPERTY_CHANGE: {
|
||||
mpv_event_property *prop = (mpv_event_property *)event->data;
|
||||
if (strcmp(prop->name, "time-pos") == 0) {
|
||||
if (prop->format == MPV_FORMAT_DOUBLE) {
|
||||
double time = *(double *)prop->data;
|
||||
Q_EMIT positionChanged(time);
|
||||
}
|
||||
} else if (strcmp(prop->name, "duration") == 0) {
|
||||
if (prop->format == MPV_FORMAT_DOUBLE) {
|
||||
double time = *(double *)prop->data;
|
||||
Q_EMIT durationChanged(time);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
default: ;
|
||||
// Ignore uninteresting or unknown events.
|
||||
}
|
||||
}
|
||||
|
||||
void MpvWidget::on_update(void *ctx)
|
||||
{
|
||||
QMetaObject::invokeMethod((MpvWidget*)ctx, "update");
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
#ifndef PLAYERWINDOW_H
|
||||
#define PLAYERWINDOW_H
|
||||
|
||||
#include <QtWidgets/QOpenGLWidget>
|
||||
#include <mpv/client.h>
|
||||
#include <mpv/opengl_cb.h>
|
||||
#include <mpv/qthelper.hpp>
|
||||
|
||||
class MpvWidget Q_DECL_FINAL: public QOpenGLWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
MpvWidget(QWidget *parent = 0, Qt::WindowFlags f = 0);
|
||||
~MpvWidget();
|
||||
void command(const QVariant& params);
|
||||
void setProperty(const QString& name, const QVariant& value);
|
||||
QVariant getProperty(const QString& name) const;
|
||||
QSize sizeHint() const { return QSize(480, 270);}
|
||||
Q_SIGNALS:
|
||||
void durationChanged(int value);
|
||||
void positionChanged(int value);
|
||||
protected:
|
||||
void initializeGL() Q_DECL_OVERRIDE;
|
||||
void paintGL() Q_DECL_OVERRIDE;
|
||||
private Q_SLOTS:
|
||||
void swapped();
|
||||
void on_mpv_events();
|
||||
private:
|
||||
void handle_mpv_event(mpv_event *event);
|
||||
static void on_update(void *ctx);
|
||||
|
||||
mpv::qt::Handle mpv;
|
||||
mpv_opengl_cb_context *mpv_gl;
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif // PLAYERWINDOW_H
|
||||
@@ -0,0 +1,13 @@
|
||||
CONFIG -= app_bundle
|
||||
QT += widgets
|
||||
|
||||
QT_CONFIG -= no-pkg-config
|
||||
CONFIG += link_pkgconfig debug
|
||||
PKGCONFIG += mpv
|
||||
|
||||
HEADERS = \
|
||||
mpvwidget.h \
|
||||
mainwindow.h
|
||||
SOURCES = main.cpp \
|
||||
mpvwidget.cpp \
|
||||
mainwindow.cpp
|
||||
+1
-38
@@ -68,7 +68,7 @@ echo "MXE_TARGETS := i686-w64-mingw32.static" >> settings.mk
|
||||
# Build required packages. The following provide a minimum required to build
|
||||
# a reasonable mpv binary (though not an absolute minimum).
|
||||
|
||||
make gcc ffmpeg libass jpeg pthreads lua
|
||||
make gcc ffmpeg libass jpeg lua
|
||||
|
||||
# Add MXE binaries to $PATH
|
||||
export PATH=/opt/mxe/usr/bin/:$PATH
|
||||
@@ -173,40 +173,3 @@ mv -f /mingw64/bin/libmpv.dll.a /mingw64/lib/
|
||||
sed -i 's_/mingw64/bin_/mingw64/lib_' /mingw64/lib/pkgconfig/mpv.pc
|
||||
rmdir /mingw64/bin/pkgconfig
|
||||
```
|
||||
|
||||
Additional dependencies
|
||||
=======================
|
||||
|
||||
pthreads
|
||||
--------
|
||||
|
||||
mpv will use a pthreads wrapper by default. Either pthreads-win32 or
|
||||
winpthreads should work. The latter is packaged with most MinGW-w64
|
||||
environments, including MSYS2, so it shouldn't be a problem. If you don't have
|
||||
a pthreads wrapper or you want to build mpv without one, configure with:
|
||||
|
||||
```bash
|
||||
./waf configure --enable-win32-internal-pthreads
|
||||
```
|
||||
|
||||
libwaio
|
||||
-------
|
||||
|
||||
If you want to use ``--input-file``, you need libwaio. It's available from
|
||||
git://midipix.org/waio
|
||||
|
||||
To compile libwaio in MSYS2, run:
|
||||
|
||||
```bash
|
||||
git clone git://midipix.org/waio && cd waio
|
||||
|
||||
# 32-bit build, run from mingw32_shell.bat
|
||||
./build-mingw-nt32 lib-static CC=gcc AR=ar
|
||||
cp -r include/waio /mingw32/include
|
||||
cp lib32/libwaio.a /mingw32/lib
|
||||
|
||||
# 64-bit build, run from mingw64_shell.bat
|
||||
./build-mingw-nt64 lib-static CC=gcc AR=ar
|
||||
cp -r include/waio /mingw64/include
|
||||
cp lib64/libwaio.a /mingw64/lib
|
||||
```
|
||||
+11
-9
@@ -14,9 +14,11 @@ Sending patches
|
||||
``git format-patch``. diffs posted as pastebins (especially if the http link
|
||||
returns HTML) just cause extra work for everyone, because they lack commit
|
||||
message and authorship information.
|
||||
- When creating pull requests, be sure to test your changes. If you didn't, please
|
||||
say so in the pull request message.
|
||||
|
||||
- All new code must be LGPLv2.1+ licensed, or come with the implicit agreement
|
||||
that it will be relicensed to LGPLv2.1+ later (see ``Copyright`` in the
|
||||
repository root directory).
|
||||
- When creating pull requests, be sure to test your changes. If you didn't,
|
||||
please say so in the pull request message.
|
||||
- Write informative commit messages. Use present tense to describe the
|
||||
situation with the patch applied, and past tense for the situation before
|
||||
the change.
|
||||
@@ -27,8 +29,8 @@ Sending patches
|
||||
|
||||
For example, you fixed a crash in af_volume.c:
|
||||
|
||||
Bad: ``fixed the bug (wtf?)``
|
||||
Good: ``af_volume: fix crash due to null pointer access``
|
||||
- Bad: ``fixed the bug (wtf?)``
|
||||
- Good: ``af_volume: fix crash due to null pointer access``
|
||||
|
||||
Having a prefix gives context, and is especially useful when trying to find
|
||||
a specific change by looking at the history, or when running ``git blame``.
|
||||
@@ -53,10 +55,10 @@ Sending patches
|
||||
something like reformatting a whole file, and hiding an actual functional
|
||||
change in the same commit.
|
||||
- If you add a new command line option, document it in options.rst. If you
|
||||
add a new input property, document it in input.rst.
|
||||
- All new code must be LGPLv2.1+ licensed, or come with the implicit agreement
|
||||
that it will be relicensed to LGPLv2.1+ later (see ``Copyright`` in the
|
||||
repository root directory).
|
||||
add a new input property, document it in input.rst. Changes to the user
|
||||
interface (options, properties, commands) should be documented in
|
||||
interface-changes.rst. Changes to libmpv should be documented in
|
||||
client-api-changes.rst.
|
||||
|
||||
Code formatting
|
||||
---------------
|
||||
|
||||
@@ -19,6 +19,31 @@ Interface changes
|
||||
|
||||
::
|
||||
|
||||
--- mpv 0.15.0 ---
|
||||
- change "yadif" video filter defaults
|
||||
--- mpv 0.14.0 ---
|
||||
- vo_opengl interpolation now requires --video-sync=display-... to be set
|
||||
- change some vo_opengl defaults (including changing tscale)
|
||||
- add "vsync-ratio", "estimated-display-fps" properties
|
||||
- add --rebase-start-time option
|
||||
This is a breaking change to start time handling. Instead of making start
|
||||
time handling an aspect of different options and properties (like
|
||||
"time-pos" vs. "playback-time"), make it dependent on the new option. For
|
||||
compatibility, the "time-start" property now always returns 0, so code
|
||||
which attempted to handle rebasing manually will not break.
|
||||
--- mpv 0.13.0 ---
|
||||
- remove VO opengl-cb frame queue suboptions (no replacement)
|
||||
--- mpv 0.12.0 ---
|
||||
- remove --use-text-osd (useless; fontconfig isn't a requirement anymore,
|
||||
and text rendering is also lazily initialized)
|
||||
- some time properties (at least "playback-time", "time-pos",
|
||||
"time-remaining", "playtime-remaining") now are unavailable if the time
|
||||
is unknown, instead of just assuming that the internal playback position
|
||||
is 0
|
||||
- add --audio-fallback-to-null option
|
||||
- replace vf_format outputlevels suboption with "video-output-levels" global
|
||||
property/option; also remove "colormatrix-output-range" property
|
||||
- vo_opengl: remove sharpen3/sharpen5 scale filters, add sharpen sub-option
|
||||
--- mpv 0.11.0 ---
|
||||
- add "af-metadata" property
|
||||
--- mpv 0.10.0 ---
|
||||
|
||||
+1
-1
@@ -164,7 +164,7 @@ Available filters are:
|
||||
|
||||
.. admonition:: Examples
|
||||
|
||||
``mpv --af=channels=4:[0-1,1-0,0-2,1-3] media.avi``
|
||||
``mpv --af=channels=4:[0-1,1-0,2-2,3-3] media.avi``
|
||||
Would change the number of channels to 4 and set up 4 routes that
|
||||
swap channel 0 and channel 1 and leave channel 2 and 3 intact.
|
||||
Observe that if media containing two channels were played back,
|
||||
|
||||
+9
-26
@@ -20,10 +20,8 @@ normal driver parameters.
|
||||
|
||||
See ``--ao=help`` for a list of compiled-in audio output drivers. The
|
||||
driver ``--ao=alsa`` is preferred. ``--ao=pulse`` is preferred on systems
|
||||
where PulseAudio is used. On Windows, ``--ao=wasapi`` is preferred,
|
||||
though it might cause trouble sometimes, in which case ``--ao=dsound``
|
||||
should be used. On BSD systems, ``--ao=oss`` or `--ao=sndio`` may work
|
||||
(the latter being experimental). On OS X systems, use ``--ao=coreaudio``.
|
||||
where PulseAudio is used. On BSD systems, ``--ao=oss`` or ``--ao=sndio``
|
||||
may work (the latter being experimental).
|
||||
|
||||
.. admonition:: Examples
|
||||
|
||||
@@ -139,16 +137,13 @@ Available audio output drivers are:
|
||||
Automatically create connections to output ports (default: enabled).
|
||||
When enabled, the maximum number of output channels will be limited to
|
||||
the number of available output ports.
|
||||
``std-channel-layout=alsa|waveext|any``
|
||||
Select the standard channel layout (default: alsa). JACK itself has no
|
||||
``std-channel-layout=waveext|any``
|
||||
Select the standard channel layout (default: waveext). JACK itself has no
|
||||
notion of channel layouts (i.e. assigning which speaker a given
|
||||
channel is supposed to map to) - it just takes whatever the application
|
||||
outputs, and reroutes it to whatever the user defines. This means the
|
||||
user and the application are in charge of dealing with the channel
|
||||
layout. ``alsa`` uses the old MPlayer layout, which is inspired by
|
||||
ALSA's standard layouts. In this mode, ao_jack will refuse to play 3
|
||||
or 7 channels (because these do not really have a defined meaning in
|
||||
MPlayer). ``waveext`` uses WAVE_FORMAT_EXTENSIBLE order, which, even
|
||||
layout. ``waveext`` uses WAVE_FORMAT_EXTENSIBLE order, which, even
|
||||
though it was defined by Microsoft, is the standard on many systems.
|
||||
The value ``any`` makes JACK accept whatever comes from the audio
|
||||
filter chain, regardless of channel layout and without reordering. This
|
||||
@@ -168,7 +163,7 @@ Available audio output drivers are:
|
||||
will actually work. The disadvantage is that it will change the
|
||||
system-wide audio settings. This is equivalent to changing the ``Format``
|
||||
setting in the ``Audio Devices`` dialog in the ``Audio MIDI Setup``
|
||||
utility. Note that this does not effect the selected speaker setup.
|
||||
utility. Note that this does not affect the selected speaker setup.
|
||||
|
||||
``exclusive``
|
||||
Use exclusive mode access. This merely redirects to
|
||||
@@ -208,19 +203,7 @@ Available audio output drivers are:
|
||||
(it used to be required to get good behavior on old PulseAudio versions).
|
||||
|
||||
If you have stuttering video when using pulse, try to enable this
|
||||
option. (Or alternatively, try to update PulseAudio.)
|
||||
|
||||
``dsound`` (Windows only)
|
||||
DirectX DirectSound audio output driver
|
||||
|
||||
.. note:: This driver is for compatibility with old systems.
|
||||
|
||||
``device=<devicenum>``
|
||||
Sets the device number to use. Playing a file with ``-v`` will show a
|
||||
list of available devices.
|
||||
|
||||
``buffersize=<ms>``
|
||||
DirectSound buffer size in milliseconds (default: 200).
|
||||
option. (Or try to update PulseAudio.)
|
||||
|
||||
``sdl``
|
||||
SDL 1.2+ audio output driver. Should work on any platform supported by SDL
|
||||
@@ -259,7 +242,7 @@ Available audio output drivers are:
|
||||
``speed``
|
||||
Simulated audio playback speed as a multiplier. Usually, a real audio
|
||||
device will not go exactly as fast as the system clock. It will deviate
|
||||
just a little, and this option helps simulating this.
|
||||
just a little, and this option helps to simulate this.
|
||||
|
||||
``latency``
|
||||
Simulated device latency. This is additional to EOF.
|
||||
@@ -328,7 +311,7 @@ Available audio output drivers are:
|
||||
String are valid; the GUID string is guaranteed to not change
|
||||
unless the driver is uninstalled.
|
||||
|
||||
Also supports searching active devices by human readable name. If more
|
||||
Also supports searching active devices by human-readable name. If more
|
||||
than one device matches the name, refuses loading it.
|
||||
|
||||
This option is mostly deprecated in favour of the more general
|
||||
|
||||
+4
-4
@@ -93,8 +93,8 @@ You can encode files from one format/codec to another using this facility.
|
||||
Completely empties the options list.
|
||||
|
||||
``--oafirst``
|
||||
Force the audio stream to become the first stream in the output. By default
|
||||
the order is unspecified.
|
||||
Force the audio stream to become the first stream in the output.
|
||||
By default, the order is unspecified.
|
||||
|
||||
``--ovc=<codec>``
|
||||
Specifies the output video codec. This can be a comma separated list of
|
||||
@@ -134,8 +134,8 @@ You can encode files from one format/codec to another using this facility.
|
||||
Completely empties the options list.
|
||||
|
||||
``--ovfirst``
|
||||
Force the video stream to become the first stream in the output. By default
|
||||
the order is unspecified.
|
||||
Force the video stream to become the first stream in the output.
|
||||
By default, the order is unspecified.
|
||||
|
||||
``--ocopyts``
|
||||
Copies input pts to the output video (not supported by some output
|
||||
|
||||
+93
-28
@@ -329,9 +329,9 @@ List of Input Commands
|
||||
This is similar to ``sub-step``, except that it seeks video and audio
|
||||
instead of adjusting the subtitle delay.
|
||||
|
||||
Like with ``sub-step``, this works with external text subtitles only. For
|
||||
embedded text subtitles (like with Matroska), this works only with subtitle
|
||||
events that have already been displayed.
|
||||
For embedded subtitles (like with Matroska), this works only with subtitle
|
||||
events that have already been displayed, or are within a short prefetch
|
||||
range.
|
||||
|
||||
``osd [<level>]``
|
||||
Toggle OSD level. If ``<level>`` is specified, set the OSD mode
|
||||
@@ -418,7 +418,7 @@ List of Input Commands
|
||||
|
||||
<reselect> (default)
|
||||
Select the default audio and subtitle streams, which typically selects
|
||||
external files with highest preference. (The implementation is not
|
||||
external files with the highest preference. (The implementation is not
|
||||
perfect, and could be improved on request.)
|
||||
|
||||
<keep-selection>
|
||||
@@ -546,6 +546,12 @@ Input Commands that are Possibly Subject to Change
|
||||
Always bind a key. (The input section that was made active most recently
|
||||
wins if there are ambiguities.)
|
||||
|
||||
This command can be used to dispatch arbitrary keys to a script or a client
|
||||
API user. If the input section defines ``script-binding`` commands, it is
|
||||
also possible to get separate events on key up/down, and relatively detailed
|
||||
information about the key state. The special key name ``unmapped`` can be
|
||||
used to match any unmapped key.
|
||||
|
||||
``overlay-add <id> <x> <y> "<file>" <offset> "<fmt>" <w> <h> <stride>``
|
||||
Add an OSD overlay sourced from raw data. This might be useful for scripts
|
||||
and applications controlling mpv, and which want to display things on top
|
||||
@@ -647,14 +653,20 @@ Input Commands that are Possibly Subject to Change
|
||||
For completeness, here is how this command works internally. The details
|
||||
could change any time. On any matching key event, ``script_message_to``
|
||||
or ``script_message`` is called (depending on whether the script name is
|
||||
included), where the first argument is the string ``key-binding``, the
|
||||
second argument is the name of the binding, and the third argument is the
|
||||
key state as string. The key state consists of a number of letters. The
|
||||
first letter is one of ``d`` (key was pressed down), ``u`` (was released),
|
||||
``r`` (key is still down, and was repeated; only if key repeat is enabled
|
||||
for this binding), ``p`` (key was pressed; happens if up/down can't be
|
||||
tracked). The second letter whether the event originates from the mouse,
|
||||
either ``m`` (mouse button) or ``-`` (something else).
|
||||
included), with the following arguments:
|
||||
|
||||
1. The string ``key-binding``.
|
||||
2. The name of the binding (as established above).
|
||||
3. The key state as string (see below).
|
||||
4. The key name (since mpv 0.15.0).
|
||||
|
||||
The key state consists of 2 letters:
|
||||
|
||||
1. One of ``d`` (key was pressed down), ``u`` (was released), ``r`` (key
|
||||
is still down, and was repeated; only if key repeat is enabled for this
|
||||
binding), ``p`` (key was pressed; happens if up/down can't be tracked).
|
||||
2. Whether the event originates from the mouse, either ``m`` (mouse button)
|
||||
or ``-`` (something else).
|
||||
|
||||
``ab-loop``
|
||||
Cycle through A-B loop states. The first command will set the ``A`` point
|
||||
@@ -782,7 +794,7 @@ Input sections group a set of bindings, and enable or disable them at once.
|
||||
In ``input.conf``, each key binding is assigned to an input section, rather
|
||||
than actually having explicit text sections.
|
||||
|
||||
Also see ``enable_section`` and ``disable_section`` commands.
|
||||
See also: ``enable_section`` and ``disable_section`` commands.
|
||||
|
||||
Predefined bindings:
|
||||
|
||||
@@ -860,7 +872,11 @@ Property list
|
||||
quantities: fps and possibly rounded timestamps.)
|
||||
|
||||
``path``
|
||||
Full path of the currently played file.
|
||||
Full path of the currently played file. Usually this is exactly the same
|
||||
string you pass on the mpv command line or the ``loadfile`` command, even
|
||||
if it's a relative path. If you expect an absolute path, you will have to
|
||||
determine it yourself, for example by using the ``working-directory``
|
||||
property.
|
||||
|
||||
``media-title``
|
||||
If the currently played file has a ``title`` tag, use that.
|
||||
@@ -913,6 +929,26 @@ Property list
|
||||
``vo-drop-frame-count``
|
||||
Frames dropped by VO (when using ``--framedrop=vo``).
|
||||
|
||||
``mistimed-frame-count``
|
||||
Number of video frames that were not timed correctly in display-sync mode
|
||||
for the sake of keeping A/V sync. This does not include external
|
||||
circumstances, such as video rendering being too slow or the graphics
|
||||
driver somehow skipping a vsync. It does not include rounding errors either
|
||||
(which can happen especially with bad source timestamps). For example,
|
||||
using the ``display-desync`` mode should never change this value from 0.
|
||||
|
||||
``vsync-ratio``
|
||||
For how many vsyncs a frame is displayed on average. This is available if
|
||||
display-sync is active only. For 30 FPS video on a 60 Hz screen, this will
|
||||
be 2. This is the moving average of what actually has been scheduled, so
|
||||
24 FPS on 60 Hz will never remain exactly on 2.5, but jitter depending on
|
||||
the last frame displayed.
|
||||
|
||||
``vo-delayed-frame-count``
|
||||
Estimated number of frames delayed due to external circumstances in
|
||||
display-sync mode. Note that in general, mpv has to guess that this is
|
||||
happening, and the guess can be inaccurate.
|
||||
|
||||
``percent-pos`` (RW)
|
||||
Position in current file (0-100). The advantage over using this instead of
|
||||
calculating it out of other properties is that it properly falls back to
|
||||
@@ -923,8 +959,9 @@ Property list
|
||||
Position in current file in seconds.
|
||||
|
||||
``time-start``
|
||||
Return the start time of the file. (Usually 0, but some kind of files,
|
||||
especially transport streams, can have a different start time.)
|
||||
Deprecated. Always returns 0. Before mpv 0.14, this used to return the start
|
||||
time of the file (could affect e.g. transport streams). See
|
||||
``--rebase-start-time`` option.
|
||||
|
||||
``time-remaining``
|
||||
Remaining length of the file in seconds. Note that the file duration is not
|
||||
@@ -934,9 +971,10 @@ Property list
|
||||
``time-remaining`` scaled by the current ``speed``.
|
||||
|
||||
``playback-time`` (RW)
|
||||
The playback time, which is the time relative to playback start. (This can
|
||||
be different from the ``time-pos`` property if the file does not start at
|
||||
position ``0``, in which case ``time-pos`` is the source timestamp.)
|
||||
Position in current file in seconds. Unlike ``time-pos``, the time is
|
||||
clamped to the range of the file. (Inaccurate file durations etc. could
|
||||
make it go out of range. Useful on attempts to seek outside of the file,
|
||||
as the seek target time is considered the current position during seeking.)
|
||||
|
||||
``chapter`` (RW)
|
||||
Current chapter number. The number of the first chapter is 0.
|
||||
@@ -1082,13 +1120,13 @@ Property list
|
||||
|
||||
``vf-metadata/<filter-label>``
|
||||
Metadata added by video filters. Accessed by the filter label,
|
||||
which if not explicitly specified using the ``@filter-label:`` syntax,
|
||||
which, if not explicitly specified using the ``@filter-label:`` syntax,
|
||||
will be ``<filter-name>NN``.
|
||||
|
||||
Works similar to ``metadata`` property. It allows the same access
|
||||
methods (using sub-properties).
|
||||
|
||||
An example of these kind of metadata are the cropping parameters
|
||||
An example of this kind of metadata are the cropping parameters
|
||||
added by ``--vf=lavfi=cropdetect``.
|
||||
|
||||
``af-metadata/<filter-label>``
|
||||
@@ -1115,7 +1153,7 @@ Property list
|
||||
|
||||
``cache-size`` (RW)
|
||||
Network cache size in KB. This is similar to ``--cache``. This allows
|
||||
to set the cache size at runtime. Currently, it's not possible to enable
|
||||
setting the cache size at runtime. Currently, it's not possible to enable
|
||||
or disable the cache at runtime using this property, just to resize an
|
||||
existing cache.
|
||||
|
||||
@@ -1171,9 +1209,6 @@ Property list
|
||||
is loaded, or when switching ordered chapter segments. This is because
|
||||
the same underlying code is used for seeking and resyncing.)
|
||||
|
||||
``pts-association-mode`` (RW)
|
||||
See ``--pts-association-mode``.
|
||||
|
||||
``hr-seek`` (RW)
|
||||
See ``--hr-seek``.
|
||||
|
||||
@@ -1260,8 +1295,8 @@ Property list
|
||||
``colormatrix-input-range`` (R)
|
||||
See ``colormatrix``.
|
||||
|
||||
``colormatrix-output-range`` (R)
|
||||
See ``colormatrix``.
|
||||
``video-output-levels`` (RW)
|
||||
See ``--video-output-levels``,
|
||||
|
||||
``colormatrix-primaries`` (R)
|
||||
See ``colormatrix``.
|
||||
@@ -1421,6 +1456,19 @@ Property list
|
||||
|
||||
Has the same sub-properties as ``video-params``.
|
||||
|
||||
``video-frame-info``
|
||||
Approximate information of the current frame. Note that if any of these
|
||||
are used on OSD, the information might be off by a few frames due to OSD
|
||||
redrawing and frame display being somewhat disconnected, and you might
|
||||
have to pause and force a redraw.
|
||||
|
||||
Sub-properties:
|
||||
|
||||
``video-frame-info/picture-type``
|
||||
``video-frame-info/interlaced``
|
||||
``video-frame-info/tff``
|
||||
``video-frame-info/repeat``
|
||||
|
||||
``fps``
|
||||
Container FPS. This can easily contain bogus values. For videos that use
|
||||
modern container formats or video codecs, this will often be incorrect.
|
||||
@@ -1447,13 +1495,21 @@ Property list
|
||||
Names of the displays that the mpv window covers. On X11, these
|
||||
are the xrandr names (LVDS1, HDMI1, DP1, VGA1, etc.).
|
||||
|
||||
``display-fps``
|
||||
``display-fps`` (RW)
|
||||
The refresh rate of the current display. Currently, this is the lowest FPS
|
||||
of any display covered by the video, as retrieved by the underlying system
|
||||
APIs (e.g. xrandr on X11). It is not the measured FPS. It's not necessarily
|
||||
available on all platforms. Note that any of the listed facts may change
|
||||
any time without a warning.
|
||||
|
||||
``estimated-display-fps``
|
||||
Only available if display-sync mode (as selected by ``--video-sync``) is
|
||||
active. Returns the actual rate at which display refreshes seem to occur,
|
||||
measured by system time.
|
||||
|
||||
``vsync-jitter``
|
||||
Estimated deviation factor of the vsync duration.
|
||||
|
||||
``video-aspect`` (RW)
|
||||
Video aspect, see ``--video-aspect``.
|
||||
|
||||
@@ -1486,6 +1542,15 @@ Property list
|
||||
``program`` (W)
|
||||
Switch TS program (write-only).
|
||||
|
||||
``dvb-channel`` (W)
|
||||
Pair of integers: card,channel of current DVB stream.
|
||||
Can be switched to switch to another channel on the same card.
|
||||
|
||||
``dvb-channel-name`` (RW)
|
||||
Name of current DVB program.
|
||||
On write, a channel-switch to the named channel on the same
|
||||
card is performed. Can also be used for channel switching.
|
||||
|
||||
``sid`` (RW)
|
||||
Current subtitle track (similar to ``--sid``).
|
||||
|
||||
|
||||
+5
-3
@@ -111,7 +111,7 @@ rely on this.
|
||||
Commands
|
||||
--------
|
||||
|
||||
Additionally to the commands described in `List of Input Commands`_, a few
|
||||
In addition to the commands described in `List of Input Commands`_, a few
|
||||
extra commands can also be used as part of the protocol:
|
||||
|
||||
``client_name``
|
||||
@@ -189,7 +189,7 @@ extra commands can also be used as part of the protocol:
|
||||
|
||||
``unobserve_property``
|
||||
Undo ``observe_property`` or ``observe_property_string``. This requires the
|
||||
numeric id passed to the observe command as argument.
|
||||
numeric id passed to the observed command as argument.
|
||||
|
||||
Example:
|
||||
|
||||
@@ -228,7 +228,9 @@ extra commands can also be used as part of the protocol:
|
||||
|
||||
``get_version``
|
||||
Returns the client API version the C API of the remote mpv instance
|
||||
provides. (Also see ``DOCS/client-api-changes.rst``.)
|
||||
provides.
|
||||
|
||||
See also: ``DOCS/client-api-changes.rst``.
|
||||
|
||||
UTF-8
|
||||
-----
|
||||
|
||||
+6
-6
@@ -198,7 +198,7 @@ The ``mp`` module is preloaded, although it can be loaded manually with
|
||||
be called (unless the user remapped the key with another binding).
|
||||
|
||||
The ``name`` argument should be a short symbolic string. It allows the user
|
||||
to remap the key binding via input.conf using the ``script_message``
|
||||
to remap the key binding via input.conf using the ``script-message``
|
||||
command, and the name of the key binding (see below for
|
||||
an example). The name should be unique across other bindings in the same
|
||||
script - if not, the previous binding with the same name will be
|
||||
@@ -220,8 +220,8 @@ The ``mp`` module is preloaded, although it can be loaded manually with
|
||||
has an ``is_mouse`` entry, which tells whether the event was caused
|
||||
by a mouse button.
|
||||
|
||||
Internally, key bindings are dispatched via the ``script_message_to`` or
|
||||
``script_binding`` input commands and ``mp.register_script_message``.
|
||||
Internally, key bindings are dispatched via the ``script-message-to`` or
|
||||
``script-binding`` input commands and ``mp.register_script_message``.
|
||||
|
||||
Trying to map multiple commands to a key will essentially prefer a random
|
||||
binding, while the other bindings are not called. It is guaranteed that
|
||||
@@ -244,7 +244,7 @@ The ``mp`` module is preloaded, although it can be loaded manually with
|
||||
|
||||
::
|
||||
|
||||
y script_binding something
|
||||
y script-binding something
|
||||
|
||||
|
||||
This will print the message when the key ``y`` is pressed. (``x`` will
|
||||
@@ -255,7 +255,7 @@ The ``mp`` module is preloaded, although it can be loaded manually with
|
||||
|
||||
::
|
||||
|
||||
y script_binding fooscript.something
|
||||
y script-binding fooscript.something
|
||||
|
||||
``mp.add_forced_key_binding(...)``
|
||||
This works almost the same as ``mp.add_key_binding``, but registers the
|
||||
@@ -389,7 +389,7 @@ The ``mp`` module is preloaded, although it can be loaded manually with
|
||||
``mp.get_script_name()``
|
||||
Return the name of the current script. The name is usually made of the
|
||||
filename of the script, with directory and file extension removed. If
|
||||
there are several script which would have the same name, it's made unique
|
||||
there are several scripts which would have the same name, it's made unique
|
||||
by appending a number.
|
||||
|
||||
.. admonition:: Example
|
||||
|
||||
+82
-81
@@ -50,7 +50,7 @@ UP and DOWN
|
||||
|
||||
Ctrl+LEFT and Ctrl+RIGHT
|
||||
Seek to the previous/next subtitle. Subject to some restrictions and
|
||||
might not work always; see ``sub_seek`` command.
|
||||
might not always work; see ``sub_seek`` command.
|
||||
|
||||
[ and ]
|
||||
Decrease/increase current playback speed by 10%.
|
||||
@@ -128,7 +128,7 @@ x and z
|
||||
Adjust subtitle delay by +/- 0.1 seconds.
|
||||
|
||||
l
|
||||
Set/clear A-B loop points. See ``ab_loop`` command for details.
|
||||
Set/clear A-B loop points. See ``ab-loop`` command for details.
|
||||
|
||||
L
|
||||
Toggle infinite looping.
|
||||
@@ -192,23 +192,19 @@ corresponding adjustment, or the software equalizer (``--vf=eq``).)
|
||||
7 and 8
|
||||
Adjust saturation.
|
||||
|
||||
(The following keys are valid only on OS X.)
|
||||
|
||||
command + 0
|
||||
Alt+0 (and command+0 on OSX)
|
||||
Resize video window to half its original size.
|
||||
(On other platforms, you can bind keys to change the ``window-scale``
|
||||
property.)
|
||||
|
||||
command + 1
|
||||
Alt+1 (and command+1 on OSX)
|
||||
Resize video window to its original size.
|
||||
|
||||
command + 2
|
||||
Alt+2 (and command+2 on OSX)
|
||||
Resize video window to double its original size.
|
||||
|
||||
command + f
|
||||
command + f (OSX only)
|
||||
Toggle fullscreen (see also ``--fs``).
|
||||
|
||||
command + [ and command + ]
|
||||
command + [ and command + ] (OSX only)
|
||||
Set video window alpha.
|
||||
|
||||
(The following keys are valid if you have a keyboard with multimedia keys.)
|
||||
@@ -226,7 +222,10 @@ PREVIOUS and NEXT
|
||||
support.)
|
||||
|
||||
h and k
|
||||
Select previous/next channel.
|
||||
Select previous/next tv-channel.
|
||||
|
||||
H and K
|
||||
Select previous/next dvb-channel.
|
||||
|
||||
Mouse Control
|
||||
-------------
|
||||
@@ -262,7 +261,7 @@ parser puts several options into a single string, and passes them to a
|
||||
component at once, instead of using multiple options on the level of the
|
||||
command line.
|
||||
|
||||
The suboption parser can quote strings with ``"``, ``'``, and ``[...]``.
|
||||
The suboption parser can quote strings with ``"`` and ``[...]``.
|
||||
Additionally, there is a special form of quoting with ``%n%`` described below.
|
||||
|
||||
For example, the ``opengl`` VO can take multiple options:
|
||||
@@ -392,10 +391,11 @@ You can put all of the options in configuration files which will be read every
|
||||
time mpv is run. The system-wide configuration file 'mpv.conf' is in your
|
||||
configuration directory (e.g. ``/etc/mpv`` or ``/usr/local/etc/mpv``), the
|
||||
user-specific one is ``~/.config/mpv/mpv.conf``. For details and platform
|
||||
specifics see the `FILES`_ section.
|
||||
specifics (in particular Windows paths) see the `FILES`_ section.
|
||||
|
||||
User-specific options override system-wide options and options given on the
|
||||
command line override either. The syntax of the configuration files is
|
||||
``option=<value>``; everything after a *#* is considered a comment. Options
|
||||
``option=value``. Everything after a *#* is considered a comment. Options
|
||||
that work without values can be enabled by setting them to *yes* and disabled by
|
||||
setting them to *no*. Even suboptions can be specified in this way.
|
||||
|
||||
@@ -413,7 +413,7 @@ Escaping spaces and special characters
|
||||
|
||||
This is done like with command line options. The shell is not involved here,
|
||||
but option values still need to be quoted as a whole if it contains certain
|
||||
characters like spaces. A config entry can be quoted with ``"`` and ``'``,
|
||||
characters like spaces. A config entry can be quoted with ``"``,
|
||||
as well as with the fixed-length syntax (``%n%``) mentioned before. This is like
|
||||
passing the exact contents of the quoted string as command line option. C-style
|
||||
escapes are currently _not_ interpreted on this level, although some options do
|
||||
@@ -460,7 +460,38 @@ description (shown by ``--profile=help``) can be defined with the
|
||||
``profile-desc`` option. To end the profile, start another one or use the
|
||||
profile name ``default`` to continue with normal options.
|
||||
|
||||
.. admonition:: Example mpv profile
|
||||
.. admonition:: Example mpv config file with profiles
|
||||
|
||||
::
|
||||
|
||||
# normal top-level option
|
||||
fullscreen=yes
|
||||
|
||||
# a profile that can be enabled with --profile=big-cache
|
||||
[big-cache]
|
||||
cache=123400
|
||||
demuxer-readahead-secs=20
|
||||
|
||||
[slow]
|
||||
profile-desc="some profile name"
|
||||
vo=opengl:scale=ewa_lanczos:scale-radius=16
|
||||
|
||||
[fast]
|
||||
vo=vdpau
|
||||
|
||||
# using a profile again extends it
|
||||
[slow]
|
||||
framedrop=no
|
||||
# you can also include other profiles
|
||||
profile=big-cache
|
||||
|
||||
|
||||
Auto profiles
|
||||
-------------
|
||||
|
||||
Some profiles are loaded automatically. The following example demonstrates this:
|
||||
|
||||
.. admonition:: Auto profile loading
|
||||
|
||||
::
|
||||
|
||||
@@ -479,14 +510,22 @@ profile name ``default`` to continue with normal options.
|
||||
[ao.alsa]
|
||||
device=spdif
|
||||
|
||||
The profile name follows the schema ``type.name``, where type can be ``vo``
|
||||
to match the value the ``--vo`` option is set to, ``ao`` for ``--ao``,
|
||||
``protocol`` for the input/output protocol in use (see ``--list-protocols``),
|
||||
and ``extension`` for the extension of the path of the currently played file
|
||||
(*not* the file format).
|
||||
|
||||
This feature is very limited, and there are no other auto profiles.
|
||||
|
||||
TAKING SCREENSHOTS
|
||||
==================
|
||||
|
||||
Screenshots of the currently played file can be taken using the 'screenshot'
|
||||
input mode command, which is by default bound to the ``s`` key. Files named
|
||||
``shotNNNN.jpg`` will be saved in the working directory, using the first
|
||||
available number - no files will be overwritten.
|
||||
``mpv-shotNNNN.jpg`` will be saved in the working directory, using the first
|
||||
available number - no files will be overwritten. In pseudo-GUI mode, the
|
||||
screenshot will be saved somewhere else. See `PSEUDO GUI MODE`_.
|
||||
|
||||
A screenshot will usually contain the unscaled video contents at the end of the
|
||||
video filter chain and subtitles. By default, ``S`` takes screenshots without
|
||||
@@ -527,16 +566,16 @@ listed.
|
||||
this will indicate a problem. (``total-avsync-change`` property.)
|
||||
- Encoding state in ``{...}``, only shown in encoding mode.
|
||||
- Display sync state. If display sync is active (``display-sync-active``
|
||||
property), this shows ``DS: +0.02598%``, where the number is the speed change
|
||||
factor applied to audio to achieve sync to display, expressed in percent
|
||||
deviation from 1.0 (``audio-speed-correction`` property). In sync modes which
|
||||
don't resample, this will always be ``+0.00000%``.
|
||||
- Missed frames, e.g. ``Missed: 4``. (``vo-missed-frame-count`` property.) Shows
|
||||
up in display sync mode only. This is incremented each time a frame took
|
||||
longer to display than intended.
|
||||
property), this shows ``DS: 2.500/13``, where the first number is average
|
||||
number of vsyncs per video frame (e.g. 2.5 when playing 24Hz videos on 60Hz
|
||||
screens), which might jitter if the ratio doesn't round off, or there are
|
||||
mistimed frames (``vsync-ratio``), and the second number of estimated number
|
||||
of vsyncs which took too long (``vo-delayed-frame-count`` property). The
|
||||
latter is a heuristic, as it's generally not possible to determine this with
|
||||
certainty.
|
||||
- Dropped frames, e.g. ``Dropped: 4``. Shows up only if the count is not 0. Can
|
||||
grow if the video framerate is higher than that of the display, or if video
|
||||
rendering is too slow. Also can be incremented on "hiccups" and when the video
|
||||
rendering is too slow. May also be incremented on "hiccups" and when the video
|
||||
frame couldn't be displayed on time. (``vo-drop-frame-count`` property.)
|
||||
If the decoder drops frames, the number of decoder-dropped frames is appended
|
||||
to the display as well, e.g.: ``Dropped: 4/34``. This happens only if
|
||||
@@ -567,7 +606,7 @@ PROTOCOLS
|
||||
Play a path from Samba share.
|
||||
|
||||
``bd://[title][/device]`` ``--bluray-device=PATH``
|
||||
Play a Blu-Ray disc. Currently, this does not accept ISO files. Instead,
|
||||
Play a Blu-ray disc. Currently, this does not accept ISO files. Instead,
|
||||
you must mount the ISO file as filesystem, and point ``--bluray-device``
|
||||
to the mounted directory directly.
|
||||
|
||||
@@ -619,9 +658,8 @@ PROTOCOLS
|
||||
absolute path.
|
||||
|
||||
``fd://123``
|
||||
Read data from the given UNIX FD (for example 123). This is similar to
|
||||
piping data to stdin via ``-``, but can use an arbitrary file descriptor.
|
||||
Will not work correctly on MS Windows.
|
||||
Read data from the given file descriptor (for example 123). This is similar
|
||||
to piping data to stdin via ``-``, but can use an arbitrary file descriptor.
|
||||
|
||||
``edl://[edl specification as in edl-mpv.rst]``
|
||||
Stitch together parts of multiple files and play them.
|
||||
@@ -688,6 +726,15 @@ The profile always overrides other settings in ``mpv.conf``.
|
||||
|
||||
.. include:: changes.rst
|
||||
|
||||
|
||||
EMBEDDING INTO OTHER PROGRAMS (LIBMPV)
|
||||
======================================
|
||||
|
||||
mpv can be embedded into other programs as video/audio playback backend. The
|
||||
recommended way to do so is using libmpv. See ``libmpv/client.h`` in the mpv
|
||||
source code repository. This provides a C API. Bindings for other languages
|
||||
might be available (see wiki).
|
||||
|
||||
ENVIRONMENT VARIABLES
|
||||
=====================
|
||||
|
||||
@@ -759,7 +806,7 @@ libdvdcss:
|
||||
|
||||
key
|
||||
is the default method. libdvdcss will use a set of calculated
|
||||
player keys to try and get the disc key. This can fail if the drive
|
||||
player keys to try to get the disc key. This can fail if the drive
|
||||
does not recognize any of the player keys.
|
||||
|
||||
disc
|
||||
@@ -875,7 +922,7 @@ locations are different. They are generally located under ``%APPDATA%/mpv/``.
|
||||
For example, the path to mpv.conf is ``%APPDATA%/mpv/mpv.conf``, which maps to
|
||||
a system and user-specific path, for example
|
||||
|
||||
``C:\users\USERNAME\Application Data\mpv\mpv.conf``
|
||||
``C:\users\USERNAME\AppData\Roaming\mpv\mpv.conf``
|
||||
|
||||
You can find the exact path by running ``echo %APPDATA%\mpv\mpv.conf`` in cmd.exe.
|
||||
|
||||
@@ -898,56 +945,10 @@ lower priority. Some config files are loaded only once, which means that
|
||||
e.g. of 2 ``input.conf`` files located in two config directories, only the
|
||||
one from the directory with higher priority will be loaded.
|
||||
|
||||
A third config directory with lowest priority is the directory named ``mpv``
|
||||
in the same directory as ``mpv.exe``. This used to be the directory with
|
||||
A third config directory with the lowest priority is the directory named ``mpv``
|
||||
in the same directory as ``mpv.exe``. This used to be the directory with the
|
||||
highest priority, but is now discouraged to use and might be removed in the
|
||||
future.
|
||||
|
||||
Note that mpv likes to mix ``/`` and ``\`` path separators for simplicity.
|
||||
kernel32.dll accepts this, but cmd.exe does not.
|
||||
|
||||
EXAMPLES OF MPV USAGE
|
||||
=====================
|
||||
|
||||
Blu-ray playback:
|
||||
- ``mpv bd:////path/to/disc``
|
||||
- ``mpv bd:// --bluray-device=/path/to/disc``
|
||||
|
||||
Play in Japanese with English subtitles:
|
||||
``mpv dvd://1 --alang=ja --slang=en``
|
||||
|
||||
Play only chapters 5, 6, 7:
|
||||
``mpv dvd://1 --chapter=5-7``
|
||||
|
||||
Play only titles 5, 6, 7:
|
||||
``mpv dvd://5-7``
|
||||
|
||||
Play a multi-angle DVD:
|
||||
``mpv dvd://1 --dvd-angle=2``
|
||||
|
||||
Play from a different DVD device:
|
||||
``mpv dvd://1 --dvd-device=/dev/dvd2``
|
||||
|
||||
Play DVD video from a directory with VOB files:
|
||||
``mpv dvd://1 --dvd-device=/path/to/directory/``
|
||||
|
||||
Stream from HTTP:
|
||||
``mpv http://example.com/example.avi``
|
||||
|
||||
Stream using RTSP:
|
||||
``mpv rtsp://server.example.com/streamName``
|
||||
|
||||
Play a libavfilter graph:
|
||||
``mpv avdevice://lavfi:mandelbrot``
|
||||
|
||||
AUTHORS
|
||||
=======
|
||||
|
||||
mpv is a MPlayer fork based on mplayer2, which in turn is a fork of MPlayer.
|
||||
|
||||
MPlayer was initially written by Arpad Gereoffy. See the ``AUTHORS`` file for
|
||||
a list of some of the many other contributors.
|
||||
|
||||
MPlayer is (C) 2000-2013 The MPlayer Team
|
||||
|
||||
This man page was written mainly by Gabucino, Jonas Jermann and Diego Biurrun.
|
||||
+170
-152
@@ -69,7 +69,8 @@ Playback Control
|
||||
|
||||
The general format for absolute times is ``[[hh:]mm:]ss[.ms]``. If the time
|
||||
is given with a prefix of ``+`` or ``-``, the seek is relative from the start
|
||||
or end of the file.
|
||||
or end of the file. (Since mpv 0.14, the start of the file is always
|
||||
considered 0.)
|
||||
|
||||
``pp%`` seeks to percent position pp (0-100).
|
||||
|
||||
@@ -101,6 +102,14 @@ Playback Control
|
||||
Stop after a given time relative to the start time.
|
||||
See ``--start`` for valid option values and examples.
|
||||
|
||||
``--rebase-start-time=<yes|no>``
|
||||
Whether to move the file start time to ``00:00:00`` (default: yes). This
|
||||
is less awkward for files which start at a random timestamp, such as
|
||||
transport streams. On the other hand, if there are timestamp resets, the
|
||||
resulting behavior can be rather weird. For this reason, and in case you
|
||||
are actually interested in the real timestamps, this behavior can be
|
||||
disabled with ``no``.
|
||||
|
||||
``--speed=<0.01-100>``
|
||||
Slow down or speed up playback by the factor given as parameter.
|
||||
|
||||
@@ -127,7 +136,9 @@ Playback Control
|
||||
|
||||
``--chapter=<start[-end]>``
|
||||
Specify which chapter to start playing at. Optionally specify which
|
||||
chapter to end playing at. Also see ``--start``.
|
||||
chapter to end playing at.
|
||||
|
||||
See also: ``--start``.
|
||||
|
||||
``--playlist-pos=<no|index>``
|
||||
Set which file on the internal playlist to start playback with. The index
|
||||
@@ -312,7 +323,7 @@ Program Behavior
|
||||
Files explicitly requested by command line options, like
|
||||
``--include`` or ``--use-filedir-conf``, will still be loaded.
|
||||
|
||||
Also see ``--config-dir``.
|
||||
See also: ``--config-dir``.
|
||||
|
||||
``--list-options``
|
||||
Prints all available options.
|
||||
@@ -456,16 +467,13 @@ Program Behavior
|
||||
|
||||
If the script can't do anything with an URL, it will do nothing.
|
||||
|
||||
(Note: this is the replacement for the now removed libquvi support.)
|
||||
|
||||
``--ytdl-format=<best|worst|mp4|webm|...>``
|
||||
Video format/quality that is directly passed to youtube-dl. The possible
|
||||
values are specific to the website and the video, for a given url the
|
||||
available formats can be found with the command
|
||||
``youtube-dl --list-formats URL``. See youtube-dl's documentation for
|
||||
available aliases. To use experimental DASH support for youtube, use
|
||||
``bestvideo+bestaudio``.
|
||||
(Default: ``best``)
|
||||
available aliases.
|
||||
(Default: youtube-dl's default, currently ``bestvideo+bestaudio/best``)
|
||||
|
||||
``--ytdl-raw-options=<key>=<value>[,<key>=<value>[,...]]``
|
||||
Pass arbitrary options to youtube-dl. Parameter and argument should be
|
||||
@@ -551,11 +559,10 @@ Video
|
||||
differences to other VOs are possible.
|
||||
|
||||
``--display-fps=<fps>``
|
||||
Set the maximum assumed display FPS used with ``--framedrop``. By default
|
||||
a detected value is used (X11 only, not correct on multi-monitor systems),
|
||||
or infinite display FPS if that fails. Infinite FPS means only frames too
|
||||
late are dropped. If a correct FPS is provided, frames that are predicted
|
||||
to be too late are dropped too.
|
||||
Set the display FPS used with the ``--video-sync=display-*`` modes. By
|
||||
default, a detected value is used (X11 only, not correct on multi-monitor
|
||||
systems). Keep in mind that setting an incorrect value (even if slightly
|
||||
incorrect) can ruin video playback.
|
||||
|
||||
``--hwdec=<api>``
|
||||
Specify the hardware video decoding API that should be used if possible.
|
||||
@@ -567,12 +574,11 @@ Video
|
||||
:no: always use software decoding (default)
|
||||
:auto: see below
|
||||
:vdpau: requires ``--vo=vdpau`` or ``--vo=opengl`` (Linux only)
|
||||
:vaapi: requires ``--vo=opengl`` or ``--vo=vaapi`` (Linux with Intel GPUs only)
|
||||
:vaapi: requires ``--vo=opengl`` or ``--vo=vaapi`` (Linux only)
|
||||
:vaapi-copy: copies video back into system RAM (Linux with Intel GPUs only)
|
||||
:vda: requires ``--vo=opengl`` (OS X only)
|
||||
:videotoolbox: requires ``--vo=opengl`` (newer OS X only)
|
||||
:videotoolbox: requires ``--vo=opengl`` (OS X 10.8 and up only)
|
||||
:dxva2-copy: copies video back to system RAM (Windows only)
|
||||
:rpi: requires ``--vo=rpi`` (Raspberry Pi only - default if available)
|
||||
:rpi: requires ``--vo=rpi`` (Raspberry Pi only - default if available)
|
||||
|
||||
``auto`` tries to automatically enable hardware decoding using the first
|
||||
available method. This still depends what VO you are using. For example,
|
||||
@@ -581,6 +587,12 @@ Video
|
||||
work, it will always fall back to software decoding, instead of trying the
|
||||
next method (might matter on some Linux systems).
|
||||
|
||||
The ``vaapi`` mode, if used with ``--vo=opengl``, requires Mesa 11 and most
|
||||
likely works with Intel GPUs only. It also requires the opengl EGL backend
|
||||
(automatically used if available). You can also try the old GLX backend by
|
||||
forcing it with ``--vo=opengl:backend=x11``, but the vaapi/GLX interop is
|
||||
said to be slower than ``vaapi-copy``.
|
||||
|
||||
The ``vaapi-copy`` mode allows you to use vaapi with any VO. Because
|
||||
this copies the decoded video back to system RAM, it's likely less efficient
|
||||
than the ``vaapi`` mode.
|
||||
@@ -603,10 +615,18 @@ Video
|
||||
|
||||
For ``opengl-cb``, if set, load the interop context as soon as the OpenGL
|
||||
context is created. Since ``opengl-cb`` has no on-demand loading, this
|
||||
allows enabling hardware decoding at runtime at all, without having to
|
||||
allows enabling hardware decoding at runtime at all, without having
|
||||
to temporarily set the ``hwdec`` option just during OpenGL context
|
||||
initialization with ``mpv_opengl_cb_init_gl()``.
|
||||
|
||||
``--videotoolbox-format=<name>``
|
||||
Set the internal pixel format used by ``--hwdec=videotoolbox`` on OSX. The
|
||||
choice of the format can influence performance considerably. On the other
|
||||
hand, there doesn't appear to be a good way to detect the best format for
|
||||
the given hardware. ``nv12``, the default, works better on modern hardware,
|
||||
while ``uyvy422`` appears to be better for old hardware. ``rgb0`` also
|
||||
works.
|
||||
|
||||
``--panscan=<0.0-1.0>``
|
||||
Enables pan-and-scan functionality (cropping the sides of e.g. a 16:9
|
||||
video to make it fit a 4:3 display without black bands). The range
|
||||
@@ -657,7 +677,7 @@ Video
|
||||
example ``--video-zoom`` does nothing if this option is enabled.)
|
||||
|
||||
The video and monitor aspects aspect will be ignored. Aspect correction
|
||||
would require to scale the video in the X or Y direction, but this option
|
||||
would require scaling the video in the X or Y direction, but this option
|
||||
disables scaling, disabling all aspect correction.
|
||||
|
||||
Note that the scaler algorithm may still be used, even if the video isn't
|
||||
@@ -677,7 +697,7 @@ Video
|
||||
|
||||
This option is disabled if the ``--no-keepaspect`` option is used.
|
||||
|
||||
``--video-rotate=<0-360|no>``
|
||||
``--video-rotate=<0-359|no>``
|
||||
Rotate the video clockwise, in degrees. Currently supports 90° steps only.
|
||||
If ``no`` is given, the video is never rotated, even if the file has
|
||||
rotation metadata. (The rotation value is added to the rotation metadata,
|
||||
@@ -745,7 +765,7 @@ Video
|
||||
if supported.
|
||||
|
||||
This behaves exactly like the ``deinterlace`` input property (usually
|
||||
mapped to ``Shift+D``).
|
||||
mapped to ``d``).
|
||||
|
||||
``auto`` is a technicality. Strictly speaking, the default for this option
|
||||
is deinterlacing disabled, but the ``auto`` case is needed if ``yadif`` was
|
||||
@@ -775,6 +795,26 @@ Video
|
||||
For audio-only playback, any value greater than 0 will quit playback
|
||||
immediately after initialization. The value 0 works as with video.
|
||||
|
||||
``--video-output-levels=<outputlevels>``
|
||||
RGB color levels used with YUV to RGB conversion. Normally, output devices
|
||||
such as PC monitors use full range color levels. However, some TVs and
|
||||
video monitors expect studio RGB levels. Providing full range output to a
|
||||
device expecting studio level input results in crushed blacks and whites,
|
||||
the reverse in dim gray blacks and dim whites.
|
||||
|
||||
Not all VOs support this option. Some will silently ignore it.
|
||||
|
||||
Available color ranges are:
|
||||
|
||||
:auto: automatic selection (equals to full range) (default)
|
||||
:limited: limited range (16-235 per component), studio levels
|
||||
:full: full range (0-255 per component), PC levels
|
||||
|
||||
.. note::
|
||||
|
||||
It is advisable to use your graphics driver's color range option
|
||||
instead, if available.
|
||||
|
||||
``--hwdec-codecs=<codec1,codec2,...|all>``
|
||||
Allow hardware decoding for a given list of codecs only. The special value
|
||||
``all`` always allows all codecs.
|
||||
@@ -782,9 +822,9 @@ Video
|
||||
You can get the list of allowed codecs with ``mpv --vd=help``. Remove the
|
||||
prefix, e.g. instead of ``lavc:h264`` use ``h264``.
|
||||
|
||||
By default this is set to ``h264,vc1,wmv3,hevc``. Note that the hardware
|
||||
acceleration special codecs like ``h264_vdpau`` are not relevant anymore,
|
||||
and in fact have been removed from Libav in this form.
|
||||
By default, this is set to ``h264,vc1,wmv3,hevc,mpeg2video``. Note that the
|
||||
hardware acceleration special codecs like ``h264_vdpau`` are not relevant
|
||||
anymore, and in fact have been removed from Libav in this form.
|
||||
|
||||
This is usually only needed with broken GPUs, where a codec is reported
|
||||
as supported, but decoding causes more problems than it solves.
|
||||
@@ -801,6 +841,11 @@ Video
|
||||
The result is most likely broken decoding, but may also help if the
|
||||
detected or reported profiles are somehow incorrect.
|
||||
|
||||
``--vd-lavc-software-fallback=<yes|no|N>``
|
||||
Fallback to software decoding if the hardware-accelerated decoder fails
|
||||
(default: 3). If this is a number, then fallback will be triggered if
|
||||
N frames fail to decode in a row. 1 is equivalent to ``yes``.
|
||||
|
||||
``--vd-lavc-bitexact``
|
||||
Only use bit-exact algorithms in all decoding steps (for codec testing).
|
||||
|
||||
@@ -821,7 +866,7 @@ Video
|
||||
|
||||
.. admonition:: Example
|
||||
|
||||
``--vd--lavc-o=debug=pict``
|
||||
``--vd-lavc-o=debug=pict``
|
||||
|
||||
``--vd-lavc-show-all=<yes|no>``
|
||||
Show even broken/corrupt frames (default: no). If this option is set to
|
||||
@@ -892,6 +937,14 @@ Audio
|
||||
|
||||
Currently not implemented for most AOs.
|
||||
|
||||
``--audio-fallback-to-null=<yes|no>``
|
||||
If no audio device can be opened, behave as if ``--ao=null`` was given. This
|
||||
is useful in combination with ``--audio-device``: instead of causing an
|
||||
error if the selected device does not exist, the client API user (or a
|
||||
Lua script) could let playback continue normally, and check the
|
||||
``current-ao`` and ``audio-device-list`` properties to make high-level
|
||||
decisions about how to continue.
|
||||
|
||||
``--ao=<driver1[:suboption1[=value]:...],driver2,...[,]>``
|
||||
Specify a priority list of audio output drivers to be used. For
|
||||
interactive use one would normally specify a single one to use, but in
|
||||
@@ -976,7 +1029,9 @@ Audio
|
||||
|
||||
``--mute=<auto|yes|no>``
|
||||
Set startup audio mute status. ``auto`` (default) will not change the mute
|
||||
status. Also see ``--volume``.
|
||||
status.
|
||||
|
||||
See also: ``--volume``.
|
||||
|
||||
``--softvol=<mode>``
|
||||
Control whether to use the volume controls of the audio output driver or
|
||||
@@ -1101,8 +1156,8 @@ Audio
|
||||
point of file change. Default: ``weak``.
|
||||
|
||||
:no: Disable gapless audio.
|
||||
:yes: The audio device is opened using parameters chosen according to the
|
||||
first file played and is then kept open for gapless playback. This
|
||||
:yes: The audio device is opened using parameters chosen for the first
|
||||
file played and is then kept open for gapless playback. This
|
||||
means that if the first file for example has a low sample rate, then
|
||||
the following files may get resampled to the same low sample rate,
|
||||
resulting in reduced sound quality. If you play files with different
|
||||
@@ -1149,7 +1204,11 @@ Audio
|
||||
:no: Don't automatically load external audio files.
|
||||
:exact: Load the media filename with audio file extension (default).
|
||||
:fuzzy: Load all audio files containing media filename.
|
||||
:all: Load all audio files in the current directory.
|
||||
:all: Load all aufio files in the current and ``--audio-file-paths``
|
||||
directories.
|
||||
|
||||
``--audio-file-paths=<path1:path2:...>``
|
||||
Equivalent to ``--sub-paths`` option, but for auto-loaded audio files.
|
||||
|
||||
``--audio-client-name=<name>``
|
||||
The application name the player reports to the audio API. Can be useful
|
||||
@@ -1186,6 +1245,14 @@ Audio
|
||||
Subtitles
|
||||
---------
|
||||
|
||||
.. note::
|
||||
|
||||
Changing styling and position does not work with all subtitles. Image-based
|
||||
subtitles (DVD, Bluray/PGS, DVB) can not changed for fundamental reasons.
|
||||
Subtitles in ASS format are normally not changed intentionally, but
|
||||
overriding them can be controlled with ``--ass-style-override``.
|
||||
|
||||
|
||||
``--no-sub``
|
||||
Do not select any subtitle when the file is loaded.
|
||||
|
||||
@@ -1283,8 +1350,8 @@ Subtitles
|
||||
|
||||
``--sub-speed=<0.1-10.0>``
|
||||
Multiply the subtitle event timestamps with the given value. Can be used
|
||||
to fix the playback speed for frame-based subtitle formats. Works for
|
||||
external text subtitles only.
|
||||
to fix the playback speed for frame-based subtitle formats. Affects text
|
||||
subtitles only.
|
||||
|
||||
.. admonition:: Example
|
||||
|
||||
@@ -1532,27 +1599,27 @@ Subtitles
|
||||
This mode doesn't take language or fallback codepage.
|
||||
|
||||
``--sub-fix-timing``, ``--no-sub-fix-timing``
|
||||
By default, external text subtitles are preprocessed to remove minor gaps
|
||||
or overlaps between subtitles (if the difference is smaller than 200 ms,
|
||||
the gap or overlap is removed). This does not affect image subtitles,
|
||||
subtitles muxed with audio/video, or subtitles in the ASS format.
|
||||
By default, subtitle timing is adjusted to remove minor gaps or overlaps
|
||||
between subtitles (if the difference is smaller than 210 ms, the gap or
|
||||
overlap is removed).
|
||||
|
||||
``--sub-forced-only``
|
||||
Display only forced subtitles for the DVD subtitle stream selected by e.g.
|
||||
``--slang``.
|
||||
|
||||
``--sub-fps=<rate>``
|
||||
Specify the framerate of the subtitle file (default: video fps).
|
||||
Specify the framerate of the subtitle file (default: video fps). Affects
|
||||
text subtitles only.
|
||||
|
||||
.. note::
|
||||
|
||||
``<rate>`` > video fps speeds the subtitles up for frame-based
|
||||
subtitle files and slows them down for time-based ones.
|
||||
|
||||
Also see ``--sub-speed`` option.
|
||||
See also: ``--sub-speed``.
|
||||
|
||||
``--sub-gauss=<0.0-3.0>``
|
||||
Apply Gaussian blur to image subtitles (default: 0). This can help making
|
||||
Apply Gaussian blur to image subtitles (default: 0). This can help to make
|
||||
pixelated DVD/Vobsubs look nicer. A value other than 0 also switches to
|
||||
software subtitle scaling. Might be slow.
|
||||
|
||||
@@ -1561,7 +1628,7 @@ Subtitles
|
||||
Never applied to text subtitles.
|
||||
|
||||
``--sub-gray``
|
||||
Convert image subtitles to grayscale. Can help making yellow DVD/Vobsubs
|
||||
Convert image subtitles to grayscale. Can help to make yellow DVD/Vobsubs
|
||||
look nicer.
|
||||
|
||||
.. note::
|
||||
@@ -1702,6 +1769,10 @@ Window
|
||||
``--ontop``
|
||||
Makes the player window stay on top of other windows.
|
||||
|
||||
On Windows, if combined with fullscreen mode, this causes mpv to be
|
||||
treated as exclusive fullscreen window that bypasses the Desktop Window
|
||||
Manager.
|
||||
|
||||
``--border``, ``--no-border``
|
||||
Play video with window border and decorations. Since this is on by
|
||||
default, use ``--no-border`` to disable the standard window decorations.
|
||||
@@ -1929,8 +2000,8 @@ Window
|
||||
always re-enabled when the player is paused.
|
||||
|
||||
This is not supported on all video outputs or platforms. Sometimes it is
|
||||
implemented, but does not work (happens often on GNOME). You might be able
|
||||
to to work this around using ``--heartbeat-cmd`` instead.
|
||||
implemented, but does not work (known to happen with GNOME). You might be
|
||||
able to work around this using ``--heartbeat-cmd`` instead.
|
||||
|
||||
``--wid=<ID>``
|
||||
This tells mpv to attach to an existing window. If a VO is selected that
|
||||
@@ -1949,7 +2020,7 @@ Window
|
||||
parent, like with X11.
|
||||
|
||||
On OSX/Cocoa, the ID is interpreted as ``NSView*``. Pass it as value cast
|
||||
to ``intptr_t``. mpv will creates its own sub-view. Because OSX does not
|
||||
to ``intptr_t``. mpv will create its own sub-view. Because OSX does not
|
||||
support window embedding of foreign processes, this works only with libmpv,
|
||||
and will crash when used from the command line.
|
||||
|
||||
@@ -1980,6 +2051,10 @@ Window
|
||||
|
||||
This option might be removed in the future.
|
||||
|
||||
``--x11-bypass-compositor=<yes|no>``
|
||||
If set to ``yes`` (default), then ask the compositor to unredirect the
|
||||
mpv window. This uses the ``_NET_WM_BYPASS_COMPOSITOR`` hint.
|
||||
|
||||
|
||||
Disc Devices
|
||||
------------
|
||||
@@ -2154,7 +2229,7 @@ Demuxer
|
||||
Encryption key the demuxer should use. This is the raw binary data of
|
||||
the key converted to a hexadecimal string.
|
||||
|
||||
``--demuxer-mkv-subtitle-preroll``, ``--mkv-subtitle-preroll``
|
||||
``--demuxer-mkv-subtitle-preroll=<yes|index|no>``, ``--mkv-subtitle-preroll``
|
||||
Try harder to show embedded soft subtitles when seeking somewhere. Normally,
|
||||
it can happen that the subtitle at the seek target is not shown due to how
|
||||
some container file formats are designed. The subtitles appear only if
|
||||
@@ -2186,7 +2261,11 @@ Demuxer
|
||||
overlap with a seek target. In these cases, mpv will reduce the amount
|
||||
of data read to a minimum. (Although it will still read *all* data between
|
||||
the cluster that contains the first wanted subtitle packet, and the seek
|
||||
target.)
|
||||
target.) If the ``index`` choice (which is the default) is specified, then
|
||||
prerolling will be done only if this information is actually available. If
|
||||
this method is used, the maximum amount of data to skip can be additionally
|
||||
controlled by ``--demuxer-mkv-subtitle-preroll-secs-index`` (it still uses
|
||||
the value of the option without ``-index`` if that is higher).
|
||||
|
||||
See also ``--hr-seek-demuxer-offset`` option. This option can achieve a
|
||||
similar effect, but only if hr-seek is active. It works with any demuxer,
|
||||
@@ -2198,6 +2277,9 @@ Demuxer
|
||||
``--demuxer-mkv-subtitle-preroll-secs=<value>``
|
||||
See ``--demuxer-mkv-subtitle-preroll``.
|
||||
|
||||
``--demuxer-mkv-subtitle-preroll-secs-index=<value>``
|
||||
See ``--demuxer-mkv-subtitle-preroll``.
|
||||
|
||||
``--demuxer-mkv-probe-video-duration=<yes|no|full>``
|
||||
When opening the file, seek to the end of it, and check what timestamp the
|
||||
last video packet has, and report that as file duration. This is strictly
|
||||
@@ -2210,18 +2292,6 @@ Demuxer
|
||||
file and can make a reliable estimate even without an index present (such
|
||||
as partial files).
|
||||
|
||||
``--demuxer-mkv-fix-timestamps=<yes|no>``
|
||||
Fix rounded Matroska timestamps (disabled by default). Matroska usually
|
||||
stores timestamps rounded to milliseconds. This means timestamps jitter
|
||||
by some amount around the intended timestamp. mpv can correct the timestamps
|
||||
based on the framerate value stored in the file: the timestamp is rounded
|
||||
to the next frame (according to the framerate), unless the new timestamp
|
||||
would deviate more than 1ms from the old one. This should undo the rounding
|
||||
done by the muxer.
|
||||
|
||||
(The allowed deviation can be less than 1ms if the file uses a non-standard
|
||||
timecode scale.)
|
||||
|
||||
``--demuxer-rawaudio-channels=<value>``
|
||||
Number of channels (or channel layout) if ``--demuxer=rawaudio`` is used
|
||||
(default: stereo).
|
||||
@@ -2334,7 +2404,7 @@ Input
|
||||
|
||||
``--input-key-fifo-size=<2-65000>``
|
||||
Specify the size of the FIFO that buffers key events (default: 7). If it
|
||||
is too small some events may be lost. The main disadvantage of setting it
|
||||
is too small, some events may be lost. The main disadvantage of setting it
|
||||
to a very large value is that if you hold down a key triggering some
|
||||
particularly slow command then the player may be unresponsive while it
|
||||
processes all the queued commands.
|
||||
@@ -2401,7 +2471,7 @@ Input
|
||||
|
||||
On X11, a sub-window with input enabled grabs all keyboard input as long
|
||||
as it is 1. a child of a focused window, and 2. the mouse is inside of
|
||||
the sub-window. The can steal away all keyboard input from the
|
||||
the sub-window. It can steal away all keyboard input from the
|
||||
application embedding the mpv window, and on the other hand, the mpv
|
||||
window will receive no input if the mouse is outside of the mpv window,
|
||||
even though mpv has focus. Modern toolkits work around this weird X11
|
||||
@@ -2441,14 +2511,14 @@ OSD
|
||||
``--osd-duration=<time>``
|
||||
Set the duration of the OSD messages in ms (default: 1000).
|
||||
|
||||
``--osd-font=<pattern>``, ``--sub-text-font=<pattern>``
|
||||
``--osd-font=<name>``, ``--sub-text-font=<name>``
|
||||
Specify font to use for OSD and for subtitles that do not themselves
|
||||
specify a particular font. The default is ``sans-serif``.
|
||||
|
||||
.. admonition:: Examples
|
||||
|
||||
- ``--osd-font='Bitstream Vera Sans'``
|
||||
- ``--osd-font='Bitstream Vera Sans:style=Bold'`` (fontconfig pattern)
|
||||
- ``--osd-font='MS Comic Sans'``
|
||||
|
||||
.. note::
|
||||
|
||||
@@ -2456,6 +2526,9 @@ OSD
|
||||
options) are ignored when ASS-subtitles are rendered, unless the
|
||||
``--no-sub-ass`` option is specified.
|
||||
|
||||
This used to support fontconfig patterns. Starting with libass 0.13.0,
|
||||
this stopped working.
|
||||
|
||||
``--osd-font-size=<size>``, ``--sub-text-font-size=<size>``
|
||||
Specify the OSD/sub font size. The unit is the size in scaled pixels at a
|
||||
window height of 720. The actual pixel size is scaled with the window
|
||||
@@ -2636,17 +2709,6 @@ OSD
|
||||
|
||||
Default: 0.
|
||||
|
||||
``--use-text-osd=<yes|no>``
|
||||
Disable text OSD rendering completely. (This includes the complete OSC as
|
||||
well.) This is mostly useful for avoiding loading fontconfig in situations
|
||||
where fontconfig does not behave well, and OSD is unused - this could for
|
||||
example allow GUI programs using libmpv to workaround fontconfig issues.
|
||||
|
||||
Note that selecting subtitles of any kind still initializes fontconfig.
|
||||
|
||||
Default: ``no``.
|
||||
|
||||
|
||||
Screenshot
|
||||
----------
|
||||
|
||||
@@ -2679,7 +2741,7 @@ Screenshot
|
||||
Specify the filename template used to save screenshots. The template
|
||||
specifies the filename without file extension, and can contain format
|
||||
specifiers, which will be substituted when taking a screenshot.
|
||||
By default the template is ``mpv-shot%n``, which results in filenames like
|
||||
By default, the template is ``mpv-shot%n``, which results in filenames like
|
||||
``mpv-shot0012.png`` for example.
|
||||
|
||||
The template can start with a relative or absolute path, in order to
|
||||
@@ -2835,7 +2897,7 @@ Terminal
|
||||
Particularly useful on slow terminals or broken ones which do not properly
|
||||
handle carriage return (i.e. ``\r``).
|
||||
|
||||
Also see ``--really-quiet`` and ``--msg-level``.
|
||||
See also: ``--really-quiet`` and ``--msg-level``.
|
||||
|
||||
``--really-quiet``
|
||||
Display even less output and status messages than with ``--quiet``.
|
||||
@@ -2968,8 +3030,9 @@ TV
|
||||
maximum size of the capture buffer in megabytes (default: dynamical)
|
||||
|
||||
``--tv-norm=<value>``
|
||||
See the console output for a list of all available norms, also see the
|
||||
``normid`` option below.
|
||||
See the console output for a list of all available norms.
|
||||
|
||||
See also: ``--tv-normid``.
|
||||
|
||||
``--tv-normid=<value> (v4l2 only)``
|
||||
Sets the TV norm to the given numeric ID. The TV norm depends on the
|
||||
@@ -3179,7 +3242,7 @@ Cache
|
||||
multiple cache streams, and using the same file for them obviously
|
||||
clashes.
|
||||
|
||||
Also see ``--cache-file-size``.
|
||||
See also: ``--cache-file-size``.
|
||||
|
||||
``--cache-file-size=<kBytes>``
|
||||
Maximum size of the file created with ``--cache-file``. For read accesses
|
||||
@@ -3245,6 +3308,13 @@ Network
|
||||
Verify peer certificates when using TLS (e.g. with ``https://...``).
|
||||
(Silently fails with older FFmpeg or Libav versions.)
|
||||
|
||||
``--tls-cert-file``
|
||||
A file containing a certificate to use in the handshake with the
|
||||
peer.
|
||||
|
||||
``--tls-key-file``
|
||||
A file containing the private key for the certificate.
|
||||
|
||||
``--referrer=<string>``
|
||||
Specify a referrer path or URL for HTTP requests.
|
||||
|
||||
@@ -3300,72 +3370,18 @@ DVB
|
||||
|
||||
``--dvbin-full-transponder=<yes|no>``
|
||||
Apply no filters on program PIDs, only tune to frequency and pass full
|
||||
transponder to demuxer. This is useful to record multiple programs
|
||||
on a single transponder, or to work around issues in the ``channels.conf``.
|
||||
transponder to demuxer.
|
||||
The player frontend selects the streams from the full TS in this case,
|
||||
so the program which is shown initially may not match the chosen channel.
|
||||
Switching between the programs is possible by cycling the ``program``
|
||||
property.
|
||||
This is useful to record multiple programs on a single transponder,
|
||||
or to work around issues in the ``channels.conf``.
|
||||
It is also recommended to use this for channels which switch PIDs
|
||||
on-the-fly, e.g. for regional news.
|
||||
|
||||
Default: ``no``
|
||||
|
||||
PVR
|
||||
---
|
||||
|
||||
``--pvr-...``
|
||||
These options tune various encoding properties of the PVR capture module.
|
||||
It has to be used with any hardware MPEG encoder based card supported by
|
||||
the V4L2 driver. The Hauppauge WinTV PVR-150/250/350/500 and all IVTV
|
||||
based cards are known as PVR capture cards. Be aware that only Linux
|
||||
2.6.18 kernel and above is able to handle MPEG stream through V4L2 layer.
|
||||
For hardware capture of an MPEG stream and watching it with mpv, use
|
||||
``pvr://`` as media URL.
|
||||
|
||||
|
||||
``--pvr-aspect=<0-3>``
|
||||
Specify input aspect ratio:
|
||||
|
||||
:0: 1:1
|
||||
:1: 4:3 (default)
|
||||
:2: 16:9
|
||||
:3: 2.21:1
|
||||
|
||||
``--pvr-arate=<32000-48000>``
|
||||
Specify encoding audio rate (default: 48000 Hz, available: 32000,
|
||||
44100 and 48000 Hz).
|
||||
|
||||
``--pvr-alayer=<1-3>``
|
||||
Specify MPEG audio layer encoding (default: 2).
|
||||
|
||||
``--pvr-abitrate=<32-448>``
|
||||
Specify audio encoding bitrate in kbps (default: 384).
|
||||
|
||||
``--pvr-amode=<value>``
|
||||
Specify audio encoding mode. Available preset values are 'stereo',
|
||||
'joint_stereo', 'dual' and 'mono' (default: stereo).
|
||||
|
||||
``--pvr-vbitrate=<value>``
|
||||
Specify average video bitrate encoding in Mbps (default: 6).
|
||||
|
||||
``--pvr-vmode=<value>``
|
||||
Specify video encoding mode:
|
||||
|
||||
:vbr: Variable Bit Rate (default)
|
||||
:cbr: Constant Bit Rate
|
||||
|
||||
``--pvr-vpeak=<value>``
|
||||
Specify peak video bitrate encoding in Mbps (only useful for VBR
|
||||
encoding, default: 9.6).
|
||||
|
||||
``--pvr-fmt=<value>``
|
||||
Choose an MPEG format for encoding:
|
||||
|
||||
:ps: MPEG-2 Program Stream (default)
|
||||
:ts: MPEG-2 Transport Stream
|
||||
:mpeg1: MPEG-1 System Stream
|
||||
:vcd: Video CD compatible stream
|
||||
:svcd: Super Video CD compatible stream
|
||||
:dvd: DVD compatible stream
|
||||
|
||||
|
||||
Miscellaneous
|
||||
-------------
|
||||
|
||||
@@ -3393,7 +3409,7 @@ Miscellaneous
|
||||
implement a perfect audio delay measurement. With this value, if large A/V
|
||||
sync offsets occur, they will only take about 1 or 2 seconds to settle
|
||||
out. This delay in reaction time to sudden A/V offsets should be the only
|
||||
side-effect of turning this option on, for all sound drivers.
|
||||
side effect of turning this option on, for all sound drivers.
|
||||
|
||||
``--video-sync=<audio|...>``
|
||||
How the player synchronizes audio and video.
|
||||
@@ -3430,6 +3446,11 @@ Miscellaneous
|
||||
:display-vdrop: Drop or repeat video frames to compensate desyncing
|
||||
video. (Although it should have the same effects as
|
||||
``audio``, the implementation is very different.)
|
||||
:display-adrop: Drop or repeat audio data to compensate desyncing
|
||||
video. See ``--video-sync-adrop-size``. This mode will
|
||||
cause severe audio artifacts if the real monitor
|
||||
refresh rate is too different from the reported or
|
||||
forced rate.
|
||||
:display-desync: Sync video to display, and let audio play on its own.
|
||||
:desync: Sync video according to system clock, and let audio play
|
||||
on its own.
|
||||
@@ -3461,6 +3482,13 @@ Miscellaneous
|
||||
frame dropping due to the audio "overshooting" and skipping multiple video
|
||||
frames before the sync logic can react.
|
||||
|
||||
``--video-sync-adrop-size=<value``
|
||||
For the ``--video-sync=display-adrop`` mode. This mode duplicates/drops
|
||||
audio data to keep audio in sync with video. To avoid audio artifacts on
|
||||
jitter (which would add/remove samples all the time), this is done in
|
||||
relatively large, fixed units, controlled by this option. The unit is
|
||||
seconds.
|
||||
|
||||
``--mf-fps=<value>``
|
||||
Framerate used when decoding from multiple PNG or JPEG files with ``mf://``
|
||||
(default: 1).
|
||||
@@ -3492,6 +3520,10 @@ Miscellaneous
|
||||
other options such as e.g. user agent are not available with all protocols,
|
||||
and printing errors for unknown options would end up being too noisy.)
|
||||
|
||||
``--vo-mmcss-profile=<name>``
|
||||
(Windows only.)
|
||||
Set the MMCSS profile for the video renderer thread (default: ``Playback``).
|
||||
|
||||
``--priority=<prio>``
|
||||
(Windows only.)
|
||||
Set process priority for mpv according to the predefined priorities
|
||||
@@ -3502,20 +3534,6 @@ Miscellaneous
|
||||
|
||||
.. warning:: Using realtime priority can cause system lockup.
|
||||
|
||||
``--pts-association-mode=<decode|sort|auto>``
|
||||
Select the method used to determine which container packet timestamp
|
||||
corresponds to a particular output frame from the video decoder. Normally
|
||||
you should not need to change this option.
|
||||
|
||||
:decoder: Use decoder reordering functionality. Unlike in classic MPlayer
|
||||
and mplayer2, this includes a DTS fallback. (Default.)
|
||||
:sort: Maintain a buffer of unused pts values and use the lowest value
|
||||
for the frame.
|
||||
:auto: Try to pick a working mode from the ones above automatically.
|
||||
|
||||
You can also try to use ``--no-correct-pts`` for files with completely
|
||||
broken timestamps.
|
||||
|
||||
``--force-media-title=<string>``
|
||||
Force the contents of the ``media-title`` property to this value. Useful
|
||||
for scripts which want to set a title, without overriding the user's
|
||||
|
||||
+20
-41
@@ -151,15 +151,15 @@ Available filters are:
|
||||
:yes: Enable accurate rounding.
|
||||
|
||||
``dsize[=w:h:aspect-method:r:aspect]``
|
||||
Changes the intended display size/aspect at an arbitrary point in the
|
||||
Changes the intended display aspect at an arbitrary point in the
|
||||
filter chain. Aspect can be given as a fraction (4/3) or floating point
|
||||
number (1.33). Alternatively, you may specify the exact display width and
|
||||
height desired. Note that this filter does *not* do any scaling itself; it
|
||||
number (1.33). Note that this filter does *not* do any scaling itself; it
|
||||
just affects what later scalers (software or hardware) will do when
|
||||
auto-scaling to the correct aspect.
|
||||
|
||||
``<w>,<h>``
|
||||
New display width and height.
|
||||
New aspect ratio given by a display width and height. Unlike older mpv
|
||||
versions or MPlayer, this does not set the display size.
|
||||
|
||||
Can also be these special values:
|
||||
|
||||
@@ -259,26 +259,6 @@ Available filters are:
|
||||
:limited: limited range (16-235 for luma, 16-240 for chroma)
|
||||
:full: full range (0-255 for both luma and chroma)
|
||||
|
||||
``<outputlevels>``
|
||||
RGB color levels used with YUV to RGB conversion. Normally, output devices
|
||||
such as PC monitors use full range color levels. However, some TVs and
|
||||
video monitors expect studio RGB levels. Providing full range output to a
|
||||
device expecting studio level input results in crushed blacks and whites,
|
||||
the reverse in dim gray blacks and dim whites.
|
||||
|
||||
The same limitations as with ``<colormatrix>`` apply.
|
||||
|
||||
Available color ranges are:
|
||||
|
||||
:auto: automatic selection (equals to full range) (default)
|
||||
:limited: limited range (16-235 per component), studio levels
|
||||
:full: full range (0-255 per component), PC levels
|
||||
|
||||
.. note::
|
||||
|
||||
It is advisable to use your graphics driver's color range option
|
||||
instead, if available.
|
||||
|
||||
``<primaries>``
|
||||
RGB primaries the source file was encoded with. Normally this should be set
|
||||
in the file header, but when playing broken or mistagged files this can be
|
||||
@@ -458,9 +438,8 @@ Available filters are:
|
||||
generating an occasional mismatched frame, but it may also cause an
|
||||
excessive number of frames to be dropped during high motion sequences.
|
||||
Conversely, setting it to -1 will make ``pullup`` match fields more
|
||||
easily. This may help processing of video where there is slight
|
||||
blurring between the fields, but may also cause there to be interlaced
|
||||
frames in the output.
|
||||
easily. This may help process video with slight blurring between the
|
||||
fields, but may also cause interlaced frames in the output.
|
||||
|
||||
``mp`` (metric plane)
|
||||
This option may be set to ``u`` or ``v`` to use a chroma plane instead of the
|
||||
@@ -475,25 +454,24 @@ Available filters are:
|
||||
|
||||
``<mode>``
|
||||
:frame: Output 1 frame for each frame.
|
||||
:field: Output 1 frame for each field.
|
||||
:field: Output 1 frame for each field (default).
|
||||
:frame-nospatial: Like ``frame`` but skips spatial interlacing check.
|
||||
:field-nospatial: Like ``field`` but skips spatial interlacing check.
|
||||
|
||||
``<interlaced-only>``
|
||||
:no: Deinterlace all frames (default).
|
||||
:yes: Only deinterlace frames marked as interlaced (default if this
|
||||
filter is inserted via ``deinterlace`` property).
|
||||
:no: Deinterlace all frames.
|
||||
:yes: Only deinterlace frames marked as interlaced (default).
|
||||
|
||||
This filter, is automatically inserted when using the ``D`` key (or any
|
||||
This filter is automatically inserted when using the ``d`` key (or any
|
||||
other key that toggles the ``deinterlace`` property or when using the
|
||||
``--deinterlace`` switch), assuming the video output does not have native
|
||||
deinterlacing support.
|
||||
|
||||
If you just want to set the default mode, put this filter and its options
|
||||
into ``--vf-defaults`` instead, and enable deinterlacing with ``D`` or
|
||||
into ``--vf-defaults`` instead, and enable deinterlacing with ``d`` or
|
||||
``--deinterlace``.
|
||||
|
||||
Also note that the ``D`` key is stupid enough to insert an interlacer twice
|
||||
Also, note that the ``d`` key is stupid enough to insert a deinterlacer twice
|
||||
when inserting yadif with ``--vf``, so using the above methods is
|
||||
recommended.
|
||||
|
||||
@@ -665,10 +643,11 @@ Available filters are:
|
||||
``buffered-frames``
|
||||
Maximum number of decoded video frames that should be buffered before
|
||||
the filter (default: 4). This specifies the maximum number of frames
|
||||
the script can requests backwards. E.g. if ``buffered-frames=5``, and
|
||||
the script just requested frame 15, it can still request frame 10, but
|
||||
frame 9 is not available anymore. If it requests frame 30, mpv will
|
||||
decode 15 more frames, and keep only frames 25-30.
|
||||
the script can request in reverse direction.
|
||||
E.g. if ``buffered-frames=5``, and the script just requested frame 15,
|
||||
it can still request frame 10, but frame 9 is not available anymore.
|
||||
If it requests frame 30, mpv will decode 15 more frames, and keep only
|
||||
frames 25-30.
|
||||
|
||||
The actual number of buffered frames also depends on the value of the
|
||||
``concurrent-frames`` option. Currently, both option values are
|
||||
@@ -741,7 +720,7 @@ Available filters are:
|
||||
``vavpp``
|
||||
VA-AP-API video post processing. Works with ``--vo=vaapi`` and ``--vo=opengl``
|
||||
only. Currently deinterlaces. This filter is automatically inserted if
|
||||
deinterlacing is requested (either using the ``D`` key, by default mapped to
|
||||
deinterlacing is requested (either using the ``d`` key, by default mapped to
|
||||
the command ``cycle deinterlace``, or the ``--deinterlace`` option).
|
||||
|
||||
``deint=<method>``
|
||||
@@ -765,7 +744,7 @@ Available filters are:
|
||||
``vdpaupp``
|
||||
VDPAU video post processing. Works with ``--vo=vdpau`` and ``--vo=opengl``
|
||||
only. This filter is automatically inserted if deinterlacing is requested
|
||||
(either using the ``D`` key, by default mapped to the command
|
||||
(either using the ``d`` key, by default mapped to the command
|
||||
``cycle deinterlace``, or the ``--deinterlace`` option). When enabling
|
||||
deinterlacing, it is always preferred over software deinterlacer filters
|
||||
if the ``vdpau`` VO is used, and also if ``opengl`` is used and hardware
|
||||
@@ -823,6 +802,6 @@ Available filters are:
|
||||
|
||||
``buffer=<num>``
|
||||
Buffer ``<num>`` frames in the filter chain. This filter is probably pretty
|
||||
useless, except for debugging. (Note that this won't help smoothing out
|
||||
useless, except for debugging. (Note that this won't help to smooth out
|
||||
latencies with decoding, because the filter will never output a frame if
|
||||
the buffer isn't full, except on EOF.)
|
||||
+183
-70
@@ -20,13 +20,10 @@ normal driver parameters.
|
||||
|
||||
See ``--vo=help`` for a list of compiled-in video output drivers.
|
||||
|
||||
The recommended output drivers are ``--vo=vdpau`` and ``--vo=opengl-hq``.
|
||||
All other drivers are just for compatibility or special purposes.
|
||||
|
||||
.. admonition:: Example
|
||||
|
||||
``--vo=opengl,xv,``
|
||||
Try the ``opengl`` driver, then the ``xv`` driver, then others.
|
||||
The recommended output driver is ``--vo=opengl-hq``. All other drivers are
|
||||
for compatibility or special purposes. By default, ``--vo=opengl`` is used,
|
||||
but if that appears not to work, it fallback to other drivers (in the same
|
||||
order as listed by ``--vo=help``).
|
||||
|
||||
Available video output drivers are:
|
||||
|
||||
@@ -75,6 +72,12 @@ Available video output drivers are:
|
||||
not responding quickly enough if video FPS is close to or higher than
|
||||
the display refresh rate.
|
||||
|
||||
``x11`` (X11 only)
|
||||
Shared memory video output driver without hardware acceleration that works
|
||||
whenever X11 is present.
|
||||
|
||||
.. note:: This is a fallback only, and should not be normally used.
|
||||
|
||||
``vdpau`` (X11 only)
|
||||
Uses the VDPAU interface to display and optionally also decode video.
|
||||
Hardware decoding is used with ``--hwdec=vdpau``.
|
||||
@@ -102,7 +105,7 @@ Available video output drivers are:
|
||||
Select deinterlacing mode (default: 0). In older versions (as well as
|
||||
MPlayer/mplayer2) you could use this option to enable deinterlacing.
|
||||
This doesn't work anymore, and deinterlacing is enabled with either
|
||||
the ``D`` key (by default mapped to the command ``cycle deinterlace``),
|
||||
the ``d`` key (by default mapped to the command ``cycle deinterlace``),
|
||||
or the ``--deinterlace`` option. Also, to select the default deint mode,
|
||||
you should use something like ``--vf-defaults=vdpaupp:deint-mode=temporal``
|
||||
instead of this sub-option.
|
||||
@@ -308,7 +311,10 @@ Available video output drivers are:
|
||||
of bad or old hardware.
|
||||
|
||||
This mode is forced automatically if needed, and this option is mostly
|
||||
useful for debugging.
|
||||
useful for debugging. It's also enabled automatically if nothing uses
|
||||
features which require FBOs.
|
||||
|
||||
This option might be silently removed in the future.
|
||||
|
||||
``scale=<filter>``
|
||||
|
||||
@@ -375,10 +381,6 @@ Available video output drivers are:
|
||||
Scale parameter (``t``). Increasing this makes the result blurrier.
|
||||
Defaults to 1.
|
||||
|
||||
sharpen3, sharpen5
|
||||
Sharpening strength. Increasing this makes the image sharper but
|
||||
adds more ringing and aliasing. Defaults to 0.5.
|
||||
|
||||
oversample
|
||||
Minimum distance to an edge before interpolation is used. Setting
|
||||
this to 0 will always interpolate edges, whereas setting it to 0.5
|
||||
@@ -408,8 +410,8 @@ Available video output drivers are:
|
||||
between 0.0 and 1.0. The default value of 0.0 disables antiringing
|
||||
entirely.
|
||||
|
||||
Note that this doesn't affect the special filters ``bilinear``,
|
||||
``bicubic_fast`` or ``sharpen``.
|
||||
Note that this doesn't affect the special filters ``bilinear`` and
|
||||
``bicubic_fast``.
|
||||
|
||||
``scale-window=<window>``
|
||||
(Advanced users only) Choose a custom windowing function for the kernel.
|
||||
@@ -429,6 +431,15 @@ Available video output drivers are:
|
||||
Scale parameter (t). Increasing this makes the window wider.
|
||||
Defaults to 1.
|
||||
|
||||
``scaler-lut-size=<4..10>``
|
||||
Set the size of the lookup texture for scaler kernels (default: 6).
|
||||
The actual size of the texture is ``2^N`` for an option value of ``N``.
|
||||
So the lookup texture with the default setting uses 64 samples.
|
||||
|
||||
All weights are bilinearly interpolated from those samples, so
|
||||
increasing the size of lookup table might improve the accuracy of
|
||||
scaler.
|
||||
|
||||
``scaler-resizes-only``
|
||||
Disable the scaler if the video image is not resized. In that case,
|
||||
``bilinear`` is used instead whatever is set with ``scale``. Bilinear
|
||||
@@ -436,10 +447,12 @@ Available video output drivers are:
|
||||
Note that this option never affects ``cscale``.
|
||||
|
||||
``pbo``
|
||||
Enable use of PBOs. This is slightly faster, but can sometimes lead to
|
||||
sporadic and temporary image corruption (in theory, because reupload
|
||||
is not retried when it fails), and perhaps actually triggers slower
|
||||
paths with drivers that don't support PBOs properly.
|
||||
Enable use of PBOs. On some drivers this can be faster, especially if
|
||||
the source video size is huge (e.g. so called "4K" video). On other
|
||||
drivers it might be slower or cause latency issues.
|
||||
|
||||
In theory, this can sometimes lead to sporadic and temporary image
|
||||
corruption (because reupload is not retried when it fails).
|
||||
|
||||
``dither-depth=<N|no|auto>``
|
||||
Set dither target depth to N. Default: no.
|
||||
@@ -470,7 +483,7 @@ Available video output drivers are:
|
||||
|
||||
``temporal-dither``
|
||||
Enable temporal dithering. (Only active if dithering is enabled in
|
||||
general.) This changes between 8 different dithering pattern on each
|
||||
general.) This changes between 8 different dithering patterns on each
|
||||
frame by changing the orientation of the tiled dithering matrix.
|
||||
Unfortunately, this can lead to flicker on LCD displays, since these
|
||||
have a high reaction time.
|
||||
@@ -481,7 +494,7 @@ Available video output drivers are:
|
||||
video frame, 2 on every other frame, etc.
|
||||
|
||||
``debug``
|
||||
Check for OpenGL errors, i.e. call ``glGetError()``. Also request a
|
||||
Check for OpenGL errors, i.e. call ``glGetError()``. Also, request a
|
||||
debug OpenGL context (which does nothing with current graphics drivers
|
||||
as of this writing).
|
||||
|
||||
@@ -489,6 +502,10 @@ Available video output drivers are:
|
||||
Reduce stuttering caused by mismatches in the video fps and display
|
||||
refresh rate (also known as judder).
|
||||
|
||||
.. warning:: This requires setting the ``--video-sync`` option to one
|
||||
of the ``display-`` modes, or it will be silently disabled.
|
||||
This was not required before mpv 0.14.0.
|
||||
|
||||
This essentially attempts to interpolate the missing frames by
|
||||
convoluting the video along the temporal axis. The filter used can be
|
||||
controlled using the ``tscale`` setting.
|
||||
@@ -520,7 +537,7 @@ Available video output drivers are:
|
||||
The filter used for interpolating the temporal axis (frames). This is
|
||||
only used if ``interpolation`` is enabled. The only valid choices
|
||||
for ``tscale`` are separable convolution filters (use ``tscale=help``
|
||||
to get a list). The default is ``oversample``.
|
||||
to get a list). The default is ``mitchell``.
|
||||
|
||||
Note that the maximum supported filter radius is currently 3, due to
|
||||
limitations in the number of video textures that can be loaded
|
||||
@@ -542,13 +559,82 @@ Available video output drivers are:
|
||||
Scale in linear light. It should only be used with a ``fbo-format``
|
||||
that has at least 16 bit precision.
|
||||
|
||||
``fancy-downscaling``
|
||||
``correct-downscaling``
|
||||
When using convolution based filters, extend the filter size
|
||||
when downscaling. Trades quality for reduced downscaling performance.
|
||||
when downscaling. Increases quality, but reduces performance while
|
||||
downscaling.
|
||||
|
||||
This will perform slightly sub-optimally for anamorphic video (but still
|
||||
better than without it) since it will extend the size to match only the
|
||||
milder of the scale factors between the axes.
|
||||
|
||||
``prescale=<filter>``
|
||||
This option provides non-convolution-based filters for upscaling. These
|
||||
filters resize the video to multiple of the original size (all currently
|
||||
supported prescalers can only perform image doubling in a single pass).
|
||||
Generally another convolution based filter (the main scaler) will be
|
||||
applied after prescaler to match the target display size.
|
||||
|
||||
``none``
|
||||
Disable all prescalers. This is the default.
|
||||
|
||||
``superxbr``
|
||||
A relatively fast prescaler originally developed for pixel art.
|
||||
|
||||
Some parameters can be tuned with ``superxbr-sharpness`` and
|
||||
``superxbr-edge-strength`` options.
|
||||
|
||||
``nnedi3``
|
||||
An artificial neural network based deinterlacer, which can be used
|
||||
to upscale images.
|
||||
|
||||
Extremely slow and requires a recent mid or high end graphics card
|
||||
to work smoothly (as of 2015).
|
||||
|
||||
Note that all the filters above are designed (or implemented) to process
|
||||
luma plane only and probably won't work as intended for video in RGB
|
||||
format.
|
||||
|
||||
``prescale-passes=<1..5>``
|
||||
The number of passes to apply the prescaler (defaults to be 1). Setting
|
||||
it to 2 will perform a 4x upscaling.
|
||||
|
||||
``prescale-downscaling-threshold=<0..32>``
|
||||
This option prevents "overkill" use of prescalers, which can be caused
|
||||
by misconfiguration, or user trying to play a video with much larger
|
||||
size. With this option, user can specify the maximal allowed downscaling
|
||||
ratio in both dimension. To satisfy it, the number of passes for
|
||||
prescaler will be reduced, and if necessary prescaler could also be
|
||||
disabled.
|
||||
|
||||
The default value is 2.0, and should be able to prevent most seemingly
|
||||
unreasonable use of prescalers. Most user would probably want to set it
|
||||
to a smaller value between 1.0 and 1.5 for better performance.
|
||||
|
||||
A value less than 1.0 will disable the check.
|
||||
|
||||
``nnedi3-neurons=<16|32|64|128>``
|
||||
Specify the neurons for nnedi3 prescaling (defaults to be 32). The
|
||||
rendering time is expected to be linear to the number of neurons.
|
||||
|
||||
``nnedi3-window=<8x4|8x6>``
|
||||
Specify the size of local window for sampling in nnedi3 prescaling
|
||||
(defaults to be ``8x4``). The ``8x6`` window produces sharper images,
|
||||
but is also slower.
|
||||
|
||||
``nnedi3-upload=<ubo|shader>``
|
||||
Specify how to upload the NN weights to GPU. Depending on the graphics
|
||||
card, driver, shader compiler and nnedi3 settings, both method can be
|
||||
faster or slower.
|
||||
|
||||
``ubo``
|
||||
Upload these weights via uniform buffer objects. This is the
|
||||
default. (requires OpenGL 3.1 / GLES 3.0)
|
||||
|
||||
``shader``
|
||||
Hard code all the weights into the shader source code. (requires
|
||||
OpenGL 3.3 / GLES 3.0)
|
||||
|
||||
This is automatically disabled for anamorphic video, because this
|
||||
feature doesn't work correctly with different scale factors in
|
||||
different directions.
|
||||
|
||||
``pre-shaders=<files>``, ``post-shaders=<files>``, ``scale-shader=<file>``
|
||||
Custom GLSL fragment shaders.
|
||||
@@ -612,11 +698,8 @@ Available video output drivers are:
|
||||
``deband-iterations=<1..16>``
|
||||
The number of debanding steps to perform per sample. Each step reduces
|
||||
a bit more banding, but takes time to compute. Note that the strength
|
||||
of each step falls off very quickly, so high numbers are practically
|
||||
useless. (Default 4)
|
||||
|
||||
If the performance hit of debanding is too great, you can reduce this
|
||||
to 2 or 1 with marginal visual quality loss.
|
||||
of each step falls off very quickly, so high numbers (>4) are
|
||||
practically useless. (Default 1)
|
||||
|
||||
``deband-threshold=<0..4096>``
|
||||
The debanding filter's cut-off threshold. Higher numbers increase the
|
||||
@@ -626,7 +709,10 @@ Available video output drivers are:
|
||||
``deband-range=<1..64>``
|
||||
The debanding filter's initial radius. The radius increases linearly
|
||||
for each iteration. A higher radius will find more gradients, but
|
||||
a lower radius will smooth more aggressively. (Default 8)
|
||||
a lower radius will smooth more aggressively. (Default 16)
|
||||
|
||||
If you increase the ``deband-iterations``, you should probably
|
||||
decrease this to compensate.
|
||||
|
||||
``deband-grain=<0..4096>``
|
||||
Add some extra noise to the image. This significantly helps cover up
|
||||
@@ -645,9 +731,19 @@ Available video output drivers are:
|
||||
The slope of the sigmoid curve used for ``sigmoid-upscaling``, must
|
||||
be a float between 1.0 and 20.0. Defaults to 6.5 if not specified.
|
||||
|
||||
``sharpen=<value>``
|
||||
If set to a value other than 0, enable an unsharp masking filter.
|
||||
Positive values will sharpen the image (but add more ringing and
|
||||
aliasing). Negative values will blur the image. If your GPU is powerful
|
||||
enough, consider alternatives like the ``ewa_lanczossharp`` scale
|
||||
filter, or the ``scale-blur`` sub-option.
|
||||
|
||||
(This feature is the replacement for the old ``sharpen3`` and
|
||||
``sharpen5`` scalers.)
|
||||
|
||||
``glfinish``
|
||||
Call ``glFinish()`` before and after swapping buffers (default: disabled).
|
||||
Slower, but might help getting better results when doing framedropping.
|
||||
Slower, but might improve results when doing framedropping.
|
||||
Can completely ruin performance. The details depend entirely on the
|
||||
OpenGL driver.
|
||||
|
||||
@@ -658,14 +754,27 @@ Available video output drivers are:
|
||||
|
||||
X11/GLX only.
|
||||
|
||||
``dwmflush=<no|windowed|yes>``
|
||||
Calls ``DwmFlush`` after swapping buffers on Windows (default: no).
|
||||
``vsync-fences=<N>``
|
||||
Synchronize the CPU to the Nth past frame using the ``GL_ARB_sync``
|
||||
extension. A value of 0 disables this behavior (default). A value of
|
||||
1 means it will synchronize to the current frame after rendering it.
|
||||
Like ``glfinish`` and ``waitvsync``, this can lower or ruin performance.
|
||||
Its advantage is that it can span multiple frames, and effectively limit
|
||||
the number of frames the GPU queues ahead (which also has an influence
|
||||
on vsync).
|
||||
|
||||
``dwmflush=<no|windowed|yes|auto>``
|
||||
Calls ``DwmFlush`` after swapping buffers on Windows (default: auto).
|
||||
It also sets ``SwapInterval(0)`` to ignore the OpenGL timing. Values
|
||||
are: no (disabled), windowed (only in windowed mode), yes (also in
|
||||
full screen).
|
||||
This may help getting more consistent frame intervals, especially with
|
||||
high-fps clips - which might also reduce dropped frames. Typically a
|
||||
value of ``windowed`` should be enough since full screen may bypass the
|
||||
|
||||
The value ``auto`` will try to determine whether the compositor is
|
||||
active, and calls ``DwmFlush`` only if it seems to be.
|
||||
|
||||
This may help to get more consistent frame intervals, especially with
|
||||
high-fps clips - which might also reduce dropped frames. Typically, a
|
||||
value of ``windowed`` should be enough, since full screen may bypass the
|
||||
DWM.
|
||||
|
||||
Windows only.
|
||||
@@ -684,22 +793,39 @@ Available video output drivers are:
|
||||
Cocoa/OS X
|
||||
win
|
||||
Win32/WGL
|
||||
angle
|
||||
Direct3D11 through the OpenGL ES translation layer ANGLE. This
|
||||
supports almost everything the ``win`` backend does, except ICC
|
||||
profiles, high bit depth video input, and the ``nnedi3`` prescaler.
|
||||
dxinterop (experimental)
|
||||
Win32, using WGL for rendering and Direct3D 9Ex for presentation.
|
||||
Works on Nvidia and AMD only.
|
||||
x11
|
||||
X11/GLX
|
||||
wayland
|
||||
Wayland/EGL
|
||||
drm-egl
|
||||
DRM/EGL
|
||||
x11egl
|
||||
X11/EGL
|
||||
|
||||
``es``
|
||||
Force or prefer GLES2/3 over desktop OpenGL, if supported.
|
||||
``es=<mode>``
|
||||
Select whether to use GLES:
|
||||
|
||||
yes
|
||||
Try to prefer ES over Desktop GL
|
||||
no
|
||||
Try to prefer desktop GL over ES
|
||||
auto
|
||||
Use the default for each backend (default)
|
||||
|
||||
``fbo-format=<fmt>``
|
||||
Selects the internal format of textures used for FBOs. The format can
|
||||
influence performance and quality of the video output.
|
||||
``fmt`` can be one of: rgb, rgba, rgb8, rgb10, rgb10_a2, rgb16, rgb16f,
|
||||
rgb32f, rgba12, rgba16, rgba16f, rgba32f.
|
||||
Default: rgba16.
|
||||
Default: ``auto``, which maps to rgba16 on desktop GL, and rgb10_a2 on
|
||||
GLES (e.g. ANGLE).
|
||||
|
||||
``gamma=<0.1..2.0>``
|
||||
Set a gamma value (default: 1.0). If gamma is adjusted in other ways
|
||||
@@ -779,7 +905,8 @@ Available video output drivers are:
|
||||
Automatically select the ICC display profile currently specified by
|
||||
the display settings of the operating system.
|
||||
|
||||
NOTE: Only implemented on OS X and X11
|
||||
NOTE: On Windows, the default profile must be an ICC profile. WCS
|
||||
profiles are not supported.
|
||||
|
||||
``icc-cache-dir=<dirname>``
|
||||
Store and load the 3D LUTs created from the ICC profile in this directory.
|
||||
@@ -830,9 +957,11 @@ Available video output drivers are:
|
||||
things like softsubbed ASS signs to match the video colors,
|
||||
but may cause SRT subtitles or similar to look slightly off.
|
||||
|
||||
``alpha=<blend|yes|no>``
|
||||
Decides what to do if the input has an alpha component (default: blend).
|
||||
``alpha=<blend-tiles|blend|yes|no>``
|
||||
Decides what to do if the input has an alpha component.
|
||||
|
||||
blend-tiles
|
||||
Blend the frame against a 16x16 gray/white tiles background (default).
|
||||
blend
|
||||
Blend the frame against a black background.
|
||||
yes
|
||||
@@ -859,7 +988,7 @@ Available video output drivers are:
|
||||
|
||||
This is equivalent to::
|
||||
|
||||
--vo=opengl:scale=spline36:cscale=spline36:dscale=mitchell:dither-depth=auto:fancy-downscaling:sigmoid-upscaling:pbo:deband
|
||||
--vo=opengl:scale=spline36:cscale=spline36:dscale=mitchell:dither-depth=auto:correct-downscaling:sigmoid-upscaling:deband:es=no
|
||||
|
||||
Note that some cheaper LCDs do dithering that gravely interferes with
|
||||
``opengl``'s dithering. Disabling dithering with ``dither-depth=no`` helps.
|
||||
@@ -899,7 +1028,7 @@ Available video output drivers are:
|
||||
|
||||
``deint-mode=<mode>``
|
||||
Select deinterlacing algorithm. Note that by default deinterlacing is
|
||||
initially always off, and needs to be enabled with the ``D`` key
|
||||
initially always off, and needs to be enabled with the ``d`` key
|
||||
(default key binding for ``cycle deinterlace``).
|
||||
|
||||
This option doesn't apply if libva supports video post processing (vpp).
|
||||
@@ -997,27 +1126,6 @@ Available video output drivers are:
|
||||
``opengl-cb``
|
||||
For use with libmpv direct OpenGL embedding; useless in any other contexts.
|
||||
(See ``<mpv/opengl_cb.h>``.)
|
||||
Usually, ``opengl-cb`` renders frames asynchronously by client and this
|
||||
can cause some frame drops. In order to provide a way to handle this
|
||||
situation, ``opengl-cb`` has its own frame queue and calls update callback
|
||||
more frequently if the queue is not empty regardless of existence of new frame.
|
||||
Once the queue is filled, ``opengl-cb`` drops frames automatically.
|
||||
|
||||
With default options, ``opengl-cb`` renders only the latest frame and drops
|
||||
all frames handed over while waiting render function after update callback.
|
||||
|
||||
``frame-queue-size=<1..100>``
|
||||
The maximum count of frames which the frame queue can hold (default: 1)
|
||||
|
||||
``frame-drop-mode=<pop|clear|block>``
|
||||
Select the behavior when the frame queue is full.
|
||||
|
||||
pop
|
||||
Drop the oldest frame in the frame queue.
|
||||
clear
|
||||
Drop all frames in the frame queue.
|
||||
block
|
||||
Wait for a short time, behave like ``clear`` on timeout. (default)
|
||||
|
||||
This also supports many of the suboptions the ``opengl`` VO has. Run
|
||||
``mpv --vo=opengl-cb:help`` for a list.
|
||||
@@ -1042,10 +1150,15 @@ Available video output drivers are:
|
||||
Normally it's better to kill the console framebuffer instead, which
|
||||
gives better performance.
|
||||
|
||||
``osd=<yes|no>``
|
||||
Enabled by default. If disabled with ``no``, no OSD layer is created.
|
||||
This also means there will be no subtitles rendered.
|
||||
|
||||
``drm`` (Direct Rendering Manager)
|
||||
Video output driver using Kernel Mode Setting / Direct Rendering Manager.
|
||||
Does not support hardware acceleration. Should be used when one doesn't
|
||||
want to install full-blown graphical environment (e.g. no X).
|
||||
Should be used when one doesn't want to install full-blown graphical
|
||||
environment (e.g. no X). Does not support hardware acceleration (if you
|
||||
need this, check the ``drm-egl`` backend for ``opengl`` VO).
|
||||
|
||||
``connector=<number>``
|
||||
Select the connector to use (usually this is a monitor.) If set to -1,
|
||||
|
||||
@@ -26,6 +26,21 @@ variety of video file formats, audio and video codecs, and subtitle types.
|
||||
|
||||
Releases can be found on the [release list][releases].
|
||||
|
||||
## System requirements
|
||||
|
||||
- A not too ancient Linux, or Windows Vista or later, or OSX 10.8 or later.
|
||||
- A somewhat capable CPU. Hardware decoding might sometimes help if the CPU
|
||||
is too slow to decode video realtime, but must be explicitly enabled with
|
||||
the `--hwdec` option. On Windows, a CPU with SSE4 instruction set is required
|
||||
to get decent hardware decoding performance.
|
||||
- A not too crappy GPU. mpv is not intended to be used with bad GPUs. There are
|
||||
many caveats with drivers or system compositors causing tearing, stutter,
|
||||
etc. On Windows, you might want to make sure the graphics drivers are
|
||||
current, especially OpenGL. In some cases, ancient fallback video output
|
||||
methods can help (such as `--vo=xv` on Linux), but this use is not
|
||||
recommended or supported.
|
||||
|
||||
|
||||
## Downloads
|
||||
|
||||
|
||||
@@ -70,7 +85,7 @@ Essential dependencies (incomplete list):
|
||||
- libass (OSD, OSC, text subtitles)
|
||||
- Lua (optional, required for the OSC pseudo-GUI and youtube-dl integration)
|
||||
- libjpeg (optional, used for screenshots only)
|
||||
- Enca (optional, for subtitle charset detection)
|
||||
- uchardet (optional, for subtitle charset detection)
|
||||
- vdpau and vaapi libraries for hardware decoding on Linux (optional)
|
||||
|
||||
Libass dependencies:
|
||||
@@ -96,13 +111,10 @@ the separately available build wrapper ([mpv-build][mpv-build]) that first compi
|
||||
libraries and libass, and then compiles the player statically linked against
|
||||
those.
|
||||
|
||||
If you are running Mac OSX and using homebrew we provide [homebrew-mpv][homebrew-mpv], an up
|
||||
to date formula that compiles mpv with sensible dependencies and defaults for
|
||||
OSX.
|
||||
|
||||
If you want to build a Windows binary, you either have to use MSYS2 and MinGW,
|
||||
or cross-compile from Linux with MinGW. See [Windows compilation][windows_compilation].
|
||||
|
||||
|
||||
## FFmpeg vs. Libav
|
||||
|
||||
|
||||
@@ -187,7 +199,7 @@ only if discretion is required.
|
||||
[windows_compilation]: https://github.com/mpv-player/mpv/blob/master/DOCS/compile-windows.md
|
||||
[mplayer-changes]: https://github.com/mpv-player/mpv/blob/master/DOCS/mplayer-changes.rst
|
||||
|
||||
## License
|
||||
## License
|
||||
|
||||
|
||||
[GPLv2](https://github.com/mpv-player/mpv/blob/master/LICENSE)
|
||||
Mostly GPLv2 or later. See [details.](https://github.com/mpv-player/mpv/blob/master/Copyright)
|
||||
+337
@@ -1,3 +1,340 @@
|
||||
Release 0.15.0
|
||||
==============
|
||||
|
||||
Build System Changes
|
||||
--------------------
|
||||
|
||||
- OS X bundle: remove git sha from the Info.plist version (issue #2677)
|
||||
- add "lua51" ("51obsd") to list of possible lua names
|
||||
- add option to customize config files system path (issue #2704)
|
||||
|
||||
|
||||
Features
|
||||
--------
|
||||
|
||||
New
|
||||
~~~
|
||||
|
||||
- vo_opengl: implement support for transparent video display on OS X (alpha=yes suboption)
|
||||
- vo_opengl: use a checkerboard pattern as background for transparent video by default
|
||||
|
||||
|
||||
Options and Commands
|
||||
--------------------
|
||||
|
||||
Added
|
||||
~~~~~
|
||||
|
||||
- add --audio-file-paths (issue #2632)
|
||||
- player, stream_dvb: implement dvb-channel-name property, add switch binding
|
||||
|
||||
|
||||
Changed
|
||||
~~~~~~~
|
||||
|
||||
- vf_stereo3d: add alternating modes
|
||||
- vo_opengl: disable pbo by default for opengl-hq due to driver problems
|
||||
- vf_yadif: change defaults (issue #2539)
|
||||
- command: change heuristic for files with 1 chapter (issue #2550)
|
||||
- demux_mkv: adjust subtitle preroll defaults
|
||||
- exclude 360 from --video-rotate range (issue #2647)
|
||||
- osd: make osd-width/height properties watchable
|
||||
|
||||
|
||||
Fixes and Minor Enhancements
|
||||
----------------------------
|
||||
|
||||
- ao_pulse: check for sample rate bounds, attempt fallback (issue #2654)
|
||||
- ao_wasapi: remove volume "restore" on exit
|
||||
- demux_cue: better error resilience
|
||||
- mixer: fix volume initialization with --af=volume
|
||||
- mpv.desktop: add audio/mp4 mime type
|
||||
- player: detect audio PTS jumps, make video PTS heuristic less aggressive
|
||||
- player: make watch later/resume work when "playing" directories
|
||||
- player: reset playback abort when reloading a file (issue #2568)
|
||||
- recognize frame sequenced 3D Matroska video
|
||||
- stream_dvb: fix channel switching
|
||||
- vaapi: add VP9 profile (requires VA-API 0.38.1 or newer)
|
||||
- vo_opengl: dxinterop: prevent crash after lost device
|
||||
- vo_opengl: enable brightness/contrast controls for RGB
|
||||
- vo_opengl: fix operation on GLES 2.0
|
||||
- vo_opengl: fix operation on GLSL versions earlier than 1.30
|
||||
- vo_opengl: flip screenshot image if backend uses flipped rendering (issue #2635)
|
||||
- vo_opengl: reset nnedi3 weights properly (issue #2661)
|
||||
- vo_rpi: handle rotation
|
||||
- vo_rpi: work around firmware oddness leading to incorrect video rect
|
||||
- windows: fix fd://
|
||||
- ytdl: Include Referer header as well
|
||||
- TOOLS/zsh.pl: add .opus extension in zsh completions
|
||||
|
||||
|
||||
This listing is not complete. Check DOCS/client-api-changes.rst for a history
|
||||
of changes to the client API. A complete changelog can be seen by running
|
||||
`git log v0.14.0..v0.15.0` in the git repository or by visiting either
|
||||
https://github.com/mpv-player/mpv/compare/v0.14.0...v0.15.0 or
|
||||
http://git.srsfckn.biz/mpv/log/?qt=range&q=v0.14.0..v0.15.0
|
||||
|
||||
|
||||
|
||||
Release 0.14.0
|
||||
==============
|
||||
|
||||
Build System Changes
|
||||
--------------------
|
||||
|
||||
- build: install scalable svg icon as well
|
||||
- vo_opengl: require --enable-gpl3 for nnedi
|
||||
- win32: enable internal pthreads wrapper by default
|
||||
|
||||
|
||||
Features
|
||||
--------
|
||||
|
||||
New
|
||||
~~~
|
||||
|
||||
- vo_opengl: add experimental dxinterop backend (renders with OpenGL, displays through Direct3D; broken with Intel drivers)
|
||||
- vo_opengl: add initial ANGLE support
|
||||
- windows: implement icc-profile-auto
|
||||
- windows: support taskbar button progress indicator (issue #2399)
|
||||
|
||||
Removed
|
||||
~~~~~~~
|
||||
|
||||
- Windows XP support
|
||||
- demux: remove old subtitle parser (FFmpeg users are unaffected; Libav loses support for some minor formats)
|
||||
- demux_libass: remove this demuxer (libavformat takes its place)
|
||||
- stream: drop old Linux PVR support
|
||||
|
||||
|
||||
Options and Commands
|
||||
--------------------
|
||||
|
||||
Added
|
||||
~~~~~
|
||||
|
||||
- command, vo: add estimated-display-fps property
|
||||
- command: add vsync-ratio property
|
||||
- command: export some per-video-frame information (issue #2444)
|
||||
- vo_opengl: make LOOKUP_TEXTURE_SIZE configurable
|
||||
- windows: add option to set VO MMCSS profile
|
||||
|
||||
|
||||
Changed
|
||||
~~~~~~~
|
||||
|
||||
- --sub-fix-timing now applies to ASS subtitles as well
|
||||
- command: rename vo-missed-frame-count property to vo-delayed-frame-count
|
||||
- input.conf: add default bindings for changing window scale (issue #2500)
|
||||
- videotoolbox: make decoder format customizable
|
||||
- vo_opengl: disable interpolation without display-sync
|
||||
- vo_opengl: make tscale=mitchell:tscale-clamp the default
|
||||
- vo_rpi: add an option to disable OSD
|
||||
|
||||
|
||||
Fixes and Minor Enhancements
|
||||
----------------------------
|
||||
|
||||
- af_lavrresample: clamp float output to range
|
||||
- ao: disambiguate default device list entries
|
||||
- ao_alsa: filter audio device list
|
||||
- ao_alsa: list bidirectional devices too
|
||||
- ao_openal: accommodate more sample formats (issue #2494)
|
||||
- ao_openal: fix virtual speaker positioning
|
||||
- ao_wasapi: only report per-app volume in shared mode
|
||||
- ao_wasapi: work around DTS passthrough failure
|
||||
- build: make vaapi-wayland depend on gl-wayland (issue #2476)
|
||||
- demux: fix seeking in .ts
|
||||
- demux_lavf: mark ASS tracks as always UTF-8
|
||||
- demux_mkv: fix incremental indexing with single-keyframe files (issue #2498)
|
||||
- drm: fix setting up connectors
|
||||
- dxva2: reject 10 bit HEVC (issue #2516)
|
||||
- player: replace mistimed-frame-count with vsync-ratio on status line
|
||||
- sd_ass: fix secondary subtitle mode
|
||||
- various display-sync improvements
|
||||
- vo_opengl: enable NNEDI3 prescaler on OpenGL ES 3.0
|
||||
- vo_opengl: enable colormatrix even for RGB input
|
||||
- vo_opengl: fix backend autoprobing, attempt to improve GLX vs. EGL backend detection
|
||||
- vo_opengl: fix backend=x11 on Intel
|
||||
- vo_opengl: fix issues with some obscure pixel formats (e.g. rgb555)
|
||||
- vo_opengl: fix precision loss of fruit dithering matrix
|
||||
- vo_opengl: force dumb mode if RG textures are not available
|
||||
- vo_opengl: improve boundary check for polar filters
|
||||
- vo_opengl: various GLES compatibility improvements
|
||||
- vo_opengl: win32: test for exclusive mode
|
||||
- vo_opengl_cb: do not block on flipping when redrawing
|
||||
- vo_rpi: set aspect ratio
|
||||
- win32: fix console output with raw stdio functions
|
||||
- windows: try to avoid detection as exclusive fullscreen window (issue #2177)
|
||||
- x11: request bypassing compositor (issue #2502)
|
||||
|
||||
|
||||
This listing is not complete. Check DOCS/client-api-changes.rst for a history
|
||||
of changes to the client API. A complete changelog can be seen by running
|
||||
`git log v0.13.0..v0.14.0` in the git repository or by visiting either
|
||||
https://github.com/mpv-player/mpv/compare/v0.13.0...v0.14.0 or
|
||||
http://git.srsfckn.biz/mpv/log/?qt=range&q=v0.13.0..v0.14.0
|
||||
|
||||
|
||||
Release 0.13.0
|
||||
==============
|
||||
|
||||
NOTE: The previous release changed the default format for youtube-dl and
|
||||
removed some workarounds related to MPEG DASH support. However, the required
|
||||
changes to FFmpeg code (FFmpeg commit 4ab56667594842283dc5ae07f0daba2a2cb4d3af)
|
||||
are not in any FFmpeg release yet (as of 2015-11-10), so for now, playing DASH
|
||||
streams requires using FFmpeg git master. You can work around this by using the
|
||||
--ytdl-format=best option.
|
||||
|
||||
|
||||
Features
|
||||
--------
|
||||
|
||||
New
|
||||
~~~
|
||||
|
||||
- SVG version of the icon (with symbolic counterpart)
|
||||
- stream_libarchive: add multivolume support
|
||||
- vo_opengl: add prescaling framework along with Super-xBR and NNEDI3 (currently very slow) prescalers (issue #2230)
|
||||
|
||||
|
||||
Options and Commands
|
||||
--------------------
|
||||
|
||||
Added
|
||||
~~~~~
|
||||
|
||||
- command: add mistimed-frame-count property
|
||||
- vo_opengl: add vsync-fences option
|
||||
|
||||
|
||||
Changed
|
||||
~~~~~~~
|
||||
|
||||
- command: make display-fps property writable
|
||||
- options: enable mpeg2 hw decoding by default if hw decoding is requested
|
||||
- vo_opengl: rename fancy-downscaling to correct-downscaling
|
||||
- vo_opengl: correct-downscaling: enable also for anamorphic clips
|
||||
- vo_opengl: rename "drm_egl" to "drm-egl"
|
||||
- vo_opengl: disable drm-egl autopickup
|
||||
- vo_opengl: never load vaapi GLX interop by default
|
||||
|
||||
|
||||
Fixes and Minor Enhancements
|
||||
----------------------------
|
||||
|
||||
- ao_alsa: fix 7.1 over HDMI
|
||||
- audio: do not require full audio chain reinit for speed changes
|
||||
- rpi: add support for codecs other than h264 (mpeg2 for now)
|
||||
- vd_lavc: make hwdec fallback more tolerant
|
||||
- video: fix playback of pal8
|
||||
- video: multiple display-sync fixes
|
||||
- vo: fix no-audio mode with interpolation enabled/display-sync disabled
|
||||
- vo_direct3d: fix operation (issue #2434)
|
||||
- vo_drm: handle possible errors from sigaction
|
||||
- vo_drm: show osd in audio only mode
|
||||
- vo_opengl: do not attempt to cache frames in FBO in dumb-mode (issue #2432)
|
||||
- vo_opengl: win32: always request MMCSS for DWM
|
||||
- vo_opengl: win32: try to enable DwmFlush by default
|
||||
- vo_vdpau: check VDP_RGBA_FORMAT_A8 support
|
||||
- win32: request MMCSS "Playback" profile
|
||||
|
||||
|
||||
This listing is not complete. Check DOCS/client-api-changes.rst for a history
|
||||
of changes to the client API. A complete changelog can be seen by running
|
||||
`git log v0.12.0..v0.13.0` in the git repository or by visiting either
|
||||
https://github.com/mpv-player/mpv/compare/v0.12.0...v0.13.0 or
|
||||
http://git.srsfckn.biz/mpv/log/?qt=range&q=v0.12.0..v0.13.0
|
||||
|
||||
|
||||
Release 0.12.0
|
||||
==============
|
||||
|
||||
NOTE: This release changes the default format for youtube-dl and removes some
|
||||
workarounds related to MPEG DASH support. However, the required changes to
|
||||
FFmpeg code are not in any FFmpeg release yet (as of 2015-10-29), so for now,
|
||||
playing DASH streams requires using FFmpeg git master. You can work around
|
||||
this by using the --ytdl-format=best option.
|
||||
|
||||
|
||||
Features
|
||||
--------
|
||||
|
||||
New
|
||||
~~~
|
||||
|
||||
- vo_opengl: support new VAAPI EGL interop (requires Mesa 11)
|
||||
- vo_opengl: vaapi: add Wayland support
|
||||
- bring back the x11 video output
|
||||
- vo_opengl: support all kinds of GBRP formats
|
||||
|
||||
Removed
|
||||
~~~~~~~
|
||||
|
||||
- video: remove VDA support (VideoToolbox is preferred)
|
||||
|
||||
Behavior
|
||||
--------
|
||||
|
||||
- vo_opengl: enable X11 EGL backend by default (disabled for NVIDIA due to driver bugs)
|
||||
- ytdl: don't override user-set format in no-video mode
|
||||
- sub: adjust behavior on mismatching video/subtitle aspect ratio
|
||||
|
||||
|
||||
Options and Commands
|
||||
--------------------
|
||||
|
||||
Added
|
||||
~~~~~
|
||||
|
||||
- audio: add option for falling back to ao_null
|
||||
- options: add support for client certificate authentication
|
||||
- input: add key name for U+3000 IDEOGRAPHIC SPACE
|
||||
- player: add audio drop/duplicate mode to video-sync
|
||||
|
||||
Changed
|
||||
~~~~~~~
|
||||
|
||||
- vo_opengl: remove sharpen scalers, add sharpen sub-option
|
||||
- vo_opengl: make sw suboption work without explicit backend selection
|
||||
- command: make time properties unavailable if timestamp is unknown
|
||||
- command: do not return 0 for bitrate if unknown (make property unavailable instead)
|
||||
- vo_opengl: make the default debanding settings less excessive
|
||||
- ytdl: disable --all-subs if "sub-lang" is in raw-options
|
||||
|
||||
Removed
|
||||
~~~~~~~
|
||||
|
||||
- video: remove user-controllable PTS sorting (--pts-association-mode)
|
||||
|
||||
|
||||
Fixes and Minor Enhancements
|
||||
----------------------------
|
||||
|
||||
- player: fix another --force-window bug
|
||||
- player: add wav to list of external audio file extensions
|
||||
- ao_alsa: fix failure to find any sample format
|
||||
- player: make stop command actually stop in all cases
|
||||
- audio: various fixes related to audio device hotplugging
|
||||
- vo_xv: fix crash with --wid
|
||||
- ytdl: Remove DASH hacks, use DASH by default
|
||||
- player: be slightly less prone to framedrop in display sync mode
|
||||
- sd_lavc: extend subtitle resolution if images go outside video frame
|
||||
- player: offset chapter display by start time
|
||||
- command: make bitrate properties work correctly for external tracks
|
||||
- w32_common: disable IME
|
||||
- player: fix display-sync A/V calculation on high playback speeds
|
||||
- player: fix display sync A/V difference estimation on drops
|
||||
- player: raise display sync desync tolerance
|
||||
|
||||
|
||||
This listing is not complete. Check DOCS/client-api-changes.rst for a history
|
||||
of changes to the client API. A complete changelog can be seen by running
|
||||
`git log v0.11.0..v0.12.0` in the git repository or by visiting either
|
||||
https://github.com/mpv-player/mpv/compare/v0.11.0...v0.12.0 or
|
||||
http://git.srsfckn.biz/mpv/log/?qt=range&q=v0.11.0..v0.12.0
|
||||
|
||||
|
||||
Release 0.11.0
|
||||
==============
|
||||
|
||||
|
||||
@@ -9,8 +9,8 @@ use warnings;
|
||||
# the exact contents of the original file.
|
||||
# FIXME: why not a char array?
|
||||
|
||||
# treat only alphanumeric and not-" punctuation as safe
|
||||
my $unsafe_chars = qr{[^][A-Za-z0-9!#%&'()*+,./:;<=>?^_{|}~ -]};
|
||||
# treat only alphanumeric and punctuations (excluding " and ?) as safe
|
||||
my $unsafe_chars = qr{[^][A-Za-z0-9!#%&'()*+,./:;<=>^_{|}~ -]};
|
||||
|
||||
for my $file (@ARGV) {
|
||||
open my $fh, '<:raw', $file or next;
|
||||
|
||||
Regular → Executable
+1
-1
@@ -5,7 +5,7 @@
|
||||
|
||||
conv() {
|
||||
echo
|
||||
identify -format "icon: %w %h" "$1"
|
||||
echo `identify -format "icon: %w %h" "$1"`
|
||||
convert "$1" -depth 8 rgba:-
|
||||
}
|
||||
|
||||
|
||||
@@ -30,7 +30,12 @@ function add_files_at(index, files)
|
||||
end
|
||||
|
||||
function get_extension(path)
|
||||
return string.match(path, "%.([^%.]+)$" )
|
||||
match = string.match(path, "%.([^%.]+)$" )
|
||||
if match == nil then
|
||||
return "nomatch"
|
||||
else
|
||||
return match
|
||||
end
|
||||
end
|
||||
|
||||
table.filter = function(t, iter)
|
||||
|
||||
@@ -1,998 +0,0 @@
|
||||
#! /bin/sh
|
||||
#
|
||||
# Original version (C) 2000 Pontscho/fresh!mindworkz pontscho@makacs.poliod.hu
|
||||
# Cleanups all over the place (c) 2001 pl
|
||||
# Rewritten for mpv in 2014.
|
||||
#
|
||||
#
|
||||
# Warning: this is not officially supported. Use on your own risk. Might require
|
||||
# modifications when used on systems other than Linux. Contributors
|
||||
# are not expected to update these files when making changes to the
|
||||
# normal/preferred waf build system.
|
||||
#
|
||||
#
|
||||
# This configure script is *not* autoconf-based and has different semantics.
|
||||
# It attempts to autodetect all settings and options where possible. It is
|
||||
# possible to override autodetection with the --enable-option/--disable-option
|
||||
# command line parameters. --enable-option forces the option on skipping
|
||||
# autodetection. Yes, this means that compilation may fail and yes, this is not
|
||||
# how autoconf-based configure scripts behave.
|
||||
#
|
||||
# configure generates a series of configuration files:
|
||||
# - config.h contains #defines that are used in the C code.
|
||||
# - config.mak is included from the Makefiles.
|
||||
#
|
||||
# If you want to add a new check for $feature, look at the existing checks
|
||||
# and try to use helper functions where you can.
|
||||
#############################################################################
|
||||
|
||||
# Prevent locale nonsense from breaking basic text processing utils
|
||||
export LC_ALL=C
|
||||
|
||||
# Store the configure line that was used
|
||||
configuration="$*"
|
||||
|
||||
# Prefer these macros to full length text !
|
||||
# These macros only return an error code - NO display is done
|
||||
command_check() {
|
||||
echo >> "$TMPLOG"
|
||||
echo "$@" >> "$TMPLOG"
|
||||
"$@" >> "$TMPLOG" 2>&1
|
||||
TMPRES="$?"
|
||||
echo >> "$TMPLOG"
|
||||
return "$TMPRES"
|
||||
}
|
||||
|
||||
compile_check() {
|
||||
source="$1"
|
||||
shift
|
||||
echo >> "$TMPLOG"
|
||||
cat "$source" >> "$TMPLOG"
|
||||
echo >> "$TMPLOG"
|
||||
echo "$_cc $OURCFLAGS $CFLAGS $source $extra_cflags $_ld_static $extra_ldflags $libs_mplayer -o $TMPEXE $@" >> "$TMPLOG"
|
||||
rm -f "$TMPEXE"
|
||||
$_cc $OURCFLAGS $CFLAGS "$source" $extra_cflags $_ld_static $extra_ldflags $libs_mplayer -o "$TMPEXE" $@ >> "$TMPLOG" 2>&1
|
||||
TMPRES="$?"
|
||||
echo >> "$TMPLOG"
|
||||
echo >> "$TMPLOG"
|
||||
return "$TMPRES"
|
||||
}
|
||||
|
||||
cflag_check() {
|
||||
echo "int main(void) { return 0; }" > $TMPC
|
||||
compile_check $TMPC $@
|
||||
}
|
||||
|
||||
statement_check() {
|
||||
echo "" > $TMPC
|
||||
for _header in $1 ; do echo "#include <$_header>" >> $TMPC ; done
|
||||
echo "int main(void) { $2; return 0; }" >> $TMPC
|
||||
shift 2
|
||||
compile_check $TMPC $@
|
||||
}
|
||||
|
||||
pkg_config_add() {
|
||||
echo >> "$TMPLOG"
|
||||
echo "$_pkg_config --cflags $@" >> "$TMPLOG"
|
||||
ctmp=$($_pkg_config --cflags "$@" 2>> "$TMPLOG") || return $?
|
||||
echo >> "$TMPLOG"
|
||||
echo "$_pkg_config --libs $@" >> "$TMPLOG"
|
||||
ltmp=$($_pkg_config --libs "$@" 2>> "$TMPLOG") || return $?
|
||||
echo >> "$TMPLOG"
|
||||
echo "cflags: $ctmp" >> "$TMPLOG"
|
||||
echo "libs: $ltmp" >> "$TMPLOG"
|
||||
echo >> "$TMPLOG"
|
||||
extra_cflags="$extra_cflags $ctmp"
|
||||
libs_mplayer="$libs_mplayer $ltmp"
|
||||
}
|
||||
|
||||
# Display error message, flushes tempfile, exit
|
||||
die () {
|
||||
echo
|
||||
echo "Error: $@" >&2
|
||||
echo >&2
|
||||
rm -f "$TMPEXE" "$TMPC"
|
||||
echo "Check \"$TMPLOG\" if you do not understand why it failed."
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Use this before starting a check
|
||||
echocheck() {
|
||||
echo "============ Checking for $@ ============" >> "$TMPLOG"
|
||||
echo ${_echo_n} "Checking for $@ ... ${_echo_c}"
|
||||
}
|
||||
|
||||
# Use this to echo the results of a check
|
||||
echores() {
|
||||
test "$res_comment" && res_comment="($res_comment)"
|
||||
echo "Result is: $@ $res_comment" >> "$TMPLOG"
|
||||
echo "##########################################" >> "$TMPLOG"
|
||||
echo "" >> "$TMPLOG"
|
||||
echo "$@ $res_comment"
|
||||
res_comment=""
|
||||
}
|
||||
|
||||
# Check how echo works in this /bin/sh
|
||||
case $(echo -n) in
|
||||
-n) _echo_n= _echo_c='\c' ;; # SysV echo
|
||||
*) _echo_n='-n ' _echo_c= ;; # BSD echo
|
||||
esac
|
||||
|
||||
# setind $a b sets the variable named by the value of the variable a to b
|
||||
setind() { eval "$1=\"\$2\"" ; }
|
||||
|
||||
# Generate --enable-NAME/--disable-NAME options, set $1 to the option value.
|
||||
# Since shell has no data structures, do a weird statemachine thing.
|
||||
# Arguments: "_name"($1) "description"($2) "default"($3)
|
||||
# If "default"($3) is empty, use "auto"
|
||||
# Option name: a leading "_" in name is stripped, further "_" are changed to "-"
|
||||
opt_yes_no() {
|
||||
_name=$(echo "$1" | sed 's/^_//' | tr _ -)
|
||||
_defval="$3"
|
||||
test -z "$_defval" && _defval=auto
|
||||
|
||||
case "$_opt_state_mode" in
|
||||
init)
|
||||
setind "$1" "$_defval"
|
||||
;;
|
||||
help)
|
||||
if test "$_defval" = yes || test "$_defval" = auto ; then
|
||||
_defdesc=enable
|
||||
test "$_defval" = auto && _defdesc=auto
|
||||
printf " %-21s disable $2 [$_defdesc]\n" "--disable-$_name"
|
||||
unset _defdesc
|
||||
else
|
||||
printf " %-21s enable $2 [disable]\n" "--enable-$_name"
|
||||
fi
|
||||
;;
|
||||
parse)
|
||||
if test "$_opt_state_name" = "--enable-$_name" ; then
|
||||
setind "$1" yes
|
||||
_opt_state_known=yes
|
||||
elif test "$_opt_state_name" = "--disable-$_name" ; then
|
||||
setind "$1" no
|
||||
_opt_state_known=yes
|
||||
elif test "$_opt_state_name" = "--auto-$_name" ; then
|
||||
setind "$1" auto
|
||||
_opt_state_known=yes
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
unset _name
|
||||
unset _defval
|
||||
}
|
||||
|
||||
options_state_machine() {
|
||||
_opt_state_mode=$1
|
||||
_opt_state_name=$2
|
||||
_opt_state_known=no
|
||||
|
||||
opt_yes_no _gl "OpenGL video output"
|
||||
opt_yes_no _libguess "libguess"
|
||||
opt_yes_no _termios "termios database for key codes"
|
||||
opt_yes_no _iconv "iconv for encoding conversion"
|
||||
opt_yes_no _vm "X video mode extensions"
|
||||
opt_yes_no _dvb "DVB input"
|
||||
opt_yes_no _tv "TV interface (TV/DVB grabbers)" yes
|
||||
opt_yes_no _tv_v4l2 "Video4Linux2 TV interface"
|
||||
opt_yes_no _libv4l2 "libv4l2"
|
||||
opt_yes_no _pvr "Video4Linux2 MPEG PVR"
|
||||
opt_yes_no _smb "Samba (SMB) input"
|
||||
opt_yes_no _lcms2 "LCMS2 support"
|
||||
opt_yes_no _bluray "Blu-ray support"
|
||||
opt_yes_no _dvdread "libdvdread"
|
||||
opt_yes_no _dvdnav "libdvdnav"
|
||||
opt_yes_no _enca "ENCA charset oracle library"
|
||||
opt_yes_no _uchardet "uchardet charset detection library"
|
||||
opt_yes_no _libass "subtitle rendering with libass"
|
||||
opt_yes_no _libavdevice "libavdevice demuxers"
|
||||
opt_yes_no _libavfilter "libavfilter"
|
||||
opt_yes_no _jpeg "support for writing JPEG screenshots"
|
||||
opt_yes_no _libcdio "libcdio support"
|
||||
opt_yes_no _librubberband "librubberband support"
|
||||
opt_yes_no _ffmpeg "skip FFmpeg/Libav autodetection"
|
||||
opt_yes_no _libavresample "libavresample (preferred over libswresample)"
|
||||
opt_yes_no _libswresample "libswresample"
|
||||
opt_yes_no _caca "CACA video output"
|
||||
opt_yes_no _sdl2 "SDL2 video and audio outputs" no
|
||||
opt_yes_no _xv "Xv video output"
|
||||
opt_yes_no _vdpau "VDPAU acceleration"
|
||||
opt_yes_no _vaapi "VAAPI acceleration"
|
||||
opt_yes_no _xrandr "Xrandr support (used for monitor FPS detection)"
|
||||
opt_yes_no _xinerama "Xinerama support"
|
||||
opt_yes_no _x11 "X11 video output"
|
||||
opt_yes_no _wayland "Wayland video output"
|
||||
opt_yes_no _xss "support for disabling screensaver via xss"
|
||||
opt_yes_no _alsa "ALSA audio output"
|
||||
opt_yes_no _ossaudio "OSS audio output"
|
||||
opt_yes_no _rsound "RSound audio output"
|
||||
opt_yes_no _sndio "sndio audio output"
|
||||
opt_yes_no _pulse "Pulseaudio audio output"
|
||||
opt_yes_no _jack "JACK audio output"
|
||||
opt_yes_no _openal "OpenAL audio output"
|
||||
opt_yes_no _shm "X11/Xv shared memory"
|
||||
opt_yes_no _lua "Lua scripting"
|
||||
opt_yes_no _vapoursynth "VapourSynth filter bridge (Python)"
|
||||
opt_yes_no _vapoursynth_lazy "VapourSynth filter bridge (Lua)"
|
||||
opt_yes_no _libarchive "libarchive"
|
||||
opt_yes_no _encoding "encoding functionality" yes
|
||||
opt_yes_no _build_man "building manpage"
|
||||
}
|
||||
|
||||
show_help(){
|
||||
cat << EOF
|
||||
Usage: $0 [OPTIONS]...
|
||||
|
||||
Configuration:
|
||||
-h, --help display this help and exit
|
||||
|
||||
Installation directories:
|
||||
--prefix=DIR prefix directory for installation [/usr/local]
|
||||
--bindir=DIR directory for installing binaries [PREFIX/bin]
|
||||
--datadir=DIR directory for installing machine independent
|
||||
data files (skins, etc) [PREFIX/share/mpv]
|
||||
--mandir=DIR directory for installing man pages [PREFIX/share/man]
|
||||
--confdir=DIR directory for installing configuration files
|
||||
[PREFIX/etc/mpv]
|
||||
|
||||
Compilation options:
|
||||
--cc=COMPILER C compiler to build mpv [gcc]
|
||||
--pkg-config=PKGCONFIG pkg-config to find some libraries [pkg-config]
|
||||
--enable-static build a statically linked binary
|
||||
--disable-debug compile-in debugging information [enable]
|
||||
--disable-optimization compile without -O2 [enable]
|
||||
|
||||
Use these options if autodetection fails:
|
||||
--extra-cflags=FLAGS extra CFLAGS
|
||||
--extra-ldflags=FLAGS extra LDFLAGS
|
||||
--extra-libs=FLAGS extra linker flags
|
||||
|
||||
Features:
|
||||
EOF
|
||||
options_state_machine help
|
||||
cat << EOF
|
||||
|
||||
This configure script is NOT autoconf-based, even though its output is similar.
|
||||
It will try to autodetect all configuration options. If you --enable an option
|
||||
it will be forcefully turned on, skipping autodetection. This can break
|
||||
compilation, so you need to know what you are doing.
|
||||
EOF
|
||||
exit 0
|
||||
} #show_help()
|
||||
|
||||
# GOTCHA: the variables below defines the default behavior for autodetection
|
||||
# and have - unless stated otherwise - at least 2 states : yes no
|
||||
# If autodetection is available then the third state is: auto
|
||||
_pkg_config=auto
|
||||
_cc=auto
|
||||
test -n "$CC" && _cc="$CC"
|
||||
_opt=-O2
|
||||
_prefix="/usr/local"
|
||||
options_state_machine init
|
||||
for ac_option do
|
||||
case "$ac_option" in
|
||||
--help|-help|-h)
|
||||
show_help
|
||||
;;
|
||||
--prefix=*)
|
||||
_prefix=$(echo $ac_option | cut -d '=' -f 2)
|
||||
;;
|
||||
--bindir=*)
|
||||
_bindir=$(echo $ac_option | cut -d '=' -f 2)
|
||||
;;
|
||||
--mandir=*)
|
||||
_mandir=$(echo $ac_option | cut -d '=' -f 2)
|
||||
;;
|
||||
--confdir=*)
|
||||
_confdir=$(echo $ac_option | cut -d '=' -f 2)
|
||||
;;
|
||||
--extra-cflags=*)
|
||||
extra_cflags="$extra_cflags $(echo $ac_option | cut -d '=' -f 2-)"
|
||||
;;
|
||||
--extra-ldflags=*)
|
||||
extra_ldflags="$extra_ldflags $(echo $ac_option | cut -d '=' -f 2-)"
|
||||
;;
|
||||
--extra-libs=*)
|
||||
libs_mplayer=$(echo $ac_option | cut -d '=' -f 2)
|
||||
;;
|
||||
--cc=*)
|
||||
_cc=$(echo $ac_option | cut -d '=' -f 2)
|
||||
;;
|
||||
--pkg-config=*)
|
||||
_pkg_config=$(echo $ac_option | cut -d '=' -f 2)
|
||||
;;
|
||||
--enable-static)
|
||||
_ld_static='-static'
|
||||
;;
|
||||
--disable-static)
|
||||
_ld_static=''
|
||||
;;
|
||||
--enable-optimization)
|
||||
_opt='-O2'
|
||||
;;
|
||||
--enable-optimization=*)
|
||||
_opt=$(echo $_echo_n '-O'$_echo_c; echo $ac_option | cut -d '=' -f 2)
|
||||
;;
|
||||
--disable-optimization)
|
||||
_opt=
|
||||
;;
|
||||
*)
|
||||
options_state_machine parse "$ac_option"
|
||||
if test "$_opt_state_known" != yes ; then
|
||||
echo "Unknown parameter: $ac_option" >&2
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
|
||||
esac
|
||||
done
|
||||
|
||||
test -z "$_bindir" && _bindir="$_prefix/bin"
|
||||
test -z "$_mandir" && _mandir="$_prefix/share/man"
|
||||
test -z "$_confdir" && _confdir="$_prefix/etc/mpv"
|
||||
|
||||
mplayer_tmpdir=$(mktemp -d -p ${TMPDIR:=/tmp} mpv-configure-XXXXXX)
|
||||
test -n "$mplayer_tmpdir" || die "Unable to create tmpdir."
|
||||
trap 'rm -rf "$mplayer_tmpdir"' EXIT
|
||||
|
||||
mkdir old_build 2> /dev/null
|
||||
|
||||
TMPLOG="old_build/config.log"
|
||||
|
||||
rm -f "$TMPLOG"
|
||||
echo Parameters configure was run with: > "$TMPLOG"
|
||||
echo CFLAGS="'$CFLAGS'" PKG_CONFIG_PATH="'$PKG_CONFIG_PATH'" ./configure $configuration >> "$TMPLOG"
|
||||
echo >> "$TMPLOG"
|
||||
|
||||
TMPC="$mplayer_tmpdir/tmp.c"
|
||||
TMPEXE="$mplayer_tmpdir/tmp"
|
||||
CONFIG_MAK="$mplayer_tmpdir/config.mak"
|
||||
CONFIG_H="$mplayer_tmpdir/config.h"
|
||||
|
||||
echo > $CONFIG_MAK
|
||||
echo > $CONFIG_H
|
||||
|
||||
test "$_pkg_config" = auto && _pkg_config=pkg-config
|
||||
test "$_cc" = auto && _cc=cc
|
||||
|
||||
extra_cflags="-I. -D_GNU_SOURCE $extra_cflags"
|
||||
|
||||
_rst2man=rst2man
|
||||
test -f "$(which rst2man.py)" && _rst2man=rst2man.py
|
||||
|
||||
echocheck "whether to build manpages with rst2man"
|
||||
if test "$_build_man" = auto ; then
|
||||
_build_man=no
|
||||
command_check "$_rst2man" --version && _build_man=yes
|
||||
fi
|
||||
echores "$_build_man"
|
||||
|
||||
echocheck "working compiler"
|
||||
cflag_check "" || die "Compiler is not functioning correctly. Check your installation and custom CFLAGS $CFLAGS ."
|
||||
echores "yes"
|
||||
|
||||
echocheck "perl"
|
||||
command_check perl -Mv5.8 -e';' || die "Perl is not functioning correctly or is ancient. Install the latest perl available."
|
||||
echores yes
|
||||
|
||||
echocheck "compiler support of -pipe option"
|
||||
cflag_check -pipe -I. && _pipe="-pipe" && echores "yes" || echores "no"
|
||||
|
||||
addcflags() { cflag_check "$@" && OURCFLAGS="$OURCFLAGS $@" ; }
|
||||
|
||||
OURCFLAGS="-std=c99 -Wall $_opt"
|
||||
|
||||
addcflags -g -g3 -ggdb
|
||||
addcflags -Wundef -Wmissing-prototypes -Wshadow -Wno-switch -Wparentheses -Wpointer-arith -Wno-redundant-decls -Wno-pointer-sign -Werror=implicit-function-declaration -Wno-error=deprecated-declarations -Wno-error=unused-function
|
||||
# clang
|
||||
addcflags -Wno-logical-op-parentheses -fcolor-diagnostics -Wno-tautological-compare -Wno-tautological-constant-out-of-range-compare
|
||||
# extra
|
||||
addcflags -Wno-format-zero-length -Wempty-body -Wdisabled-optimization -Wstrict-prototypes
|
||||
|
||||
cflag_check -MD -MP && DEPFLAGS="-MD -MP"
|
||||
cflag_check -lm && _ld_lm="-lm"
|
||||
|
||||
extra_ldflags="$extra_ldflags $LDFLAGS"
|
||||
extra_cflags="$extra_cflags $CPPFLAGS"
|
||||
|
||||
# If $1 is "yes", define $2 as 1 in config.h, else define it as 0
|
||||
define_yes_no() {
|
||||
if test "$1" = yes ; then
|
||||
echo "#define $2 1" >> $CONFIG_H
|
||||
else
|
||||
echo "#define $2 0" >> $CONFIG_H
|
||||
fi
|
||||
}
|
||||
|
||||
# Write the results of a check to config.mak/.h.
|
||||
# Arguments: "yes/no"($1) "name"($2)
|
||||
check_yes_no() {
|
||||
define_yes_no $1 "HAVE_$2"
|
||||
echo "$2 = $1" >> $CONFIG_MAK
|
||||
}
|
||||
|
||||
check_trivial() {
|
||||
echocheck "$1"
|
||||
check_yes_no $2 $3
|
||||
echores "$2"
|
||||
}
|
||||
|
||||
# Arguments: "message"($1) "setting"($2) "name"($3) "code"($4)
|
||||
# Also, $5 - $N can be libraries needed - it'll try each separately.
|
||||
# Use " " as first entry if you want to try with no libraries too.
|
||||
check_compile() {
|
||||
_res="$2"
|
||||
_name="$3"
|
||||
_code="$4"
|
||||
echocheck "$1"
|
||||
if test $_res = auto ; then
|
||||
_res=no
|
||||
if test $# -gt 4 ; then
|
||||
shift 4
|
||||
else
|
||||
shift $#
|
||||
fi
|
||||
while true ; do
|
||||
compile_check "$_code" "$1" && libs_mplayer="$libs_mplayer $1" && _res=yes && break
|
||||
test -z "$1" && break
|
||||
shift
|
||||
done
|
||||
fi
|
||||
check_yes_no $_res $_name
|
||||
echores $_res
|
||||
test $_res = yes && return 0 || return 1
|
||||
}
|
||||
|
||||
# Arguments: "message"($1) "setting"($2) "name"($3) "include"($4) "statement"($5)
|
||||
# Also, $6 - $N can be libraries needed - it'll try each separately.
|
||||
# Use " " as first entry if you want to try with no libraries too.
|
||||
check_statement_libs() {
|
||||
_res="$2"
|
||||
_name="$3"
|
||||
_inc="$4"
|
||||
_st="$5"
|
||||
echocheck "$1"
|
||||
if test $_res = auto ; then
|
||||
_res=no
|
||||
if test $# -gt 5 ; then
|
||||
shift 5
|
||||
else
|
||||
shift $#
|
||||
fi
|
||||
while true ; do
|
||||
statement_check "$_inc" "$_st" "$1" && libs_mplayer="$libs_mplayer $1" && _res=yes && break
|
||||
test -z "$1" && break
|
||||
shift
|
||||
done
|
||||
fi
|
||||
check_yes_no $_res $_name
|
||||
echores $_res
|
||||
test $_res = yes && return 0 || return 1
|
||||
}
|
||||
|
||||
# Print "yes" if previous command succeeded, else "no"
|
||||
defretval() { # shell is retarded?
|
||||
if test $? = 0 ; then
|
||||
echo "yes"
|
||||
else
|
||||
echo "no"
|
||||
fi
|
||||
}
|
||||
|
||||
echocheck "dynamic loader"
|
||||
_dl=no
|
||||
for _ld_tmp in "" "-ldl"; do
|
||||
statement_check dlfcn.h 'dlopen("", 0)' $_ld_tmp && _ld_dl="$_ld_tmp" && _dl=yes && break
|
||||
done
|
||||
define_yes_no $_dl HAVE_LIBDL
|
||||
echores "$_dl"
|
||||
|
||||
echocheck "pthread"
|
||||
cflag_check -pthread && _ld_pthread="$_ld_pthread -pthread"
|
||||
cflag_check -lpthread && _ld_pthread="$_ld_pthread -lpthread"
|
||||
cflag_check -lrt && _ld_pthread="$_ld_pthread -lrt"
|
||||
extra_cflags="$extra_cflags -D_REENTRANT -D_THREAD_SAFE"
|
||||
compile_check waftools/fragments/pthreads.c "$_ld_pthread" || die "Unable to find pthreads support."
|
||||
echores "yes"
|
||||
|
||||
check_statement_libs "support for stdatomic.h" auto STDATOMIC \
|
||||
stdatomic.h 'atomic_int_least64_t test = ATOMIC_VAR_INIT(123); int test2 = atomic_load(&test)' \
|
||||
" " "-latomic"
|
||||
_stdatomic=$(defretval)
|
||||
|
||||
_atomic=auto
|
||||
test "$_stdatomic" = yes && _atomic=no
|
||||
check_statement_libs "compiler support for __atomic built-ins" $_atomic ATOMIC_BUILTINS \
|
||||
stdint.h 'int64_t test = 0; test = __atomic_add_fetch(&test, 1, __ATOMIC_SEQ_CST)' \
|
||||
" " "-latomic"
|
||||
_atomic=$(defretval)
|
||||
|
||||
_sync=auto
|
||||
(test "$_atomic" = yes || test "$_stdatomic" = yes ) && _sync=no
|
||||
check_statement_libs "compiler support for __sync built-ins" $_sync SYNC_BUILTINS \
|
||||
stdint.h 'int64_t test = 0; test = __sync_add_and_fetch(&test, 1)'
|
||||
_sync=$(defretval)
|
||||
|
||||
_any_atomic=yes
|
||||
if test "$_atomic" = no && test "$_sync" = no && test "$_stdatomic" = no ; then
|
||||
echo "your compiler must support either stdatomic.h, or __atomic, or __sync built-ins."
|
||||
_any_atomic=no
|
||||
fi
|
||||
define_yes_no $_any_atomic HAVE_ATOMICS
|
||||
|
||||
check_compile "iconv" $_iconv ICONV waftools/fragments/iconv.c " " "-liconv" "-liconv $_ld_dl"
|
||||
_iconv=$(defretval)
|
||||
if test "$_iconv" != yes ; then
|
||||
die "Unable to find iconv which should be part of standard compilation environment. Aborting. If you really mean to compile without iconv support use --disable-iconv."
|
||||
fi
|
||||
|
||||
_soundcard_header=sys/soundcard.h
|
||||
_check_snd=yes
|
||||
check_statement_libs "sys/soundcard.h" auto SYS_SOUNDCARD_H sys/soundcard.h
|
||||
test $(defretval) = yes && _soundcard_header=sys/soundcard.h && _check_snd=no
|
||||
check_statement_libs "soundcard.h" $_check_snd SOUNDCARD_H soundcard.h
|
||||
test $(defretval) = yes && _soundcard_header=soundcard.h
|
||||
|
||||
check_statement_libs "sys/videoio.h" auto SYS_VIDEOIO_H sys/videoio.h
|
||||
|
||||
_termios_ok=no
|
||||
check_statement_libs "termios.h" $_termios TERMIOS_H termios.h
|
||||
test $(defretval) = yes && _termios_ok=yes && _termios=no
|
||||
check_statement_libs "sys/termios.h" $_termios SYS_TERMIOS_H 'sys/termios.h'
|
||||
test $(defretval) = yes && _termios_ok=yes
|
||||
define_yes_no $_termios_ok HAVE_TERMIOS
|
||||
|
||||
check_statement_libs "shm" $_shm SHM "sys/types.h sys/ipc.h sys/shm.h" \
|
||||
"shmget(0, 0, 0); shmat(0, 0, 0); shmctl(0, 0, 0);"
|
||||
|
||||
echocheck "pkg-config"
|
||||
if $($_pkg_config --version > /dev/null 2>&1); then
|
||||
if test "$_ld_static"; then
|
||||
_pkg_config="$_pkg_config --static"
|
||||
fi
|
||||
echores "yes"
|
||||
else
|
||||
_pkg_config=false
|
||||
echores "no"
|
||||
fi
|
||||
|
||||
# Arguments: "message"($1) "setting"($2) "name"($3) "pkg-config string"($4)
|
||||
# The name will be used as "#define HAVE_$name 1/0" in config.h, and as
|
||||
# "$name = yes/no" in config.mak
|
||||
# "setting"($2) is yes/no/auto and represents the --enable/--disable option
|
||||
check_pkg_config() {
|
||||
echocheck "$1"
|
||||
_res=$2
|
||||
if test "$2" = auto ; then
|
||||
_res=no
|
||||
if pkg_config_add "$4" ; then
|
||||
_res=yes
|
||||
fi
|
||||
fi
|
||||
check_yes_no $_res $3
|
||||
echores "$_res"
|
||||
test $_res = yes && return 0 || return 1
|
||||
}
|
||||
|
||||
check_pkg_config "libguess support" $_libguess LIBGUESS 'libguess >= 1.0'
|
||||
|
||||
check_pkg_config "Samba support (libsmbclient)" $_smb LIBSMBCLIENT 'smbclient >= 0.2.0'
|
||||
|
||||
_wlver="1.6.0"
|
||||
check_pkg_config "Wayland" $_wayland WAYLAND "wayland-client >= $_wlver wayland-cursor >= $_wlver xkbcommon >= 0.3.0"
|
||||
_wayland=$(defretval)
|
||||
|
||||
check_pkg_config "X11" $_x11 X11 "x11"
|
||||
_x11=$(defretval)
|
||||
|
||||
# Disable X11 dependencies
|
||||
_xext=auto
|
||||
if test "$_x11" = no ; then
|
||||
_xss=no
|
||||
_xext=no
|
||||
_xv=no
|
||||
_vdpau=no
|
||||
_vaapi=no
|
||||
_xinerama=no
|
||||
_vm=no
|
||||
fi
|
||||
|
||||
check_pkg_config "Xss screensaver extensions" $_xss XSS "xscrnsaver"
|
||||
|
||||
check_pkg_config "X extensions" $_xext XEXT "xext"
|
||||
|
||||
check_pkg_config "Xv" $_xv XV "xv"
|
||||
|
||||
check_pkg_config "VDPAU" $_vdpau VDPAU "vdpau >= 0.2"
|
||||
_vdpau=$(defretval)
|
||||
define_yes_no $_vdpau HAVE_VDPAU_HWACCEL
|
||||
|
||||
check_pkg_config "VAAPI" $_vaapi VAAPI 'libva >= 0.32.0 libva-x11 >= 0.32.0'
|
||||
_vaapi=$(defretval)
|
||||
define_yes_no $_vaapi HAVE_VAAPI_HWACCEL
|
||||
|
||||
if test "$_vaapi" = yes ; then
|
||||
check_pkg_config "VAAPI VPP" auto VAAPI_VPP 'libva >= 0.34.0'
|
||||
else
|
||||
check_yes_no no VAAPI_VPP
|
||||
fi
|
||||
|
||||
check_pkg_config "Xinerama" $_xinerama XINERAMA 'xinerama'
|
||||
|
||||
check_pkg_config "Xrandr" $_xrandr XRANDR 'xrandr >= 1.2.0'
|
||||
|
||||
check_pkg_config "CACA" $_caca CACA 'caca >= 0.99.beta18'
|
||||
|
||||
check_compile "DVB" $_dvb DVB waftools/fragments/dvb.c
|
||||
_dvbin=$(defretval)
|
||||
check_yes_no $_dvbin DVBIN
|
||||
|
||||
check_statement_libs "JPEG support" $_jpeg JPEG "stdio.h jpeglib.h" "" "-ljpeg $_ld_lm"
|
||||
|
||||
_gl_x11_egl=no
|
||||
(test "$_x11" = no && test "$_wayland" = no) && _gl=no
|
||||
echocheck "OpenGL"
|
||||
#Note: this test is run even with --enable-gl since we autodetect linker flags
|
||||
if test "$_gl" != no ; then
|
||||
cat > $TMPC << EOF
|
||||
#if defined(GL_WAYLAND) || defined(EGL_X11)
|
||||
#include <EGL/egl.h>
|
||||
#else
|
||||
#include <X11/Xlib.h>
|
||||
#include <GL/glx.h>
|
||||
#endif
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glext.h>
|
||||
int main(int argc, char *argv[]) {
|
||||
#if defined(GL_WAYLAND)
|
||||
eglCreateContext(NULL, NULL, EGL_NO_CONTEXT, NULL);
|
||||
#else
|
||||
glXCreateContext(NULL, NULL, NULL, True);
|
||||
#endif
|
||||
glFinish();
|
||||
return !GL_INVALID_FRAMEBUFFER_OPERATION; // check correct glext.h
|
||||
}
|
||||
EOF
|
||||
_gl=no
|
||||
if test "$_x11" = yes ; then
|
||||
for _ld_tmp in "" -lGL "-lGL -lXdamage" "-lGL $_ld_pthread" ; do
|
||||
if compile_check $TMPC $_ld_tmp $_ld_lm ; then
|
||||
_gl=yes
|
||||
_gl_x11=yes
|
||||
libs_mplayer="$libs_mplayer $_ld_tmp $_ld_dl"
|
||||
test "$_gl_x11" = yes && res_comment="$res_comment x11"
|
||||
break
|
||||
fi
|
||||
done
|
||||
fi
|
||||
if test "$_wayland" = yes && compile_check $TMPC -DGL_WAYLAND -lGL -lEGL &&
|
||||
pkg_config_add "wayland-egl >= 9.0.0"; then
|
||||
_gl=yes
|
||||
_gl_wayland=yes
|
||||
libs_mplayer="$libs_mplayer -lGL -lEGL"
|
||||
test "$_gl_wayland" = yes && res_comment="$res_comment wayland"
|
||||
else
|
||||
_gl_wayland=no
|
||||
fi
|
||||
if test "$_x11" = yes && test "$_gl" = yes && pkg_config_add "egl"; then
|
||||
_gl_x11_egl=yes
|
||||
res_comment="$res_comment x11egl"
|
||||
fi
|
||||
else
|
||||
_gl=no
|
||||
fi
|
||||
|
||||
if test "$_gl" = no ; then
|
||||
_gl_x11=no
|
||||
_gl_wayland=no
|
||||
_gl_x11_egl=no
|
||||
fi
|
||||
check_yes_no $_gl GL
|
||||
check_yes_no $_gl_x11 GL_X11
|
||||
check_yes_no $_gl_x11_egl EGL_X11
|
||||
check_yes_no $_gl_wayland GL_WAYLAND
|
||||
echores "$_gl"
|
||||
|
||||
echocheck "VDPAU with OpenGL/X11"
|
||||
_vdpau_gl_x11=no
|
||||
(test "$_gl_x11" = yes && test "$_vdpau" = yes) && _vdpau_gl_x11=yes
|
||||
check_yes_no $_vdpau_gl_x11 VDPAU_GL_X11
|
||||
echores "$_vdpau_gl_x11"
|
||||
|
||||
_vaapi_glx=no
|
||||
(test "$_gl_x11" = yes && test "$_vaapi" = yes) && _vaapi_glx=auto
|
||||
check_pkg_config "VAAPI with OpenGL/X11" $_vaapi_glx VAAPI_GLX 'libva-glx >= 0.32.0'
|
||||
|
||||
check_pkg_config "SDL 2.0" $_sdl2 SDL2 'sdl2'
|
||||
|
||||
check_statement_libs "OSS Audio" $_ossaudio OSS_AUDIO $_soundcard_header "int x = SNDCTL_DSP_SETFRAGMENT;"
|
||||
|
||||
check_statement_libs "RSound" $_rsound RSOUND rsound.h 'rsd_init(NULL);' -lrsound
|
||||
|
||||
check_statement_libs "sndio" $_sndio SNDIO sndio.h 'struct sio_par par; sio_initpar(&par); const char *s = SIO_DEVANY' -lsndio
|
||||
|
||||
check_pkg_config "PulseAudio" $_pulse PULSE 'libpulse >= 1.0'
|
||||
|
||||
check_pkg_config "JACK" $_jack JACK 'jack'
|
||||
|
||||
check_pkg_config "OpenAL" $_openal OPENAL 'openal >= 1.13'
|
||||
|
||||
check_pkg_config "ALSA audio" $_alsa ALSA 'alsa >= 1.0.9'
|
||||
|
||||
check_pkg_config "Blu-ray support" $_bluray LIBBLURAY 'libbluray >= 0.3.0'
|
||||
|
||||
check_pkg_config "dvdread" $_dvdread DVDREAD 'dvdread >= 4.1.0'
|
||||
|
||||
check_pkg_config "dvdnav" $_dvdnav DVDNAV 'dvdnav >= 4.2.0'
|
||||
|
||||
check_pkg_config "libcdio" $_libcdio CDDA 'libcdio_paranoia'
|
||||
|
||||
check_pkg_config "rubberband" $_librubberband RUBBERBAND 'rubberband'
|
||||
|
||||
_oldass=$_libass
|
||||
check_pkg_config "SSA/ASS support" $_libass LIBASS 'libass'
|
||||
_libass=$(defretval)
|
||||
if test $_oldass != no && test $_libass = no ; then
|
||||
die "Unable to find development files for libass. Aborting. If you really mean to compile without libass support use --disable-libass."
|
||||
fi
|
||||
|
||||
_dummy_osd=yes
|
||||
test $_libass = yes && _dummy_osd=no
|
||||
echo "LIBASS_OSD = $_libass" >> $CONFIG_MAK
|
||||
echo "DUMMY_OSD = $_dummy_osd" >> $CONFIG_MAK
|
||||
|
||||
check_pkg_config "ENCA" $_enca ENCA 'enca'
|
||||
check_pkg_config "uchardet" $_uchardet UCHARDET 'uchardet'
|
||||
|
||||
check_pkg_config "zlib" auto ZLIB 'zlib'
|
||||
test $(defretval) = no && die "Unable to find development files for zlib."
|
||||
|
||||
check_pkg_config "LCMS2 support" $_lcms2 LCMS2 'lcms2 >= 2.6'
|
||||
|
||||
check_pkg_config "FFmpeg/Libav" $_ffmpeg FFMPEG \
|
||||
"libavutil >= 54.02.0 libavcodec >= 56.1.0 libavformat >= 56.01.0 libswscale >= 2.1.3"
|
||||
test $(defretval) = no && die "Unable to find development files for some of the required Libav libraries above. Aborting."
|
||||
|
||||
check_pkg_config "Libswresample" $_libswresample LIBSWRESAMPLE 'libswresample >= 1.1.100'
|
||||
_libswresample=$(defretval)
|
||||
|
||||
_libavresample=auto
|
||||
test $_libswresample = yes && _libavresample=no
|
||||
check_pkg_config "Libavresample" $_libavresample LIBAVRESAMPLE 'libavresample >= 2.1.0'
|
||||
_libavresample=$(defretval)
|
||||
|
||||
if test "$_libswresample" = no && test "$_libavresample" = no ; then
|
||||
die "No resampler found. Install libavresample or libswresample (FFmpeg)."
|
||||
fi
|
||||
|
||||
# Arguments: "message"($1) "define"($2) "header"($3) "code"($4)
|
||||
api_statement_check() {
|
||||
echocheck "$1"
|
||||
_res=no
|
||||
statement_check "$3" "$4" && _res=yes
|
||||
define_yes_no $_res "$2"
|
||||
echores "$_res"
|
||||
}
|
||||
|
||||
api_statement_check \
|
||||
"libavcodec avcodec_enum_to_chroma_pos API" \
|
||||
HAVE_AVCODEC_CHROMA_POS_API \
|
||||
libavcodec/avcodec.h \
|
||||
'int x, y; avcodec_enum_to_chroma_pos(&x, &y, AVCHROMA_LOC_UNSPECIFIED)'
|
||||
|
||||
api_statement_check \
|
||||
"libavutil AVFrame metadata" \
|
||||
HAVE_AVFRAME_METADATA \
|
||||
libavutil/frame.h \
|
||||
'av_frame_get_metadata(NULL)'
|
||||
|
||||
api_statement_check \
|
||||
"libavutil AVFrame skip samples metadata" \
|
||||
HAVE_AVFRAME_SKIP_SAMPLES \
|
||||
libavutil/frame.h \
|
||||
'enum AVFrameSideDataType type = AV_FRAME_DATA_SKIP_SAMPLES'
|
||||
|
||||
api_statement_check \
|
||||
"libavutil av_version_info()" \
|
||||
HAVE_AV_VERSION_INFO \
|
||||
libavutil/avutil.h \
|
||||
'const char *x = av_version_info()'
|
||||
|
||||
api_statement_check \
|
||||
"libavutil new pixdesc fields" \
|
||||
HAVE_AV_NEW_PIXDESC \
|
||||
libavutil/pixdesc.h \
|
||||
'AVComponentDescriptor d; int x = d.depth'
|
||||
|
||||
check_pkg_config "libavfilter" $_libavfilter LIBAVFILTER 'libavfilter >= 5.0.0'
|
||||
|
||||
check_pkg_config "libavdevice" $_libavdevice LIBAVDEVICE 'libavdevice >= 55.0.0'
|
||||
|
||||
check_trivial "TV interface" $_tv TV
|
||||
|
||||
check_statement_libs "Video 4 Linux 2 TV interface" $_tv_v4l2 TV_V4L2 \
|
||||
"sys/time.h linux/videodev2.h"
|
||||
_tv_v4l2=$(defretval)
|
||||
check_trivial "TV audio input" $_tv_v4l2 AUDIO_INPUT
|
||||
|
||||
test $_tv_v4l2 = no && _libv4l2=no
|
||||
check_pkg_config "libv4l2 support" $_libv4l2 LIBV4L2 'libv4l2'
|
||||
|
||||
test "$_tv_v4l2" = no && _pvr=no
|
||||
check_compile "Video 4 Linux 2 MPEG PVR interface" $_pvr PVR waftools/fragments/pvr.c
|
||||
|
||||
# Note: Lua has no official .pc file, so there are different OS-specific ones.
|
||||
# Also, we support luajit, which is compatible to 5.1.
|
||||
|
||||
test_lua() {
|
||||
if test "$_lua" = auto && $_pkg_config "$1" ; then
|
||||
check_pkg_config "Lua ($1)" $_lua LUA "$1"
|
||||
_lua=$(defretval)
|
||||
fi
|
||||
}
|
||||
|
||||
test_lua "lua >= 5.1.0 lua < 5.2.0"
|
||||
test_lua "lua5.1 >= 5.1.0" # debian
|
||||
test_lua "lua51 >= 5.1.0" # OpenBSD
|
||||
test_lua "luajit >= 2.0.0"
|
||||
test_lua "lua5.2 >= 5.2.0" # debian
|
||||
test_lua "lua52 >= 5.2.0" # OpenBSD
|
||||
test_lua "lua >= 5.2.0"
|
||||
|
||||
test "$_lua" != yes && check_yes_no no LUA
|
||||
|
||||
if ! ( $_pkg_config 'vapoursynth >= 24' ) ; then
|
||||
_vapoursynth=no
|
||||
_vapoursynth_lazy=no
|
||||
fi
|
||||
check_pkg_config "VapourSynth support (Python)" $_vapoursynth VAPOURSYNTH 'vapoursynth >= 23 vapoursynth-script >= 23'
|
||||
_vapoursynth=$(defretval)
|
||||
if test "$_lua" = no ; then
|
||||
_vapoursynth_lazy=no
|
||||
fi
|
||||
check_pkg_config "VapourSynth support (Lua)" $_vapoursynth_lazy VAPOURSYNTH_LAZY 'vapoursynth >= 23'
|
||||
_vapoursynth_lazy=$(defretval)
|
||||
|
||||
_vapoursynth_core=yes
|
||||
if test "$_vapoursynth" = no && test "$_vapoursynth_lazy" = no ; then
|
||||
_vapoursynth_core=no
|
||||
fi
|
||||
check_trivial "VapourSynth core" $_vapoursynth_core VAPOURSYNTH_CORE
|
||||
|
||||
check_pkg_config "libarchive support" $_libarchive LIBARCHIVE 'libarchive >= 3.0.0'
|
||||
|
||||
check_trivial "encoding" $_encoding ENCODING
|
||||
|
||||
# needs dlopen on unix
|
||||
_dlopen="$_dl"
|
||||
check_yes_no $_dlopen DLOPEN
|
||||
|
||||
extra_ldflags="$extra_ldflags $_ld_pthread"
|
||||
libs_mplayer="$libs_mplayer $_ld_dl"
|
||||
|
||||
CFLAGS="$CFLAGS -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE"
|
||||
|
||||
# This is done so waf builds won't conflict with this. In fact, waf and old
|
||||
# build system can coexist in parallel, at the same time. This is because
|
||||
# waf always does out-of-tree builds, while this build system does always
|
||||
# in-tree builds.
|
||||
|
||||
if test ! -f Makefile ; then
|
||||
ln -s TOOLS/old-makefile Makefile
|
||||
fi
|
||||
|
||||
cat > old_build/config.mak << EOF
|
||||
# -------- Generated by configure -----------
|
||||
export LC_ALL = C
|
||||
|
||||
CONFIGURATION = $configuration
|
||||
|
||||
prefix = \$(DESTDIR)$_prefix
|
||||
BINDIR = \$(DESTDIR)$_bindir
|
||||
MANDIR = \$(DESTDIR)$_mandir
|
||||
CONFDIR = \$(DESTDIR)$_confdir
|
||||
|
||||
CC = $_cc
|
||||
INSTALL = install
|
||||
|
||||
CFLAGS = -Iold_build $OURCFLAGS $CFLAGS $extra_cflags
|
||||
DEPFLAGS = $DEPFLAGS
|
||||
|
||||
EXTRALIBS = $extra_ldflags $_ld_static $_ld_lm $libs_mplayer $end_ldflags
|
||||
|
||||
RST2MAN = $_rst2man
|
||||
BUILD_MAN = $_build_man
|
||||
|
||||
# features
|
||||
EOF
|
||||
cat $CONFIG_MAK >> old_build/config.mak
|
||||
|
||||
cat > $TMPC << EOF
|
||||
/*----------------------------------------------------------------------------
|
||||
** This file has been automatically generated by configure any changes in it
|
||||
** will be lost when you run configure again.
|
||||
** Instead of modifying definitions here, use the --enable/--disable options
|
||||
** of the configure script! See ./configure --help for details.
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef MPV_CONFIG_H
|
||||
#define MPV_CONFIG_H
|
||||
|
||||
#define CONFIGURATION "$configuration"
|
||||
|
||||
#define MPV_CONFDIR "$_confdir"
|
||||
|
||||
/* we didn't bother to add actual config checks for this, or they are
|
||||
for platforms not supported by this configure script */
|
||||
#define HAVE_BSD_FSTATFS 0
|
||||
#define HAVE_LINUX_FSTATFS 1
|
||||
#define HAVE_VDA_AV_VDA_ALLOC_CONTEXT 0
|
||||
#define HAVE_VDA_HWACCEL 0
|
||||
#define HAVE_VDA_LIBAVCODEC_REFCOUNTING 0
|
||||
#define HAVE_VDA_GL 0
|
||||
#define HAVE_GL_COCOA 0
|
||||
#define HAVE_COCOA 0
|
||||
#define HAVE_COCOA_APPLICATION 0
|
||||
#define HAVE_COREVIDEO 0
|
||||
#define HAVE_COREAUDIO 0
|
||||
#define HAVE_GL_WIN32 0
|
||||
#define HAVE_DIRECT3D 0
|
||||
#define HAVE_DSOUND 0
|
||||
#define HAVE_WASAPI 0
|
||||
#define HAVE_DOS_PATHS 0
|
||||
#define HAVE_PRIORITY 0
|
||||
#define HAVE_GLOB 1
|
||||
#define HAVE_NANOSLEEP 1
|
||||
#define HAVE_SDL1 0
|
||||
#define HAVE_WAIO 0
|
||||
#define HAVE_POSIX_SPAWN 1
|
||||
#define HAVE_GLIBC_THREAD_NAME (!!__GLIBC__)
|
||||
#define HAVE_OSX_THREAD_NAME 0
|
||||
#define HAVE_BSD_THREAD_NAME 0
|
||||
#define HAVE_NETBSD_THREAD_NAME 0
|
||||
#define HAVE_DXVA2_HWACCEL 0
|
||||
#define HAVE_FCHMOD 0
|
||||
#define HAVE_RPI 0
|
||||
#define HAVE_RPI_GLES 0
|
||||
#define HAVE_AV_PIX_FMT_MMAL 0
|
||||
#define HAVE_DRM 0
|
||||
#define HAVE_VIDEOTOOLBOX_HWACCEL 0
|
||||
#define HAVE_VIDEOTOOLBOX_GL 0
|
||||
#define HAVE_VIDEOTOOLBOX_VDA_GL 0
|
||||
|
||||
#ifdef __OpenBSD__
|
||||
#define DEFAULT_CDROM_DEVICE "/dev/rcd0c"
|
||||
#define DEFAULT_DVD_DEVICE "/dev/rcd0c"
|
||||
#else
|
||||
#define DEFAULT_CDROM_DEVICE "/dev/cdrom"
|
||||
#define DEFAULT_DVD_DEVICE "/dev/dvd"
|
||||
#endif
|
||||
#define PATH_DEV_DSP "/dev/dsp"
|
||||
#define PATH_DEV_MIXER "/dev/mixer"
|
||||
|
||||
EOF
|
||||
cat $CONFIG_H >> $TMPC
|
||||
echo '#endif /* MPV_CONFIG_H */' >> $TMPC
|
||||
|
||||
# Do not overwrite an unchanged config.h to avoid superfluous rebuilds.
|
||||
cmp -s "$TMPC" old_build/config.h || mv -f "$TMPC" old_build/config.h
|
||||
|
||||
cat <<EOF
|
||||
|
||||
Configuration successful. See $TMPLOG for details.
|
||||
|
||||
NOTE: The --enable-* parameters unconditionally force options on, completely
|
||||
skipping autodetection. This behavior is unlike what you may be used to from
|
||||
autoconf-based configure scripts that can decide to override you. This greater
|
||||
level of control comes at a price. You may have to provide the correct compiler
|
||||
and linker flags yourself.
|
||||
If you used one of these options and experience a compilation or
|
||||
linking failure, make sure you have passed the necessary compiler/linker flags
|
||||
to configure.
|
||||
|
||||
WARNING: The ./old-configure + make build system you are using is deprecated in
|
||||
favour of waf and will be removed in a future version of mpv. Check the
|
||||
README for instructions on how to build mpv with the new build system.
|
||||
This will not work correctly on MinGW, Cygwin, OSX, and other systems.
|
||||
|
||||
EOF
|
||||
@@ -1,483 +0,0 @@
|
||||
# MPlayer Makefile
|
||||
#
|
||||
# copyright (c) 2008 Diego Biurrun
|
||||
# Rewritten entirely from a set of Makefiles written by Arpi and many others.
|
||||
#
|
||||
# This file is part of MPlayer.
|
||||
#
|
||||
# MPlayer is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# MPlayer is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License along
|
||||
# with MPlayer; if not, write to the Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
include old_build/config.mak
|
||||
|
||||
###### variable declarations #######
|
||||
|
||||
SOURCES_AUDIO_INPUT-$(ALSA) += stream/ai_alsa1x.c
|
||||
SOURCES_AUDIO_INPUT-$(OSS_AUDIO)+= stream/ai_oss.c
|
||||
SOURCES_AUDIO_INPUT-$(SNDIO) += stream/ai_sndio.c
|
||||
SOURCES-$(AUDIO_INPUT) += $(SOURCES_AUDIO_INPUT-yes)
|
||||
SOURCES-$(CDDA) += stream/stream_cdda.c
|
||||
SOURCES-$(DVBIN) += stream/dvb_tune.c \
|
||||
stream/stream_dvb.c
|
||||
SOURCES-$(DVDREAD) += stream/stream_dvd.c \
|
||||
stream/stream_dvd_common.c
|
||||
SOURCES-$(DVDNAV) += stream/stream_dvdnav.c \
|
||||
stream/stream_dvd_common.c
|
||||
|
||||
SOURCES-$(RUBBERBAND) += audio/filter/af_rubberband.c
|
||||
SOURCES-$(LIBASS) += sub/ass_mp.c sub/sd_ass.c \
|
||||
demux/demux_libass.c
|
||||
|
||||
SOURCES-$(LIBBLURAY) += stream/stream_bluray.c
|
||||
|
||||
SOURCES-$(LIBSMBCLIENT) += stream/stream_smb.c
|
||||
|
||||
SOURCES-$(PVR) += stream/stream_pvr.c
|
||||
|
||||
SOURCES-$(TV) += stream/stream_tv.c stream/tv.c \
|
||||
stream/frequencies.c stream/tvi_dummy.c \
|
||||
demux/demux_tv.c
|
||||
|
||||
SOURCES-$(TV_V4L2) += stream/tvi_v4l2.c stream/audio_in.c
|
||||
SOURCES-$(DUMMY_OSD) += sub/osd_dummy.c
|
||||
SOURCES-$(LIBASS_OSD) += sub/osd_libass.c
|
||||
|
||||
SOURCES-$(ALSA) += audio/out/ao_alsa.c
|
||||
SOURCES-$(CACA) += video/out/vo_caca.c
|
||||
SOURCES-$(SDL2) += audio/out/ao_sdl.c video/out/vo_sdl.c
|
||||
SOURCES-$(GL) += video/out/opengl/common.c \
|
||||
video/out/opengl/osd.c \
|
||||
video/out/opengl/lcms.c \
|
||||
video/out/opengl/video.c \
|
||||
video/out/opengl/video_shaders.c \
|
||||
video/out/dither.c \
|
||||
video/out/opengl/hwdec.c \
|
||||
video/out/opengl/utils.c \
|
||||
video/out/vo_opengl.c \
|
||||
video/out/vo_opengl_cb.c
|
||||
|
||||
SOURCES-$(ENCODING) += video/out/vo_lavc.c audio/out/ao_lavc.c \
|
||||
common/encode_lavc.c
|
||||
|
||||
SOURCES-$(GL_X11) += video/out/x11_common.c video/out/opengl/x11.c
|
||||
SOURCES-$(EGL_X11) += video/out/x11_common.c video/out/opengl/x11egl.c
|
||||
SOURCES-$(GL_WAYLAND) += video/out/wayland_common.c \
|
||||
video/out/opengl/wayland.c
|
||||
|
||||
SOURCES-$(JACK) += audio/out/ao_jack.c
|
||||
SOURCES-$(OPENAL) += audio/out/ao_openal.c
|
||||
SOURCES-$(OSS_AUDIO) += audio/out/ao_oss.c
|
||||
SOURCES-$(PULSE) += audio/out/ao_pulse.c
|
||||
SOURCES-$(RSOUND) += audio/out/ao_rsound.c
|
||||
SOURCES-$(SNDIO) += audio/out/ao_sndio.c
|
||||
SOURCES-$(VDPAU) += video/vdpau.c video/vdpau_mixer.c \
|
||||
video/out/vo_vdpau.c video/decode/vdpau.c \
|
||||
video/filter/vf_vdpaupp.c \
|
||||
video/filter/vf_vdpaurb.c
|
||||
SOURCES-$(VDPAU_GL_X11) += video/out/opengl/hwdec_vdpau.c
|
||||
SOURCES-$(VAAPI) += video/out/vo_vaapi.c \
|
||||
video/decode/vaapi.c \
|
||||
video/vaapi.c
|
||||
SOURCES-$(VAAPI_VPP) += video/filter/vf_vavpp.c
|
||||
SOURCES-$(VAAPI_GLX) += video/out/opengl/hwdec_vaglx.c
|
||||
|
||||
SOURCES-$(XV) += video/out/x11_common.c video/out/vo_xv.c
|
||||
SOURCES-$(WAYLAND) += video/out/vo_wayland.c \
|
||||
video/out/wayland_common.c \
|
||||
video/out/wayland/buffer.c \
|
||||
video/out/wayland/memfile.c
|
||||
|
||||
SOURCES-$(LIBAVFILTER) += video/filter/vf_lavfi.c \
|
||||
video/filter/vf_gradfun.c \
|
||||
video/filter/vf_pullup.c \
|
||||
video/filter/vf_rotate.c \
|
||||
video/filter/vf_yadif.c \
|
||||
audio/filter/af_lavfi.c
|
||||
|
||||
SOURCES-$(LUA) += player/lua.c
|
||||
SOURCES-$(VAPOURSYNTH_CORE) += video/filter/vf_vapoursynth.c
|
||||
SOURCES-$(LIBARCHIVE) += demux/demux_libarchive.c \
|
||||
stream/stream_libarchive.c
|
||||
SOURCES-$(DLOPEN) += video/filter/vf_dlopen.c
|
||||
|
||||
SOURCES = audio/audio.c \
|
||||
audio/audio_buffer.c \
|
||||
audio/chmap.c \
|
||||
audio/chmap_sel.c \
|
||||
audio/fmt-conversion.c \
|
||||
audio/format.c \
|
||||
audio/mixer.c \
|
||||
audio/decode/ad_lavc.c \
|
||||
audio/decode/ad_spdif.c \
|
||||
audio/decode/dec_audio.c \
|
||||
audio/filter/af.c \
|
||||
audio/filter/af_channels.c \
|
||||
audio/filter/af_delay.c \
|
||||
audio/filter/af_equalizer.c \
|
||||
audio/filter/af_format.c \
|
||||
audio/filter/af_lavcac3enc.c \
|
||||
audio/filter/af_lavrresample.c \
|
||||
audio/filter/af_pan.c \
|
||||
audio/filter/af_scaletempo.c \
|
||||
audio/filter/af_drc.c \
|
||||
audio/filter/af_volume.c \
|
||||
audio/filter/tools.c \
|
||||
audio/out/ao.c \
|
||||
audio/out/ao_null.c \
|
||||
audio/out/ao_pcm.c \
|
||||
audio/out/pull.c \
|
||||
audio/out/push.c \
|
||||
common/av_common.c \
|
||||
common/av_log.c \
|
||||
common/codecs.c \
|
||||
common/common.c \
|
||||
common/msg.c \
|
||||
common/playlist.c \
|
||||
common/tags.c \
|
||||
common/version.c \
|
||||
demux/codec_tags.c \
|
||||
demux/cue.c \
|
||||
demux/demux.c \
|
||||
demux/demux_edl.c \
|
||||
demux/demux_cue.c \
|
||||
demux/demux_disc.c \
|
||||
demux/demux_lavf.c \
|
||||
demux/demux_mf.c \
|
||||
demux/demux_mkv.c \
|
||||
demux/demux_mkv_timeline.c \
|
||||
demux/demux_playlist.c \
|
||||
demux/demux_rar.c \
|
||||
demux/demux_raw.c \
|
||||
demux/demux_subreader.c \
|
||||
demux/ebml.c \
|
||||
demux/packet.c \
|
||||
demux/timeline.c \
|
||||
input/cmd_list.c \
|
||||
input/cmd_parse.c \
|
||||
input/event.c \
|
||||
input/input.c \
|
||||
input/ipc.c \
|
||||
input/keycodes.c \
|
||||
misc/bstr.c \
|
||||
misc/charset_conv.c \
|
||||
misc/dispatch.c \
|
||||
misc/json.c \
|
||||
misc/rendezvous.c \
|
||||
misc/ring.c \
|
||||
options/m_config.c \
|
||||
options/m_option.c \
|
||||
options/m_property.c \
|
||||
options/options.c \
|
||||
options/parse_commandline.c \
|
||||
options/parse_configfile.c \
|
||||
options/path.c \
|
||||
osdep/io.c \
|
||||
osdep/path-unix.c \
|
||||
osdep/semaphore_osx.c \
|
||||
osdep/subprocess.c \
|
||||
osdep/subprocess-posix.c \
|
||||
osdep/terminal-unix.c \
|
||||
osdep/timer.c \
|
||||
osdep/timer-linux.c \
|
||||
osdep/threads.c \
|
||||
player/audio.c \
|
||||
player/client.c \
|
||||
player/configfiles.c \
|
||||
player/command.c \
|
||||
player/external_files.c \
|
||||
player/loadfile.c \
|
||||
player/main.c \
|
||||
player/misc.c \
|
||||
player/osd.c \
|
||||
player/playloop.c \
|
||||
player/screenshot.c \
|
||||
player/scripting.c \
|
||||
player/sub.c \
|
||||
player/video.c \
|
||||
stream/cache.c \
|
||||
stream/cache_file.c \
|
||||
stream/cookies.c \
|
||||
stream/rar.c \
|
||||
stream/stream.c \
|
||||
stream/stream_avdevice.c \
|
||||
stream/stream_edl.c \
|
||||
stream/stream_file.c \
|
||||
stream/stream_lavf.c \
|
||||
stream/stream_memory.c \
|
||||
stream/stream_mf.c \
|
||||
stream/stream_null.c \
|
||||
stream/stream_rar.c \
|
||||
sub/dec_sub.c \
|
||||
sub/draw_bmp.c \
|
||||
sub/img_convert.c \
|
||||
sub/osd.c \
|
||||
sub/sd_lavc.c \
|
||||
sub/sd_lavc_conv.c \
|
||||
sub/sd_lavf_srt.c \
|
||||
sub/sd_microdvd.c \
|
||||
sub/sd_movtext.c \
|
||||
sub/sd_srt.c \
|
||||
ta/ta.c \
|
||||
ta/ta_utils.c \
|
||||
ta/ta_talloc.c \
|
||||
video/csputils.c \
|
||||
video/fmt-conversion.c \
|
||||
video/image_writer.c \
|
||||
video/img_format.c \
|
||||
video/mp_image.c \
|
||||
video/mp_image_pool.c \
|
||||
video/sws_utils.c \
|
||||
video/decode/dec_video.c \
|
||||
video/decode/vd_lavc.c \
|
||||
video/filter/vf.c \
|
||||
video/filter/vf_buffer.c \
|
||||
video/filter/vf_crop.c \
|
||||
video/filter/vf_dsize.c \
|
||||
video/filter/vf_eq.c \
|
||||
video/filter/vf_expand.c \
|
||||
video/filter/vf_flip.c \
|
||||
video/filter/vf_format.c \
|
||||
video/filter/vf_mirror.c \
|
||||
video/filter/vf_noformat.c \
|
||||
video/filter/vf_scale.c \
|
||||
video/filter/vf_stereo3d.c \
|
||||
video/filter/vf_sub.c \
|
||||
video/out/bitmap_packer.c \
|
||||
video/out/aspect.c \
|
||||
video/out/filter_kernels.c \
|
||||
video/out/vo.c \
|
||||
video/out/vo_null.c \
|
||||
video/out/vo_image.c \
|
||||
video/out/win_state.c \
|
||||
$(SOURCES-yes)
|
||||
|
||||
OBJECTS += $(addsuffix .o, $(basename $(SOURCES)))
|
||||
OBJECTS += $(OBJECTS-yes)
|
||||
|
||||
DEP_FILES = $(patsubst %.S,%.d,$(patsubst %.cpp,%.d,$(patsubst %.c,%.d,$(SOURCES:.m=.d) $(SOURCES:.m=.d))))
|
||||
|
||||
ALL_TARGETS += mpv
|
||||
|
||||
INSTALL_BIN += install-mpv
|
||||
INSTALL_BIN_STRIP += install-mpv-strip
|
||||
INSTALL_MAN =
|
||||
|
||||
ifeq ($(BUILD_MAN),yes)
|
||||
INSTALL_MAN += install-mpv-man
|
||||
ALL_TARGETS += DOCS/man/mpv.1
|
||||
endif
|
||||
|
||||
DIRS = . \
|
||||
audio \
|
||||
audio/decode \
|
||||
audio/filter \
|
||||
audio/out \
|
||||
common \
|
||||
compat \
|
||||
input \
|
||||
player/timeline \
|
||||
demux \
|
||||
misc \
|
||||
options \
|
||||
osdep \
|
||||
osdep/ar \
|
||||
player \
|
||||
stream \
|
||||
sub \
|
||||
ta \
|
||||
video \
|
||||
video/decode \
|
||||
video/filter \
|
||||
video/out
|
||||
|
||||
|
||||
ADDSUFFIXES = $(foreach suf,$(1),$(addsuffix $(suf),$(2)))
|
||||
ADD_ALL_DIRS = $(call ADDSUFFIXES,$(1),$(DIRS))
|
||||
|
||||
###### brief build output #######
|
||||
|
||||
ifndef V
|
||||
$(eval override CC = @printf "CC\t$$@\n"; $(CC))
|
||||
$(eval override RM = @$(RM))
|
||||
endif
|
||||
|
||||
###### generic rules #######
|
||||
|
||||
all: $(ALL_TARGETS)
|
||||
|
||||
%.1: %.rst
|
||||
$(RST2MAN) $< $@
|
||||
|
||||
%.o: %.c
|
||||
$(CC) $(DEPFLAGS) $(CFLAGS) -c -o $@ $<
|
||||
|
||||
mpv: $(OBJECTS) osdep/main-fn-unix.o
|
||||
$(CC) -o $@ $^ $(EXTRALIBS)
|
||||
|
||||
input/input.c: input/input_conf.h
|
||||
input/input_conf.h: TOOLS/file2string.pl etc/input.conf
|
||||
./$^ >$@
|
||||
|
||||
MKVLIB_DEPS = TOOLS/lib/Parse/Matroska.pm \
|
||||
TOOLS/lib/Parse/Matroska/Definitions.pm \
|
||||
TOOLS/lib/Parse/Matroska/Element.pm \
|
||||
TOOLS/lib/Parse/Matroska/Reader.pm \
|
||||
TOOLS/lib/Parse/Matroska/Utils.pm \
|
||||
|
||||
demux/ebml.c demux/demux_mkv.c: demux/ebml_types.h
|
||||
demux/ebml_types.h: TOOLS/matroska.pl $(MKVLIB_DEPS)
|
||||
./$< --generate-header > $@
|
||||
|
||||
demux/ebml.c: demux/ebml_defs.c
|
||||
demux/ebml_defs.c: TOOLS/matroska.pl $(MKVLIB_DEPS)
|
||||
./$< --generate-definitions > $@
|
||||
|
||||
video/out/x11_common.c: video/out/x11_icon.inc
|
||||
video/out/x11_icon.inc: TOOLS/file2string.pl video/out/x11_icon.bin
|
||||
./$^ >$@
|
||||
|
||||
sub/osd_libass.c: sub/osd_font.h
|
||||
sub/osd_font.h: TOOLS/file2string.pl sub/osd_font.otf
|
||||
./$^ >$@
|
||||
|
||||
player/lua/%.inc: TOOLS/file2string.pl player/lua/%.lua
|
||||
./$^ >$@
|
||||
|
||||
player/lua.c: player/lua/defaults.inc \
|
||||
player/lua/assdraw.inc \
|
||||
player/lua/osc.inc \
|
||||
player/lua/ytdl_hook.inc \
|
||||
player/lua/options.inc
|
||||
|
||||
etc/_mpv: TOOLS/zsh.pl ./mpv
|
||||
./$< > $@
|
||||
|
||||
# ./configure must be rerun if it changed
|
||||
config.mak: configure
|
||||
@echo "############################################################"
|
||||
@echo "####### Please run ./configure again - it's changed! #######"
|
||||
@echo "############################################################"
|
||||
|
||||
old_build/version.h .version: version.sh
|
||||
./version.sh --versionh=old_build/version.h
|
||||
|
||||
# Force version.sh to run to potentially regenerate version.h
|
||||
-include .version
|
||||
|
||||
%: %.c
|
||||
$(CC) $(CFLAGS) -o $@ $^
|
||||
|
||||
|
||||
###### dependency declarations / specific CFLAGS ######
|
||||
|
||||
common/version.c: old_build/version.h
|
||||
|
||||
DOCS/man/mpv.1: DOCS/man/af.rst \
|
||||
DOCS/man/ao.rst \
|
||||
DOCS/man/changes.rst \
|
||||
DOCS/man/encode.rst \
|
||||
DOCS/man/input.rst \
|
||||
DOCS/man/options.rst \
|
||||
DOCS/man/vf.rst \
|
||||
DOCS/man/vo.rst
|
||||
|
||||
###### installation / clean / generic rules #######
|
||||
|
||||
install: $(INSTALL_BIN) install-data $(INSTALL_MAN)
|
||||
install-no-man: $(INSTALL_BIN) install-data
|
||||
install-strip: $(INSTALL_BIN_STRIP) install-data $(INSTALL_MAN)
|
||||
install-strip-no-man: $(INSTALL_BIN_STRIP) install-data
|
||||
|
||||
install-dirs:
|
||||
if test ! -d $(BINDIR) ; then $(INSTALL) -d $(BINDIR) ; fi
|
||||
|
||||
install-%: % install-dirs
|
||||
$(INSTALL) -m 755 $< $(BINDIR)
|
||||
|
||||
install-%-strip: % install-dirs
|
||||
$(INSTALL) -m 755 -s $< $(BINDIR)
|
||||
|
||||
install-mpv-man: install-mpv-man-en
|
||||
|
||||
install-mpv-man-en: DOCS/man/mpv.1
|
||||
if test ! -d $(MANDIR)/man1 ; then $(INSTALL) -d $(MANDIR)/man1 ; fi
|
||||
$(INSTALL) -m 644 DOCS/man/mpv.1 $(MANDIR)/man1/
|
||||
|
||||
ICONSIZES = 16x16 32x32 64x64
|
||||
|
||||
define ICON_INSTALL_RULE
|
||||
install-mpv-icon-$(size): etc/mpv-icon-8bit-$(size).png
|
||||
$(INSTALL) -d $(prefix)/share/icons/hicolor/$(size)/apps
|
||||
$(INSTALL) -m 644 etc/mpv-icon-8bit-$(size).png $(prefix)/share/icons/hicolor/$(size)/apps/mpv.png
|
||||
endef
|
||||
|
||||
$(foreach size,$(ICONSIZES),$(eval $(ICON_INSTALL_RULE)))
|
||||
|
||||
install-mpv-icons: $(foreach size,$(ICONSIZES),install-mpv-icon-$(size))
|
||||
|
||||
install-mpv-desktop: etc/mpv.desktop
|
||||
$(INSTALL) -d $(prefix)/share/applications
|
||||
$(INSTALL) -m 644 etc/mpv.desktop $(prefix)/share/applications/
|
||||
|
||||
install-mpv-config: etc/encoding-profiles.conf
|
||||
$(INSTALL) -d $(CONFDIR)
|
||||
$(INSTALL) -m 644 etc/encoding-profiles.conf $(CONFDIR)
|
||||
|
||||
install-mpv-zsh: etc/_mpv
|
||||
$(INSTALL) -d $(prefix)/share/zsh/vendor-completions
|
||||
$(INSTALL) -m 644 etc/_mpv $(prefix)/share/zsh/vendor-completions/
|
||||
|
||||
install-data: install-mpv-icons install-mpv-desktop install-mpv-config install-mpv-zsh
|
||||
|
||||
uninstall:
|
||||
$(RM) $(BINDIR)/mpv
|
||||
$(RM) $(MANDIR)/man1/mpv.1 $(MANDIR)/man1/mpv.1
|
||||
$(RM) $(prefix)/share/applications/mpv.desktop
|
||||
$(RM) $(prefix)/share/zsh/vendor-completions/_mpv
|
||||
$(RM) $(foreach size,$(ICONSIZES),$(prefix)/share/icons/hicolor/$(size)/apps/mpv.png)
|
||||
|
||||
clean:
|
||||
-$(RM) $(call ADD_ALL_DIRS,/*.o /*.d /*.a /*.ho /*~)
|
||||
-$(RM) $(call ADD_ALL_DIRS,/*.o /*.a /*.ho /*~)
|
||||
-$(RM) mpv
|
||||
-$(RM) DOCS/man/*/mpv.1
|
||||
-$(RM) old_build/version.h version.h
|
||||
-$(RM) input/input_conf.h
|
||||
-$(RM) video/out/vdpau_template.c
|
||||
-$(RM) demux/ebml_types.h demux/ebml_defs.c
|
||||
-$(RM) video/out/x11_icon.inc
|
||||
-$(RM) sub/osd_font.h
|
||||
-$(RM) player/lua/defaults.inc
|
||||
-$(RM) player/lua/assdraw.inc
|
||||
-$(RM) player/lua/osc.inc
|
||||
-$(RM) player/lua/ytdl_hook.inc
|
||||
-$(RM) player/lua/options.inc
|
||||
|
||||
distclean: clean
|
||||
-$(RM) config.log old_build/config.h old_build/config.mak Makefile
|
||||
-rmdir old_build/
|
||||
|
||||
-include $(DEP_FILES)
|
||||
|
||||
.PHONY: all *install* *clean .version
|
||||
|
||||
# Disable suffix rules. Most of the builtin rules are suffix rules,
|
||||
# so this saves some time on slow systems.
|
||||
.SUFFIXES:
|
||||
|
||||
# If a command returns failure but changed its target file, delete the
|
||||
# (presumably malformed) file. Otherwise the file would be considered to
|
||||
# be up to date if make is restarted.
|
||||
|
||||
.DELETE_ON_ERROR:
|
||||
+10
-1
@@ -39,8 +39,17 @@ def apply_plist_template(plist_file, version):
|
||||
for line in fileinput.input(plist_file, inplace=1):
|
||||
print (line.rstrip().replace('${VERSION}', version))
|
||||
|
||||
def bundle_version():
|
||||
if os.path.exists('VERSION'):
|
||||
x = open('VERSION')
|
||||
version = x.read()
|
||||
x.close()
|
||||
else:
|
||||
version = sh("./version.sh").strip()
|
||||
return version
|
||||
|
||||
def main():
|
||||
version = sh("./version.sh").strip()
|
||||
version = bundle_version().rstrip()
|
||||
|
||||
usage = "usage: %prog [options] arg"
|
||||
parser = OptionParser(usage)
|
||||
|
||||
+32
-14
@@ -1,5 +1,6 @@
|
||||
#!/usr/bin/env python3
|
||||
import matplotlib.pyplot as plot
|
||||
from pyqtgraph.Qt import QtGui, QtCore
|
||||
import pyqtgraph as pg
|
||||
import sys
|
||||
import re
|
||||
|
||||
@@ -38,8 +39,8 @@ Currently, the following event types are supported:
|
||||
class G:
|
||||
events = {}
|
||||
start = None
|
||||
# http://matplotlib.org/api/markers_api.html#module-matplotlib.markers
|
||||
markers = ["o", "8", "s", "p", "*", "h", "+", "x", "D"]
|
||||
markers = ["o", "s", "t", "d"]
|
||||
curveno = {}
|
||||
|
||||
def find_marker():
|
||||
if len(G.markers) == 0:
|
||||
@@ -65,6 +66,10 @@ def get_event(event, evtype):
|
||||
G.events[event] = e
|
||||
return G.events[event]
|
||||
|
||||
colors = [(0.0, 0.5, 0.0), (0.0, 0.0, 1.0), (0.0, 0.0, 0.0), (1.0, 0.0, 0.0), (0.75, 0.75, 0), (0.0, 0.75, 0.75), (0.75, 0, 0.75)]
|
||||
def mkColor(t):
|
||||
return pg.mkColor(int(t[0] * 255), int(t[1] * 255), int(t[2] * 255))
|
||||
|
||||
SCALE = 1e6 # microseconds to seconds
|
||||
|
||||
for line in [line.split("#")[0].strip() for line in open(filename, "r")]:
|
||||
@@ -128,20 +133,33 @@ for e, index in zip(G.sevents, range(len(G.sevents))):
|
||||
else:
|
||||
e.vals = [(x, y * (m - index) / m) for (x, y) in e.vals]
|
||||
|
||||
fig = plot.figure()
|
||||
fig.hold(True)
|
||||
pg.setConfigOption('background', 'w')
|
||||
pg.setConfigOption('foreground', 'k')
|
||||
app = QtGui.QApplication([])
|
||||
win = pg.GraphicsWindow()
|
||||
#win.resize(1500, 900)
|
||||
|
||||
ax = [None, None]
|
||||
plots = 2 if hasval else 1
|
||||
ax[0] = fig.add_subplot(plots, 1, 1)
|
||||
ax[0] = win.addPlot()
|
||||
if hasval:
|
||||
ax[1] = fig.add_subplot(plots, 1, 2, sharex=ax[0])
|
||||
legends = [[], []]
|
||||
win.nextRow()
|
||||
ax[1] = win.addPlot()
|
||||
ax[1].setXLink(ax[0])
|
||||
for cur in ax:
|
||||
if cur is not None:
|
||||
cur.addLegend(offset = (-1, 1))
|
||||
for e in G.sevents:
|
||||
cur = ax[1 if e.type == "value" else 0]
|
||||
pl, = cur.plot([x for x,y in e.vals], [y for x,y in e.vals], label=e.name)
|
||||
args = {'name': e.name,'antialias':True}
|
||||
if e.type == "event-signal":
|
||||
plot.setp(pl, marker = e.marker, linestyle = "None")
|
||||
for cur in ax:
|
||||
if cur is not None:
|
||||
cur.legend()
|
||||
plot.show()
|
||||
args['symbol'] = e.marker
|
||||
args['pen'] = None
|
||||
else:
|
||||
if not cur in G.curveno:
|
||||
G.curveno[cur] = 0
|
||||
args['pen'] = pg.mkPen(mkColor(colors[G.curveno[cur] % len(colors)]), width=0)
|
||||
G.curveno[cur] += 1
|
||||
n = cur.plot([x for x,y in e.vals], [y for x,y in e.vals], **args)
|
||||
|
||||
QtGui.QApplication.instance().exec_()
|
||||
+1
-1
@@ -120,7 +120,7 @@ $profile_comp
|
||||
_tags files urls
|
||||
while _tags; do
|
||||
_requested files expl 'media file' _files -g \\
|
||||
"*.(#i)(asf|asx|avi|flac|flv|m1v|m2p|m2v|m4v|mjpg|mka|mkv|mov|mp3|mp4|mpe|mpeg|mpg|ogg|ogm|ogv|qt|rm|ts|vob|wav|webm|wma|wmv)(-.)" && rc=0
|
||||
"*.(#i)(asf|asx|avi|flac|flv|m1v|m2p|m2v|m4v|mjpg|mka|mkv|mov|mp3|mp4|mpe|mpeg|mpg|ogg|ogm|ogv|opus|qt|rm|ts|vob|wav|webm|wma|wmv)(-.)" && rc=0
|
||||
if _requested urls; then
|
||||
while _next_label urls expl URL; do
|
||||
_urls "\$expl[@]" && rc=0
|
||||
|
||||
+8
-6
@@ -24,7 +24,7 @@
|
||||
#include <libavutil/frame.h>
|
||||
#include <libavutil/version.h>
|
||||
|
||||
#include "talloc.h"
|
||||
#include "mpv_talloc.h"
|
||||
#include "common/common.h"
|
||||
#include "fmt-conversion.h"
|
||||
#include "audio.h"
|
||||
@@ -323,21 +323,23 @@ struct mp_audio *mp_audio_from_avframe(struct AVFrame *avframe)
|
||||
}
|
||||
|
||||
// If we can't handle the format (e.g. too many channels), bail out.
|
||||
if (!mp_audio_config_valid(new) || avframe->nb_extended_buf)
|
||||
if (!mp_audio_config_valid(new))
|
||||
goto fail;
|
||||
|
||||
for (int n = 0; n < AV_NUM_DATA_POINTERS; n++) {
|
||||
if (!avframe->buf[n])
|
||||
for (int n = 0; n < AV_NUM_DATA_POINTERS + avframe->nb_extended_buf; n++) {
|
||||
AVBufferRef *buf = n < AV_NUM_DATA_POINTERS ? avframe->buf[n]
|
||||
: avframe->extended_buf[n - AV_NUM_DATA_POINTERS];
|
||||
if (!buf)
|
||||
break;
|
||||
if (n >= MP_NUM_CHANNELS)
|
||||
goto fail;
|
||||
new->allocated[n] = av_buffer_ref(avframe->buf[n]);
|
||||
new->allocated[n] = av_buffer_ref(buf);
|
||||
if (!new->allocated[n])
|
||||
goto fail;
|
||||
}
|
||||
|
||||
for (int n = 0; n < new->num_planes; n++)
|
||||
new->planes[n] = avframe->data[n];
|
||||
new->planes[n] = avframe->extended_data[n];
|
||||
new->samples = avframe->nb_samples;
|
||||
|
||||
return new;
|
||||
|
||||
@@ -37,6 +37,8 @@ struct mp_audio {
|
||||
int num_planes; // number of planes
|
||||
int bps; // size of sub-samples (af_fmt_to_bytes(format))
|
||||
|
||||
double pts; // currently invalid within the filter chain
|
||||
|
||||
// --- private
|
||||
// These do not necessarily map directly to planes[]. They can have
|
||||
// different order or count. There shouldn't be more buffers than planes.
|
||||
|
||||
@@ -119,6 +119,15 @@ void mp_audio_buffer_prepend_silence(struct mp_audio_buffer *ab, int samples)
|
||||
mp_audio_fill_silence(ab->buffer, 0, samples);
|
||||
}
|
||||
|
||||
void mp_audio_buffer_duplicate(struct mp_audio_buffer *ab, int samples)
|
||||
{
|
||||
assert(samples >= 0 && samples <= ab->buffer->samples);
|
||||
int oldlen = ab->buffer->samples;
|
||||
ab->buffer->samples += samples;
|
||||
mp_audio_realloc_min(ab->buffer, ab->buffer->samples);
|
||||
mp_audio_copy(ab->buffer, oldlen, ab->buffer, oldlen - samples, samples);
|
||||
}
|
||||
|
||||
// Get the start of the current readable buffer.
|
||||
void mp_audio_buffer_peek(struct mp_audio_buffer *ab, struct mp_audio *out_mpa)
|
||||
{
|
||||
|
||||
@@ -35,6 +35,7 @@ void mp_audio_buffer_get_write_buffer(struct mp_audio_buffer *ab, int minsamples
|
||||
void mp_audio_buffer_finish_write(struct mp_audio_buffer *ab, int samples);
|
||||
void mp_audio_buffer_append(struct mp_audio_buffer *ab, struct mp_audio *mpa);
|
||||
void mp_audio_buffer_prepend_silence(struct mp_audio_buffer *ab, int samples);
|
||||
void mp_audio_buffer_duplicate(struct mp_audio_buffer *ab, int samples);
|
||||
void mp_audio_buffer_peek(struct mp_audio_buffer *ab, struct mp_audio *out_mpa);
|
||||
void mp_audio_buffer_skip(struct mp_audio_buffer *ab, int samples);
|
||||
void mp_audio_buffer_clear(struct mp_audio_buffer *ab);
|
||||
|
||||
+11
-29
@@ -93,7 +93,7 @@ static const char *const std_layout_names[][2] = {
|
||||
{"7.1(alsa)", "fl-fr-bl-br-fc-lfe-sl-sr"}, // not in lavc
|
||||
{"7.1(wide)", "fl-fr-fc-lfe-bl-br-flc-frc"},
|
||||
{"7.1(wide-side)", "fl-fr-fc-lfe-flc-frc-sl-sr"},
|
||||
{"7.1(rear)", "fl-fr-fc-lfe-bl-br-sdl-sdr"},
|
||||
{"7.1(rear)", "fl-fr-fc-lfe-bl-br-sdl-sdr"}, // not in lavc
|
||||
{"octagonal", "fl-fr-fc-bl-br-bc-sl-sr"},
|
||||
{"downmix", "dl-dr"},
|
||||
{"auto", ""}, // not in lavc
|
||||
@@ -112,19 +112,6 @@ static const struct mp_chmap default_layouts[] = {
|
||||
MP_CHMAP8(FL, FR, FC, LFE, BL, BR, SL, SR), // 7.1
|
||||
};
|
||||
|
||||
// The channel order was lavc/waveex, but differs from lavc for 5, 6 and 8
|
||||
// channels. 3 and 7 channels were likely undefined (no ALSA support).
|
||||
// I'm not sure about the 4 channel case: ALSA uses "quad", while the ffmpeg
|
||||
// default layout is "4.0".
|
||||
static const char *const mplayer_layouts[MP_NUM_CHANNELS + 1] = {
|
||||
[1] = "mono",
|
||||
[2] = "stereo",
|
||||
[4] = "quad",
|
||||
[5] = "5.0(alsa)",
|
||||
[6] = "5.1(alsa)",
|
||||
[8] = "7.1(alsa)",
|
||||
};
|
||||
|
||||
// Returns true if speakers are mapped uniquely, and there's at least 1 channel.
|
||||
bool mp_chmap_is_valid(const struct mp_chmap *src)
|
||||
{
|
||||
@@ -227,19 +214,6 @@ void mp_chmap_from_channels(struct mp_chmap *dst, int num_channels)
|
||||
mp_chmap_set_unknown(dst, num_channels);
|
||||
}
|
||||
|
||||
// Try to do what mplayer/mplayer2/mpv did before channel layouts were
|
||||
// introduced, i.e. get the old default channel order.
|
||||
void mp_chmap_from_channels_alsa(struct mp_chmap *dst, int num_channels)
|
||||
{
|
||||
if (num_channels < 0 || num_channels > MP_NUM_CHANNELS) {
|
||||
*dst = (struct mp_chmap) {0};
|
||||
} else {
|
||||
mp_chmap_from_str(dst, bstr0(mplayer_layouts[num_channels]));
|
||||
if (!dst->num)
|
||||
mp_chmap_from_channels(dst, num_channels);
|
||||
}
|
||||
}
|
||||
|
||||
// Set *dst to an unknown layout for the given numbers of channels.
|
||||
// If the number of channels is invalid, an invalid map is set, and
|
||||
// mp_chmap_is_valid(dst) will return false.
|
||||
@@ -298,12 +272,18 @@ void mp_chmap_remove_useless_channels(struct mp_chmap *map,
|
||||
// Speakers not representable by ffmpeg/libav are dropped.
|
||||
// Warning: this ignores the order of the channels, and will return a channel
|
||||
// mask even if the order is different from libavcodec's.
|
||||
// Also, "unknown" channel maps are translated to non-sense channel
|
||||
// maps with the same number of channels.
|
||||
uint64_t mp_chmap_to_lavc_unchecked(const struct mp_chmap *src)
|
||||
{
|
||||
// lavc has no concept for unknown layouts yet, so pick a default
|
||||
struct mp_chmap t = *src;
|
||||
if (t.num > 64)
|
||||
return 0;
|
||||
// lavc has no concept for unknown layouts yet, so pick something that does
|
||||
// the job of signaling the number of channels, even if it makes no sense
|
||||
// as a proper layout.
|
||||
if (mp_chmap_is_unknown(&t))
|
||||
mp_chmap_from_channels(&t, t.num);
|
||||
return t.num == 64 ? (uint64_t)-1 : (1ULL << t.num) - 1;
|
||||
uint64_t mask = 0;
|
||||
for (int n = 0; n < t.num; n++) {
|
||||
if (t.speaker[n] < 64) // ignore MP_SPEAKER_ID_NA etc.
|
||||
@@ -359,6 +339,8 @@ bool mp_chmap_is_lavc(const struct mp_chmap *src)
|
||||
return true;
|
||||
}
|
||||
|
||||
// Warning: for "unknown" channel maps, this returns something that may not
|
||||
// make sense. Invalid channel maps are not changed.
|
||||
void mp_chmap_reorder_to_lavc(struct mp_chmap *map)
|
||||
{
|
||||
if (!mp_chmap_is_valid(map))
|
||||
|
||||
+1
-2
@@ -22,7 +22,7 @@
|
||||
#include <stdbool.h>
|
||||
#include "misc/bstr.h"
|
||||
|
||||
#define MP_NUM_CHANNELS 8
|
||||
#define MP_NUM_CHANNELS 16
|
||||
|
||||
// Speaker a channel can be assigned to.
|
||||
// This corresponds to WAVEFORMATEXTENSIBLE channel mask bit indexes.
|
||||
@@ -108,7 +108,6 @@ void mp_chmap_fill_na(struct mp_chmap *map, int num);
|
||||
|
||||
void mp_chmap_from_channels(struct mp_chmap *dst, int num_channels);
|
||||
void mp_chmap_set_unknown(struct mp_chmap *dst, int num_channels);
|
||||
void mp_chmap_from_channels_alsa(struct mp_chmap *dst, int num_channels);
|
||||
|
||||
void mp_chmap_remove_useless_channels(struct mp_chmap *map,
|
||||
const struct mp_chmap *requested);
|
||||
|
||||
+37
-20
@@ -20,6 +20,7 @@
|
||||
#include <limits.h>
|
||||
|
||||
#include "common/common.h"
|
||||
#include "common/msg.h"
|
||||
#include "chmap_sel.h"
|
||||
|
||||
static const struct mp_chmap speaker_replacements[][2] = {
|
||||
@@ -94,17 +95,6 @@ void mp_chmap_sel_add_waveext(struct mp_chmap_sel *s)
|
||||
s->allow_waveext = true;
|
||||
}
|
||||
|
||||
// Classic ALSA-based MPlayer layouts.
|
||||
void mp_chmap_sel_add_alsa_def(struct mp_chmap_sel *s)
|
||||
{
|
||||
for (int n = 1; n <= MP_NUM_CHANNELS; n++) {
|
||||
struct mp_chmap t;
|
||||
mp_chmap_from_channels_alsa(&t, n);
|
||||
if (t.num)
|
||||
mp_chmap_sel_add_map(s, &t);
|
||||
}
|
||||
}
|
||||
|
||||
// Add a channel map that should be allowed.
|
||||
void mp_chmap_sel_add_map(struct mp_chmap_sel *s, const struct mp_chmap *map)
|
||||
{
|
||||
@@ -284,19 +274,25 @@ static bool mp_chmap_is_better(struct mp_chmap *req, struct mp_chmap *old,
|
||||
if (new_lost_r != old_lost_r)
|
||||
return new_lost_r < old_lost_r;
|
||||
|
||||
int old_lost = mp_chmap_diffn(req, old);
|
||||
int new_lost = mp_chmap_diffn(req, new);
|
||||
|
||||
// If the situation is equal with replaced speakers, but one of them loses
|
||||
// less if no replacements are performed, pick the better one, even if it
|
||||
// means an upmix. This prefers exact supersets over inexact equivalents.
|
||||
if (new_lost != old_lost)
|
||||
return new_lost < old_lost;
|
||||
|
||||
struct mp_chmap old_p = *old, new_p = *new;
|
||||
mp_chmap_remove_na(&old_p);
|
||||
mp_chmap_remove_na(&new_p);
|
||||
|
||||
// If the situation is equal with replaced speakers, but the replacement is
|
||||
// perfect for only one of them, let the better one win. This prefers
|
||||
// inexact equivalents over exact supersets.
|
||||
bool perfect_r_new = !new_lost_r && new_p.num <= old_p.num;
|
||||
bool perfect_r_old = !old_lost_r && old_p.num <= new_p.num;
|
||||
if (perfect_r_new != perfect_r_old)
|
||||
return perfect_r_new;
|
||||
|
||||
int old_lost = mp_chmap_diffn(req, old);
|
||||
int new_lost = mp_chmap_diffn(req, new);
|
||||
// If the situation is equal with replaced speakers, pick the better one,
|
||||
// even if it means an upmix.
|
||||
if (new_lost != old_lost)
|
||||
return new_lost < old_lost;
|
||||
|
||||
// Some kind of upmix. If it's perfect, prefer the smaller one. Even if not,
|
||||
// both have equal loss, so also prefer the smaller one.
|
||||
// Drop padding channels (NA) for the sake of this check, as the number of
|
||||
@@ -357,3 +353,24 @@ bool mp_chmap_sel_get_def(const struct mp_chmap_sel *s, struct mp_chmap *map,
|
||||
}
|
||||
return map->num > 0;
|
||||
}
|
||||
|
||||
// Print the set of allowed channel layouts.
|
||||
void mp_chmal_sel_log(const struct mp_chmap_sel *s, struct mp_log *log, int lev)
|
||||
{
|
||||
if (!mp_msg_test(log, lev))
|
||||
return;
|
||||
|
||||
for (int i = 0; i < s->num_chmaps; i++)
|
||||
mp_msg(log, lev, " - %s\n", mp_chmap_to_str(&s->chmaps[i]));
|
||||
for (int i = 0; i < MP_SPEAKER_ID_COUNT; i++) {
|
||||
if (!s->speakers[i])
|
||||
continue;
|
||||
struct mp_chmap l = {.num = 1, .speaker = { i }};
|
||||
mp_msg(log, lev, " - #%s\n",
|
||||
i == MP_SPEAKER_ID_FC ? "fc" : mp_chmap_to_str_hr(&l));
|
||||
}
|
||||
if (s->allow_waveext)
|
||||
mp_msg(log, lev, " - waveext\n");
|
||||
if (s->allow_any)
|
||||
mp_msg(log, lev, " - anything\n");
|
||||
}
|
||||
+3
-1
@@ -37,7 +37,6 @@ struct mp_chmap_sel {
|
||||
void mp_chmap_sel_add_any(struct mp_chmap_sel *s);
|
||||
void mp_chmap_sel_add_waveext(struct mp_chmap_sel *s);
|
||||
void mp_chmap_sel_add_waveext_def(struct mp_chmap_sel *s);
|
||||
void mp_chmap_sel_add_alsa_def(struct mp_chmap_sel *s);
|
||||
void mp_chmap_sel_add_map(struct mp_chmap_sel *s, const struct mp_chmap *map);
|
||||
void mp_chmap_sel_add_speaker(struct mp_chmap_sel *s, int id);
|
||||
bool mp_chmap_sel_adjust(const struct mp_chmap_sel *s, struct mp_chmap *map);
|
||||
@@ -45,4 +44,7 @@ bool mp_chmap_sel_fallback(const struct mp_chmap_sel *s, struct mp_chmap *map);
|
||||
bool mp_chmap_sel_get_def(const struct mp_chmap_sel *s, struct mp_chmap *map,
|
||||
int num);
|
||||
|
||||
struct mp_log;
|
||||
void mp_chmal_sel_log(const struct mp_chmap_sel *s, struct mp_log *log, int lev);
|
||||
|
||||
#endif
|
||||
+20
-28
@@ -26,7 +26,7 @@
|
||||
#include <libavutil/common.h>
|
||||
#include <libavutil/intreadwrite.h>
|
||||
|
||||
#include "talloc.h"
|
||||
#include "mpv_talloc.h"
|
||||
|
||||
#include "config.h"
|
||||
#include "common/av_common.h"
|
||||
@@ -79,12 +79,12 @@ static int init(struct dec_audio *da, const char *decoder)
|
||||
AVCodecContext *lavc_context;
|
||||
AVCodec *lavc_codec;
|
||||
struct sh_stream *sh = da->header;
|
||||
struct sh_audio *sh_audio = sh->audio;
|
||||
struct mp_codec_params *c = sh->codec;
|
||||
|
||||
struct priv *ctx = talloc_zero(NULL, struct priv);
|
||||
da->priv = ctx;
|
||||
|
||||
ctx->force_channel_map = sh_audio->force_channels;
|
||||
ctx->force_channel_map = c->force_channels;
|
||||
|
||||
lavc_codec = avcodec_find_decoder_by_name(decoder);
|
||||
if (!lavc_codec) {
|
||||
@@ -116,20 +116,20 @@ static int init(struct dec_audio *da, const char *decoder)
|
||||
|
||||
mp_set_avopts(da->log, lavc_context, opts->avopts);
|
||||
|
||||
lavc_context->codec_tag = sh->codec_tag;
|
||||
lavc_context->sample_rate = sh_audio->samplerate;
|
||||
lavc_context->bit_rate = sh_audio->bitrate;
|
||||
lavc_context->block_align = sh_audio->block_align;
|
||||
lavc_context->bits_per_coded_sample = sh_audio->bits_per_coded_sample;
|
||||
lavc_context->channels = sh_audio->channels.num;
|
||||
if (!mp_chmap_is_unknown(&sh_audio->channels))
|
||||
lavc_context->channel_layout = mp_chmap_to_lavc(&sh_audio->channels);
|
||||
lavc_context->codec_tag = c->codec_tag;
|
||||
lavc_context->sample_rate = c->samplerate;
|
||||
lavc_context->bit_rate = c->bitrate;
|
||||
lavc_context->block_align = c->block_align;
|
||||
lavc_context->bits_per_coded_sample = c->bits_per_coded_sample;
|
||||
lavc_context->channels = c->channels.num;
|
||||
if (!mp_chmap_is_unknown(&c->channels))
|
||||
lavc_context->channel_layout = mp_chmap_to_lavc(&c->channels);
|
||||
|
||||
// demux_mkv
|
||||
mp_lavc_set_extradata(lavc_context, sh->extradata, sh->extradata_size);
|
||||
mp_lavc_set_extradata(lavc_context, c->extradata, c->extradata_size);
|
||||
|
||||
if (sh->lav_headers)
|
||||
mp_copy_lav_codec_headers(lavc_context, sh->lav_headers);
|
||||
if (c->lav_headers)
|
||||
mp_copy_lav_codec_headers(lavc_context, c->lav_headers);
|
||||
|
||||
mp_set_avcodec_threads(da->log, lavc_context, opts->threads);
|
||||
|
||||
@@ -191,12 +191,6 @@ static int decode_packet(struct dec_audio *da, struct mp_audio **out)
|
||||
AVPacket pkt;
|
||||
mp_set_av_packet(&pkt, mpkt, NULL);
|
||||
|
||||
// If we don't have a PTS yet, use the first packet PTS we can get.
|
||||
if (da->pts == MP_NOPTS_VALUE && mpkt && mpkt->pts != MP_NOPTS_VALUE) {
|
||||
da->pts = mpkt->pts;
|
||||
da->pts_offset = 0;
|
||||
}
|
||||
|
||||
int got_frame = 0;
|
||||
av_frame_unref(priv->avframe);
|
||||
int ret = avcodec_decode_audio4(avctx, priv->avframe, &got_frame, &pkt);
|
||||
@@ -225,10 +219,6 @@ static int decode_packet(struct dec_audio *da, struct mp_audio **out)
|
||||
return mpkt ? AD_OK : AD_EOF;
|
||||
|
||||
double out_pts = mp_pts_from_av(priv->avframe->pkt_pts, NULL);
|
||||
if (out_pts != MP_NOPTS_VALUE) {
|
||||
da->pts = out_pts;
|
||||
da->pts_offset = 0;
|
||||
}
|
||||
|
||||
struct mp_audio *mpframe = mp_audio_from_avframe(priv->avframe);
|
||||
if (!mpframe)
|
||||
@@ -238,12 +228,13 @@ static int decode_packet(struct dec_audio *da, struct mp_audio **out)
|
||||
if (lavc_chmap.num != avctx->channels)
|
||||
mp_chmap_from_channels(&lavc_chmap, avctx->channels);
|
||||
if (priv->force_channel_map) {
|
||||
struct sh_audio *sh_audio = da->header->audio;
|
||||
if (lavc_chmap.num == sh_audio->channels.num)
|
||||
lavc_chmap = sh_audio->channels;
|
||||
if (lavc_chmap.num == da->header->codec->channels.num)
|
||||
lavc_chmap = da->header->codec->channels;
|
||||
}
|
||||
mp_audio_set_channels(mpframe, &lavc_chmap);
|
||||
|
||||
mpframe->pts = out_pts;
|
||||
|
||||
#if HAVE_AVFRAME_SKIP_SAMPLES
|
||||
AVFrameSideData *sd =
|
||||
av_frame_get_side_data(priv->avframe, AV_FRAME_DATA_SKIP_SAMPLES);
|
||||
@@ -254,7 +245,8 @@ static int decode_packet(struct dec_audio *da, struct mp_audio **out)
|
||||
uint32_t skip = MPMIN(priv->skip_samples, mpframe->samples);
|
||||
if (skip) {
|
||||
mp_audio_skip_samples(mpframe, skip);
|
||||
da->pts_offset += skip;
|
||||
if (mpframe->pts != MP_NOPTS_VALUE)
|
||||
mpframe->pts += skip / (double)mpframe->rate;
|
||||
priv->skip_samples -= skip;
|
||||
}
|
||||
if (pad <= mpframe->samples)
|
||||
|
||||
@@ -253,13 +253,11 @@ static int decode_packet(struct dec_audio *da, struct mp_audio **out)
|
||||
if (!mpkt)
|
||||
return AD_EOF;
|
||||
|
||||
double pts = mpkt->pts;
|
||||
|
||||
AVPacket pkt;
|
||||
mp_set_av_packet(&pkt, mpkt, NULL);
|
||||
pkt.pts = pkt.dts = 0;
|
||||
if (mpkt->pts != MP_NOPTS_VALUE) {
|
||||
da->pts = mpkt->pts;
|
||||
da->pts_offset = 0;
|
||||
}
|
||||
if (!spdif_ctx->lavf_ctx) {
|
||||
if (init_filter(da, &pkt) < 0)
|
||||
return AD_ERR;
|
||||
@@ -276,6 +274,7 @@ static int decode_packet(struct dec_audio *da, struct mp_audio **out)
|
||||
return AD_ERR;
|
||||
|
||||
memcpy((*out)->planes[0], spdif_ctx->out_buffer, spdif_ctx->out_buffer_len);
|
||||
(*out)->pts = pts;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <math.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include <libavutil/mem.h>
|
||||
@@ -87,7 +88,7 @@ struct mp_decoder_list *audio_decoder_list(void)
|
||||
static struct mp_decoder_list *audio_select_decoders(struct dec_audio *d_audio)
|
||||
{
|
||||
struct MPOpts *opts = d_audio->opts;
|
||||
const char *codec = d_audio->header->codec;
|
||||
const char *codec = d_audio->header->codec->codec;
|
||||
|
||||
struct mp_decoder_list *list = audio_decoder_list();
|
||||
struct mp_decoder_list *new =
|
||||
@@ -145,7 +146,7 @@ int audio_init_best_codec(struct dec_audio *d_audio)
|
||||
MP_VERBOSE(d_audio, "Selected audio codec: %s\n", d_audio->decoder_desc);
|
||||
} else {
|
||||
MP_ERR(d_audio, "Failed to initialize an audio decoder for codec '%s'.\n",
|
||||
d_audio->header->codec ? d_audio->header->codec : "<unknown>");
|
||||
d_audio->header->codec->codec);
|
||||
}
|
||||
|
||||
talloc_free(list);
|
||||
@@ -170,14 +171,38 @@ static int decode_new_frame(struct dec_audio *da)
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
if (da->pts == MP_NOPTS_VALUE && da->header->missing_timestamps)
|
||||
da->pts = 0;
|
||||
|
||||
if (da->waiting) {
|
||||
if (da->waiting->pts != MP_NOPTS_VALUE) {
|
||||
if (da->pts != MP_NOPTS_VALUE) {
|
||||
da->pts += da->pts_offset / (double)da->waiting->rate;
|
||||
da->pts_offset = 0;
|
||||
}
|
||||
double newpts = da->waiting->pts;
|
||||
// Keep the interpolated timestamp if it doesn't deviate more
|
||||
// than 1 ms from the real one. (MKV rounded timestamps.)
|
||||
if (da->pts == MP_NOPTS_VALUE || da->pts_offset != 0 ||
|
||||
fabs(da->pts - newpts) > 0.001)
|
||||
{
|
||||
// Attempt to detect jumps in PTS. Even for the lowest
|
||||
// sample rates and with worst container rounded timestamp,
|
||||
// this should be a margin more than enough.
|
||||
if (da->pts != MP_NOPTS_VALUE && fabs(newpts - da->pts) > 0.1)
|
||||
{
|
||||
MP_WARN(da, "Invalid audio PTS: %f -> %f\n",
|
||||
da->pts, newpts);
|
||||
da->pts_reset = true;
|
||||
}
|
||||
da->pts = da->waiting->pts;
|
||||
da->pts_offset = 0;
|
||||
}
|
||||
}
|
||||
da->pts_offset += da->waiting->samples;
|
||||
da->decode_format = *da->waiting;
|
||||
mp_audio_set_null_data(&da->decode_format);
|
||||
}
|
||||
|
||||
if (da->pts == MP_NOPTS_VALUE && da->header->missing_timestamps)
|
||||
da->pts = 0;
|
||||
}
|
||||
return mp_audio_config_valid(da->waiting) ? AD_OK : AD_ERR;
|
||||
}
|
||||
@@ -259,6 +284,7 @@ void audio_reset_decoding(struct dec_audio *d_audio)
|
||||
af_seek_reset(d_audio->afilter);
|
||||
d_audio->pts = MP_NOPTS_VALUE;
|
||||
d_audio->pts_offset = 0;
|
||||
d_audio->pts_reset = false;
|
||||
if (d_audio->waiting) {
|
||||
talloc_free(d_audio->waiting);
|
||||
d_audio->waiting = NULL;
|
||||
|
||||
@@ -30,7 +30,7 @@ struct dec_audio {
|
||||
struct mp_log *log;
|
||||
struct MPOpts *opts;
|
||||
struct mpv_global *global;
|
||||
bool spdif_passthrough;
|
||||
bool spdif_passthrough, spdif_failed;
|
||||
const struct ad_functions *ad_driver;
|
||||
struct sh_stream *header;
|
||||
struct af_stream *afilter;
|
||||
@@ -45,6 +45,8 @@ struct dec_audio {
|
||||
double pts;
|
||||
// number of samples output by decoder after last known pts
|
||||
int pts_offset;
|
||||
// set every time a jump in timestamps is encountered
|
||||
bool pts_reset;
|
||||
// For free use by the ad_driver
|
||||
void *priv;
|
||||
};
|
||||
|
||||
+2
-1
@@ -461,7 +461,8 @@ static int af_reinit(struct af_stream *s)
|
||||
struct af_instance *aft = af->prev;
|
||||
af_remove(s, af);
|
||||
af = aft->next;
|
||||
break;
|
||||
retry++;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
goto negotiate_error;
|
||||
|
||||
@@ -49,7 +49,6 @@ const uint16_t ac3_bitrate_tab[19] = {
|
||||
typedef struct af_ac3enc_s {
|
||||
struct AVCodec *lavc_acodec;
|
||||
struct AVCodecContext *lavc_actx;
|
||||
AVPacket pkt;
|
||||
int bit_rate;
|
||||
struct mp_audio *input; // frame passed to libavcodec
|
||||
struct mp_audio *pending; // unconsumed input data
|
||||
@@ -146,7 +145,6 @@ static void uninit(struct af_instance* af)
|
||||
af_ac3enc_t *s = af->priv;
|
||||
|
||||
if (s) {
|
||||
av_free_packet(&s->pkt);
|
||||
if(s->lavc_actx) {
|
||||
avcodec_close(s->lavc_actx);
|
||||
av_free(s->lavc_actx);
|
||||
@@ -212,6 +210,8 @@ static int filter_out(struct af_instance *af)
|
||||
MP_FATAL(af, "Could not allocate memory \n");
|
||||
return -1;
|
||||
}
|
||||
int err = -1;
|
||||
|
||||
frame->nb_samples = s->in_samples;
|
||||
frame->format = s->lavc_actx->sample_fmt;
|
||||
frame->channel_layout = s->lavc_actx->channel_layout;
|
||||
@@ -221,30 +221,33 @@ static int filter_out(struct af_instance *af)
|
||||
frame->data[n] = s->input->planes[n];
|
||||
frame->linesize[0] = s->input->samples * s->input->sstride;
|
||||
|
||||
AVPacket pkt = {0};
|
||||
av_init_packet(&pkt);
|
||||
|
||||
int ok;
|
||||
int lavc_ret = avcodec_encode_audio2(s->lavc_actx, &s->pkt, frame, &ok);
|
||||
int lavc_ret = avcodec_encode_audio2(s->lavc_actx, &pkt, frame, &ok);
|
||||
av_frame_free(&frame);
|
||||
s->input->samples = 0;
|
||||
if (lavc_ret < 0 || !ok) {
|
||||
MP_FATAL(af, "Encode failed.\n");
|
||||
return -1;
|
||||
goto done;
|
||||
}
|
||||
|
||||
MP_DBG(af, "avcodec_encode_audio got %d, pending %d.\n",
|
||||
s->pkt.size, s->pending->samples);
|
||||
pkt.size, s->pending->samples);
|
||||
|
||||
struct mp_audio *out =
|
||||
mp_audio_pool_get(af->out_pool, af->data, s->out_samples);
|
||||
if (!out)
|
||||
return -1;
|
||||
goto done;
|
||||
mp_audio_copy_attributes(out, s->pending);
|
||||
|
||||
int frame_size = s->pkt.size;
|
||||
int frame_size = pkt.size;
|
||||
int header_len = 0;
|
||||
char hdr[8];
|
||||
|
||||
if (s->cfg_add_iec61937_header && s->pkt.size > 5) {
|
||||
int bsmod = s->pkt.data[5] & 0x7;
|
||||
if (s->cfg_add_iec61937_header && pkt.size > 5) {
|
||||
int bsmod = pkt.data[5] & 0x7;
|
||||
int len = frame_size;
|
||||
|
||||
frame_size = AC3_FRAME_SIZE * 2 * 2;
|
||||
@@ -262,14 +265,18 @@ static int filter_out(struct af_instance *af)
|
||||
|
||||
char *buf = (char *)out->planes[0];
|
||||
memcpy(buf, hdr, header_len);
|
||||
memcpy(buf + header_len, s->pkt.data, s->pkt.size);
|
||||
memset(buf + header_len + s->pkt.size, 0,
|
||||
frame_size - (header_len + s->pkt.size));
|
||||
swap_16((uint16_t *)(buf + header_len), s->pkt.size / 2);
|
||||
memcpy(buf + header_len, pkt.data, pkt.size);
|
||||
memset(buf + header_len + pkt.size, 0,
|
||||
frame_size - (header_len + pkt.size));
|
||||
swap_16((uint16_t *)(buf + header_len), pkt.size / 2);
|
||||
out->samples = frame_size / out->sstride;
|
||||
af_add_output_frame(af, out);
|
||||
update_delay(af);
|
||||
return 0;
|
||||
|
||||
err = 0;
|
||||
done:
|
||||
av_packet_unref(&pkt);
|
||||
return err;
|
||||
}
|
||||
|
||||
static int af_open(struct af_instance* af){
|
||||
@@ -307,8 +314,6 @@ static int af_open(struct af_instance* af){
|
||||
MP_VERBOSE(af, "[af_lavcac3enc]: in sample format: %s\n",
|
||||
af_fmt_to_str(s->in_sampleformat));
|
||||
|
||||
av_init_packet(&s->pkt);
|
||||
|
||||
s->input = talloc_zero(s, struct mp_audio);
|
||||
|
||||
if (s->cfg_bit_rate) {
|
||||
|
||||
@@ -195,6 +195,10 @@ static int control(struct af_instance *af, int cmd, void *arg)
|
||||
if (af_to_avformat(in->format) == AV_SAMPLE_FMT_NONE)
|
||||
mp_audio_set_format(in, AF_FORMAT_FLOAT);
|
||||
|
||||
// Removing this requires fixing AVFrame.data vs. AVFrame.extended_data
|
||||
if (in->channels.num > AV_NUM_DATA_POINTERS)
|
||||
return AF_ERROR;
|
||||
|
||||
if (!mp_chmap_is_lavc(&in->channels))
|
||||
mp_chmap_reorder_to_lavc(&in->channels); // will always work
|
||||
|
||||
@@ -211,7 +215,7 @@ static int control(struct af_instance *af, int cmd, void *arg)
|
||||
mp_chmap_from_lavc(&out_cm, l_out->channel_layout);
|
||||
mp_audio_set_channels(out, &out_cm);
|
||||
|
||||
if (!mp_audio_config_valid(out))
|
||||
if (!mp_audio_config_valid(out) || out->channels.num > AV_NUM_DATA_POINTERS)
|
||||
return AF_ERROR;
|
||||
|
||||
p->timebase_out = l_out->time_base;
|
||||
@@ -349,8 +353,6 @@ static int af_open(struct af_instance *af)
|
||||
af->uninit = uninit;
|
||||
af->filter_frame = filter_frame;
|
||||
af->filter_out = filter_out;
|
||||
// Removing this requires fixing AVFrame.data vs. AVFrame.extended_data
|
||||
assert(MP_NUM_CHANNELS <= AV_NUM_DATA_POINTERS);
|
||||
return AF_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -49,6 +49,7 @@
|
||||
#define avresample_convert(ctx, out, out_planesize, out_samples, in, in_planesize, in_samples) \
|
||||
swr_convert(ctx, out, out_samples, (const uint8_t**)(in), in_samples)
|
||||
#define avresample_set_channel_mapping swr_set_channel_mapping
|
||||
#define avresample_set_compensation swr_set_compensation
|
||||
#else
|
||||
#error "config.h broken or no resampler found"
|
||||
#endif
|
||||
@@ -304,14 +305,15 @@ static int configure_lavrr(struct af_instance *af, struct mp_audio *in,
|
||||
av_opt_set_int(s->avrctx, "in_sample_fmt", in_samplefmt, 0);
|
||||
av_opt_set_int(s->avrctx, "out_sample_fmt", out_samplefmtp, 0);
|
||||
|
||||
// Just needs the correct number of channels.
|
||||
int fake_out_ch_layout = av_get_default_channel_layout(map_out.num);
|
||||
// Just needs the correct number of channels for deplanarization.
|
||||
struct mp_chmap fake_chmap;
|
||||
mp_chmap_set_unknown(&fake_chmap, map_out.num);
|
||||
uint64_t fake_out_ch_layout = mp_chmap_to_lavc_unchecked(&fake_chmap);
|
||||
if (!fake_out_ch_layout)
|
||||
goto error;
|
||||
|
||||
// Deplanarize if needed.
|
||||
av_opt_set_int(s->avrctx_out, "in_channel_layout", fake_out_ch_layout, 0);
|
||||
av_opt_set_int(s->avrctx_out, "out_channel_layout", fake_out_ch_layout, 0);
|
||||
|
||||
av_opt_set_int(s->avrctx_out, "in_sample_fmt", out_samplefmtp, 0);
|
||||
av_opt_set_int(s->avrctx_out, "out_sample_fmt", out_samplefmt, 0);
|
||||
av_opt_set_int(s->avrctx_out, "in_sample_rate", s->out_rate, 0);
|
||||
@@ -386,14 +388,6 @@ static int control(struct af_instance *af, int cmd, void *arg)
|
||||
return AF_OK;
|
||||
case AF_CONTROL_SET_PLAYBACK_SPEED_RESAMPLE: {
|
||||
s->playback_speed = *(double *)arg;
|
||||
int new_rate = rate_from_speed(s->in_rate_af, s->playback_speed);
|
||||
if (new_rate != s->in_rate && s->avrctx && af->fmt_out.format) {
|
||||
// Before reconfiguring, drain the audio that is still buffered
|
||||
// in the resampler.
|
||||
af->filter_frame(af, NULL);
|
||||
// Reinitialize resampler.
|
||||
configure_lavrr(af, &af->fmt_in, &af->fmt_out, false);
|
||||
}
|
||||
return AF_OK;
|
||||
}
|
||||
case AF_CONTROL_RESET:
|
||||
@@ -429,6 +423,18 @@ static void extra_output_conversion(struct af_instance *af, struct mp_audio *mpa
|
||||
}
|
||||
mp_audio_set_format(mpa, AF_FORMAT_S24);
|
||||
}
|
||||
|
||||
for (int p = 0; p < mpa->num_planes; p++) {
|
||||
void *ptr = mpa->planes[p];
|
||||
int total = mpa->samples * mpa->spf;
|
||||
if (af_fmt_from_planar(mpa->format) == AF_FORMAT_FLOAT) {
|
||||
for (int s = 0; s < total; s++)
|
||||
((float *)ptr)[s] = av_clipf(((float *)ptr)[s], -1.0f, 1.0f);
|
||||
} else if (af_fmt_from_planar(mpa->format) == AF_FORMAT_DOUBLE) {
|
||||
for (int s = 0; s < total; s++)
|
||||
((double *)ptr)[s] = MPCLAMP(((double *)ptr)[s], -1.0, 1.0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// This relies on the tricky way mpa was allocated.
|
||||
@@ -455,7 +461,7 @@ static void reorder_planes(struct mp_audio *mpa, int *reorder,
|
||||
}
|
||||
}
|
||||
|
||||
static int filter(struct af_instance *af, struct mp_audio *in)
|
||||
static int filter_resample(struct af_instance *af, struct mp_audio *in)
|
||||
{
|
||||
struct af_resample *s = af->priv;
|
||||
|
||||
@@ -516,6 +522,39 @@ error:
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int filter(struct af_instance *af, struct mp_audio *in)
|
||||
{
|
||||
struct af_resample *s = af->priv;
|
||||
|
||||
int new_rate = rate_from_speed(s->in_rate_af, s->playback_speed);
|
||||
bool need_reinit = fabs(new_rate / (double)s->in_rate - 1) > 0.01;
|
||||
|
||||
if (s->avrctx) {
|
||||
AVRational r = av_d2q(s->playback_speed * s->in_rate_af / s->in_rate,
|
||||
INT_MAX / 2);
|
||||
// Essentially, swr/avresample_set_compensation() does 2 things:
|
||||
// - adjust output sample rate by sample_delta/compensation_distance
|
||||
// - reset the adjustment after compensation_distance output samples
|
||||
// Increase the compensation_distance to avoid undesired reset
|
||||
// semantics - we want to keep the ratio for the whole frame we're
|
||||
// feeding it, until the next filter() call.
|
||||
int mult = INT_MAX / 2 / MPMAX(MPMAX(abs(r.num), abs(r.den)), 1);
|
||||
r = (AVRational){ r.num * mult, r.den * mult };
|
||||
if (avresample_set_compensation(s->avrctx, r.den - r.num, r.den) < 0)
|
||||
need_reinit = true;
|
||||
}
|
||||
|
||||
if (need_reinit && new_rate != s->in_rate) {
|
||||
// Before reconfiguring, drain the audio that is still buffered
|
||||
// in the resampler.
|
||||
filter_resample(af, NULL);
|
||||
// Reinitialize resampler.
|
||||
configure_lavrr(af, &af->fmt_in, &af->fmt_out, false);
|
||||
}
|
||||
|
||||
return filter_resample(af, in);
|
||||
}
|
||||
|
||||
static int af_open(struct af_instance *af)
|
||||
{
|
||||
struct af_resample *s = af->priv;
|
||||
|
||||
@@ -286,9 +286,6 @@ static void update_speed(struct af_instance *af, float speed)
|
||||
|
||||
s->frames_stride_scaled = s->scale * s->frames_stride;
|
||||
s->frames_stride_error = MPMIN(s->frames_stride_error, s->frames_stride_scaled);
|
||||
|
||||
MP_VERBOSE(af, "%.3f speed * %.3f scale_nominal = %.3f\n",
|
||||
s->speed, s->scale_nominal, s->scale);
|
||||
}
|
||||
|
||||
// Initialization and runtime control
|
||||
|
||||
+1
-1
@@ -51,7 +51,7 @@ int af_fmt_change_bytes(int format, int bytes)
|
||||
if (af_fmt_to_bytes(fmt) == bytes &&
|
||||
af_fmt_is_float(fmt) == af_fmt_is_float(format) &&
|
||||
af_fmt_is_planar(fmt) == af_fmt_is_planar(format) &&
|
||||
af_fmt_is_spdif(fmt) == af_fmt_is_spdif(format))
|
||||
(fmt == format || (!af_fmt_is_spdif(fmt) && !af_fmt_is_spdif(format))))
|
||||
return fmt;
|
||||
}
|
||||
return 0;
|
||||
|
||||
+10
-5
@@ -27,7 +27,7 @@
|
||||
#include "audio/filter/af.h"
|
||||
#include "common/global.h"
|
||||
#include "common/msg.h"
|
||||
#include "talloc.h"
|
||||
#include "mpv_talloc.h"
|
||||
#include "mixer.h"
|
||||
|
||||
struct mixer {
|
||||
@@ -120,8 +120,11 @@ void mixer_getvolume(struct mixer *mixer, float *l, float *r)
|
||||
*r = mixer->vol_r;
|
||||
}
|
||||
|
||||
static void setvolume_internal(struct mixer *mixer, float l, float r)
|
||||
static void setvolume_internal(struct mixer *mixer)
|
||||
{
|
||||
float l = mixer->vol_l, r = mixer->vol_r;
|
||||
if (mixer->emulate_mute && mixer->muted)
|
||||
l = r = 0;
|
||||
if (!mixer->softvol) {
|
||||
MP_DBG(mixer, "Setting volume on AO.\n");
|
||||
struct ao_control_vol vol = {.left = l, .right = r};
|
||||
@@ -147,8 +150,8 @@ void mixer_setvolume(struct mixer *mixer, float l, float r)
|
||||
float max = mixer_getmaxvolume(mixer);
|
||||
mixer->vol_l = MPCLAMP(l, 0, max);
|
||||
mixer->vol_r = MPCLAMP(r, 0, max);
|
||||
if (mixer->ao && !(mixer->emulate_mute && mixer->muted))
|
||||
setvolume_internal(mixer, mixer->vol_l, mixer->vol_r);
|
||||
if (mixer->ao)
|
||||
setvolume_internal(mixer);
|
||||
}
|
||||
|
||||
void mixer_getbothvolume(struct mixer *mixer, float *b)
|
||||
@@ -167,7 +170,7 @@ void mixer_setmute(struct mixer *mixer, bool mute)
|
||||
mixer->muted = mute;
|
||||
mixer->muted_by_us = mute;
|
||||
if (mixer->emulate_mute) {
|
||||
setvolume_internal(mixer, mixer->vol_l*!mute, mixer->vol_r*!mute);
|
||||
setvolume_internal(mixer);
|
||||
} else {
|
||||
ao_control(mixer->ao, AOCONTROL_SET_MUTE, &mute);
|
||||
}
|
||||
@@ -293,6 +296,8 @@ static void restore_volume(struct mixer *mixer)
|
||||
|
||||
const char *prev_driver = mixer->driver;
|
||||
mixer->driver = mixer->softvol ? "softvol" : ao_get_name(ao);
|
||||
if (!prev_driver[0])
|
||||
prev_driver = mixer->driver;
|
||||
|
||||
// Restore old parameters if volume won't survive reinitialization.
|
||||
// But not if volume scale is possibly different.
|
||||
|
||||
+59
-56
@@ -20,7 +20,7 @@
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "talloc.h"
|
||||
#include "mpv_talloc.h"
|
||||
|
||||
#include "config.h"
|
||||
#include "ao.h"
|
||||
@@ -45,7 +45,6 @@ extern const struct ao_driver audio_out_jack;
|
||||
extern const struct ao_driver audio_out_openal;
|
||||
extern const struct ao_driver audio_out_null;
|
||||
extern const struct ao_driver audio_out_alsa;
|
||||
extern const struct ao_driver audio_out_dsound;
|
||||
extern const struct ao_driver audio_out_wasapi;
|
||||
extern const struct ao_driver audio_out_pcm;
|
||||
extern const struct ao_driver audio_out_lavc;
|
||||
@@ -65,9 +64,6 @@ static const struct ao_driver * const audio_out_drivers[] = {
|
||||
#if HAVE_WASAPI
|
||||
&audio_out_wasapi,
|
||||
#endif
|
||||
#if HAVE_DSOUND
|
||||
&audio_out_dsound,
|
||||
#endif
|
||||
#if HAVE_OSS_AUDIO
|
||||
&audio_out_oss,
|
||||
#endif
|
||||
@@ -240,6 +236,7 @@ static void split_ao_device(void *tmp, char *opt, char **out_ao, char **out_dev)
|
||||
}
|
||||
|
||||
struct ao *ao_init_best(struct mpv_global *global,
|
||||
bool ao_null_fallback,
|
||||
struct input_ctx *input_ctx,
|
||||
struct encode_lavc_context *encode_lavc_ctx,
|
||||
int samplerate, int format, struct mp_chmap channels)
|
||||
@@ -248,58 +245,67 @@ struct ao *ao_init_best(struct mpv_global *global,
|
||||
void *tmp = talloc_new(NULL);
|
||||
struct mp_log *log = mp_log_new(tmp, global->log, "ao");
|
||||
struct ao *ao = NULL;
|
||||
struct m_obj_settings *ao_list = opts->audio_driver_list;
|
||||
struct m_obj_settings *ao_list = NULL;
|
||||
int ao_num = 0;
|
||||
|
||||
for (int n = 0; opts->audio_driver_list && opts->audio_driver_list[n].name; n++)
|
||||
MP_TARRAY_APPEND(tmp, ao_list, ao_num, opts->audio_driver_list[n]);
|
||||
|
||||
bool forced_dev = false;
|
||||
char *pref_ao, *pref_dev;
|
||||
split_ao_device(tmp, opts->audio_device, &pref_ao, &pref_dev);
|
||||
if (!(ao_list && ao_list[0].name) && pref_ao) {
|
||||
if (!ao_num && pref_ao) {
|
||||
// Reuse the autoselection code
|
||||
ao_list = talloc_zero_array(tmp, struct m_obj_settings, 2);
|
||||
ao_list[0].name = pref_ao;
|
||||
MP_TARRAY_APPEND(tmp, ao_list, ao_num,
|
||||
(struct m_obj_settings){.name = pref_ao});
|
||||
forced_dev = true;
|
||||
}
|
||||
|
||||
if (ao_list && ao_list[0].name) {
|
||||
for (int n = 0; ao_list[n].name; n++) {
|
||||
if (strlen(ao_list[n].name) == 0)
|
||||
goto autoprobe;
|
||||
mp_verbose(log, "Trying preferred audio driver '%s'\n",
|
||||
ao_list[n].name);
|
||||
char *dev = NULL;
|
||||
if (pref_ao && strcmp(ao_list[n].name, pref_ao) == 0)
|
||||
dev = pref_dev;
|
||||
if (dev)
|
||||
mp_verbose(log, "Using preferred device '%s'\n", dev);
|
||||
ao = ao_init(false, global, input_ctx, encode_lavc_ctx,
|
||||
samplerate, format, channels, dev,
|
||||
ao_list[n].name, ao_list[n].attribs);
|
||||
if (ao)
|
||||
goto done;
|
||||
mp_err(log, "Failed to initialize audio driver '%s'\n",
|
||||
ao_list[n].name);
|
||||
if (forced_dev) {
|
||||
mp_err(log, "This audio driver/device was forced with the "
|
||||
"--audio-device option.\n"
|
||||
"Try unsetting it.\n");
|
||||
}
|
||||
bool autoprobe = ao_num == 0;
|
||||
|
||||
// Something like "--ao=a,b," means do autoprobing after a and b fail.
|
||||
if (ao_num && strlen(ao_list[ao_num - 1].name) == 0) {
|
||||
ao_num -= 1;
|
||||
autoprobe = true;
|
||||
}
|
||||
|
||||
if (autoprobe) {
|
||||
for (int n = 0; audio_out_drivers[n]; n++) {
|
||||
const struct ao_driver *driver = audio_out_drivers[n];
|
||||
if (driver == &audio_out_null)
|
||||
break;
|
||||
MP_TARRAY_APPEND(tmp, ao_list, ao_num,
|
||||
(struct m_obj_settings){.name = (char *)driver->name});
|
||||
}
|
||||
goto done;
|
||||
}
|
||||
|
||||
autoprobe: ;
|
||||
// now try the rest...
|
||||
for (int i = 0; audio_out_drivers[i]; i++) {
|
||||
const struct ao_driver *driver = audio_out_drivers[i];
|
||||
if (driver == &audio_out_null)
|
||||
break;
|
||||
ao = ao_init(true, global, input_ctx, encode_lavc_ctx, samplerate,
|
||||
format, channels, NULL, (char *)driver->name, NULL);
|
||||
if (ao_null_fallback) {
|
||||
MP_TARRAY_APPEND(tmp, ao_list, ao_num,
|
||||
(struct m_obj_settings){.name = "null"});
|
||||
}
|
||||
|
||||
for (int n = 0; n < ao_num; n++) {
|
||||
struct m_obj_settings *entry = &ao_list[n];
|
||||
bool probing = n + 1 != ao_num;
|
||||
mp_verbose(log, "Trying audio driver '%s'\n", entry->name);
|
||||
char *dev = NULL;
|
||||
if (pref_ao && pref_dev && strcmp(entry->name, pref_ao) == 0) {
|
||||
dev = pref_dev;
|
||||
mp_verbose(log, "Using preferred device '%s'\n", dev);
|
||||
}
|
||||
ao = ao_init(probing, global, input_ctx, encode_lavc_ctx,
|
||||
samplerate, format, channels, dev,
|
||||
entry->name, entry->attribs);
|
||||
if (ao)
|
||||
goto done;
|
||||
break;
|
||||
if (!probing)
|
||||
mp_err(log, "Failed to initialize audio driver '%s'\n", entry->name);
|
||||
if (dev && forced_dev) {
|
||||
mp_err(log, "This audio driver/device was forced with the "
|
||||
"--audio-device option.\nTry unsetting it.\n");
|
||||
}
|
||||
}
|
||||
|
||||
done:
|
||||
talloc_free(tmp);
|
||||
return ao;
|
||||
}
|
||||
@@ -411,18 +417,11 @@ void ao_hotplug_event(struct ao *ao)
|
||||
bool ao_chmap_sel_adjust(struct ao *ao, const struct mp_chmap_sel *s,
|
||||
struct mp_chmap *map)
|
||||
{
|
||||
if (mp_msg_test(ao->log, MSGL_DEBUG)) {
|
||||
for (int i = 0; i < s->num_chmaps; i++) {
|
||||
struct mp_chmap c = s->chmaps[i];
|
||||
MP_DBG(ao, "chmap_sel #%d: %s (%s)\n", i, mp_chmap_to_str(&c),
|
||||
mp_chmap_to_str_hr(&c));
|
||||
}
|
||||
}
|
||||
MP_VERBOSE(ao, "Channel layouts:\n");
|
||||
mp_chmal_sel_log(s, ao->log, MSGL_V);
|
||||
bool r = mp_chmap_sel_adjust(s, map);
|
||||
if (r) {
|
||||
MP_DBG(ao, "result: %s (%s)\n", mp_chmap_to_str(map),
|
||||
mp_chmap_to_str_hr(map));
|
||||
}
|
||||
if (r)
|
||||
MP_VERBOSE(ao, "result: %s\n", mp_chmap_to_str(map));
|
||||
return r;
|
||||
}
|
||||
|
||||
@@ -490,8 +489,12 @@ static void get_devices(struct ao *ao, struct ao_device_list *list)
|
||||
if (ao->driver->list_devs)
|
||||
ao->driver->list_devs(ao, list);
|
||||
// Add at least a default entry
|
||||
if (list->num_devices == num)
|
||||
ao_device_list_add(list, ao, &(struct ao_device_desc){"", "Default"});
|
||||
if (list->num_devices == num) {
|
||||
char name[80] = "Default";
|
||||
if (num > 1)
|
||||
mp_snprintf_cat(name, sizeof(name), " (%s)", ao->driver->name);
|
||||
ao_device_list_add(list, ao, &(struct ao_device_desc){"", name});
|
||||
}
|
||||
}
|
||||
|
||||
bool ao_hotplug_check_update(struct ao_hotplug *hp)
|
||||
|
||||
@@ -72,6 +72,7 @@ struct encode_lavc_context;
|
||||
struct mp_audio;
|
||||
|
||||
struct ao *ao_init_best(struct mpv_global *global,
|
||||
bool ao_null_fallback,
|
||||
struct input_ctx *input_ctx,
|
||||
struct encode_lavc_context *encode_lavc_ctx,
|
||||
int samplerate, int format, struct mp_chmap channels);
|
||||
|
||||
+281
-202
@@ -50,12 +50,13 @@
|
||||
|
||||
struct priv {
|
||||
snd_pcm_t *alsa;
|
||||
bool device_lost;
|
||||
snd_pcm_format_t alsa_fmt;
|
||||
int can_pause;
|
||||
bool can_pause;
|
||||
snd_pcm_sframes_t prepause_frames;
|
||||
double delay_before_pause;
|
||||
int buffersize; // in frames
|
||||
int outburst; // in frames
|
||||
snd_pcm_uframes_t buffersize;
|
||||
snd_pcm_uframes_t outburst;
|
||||
|
||||
char *cfg_device;
|
||||
char *cfg_mixer_device;
|
||||
@@ -83,6 +84,21 @@ struct priv {
|
||||
MP_WARN(ao, "%s: %s\n", (message), snd_strerror(err)); \
|
||||
} while (0)
|
||||
|
||||
// Common code for handling ENODEV, which happens if a device gets "lost", and
|
||||
// can't be used anymore. Returns true if alsa_err is not ENODEV.
|
||||
static bool check_device_present(struct ao *ao, int alsa_err)
|
||||
{
|
||||
struct priv *p = ao->priv;
|
||||
if (alsa_err != -ENODEV)
|
||||
return true;
|
||||
if (!p->device_lost) {
|
||||
MP_WARN(ao, "Device lost, trying to recover...\n");
|
||||
ao_request_reload(ao);
|
||||
p->device_lost = true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static int control(struct ao *ao, enum aocontrol cmd, void *arg)
|
||||
{
|
||||
struct priv *p = ao->priv;
|
||||
@@ -211,24 +227,19 @@ static const int mp_to_alsa_format[][2] = {
|
||||
MP_SELECT_LE_BE(SND_PCM_FORMAT_S24_3LE, SND_PCM_FORMAT_S24_3BE)},
|
||||
{AF_FORMAT_FLOAT, SND_PCM_FORMAT_FLOAT},
|
||||
{AF_FORMAT_DOUBLE, SND_PCM_FORMAT_FLOAT64},
|
||||
{AF_FORMAT_S_MP3, SND_PCM_FORMAT_MPEG},
|
||||
{AF_FORMAT_UNKNOWN, SND_PCM_FORMAT_UNKNOWN},
|
||||
};
|
||||
|
||||
static int find_alsa_format(int af_format)
|
||||
{
|
||||
if (af_fmt_is_spdif(af_format)) {
|
||||
if (af_format == AF_FORMAT_S_MP3) {
|
||||
return SND_PCM_FORMAT_MPEG;
|
||||
} else {
|
||||
return SND_PCM_FORMAT_S16;
|
||||
}
|
||||
}
|
||||
|
||||
af_format = af_fmt_from_planar(af_format);
|
||||
for (int n = 0; mp_to_alsa_format[n][0] != AF_FORMAT_UNKNOWN; n++) {
|
||||
if (mp_to_alsa_format[n][0] == af_format)
|
||||
return mp_to_alsa_format[n][1];
|
||||
}
|
||||
if (af_fmt_is_spdif(af_format))
|
||||
return SND_PCM_FORMAT_S16;
|
||||
return SND_PCM_FORMAT_UNKNOWN;
|
||||
}
|
||||
|
||||
@@ -259,6 +270,7 @@ static const int alsa_to_mp_channels[][2] = {
|
||||
{SND_CHMAP_RLC, MP_SP(SDL)},
|
||||
{SND_CHMAP_MONO, MP_SP(FC)},
|
||||
{SND_CHMAP_NA, MP_SPEAKER_ID_NA},
|
||||
{SND_CHMAP_UNKNOWN, MP_SPEAKER_ID_NA},
|
||||
{SND_CHMAP_LAST, MP_SPEAKER_ID_COUNT}
|
||||
};
|
||||
|
||||
@@ -272,28 +284,48 @@ static int find_mp_channel(int alsa_channel)
|
||||
return MP_SPEAKER_ID_COUNT;
|
||||
}
|
||||
|
||||
static int find_alsa_channel(int mp_channel)
|
||||
{
|
||||
for (int i = 0; alsa_to_mp_channels[i][1] != MP_SPEAKER_ID_COUNT; i++) {
|
||||
if (alsa_to_mp_channels[i][1] == mp_channel)
|
||||
return alsa_to_mp_channels[i][0];
|
||||
}
|
||||
#define CHMAP(n, ...) &(struct mp_chmap) MP_CONCAT(MP_CHMAP, n) (__VA_ARGS__)
|
||||
|
||||
return SND_CHMAP_UNKNOWN;
|
||||
// Replace each channel in a with b (a->num == b->num)
|
||||
static void replace_submap(struct mp_chmap *dst, struct mp_chmap *a,
|
||||
struct mp_chmap *b)
|
||||
{
|
||||
struct mp_chmap t = *dst;
|
||||
if (!mp_chmap_is_valid(&t) || mp_chmap_diffn(a, &t) != 0)
|
||||
return;
|
||||
assert(a->num == b->num);
|
||||
for (int n = 0; n < t.num; n++) {
|
||||
for (int i = 0; i < a->num; i++) {
|
||||
if (t.speaker[n] == a->speaker[i]) {
|
||||
t.speaker[n] = b->speaker[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (mp_chmap_is_valid(&t))
|
||||
*dst = t;
|
||||
}
|
||||
|
||||
static int mp_chmap_from_alsa(struct mp_chmap *dst, snd_pcm_chmap_t *src)
|
||||
static bool mp_chmap_from_alsa(struct mp_chmap *dst, snd_pcm_chmap_t *src)
|
||||
{
|
||||
*dst = (struct mp_chmap) {0};
|
||||
|
||||
if (src->channels > MP_NUM_CHANNELS)
|
||||
return -1;
|
||||
return false;
|
||||
|
||||
dst->num = src->channels;
|
||||
for (int c = 0; c < dst->num; c++)
|
||||
dst->speaker[c] = find_mp_channel(src->pos[c]);
|
||||
|
||||
return 0;
|
||||
// Assume anything with 1 channel is mono.
|
||||
if (dst->num == 1)
|
||||
dst->speaker[0] = MP_SP(FC);
|
||||
|
||||
// Remap weird Intel HDA HDMI 7.1 layouts correctly.
|
||||
replace_submap(dst, CHMAP(6, FL, FR, BL, BR, SDL, SDR),
|
||||
CHMAP(6, FL, FR, SL, SR, BL, BR));
|
||||
|
||||
return mp_chmap_is_valid(dst);
|
||||
}
|
||||
|
||||
static bool query_chmaps(struct ao *ao, struct mp_chmap *chmap)
|
||||
@@ -306,20 +338,21 @@ static bool query_chmaps(struct ao *ao, struct mp_chmap *chmap)
|
||||
return false;
|
||||
|
||||
for (int i = 0; maps[i] != NULL; i++) {
|
||||
struct mp_chmap entry;
|
||||
mp_chmap_from_alsa(&entry, &maps[i]->map);
|
||||
char aname[128];
|
||||
if (snd_pcm_chmap_print(&maps[i]->map, sizeof(aname), aname) <= 0)
|
||||
aname[0] = '\0';
|
||||
|
||||
if (mp_chmap_is_valid(&entry)) {
|
||||
struct mp_chmap entry;
|
||||
if (mp_chmap_from_alsa(&entry, &maps[i]->map)) {
|
||||
struct mp_chmap reorder = entry;
|
||||
if (maps[i]->type == SND_CHMAP_TYPE_VAR)
|
||||
mp_chmap_reorder_norm(&entry);
|
||||
MP_VERBOSE(ao, "Got supported channel map: %s (type %s)\n",
|
||||
mp_chmap_to_str(&entry),
|
||||
snd_pcm_chmap_type_name(maps[i]->type));
|
||||
mp_chmap_sel_add_map(&chmap_sel, &entry);
|
||||
mp_chmap_reorder_norm(&reorder);
|
||||
MP_DBG(ao, "Got supported channel map: %s (type %s) -> %s -> %s\n",
|
||||
aname, snd_pcm_chmap_type_name(maps[i]->type),
|
||||
mp_chmap_to_str(&entry), mp_chmap_to_str(&reorder));
|
||||
mp_chmap_sel_add_map(&chmap_sel, &reorder);
|
||||
} else {
|
||||
char tmp[128];
|
||||
if (snd_pcm_chmap_print(&maps[i]->map, sizeof(tmp), tmp) > 0)
|
||||
MP_VERBOSE(ao, "skipping unknown ALSA channel map: %s\n", tmp);
|
||||
MP_VERBOSE(ao, "skipping unknown ALSA channel map: %s\n", aname);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -328,6 +361,108 @@ static bool query_chmaps(struct ao *ao, struct mp_chmap *chmap)
|
||||
return ao_chmap_sel_adjust(ao, &chmap_sel, chmap);
|
||||
}
|
||||
|
||||
// Map back our selected channel layout to an ALSA one. This is done this way so
|
||||
// that our ALSA->mp_chmap mapping function only has to go one way.
|
||||
// The return value is to be freed with free().
|
||||
static snd_pcm_chmap_t *map_back_chmap(struct ao *ao, struct mp_chmap *chmap)
|
||||
{
|
||||
struct priv *p = ao->priv;
|
||||
if (!mp_chmap_is_valid(chmap))
|
||||
return NULL;
|
||||
|
||||
snd_pcm_chmap_query_t **maps = snd_pcm_query_chmaps(p->alsa);
|
||||
if (!maps)
|
||||
return NULL;
|
||||
|
||||
snd_pcm_chmap_t *alsa_chmap = NULL;
|
||||
|
||||
for (int i = 0; maps[i] != NULL; i++) {
|
||||
struct mp_chmap entry;
|
||||
if (!mp_chmap_from_alsa(&entry, &maps[i]->map))
|
||||
continue;
|
||||
|
||||
if (mp_chmap_equals(chmap, &entry) ||
|
||||
(mp_chmap_equals_reordered(chmap, &entry) &&
|
||||
maps[i]->type == SND_CHMAP_TYPE_VAR))
|
||||
{
|
||||
alsa_chmap = calloc(1, sizeof(*alsa_chmap) +
|
||||
sizeof(alsa_chmap->pos[0]) * entry.num);
|
||||
if (!alsa_chmap)
|
||||
break;
|
||||
alsa_chmap->channels = entry.num;
|
||||
|
||||
// Undo if mp_chmap_reorder() was called on the result.
|
||||
int reorder[MP_NUM_CHANNELS];
|
||||
mp_chmap_get_reorder(reorder, chmap, &entry);
|
||||
for (int n = 0; n < entry.num; n++)
|
||||
alsa_chmap->pos[n] = maps[i]->map.pos[reorder[n]];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
snd_pcm_free_chmaps(maps);
|
||||
return alsa_chmap;
|
||||
}
|
||||
|
||||
|
||||
static int set_chmap(struct ao *ao, struct mp_chmap *dev_chmap, int num_channels)
|
||||
{
|
||||
struct priv *p = ao->priv;
|
||||
int err;
|
||||
|
||||
snd_pcm_chmap_t *alsa_chmap = map_back_chmap(ao, dev_chmap);
|
||||
if (alsa_chmap) {
|
||||
char tmp[128];
|
||||
if (snd_pcm_chmap_print(alsa_chmap, sizeof(tmp), tmp) > 0)
|
||||
MP_VERBOSE(ao, "trying to set ALSA channel map: %s\n", tmp);
|
||||
|
||||
err = snd_pcm_set_chmap(p->alsa, alsa_chmap);
|
||||
if (err == -ENXIO) {
|
||||
// A device my not be able to set any channel map, even channel maps
|
||||
// that were reported as supported. This is either because the ALSA
|
||||
// device is broken (dmix), or because the driver has only 1
|
||||
// channel map per channel count, and setting the map is not needed.
|
||||
MP_VERBOSE(ao, "device returned ENXIO when setting channel map %s\n",
|
||||
mp_chmap_to_str(dev_chmap));
|
||||
} else {
|
||||
CHECK_ALSA_WARN("Channel map setup failed");
|
||||
}
|
||||
|
||||
free(alsa_chmap);
|
||||
}
|
||||
|
||||
alsa_chmap = snd_pcm_get_chmap(p->alsa);
|
||||
if (alsa_chmap) {
|
||||
char tmp[128];
|
||||
if (snd_pcm_chmap_print(alsa_chmap, sizeof(tmp), tmp) > 0)
|
||||
MP_VERBOSE(ao, "channel map reported by ALSA: %s\n", tmp);
|
||||
|
||||
struct mp_chmap chmap;
|
||||
mp_chmap_from_alsa(&chmap, alsa_chmap);
|
||||
|
||||
MP_VERBOSE(ao, "which we understand as: %s\n", mp_chmap_to_str(&chmap));
|
||||
|
||||
if (p->cfg_ignore_chmap) {
|
||||
MP_VERBOSE(ao, "user set ignore-chmap; ignoring the channel map.\n");
|
||||
} else if (af_fmt_is_spdif(ao->format)) {
|
||||
MP_VERBOSE(ao, "using spdif passthrough; ignoring the channel map.\n");
|
||||
} else if (!mp_chmap_is_valid(&chmap)) {
|
||||
MP_WARN(ao, "Got unknown channel map from ALSA.\n");
|
||||
} else if (chmap.num != num_channels) {
|
||||
MP_WARN(ao, "ALSA channel map conflicts with channel count!\n");
|
||||
} else {
|
||||
MP_VERBOSE(ao, "using the ALSA channel map.\n");
|
||||
if (mp_chmap_equals(&chmap, &ao->channels))
|
||||
MP_VERBOSE(ao, "which is what we requested.\n");
|
||||
ao->channels = chmap;
|
||||
}
|
||||
|
||||
free(alsa_chmap);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#else /* HAVE_CHMAP_API */
|
||||
|
||||
static bool query_chmaps(struct ao *ao, struct mp_chmap *chmap)
|
||||
@@ -335,6 +470,11 @@ static bool query_chmaps(struct ao *ao, struct mp_chmap *chmap)
|
||||
return false;
|
||||
}
|
||||
|
||||
static int set_chmap(struct ao *ao, struct mp_chmap *dev_chmap, int num_channels)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* else HAVE_CHMAP_API */
|
||||
|
||||
static int map_iec958_srate(int srate)
|
||||
@@ -355,8 +495,8 @@ static int map_iec958_srate(int srate)
|
||||
}
|
||||
|
||||
// ALSA device strings can have parameters. They are usually appended to the
|
||||
// device name. Since there can be various forms, and we (sometimes) want to
|
||||
// append them to unknown device strings, which possibly already include params.
|
||||
// device name. There can be various forms, and we (sometimes) want to append
|
||||
// them to unknown device strings, which possibly already include params.
|
||||
static char *append_params(void *ta_parent, const char *device, const char *p)
|
||||
{
|
||||
if (!p || !p[0])
|
||||
@@ -427,16 +567,14 @@ static void uninit(struct ao *ao)
|
||||
int err;
|
||||
|
||||
err = snd_pcm_close(p->alsa);
|
||||
p->alsa = NULL;
|
||||
CHECK_ALSA_ERROR("pcm close error");
|
||||
}
|
||||
|
||||
alsa_error: ;
|
||||
}
|
||||
|
||||
#define INIT_OK 0
|
||||
#define INIT_ERROR -1
|
||||
#define INIT_BRAINDEATH -2
|
||||
static int init_device(struct ao *ao, bool second_try)
|
||||
static int init_device(struct ao *ao)
|
||||
{
|
||||
struct priv *p = ao->priv;
|
||||
int err;
|
||||
@@ -454,31 +592,18 @@ static int init_device(struct ao *ao, bool second_try)
|
||||
CHECK_ALSA_WARN("Unable to set blocking mode");
|
||||
|
||||
snd_pcm_hw_params_t *alsa_hwparams;
|
||||
snd_pcm_sw_params_t *alsa_swparams;
|
||||
|
||||
snd_pcm_hw_params_alloca(&alsa_hwparams);
|
||||
snd_pcm_sw_params_alloca(&alsa_swparams);
|
||||
|
||||
err = snd_pcm_hw_params_any(p->alsa, alsa_hwparams);
|
||||
CHECK_ALSA_ERROR("Unable to get initial parameters");
|
||||
|
||||
int try_formats[AF_FORMAT_COUNT];
|
||||
af_get_best_sample_formats(ao->format, try_formats);
|
||||
for (int n = 0; try_formats[n]; n++) {
|
||||
ao->format = try_formats[n];
|
||||
p->alsa_fmt = find_alsa_format(ao->format);
|
||||
if (snd_pcm_hw_params_test_format(p->alsa, alsa_hwparams, p->alsa_fmt) >= 0)
|
||||
break;
|
||||
// Some ALSA drivers have broken delay reporting, so disable the ALSA
|
||||
// resampling plugin by default.
|
||||
if (!p->cfg_resample) {
|
||||
err = snd_pcm_hw_params_set_rate_resample(p->alsa, alsa_hwparams, 0);
|
||||
CHECK_ALSA_ERROR("Unable to disable resampling");
|
||||
}
|
||||
|
||||
if (!ao->format) {
|
||||
MP_ERR(ao, "Can't find appropriate sample format.\n");
|
||||
goto alsa_error;
|
||||
}
|
||||
|
||||
err = snd_pcm_hw_params_set_format(p->alsa, alsa_hwparams, p->alsa_fmt);
|
||||
CHECK_ALSA_ERROR("Unable to set format");
|
||||
|
||||
snd_pcm_access_t access = af_fmt_is_planar(ao->format)
|
||||
? SND_PCM_ACCESS_RW_NONINTERLEAVED
|
||||
: SND_PCM_ACCESS_RW_INTERLEAVED;
|
||||
@@ -490,6 +615,29 @@ static int init_device(struct ao *ao, bool second_try)
|
||||
}
|
||||
CHECK_ALSA_ERROR("Unable to set access type");
|
||||
|
||||
bool found_format = false;
|
||||
int try_formats[AF_FORMAT_COUNT];
|
||||
af_get_best_sample_formats(ao->format, try_formats);
|
||||
for (int n = 0; try_formats[n]; n++) {
|
||||
if (af_fmt_is_planar(ao->format) != af_fmt_is_planar(try_formats[n]))
|
||||
continue; // implied SND_PCM_ACCESS mismatches
|
||||
p->alsa_fmt = find_alsa_format(try_formats[n]);
|
||||
MP_VERBOSE(ao, "trying format %s\n", af_fmt_to_str(try_formats[n]));
|
||||
if (snd_pcm_hw_params_test_format(p->alsa, alsa_hwparams, p->alsa_fmt) >= 0) {
|
||||
ao->format = try_formats[n];
|
||||
found_format = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!found_format) {
|
||||
MP_ERR(ao, "Can't find appropriate sample format.\n");
|
||||
goto alsa_error;
|
||||
}
|
||||
|
||||
err = snd_pcm_hw_params_set_format(p->alsa, alsa_hwparams, p->alsa_fmt);
|
||||
CHECK_ALSA_ERROR("Unable to set format");
|
||||
|
||||
struct mp_chmap dev_chmap = ao->channels;
|
||||
if (af_fmt_is_spdif(ao->format) || p->cfg_ignore_chmap) {
|
||||
dev_chmap.num = 0; // disable chmap API
|
||||
@@ -514,157 +662,51 @@ static int init_device(struct ao *ao, bool second_try)
|
||||
goto alsa_error;
|
||||
}
|
||||
|
||||
if (num_channels != ao->channels.num) {
|
||||
int req = ao->channels.num;
|
||||
mp_chmap_from_channels_alsa(&ao->channels, num_channels);
|
||||
if (!mp_chmap_is_valid(&ao->channels))
|
||||
mp_chmap_from_channels(&ao->channels, 2);
|
||||
MP_ERR(ao, "Asked for %d channels, got %d - fallback to %s.\n", req,
|
||||
num_channels, mp_chmap_to_str(&ao->channels));
|
||||
}
|
||||
|
||||
// Some ALSA drivers have broken delay reporting, so disable the ALSA
|
||||
// resampling plugin by default.
|
||||
if (!p->cfg_resample) {
|
||||
err = snd_pcm_hw_params_set_rate_resample(p->alsa, alsa_hwparams, 0);
|
||||
CHECK_ALSA_ERROR("Unable to disable resampling");
|
||||
}
|
||||
|
||||
err = snd_pcm_hw_params_set_rate_near
|
||||
(p->alsa, alsa_hwparams, &ao->samplerate, NULL);
|
||||
CHECK_ALSA_ERROR("Unable to set samplerate-2");
|
||||
|
||||
snd_pcm_hw_params_t *hwparams_backup;
|
||||
snd_pcm_hw_params_alloca(&hwparams_backup);
|
||||
snd_pcm_hw_params_copy(hwparams_backup, alsa_hwparams);
|
||||
|
||||
// Cargo-culted buffer settings; might still be useful for PulseAudio.
|
||||
err = snd_pcm_hw_params_set_buffer_time_near
|
||||
(p->alsa, alsa_hwparams, &(unsigned int){BUFFER_TIME}, NULL);
|
||||
CHECK_ALSA_WARN("Unable to set buffer time near");
|
||||
|
||||
err = snd_pcm_hw_params_set_periods_near
|
||||
(p->alsa, alsa_hwparams, &(unsigned int){FRAGCOUNT}, NULL);
|
||||
CHECK_ALSA_WARN("Unable to set periods");
|
||||
if (err >= 0) {
|
||||
err = snd_pcm_hw_params_set_periods_near
|
||||
(p->alsa, alsa_hwparams, &(unsigned int){FRAGCOUNT}, NULL);
|
||||
CHECK_ALSA_WARN("Unable to set periods");
|
||||
}
|
||||
if (err < 0)
|
||||
snd_pcm_hw_params_copy(alsa_hwparams, hwparams_backup);
|
||||
|
||||
/* finally install hardware parameters */
|
||||
err = snd_pcm_hw_params(p->alsa, alsa_hwparams);
|
||||
CHECK_ALSA_ERROR("Unable to set hw-parameters");
|
||||
|
||||
/* end setting hw-params */
|
||||
if (set_chmap(ao, &dev_chmap, num_channels) < 0)
|
||||
goto alsa_error;
|
||||
|
||||
#if HAVE_CHMAP_API
|
||||
if (mp_chmap_is_valid(&dev_chmap)) {
|
||||
snd_pcm_chmap_t *alsa_chmap =
|
||||
calloc(1, sizeof(*alsa_chmap) +
|
||||
sizeof(alsa_chmap->pos[0]) * dev_chmap.num);
|
||||
if (!alsa_chmap)
|
||||
goto alsa_error;
|
||||
|
||||
alsa_chmap->channels = dev_chmap.num;
|
||||
for (int c = 0; c < dev_chmap.num; c++)
|
||||
alsa_chmap->pos[c] = find_alsa_channel(dev_chmap.speaker[c]);
|
||||
|
||||
// mpv and ALSA use different conventions for mono
|
||||
if (dev_chmap.num == 1 && dev_chmap.speaker[0] == MP_SP(FC))
|
||||
alsa_chmap->pos[0] = SND_CHMAP_MONO;
|
||||
|
||||
char tmp[128];
|
||||
if (snd_pcm_chmap_print(alsa_chmap, sizeof(tmp), tmp) > 0)
|
||||
MP_VERBOSE(ao, "trying to set ALSA channel map: %s\n", tmp);
|
||||
|
||||
err = snd_pcm_set_chmap(p->alsa, alsa_chmap);
|
||||
if (err == -ENXIO) {
|
||||
// A device my not be able to set any channel map, even channel maps
|
||||
// that were reported as supported. This is either because the ALSA
|
||||
// device is broken (dmix), or because the driver has only 1
|
||||
// channel map per channel count, and setting the map is not needed.
|
||||
MP_VERBOSE(ao, "device returned ENXIO when setting channel map %s\n",
|
||||
mp_chmap_to_str(&dev_chmap));
|
||||
} else {
|
||||
CHECK_ALSA_WARN("Channel map setup failed");
|
||||
}
|
||||
|
||||
free(alsa_chmap);
|
||||
if (num_channels != ao->channels.num) {
|
||||
int req = ao->channels.num;
|
||||
mp_chmap_from_channels(&ao->channels, MPMIN(2, num_channels));
|
||||
MP_ERR(ao, "Asked for %d channels, got %d - fallback to %s.\n", req,
|
||||
num_channels, mp_chmap_to_str(&ao->channels));
|
||||
}
|
||||
|
||||
snd_pcm_chmap_t *alsa_chmap = snd_pcm_get_chmap(p->alsa);
|
||||
if (alsa_chmap) {
|
||||
char tmp[128];
|
||||
if (snd_pcm_chmap_print(alsa_chmap, sizeof(tmp), tmp) > 0)
|
||||
MP_VERBOSE(ao, "channel map reported by ALSA: %s\n", tmp);
|
||||
|
||||
struct mp_chmap chmap;
|
||||
mp_chmap_from_alsa(&chmap, alsa_chmap);
|
||||
|
||||
MP_VERBOSE(ao, "which we understand as: %s\n", mp_chmap_to_str(&chmap));
|
||||
|
||||
if (p->cfg_ignore_chmap) {
|
||||
MP_VERBOSE(ao, "user set ignore-chmap; ignoring the channel map.\n");
|
||||
} else if (af_fmt_is_spdif(ao->format)) {
|
||||
MP_VERBOSE(ao, "using spdif passthrough; ignoring the channel map.\n");
|
||||
} else if (mp_chmap_is_valid(&chmap)) {
|
||||
// Is it one that contains NA channels?
|
||||
struct mp_chmap without_na = chmap;
|
||||
mp_chmap_remove_na(&without_na);
|
||||
|
||||
if (mp_chmap_is_valid(&without_na) &&
|
||||
!mp_chmap_equals(&without_na, &chmap) &&
|
||||
!mp_chmap_equals(&chmap, &ao->channels) &&
|
||||
!second_try)
|
||||
{
|
||||
// Sometimes, ALSA will advertise certain chmaps, but it's not
|
||||
// possible to set them. This can happen with dmix: as of
|
||||
// alsa 1.0.28, dmix can do stereo only, but advertises the
|
||||
// surround chmaps of the underlying device. In this case,
|
||||
// e.g. setting 6 channels will succeed, but requesting 5.1
|
||||
// afterwards will fail. Then it will return something like
|
||||
// "FL FR NA NA NA NA" as channel map. This means we would
|
||||
// have to pad stereo output to 6 channels with silence, which
|
||||
// would require lots of extra processing. You can't change
|
||||
// the number of channels to 2 either, because the hw params
|
||||
// are already set! So just fuck it and reopen the device with
|
||||
// the chmap "cleaned out" of NA entries.
|
||||
MP_VERBOSE(ao, "Working around braindead ALSA behavior.\n");
|
||||
err = snd_pcm_close(p->alsa);
|
||||
p->alsa = NULL;
|
||||
CHECK_ALSA_ERROR("pcm close error");
|
||||
ao->channels = without_na;
|
||||
return INIT_BRAINDEATH;
|
||||
}
|
||||
|
||||
if (mp_chmap_equals(&chmap, &ao->channels)) {
|
||||
MP_VERBOSE(ao, "which is what we requested.\n");
|
||||
} else if (chmap.num == ao->channels.num) {
|
||||
MP_VERBOSE(ao, "using the ALSA channel map.\n");
|
||||
ao->channels = chmap;
|
||||
} else {
|
||||
MP_WARN(ao, "ALSA channel map conflicts with channel count!\n");
|
||||
}
|
||||
} else {
|
||||
MP_WARN(ao, "Got unknown channel map from ALSA.\n");
|
||||
}
|
||||
|
||||
// mpv and ALSA use different conventions for mono
|
||||
if (ao->channels.num == 1) {
|
||||
MP_VERBOSE(ao, "assuming we actually got MONO from ALSA.\n");
|
||||
ao->channels.speaker[0] = MP_SP(FC);
|
||||
}
|
||||
|
||||
free(alsa_chmap);
|
||||
}
|
||||
#endif
|
||||
|
||||
snd_pcm_uframes_t bufsize;
|
||||
err = snd_pcm_hw_params_get_buffer_size(alsa_hwparams, &bufsize);
|
||||
err = snd_pcm_hw_params_get_buffer_size(alsa_hwparams, &p->buffersize);
|
||||
CHECK_ALSA_ERROR("Unable to get buffersize");
|
||||
|
||||
p->buffersize = bufsize;
|
||||
MP_VERBOSE(ao, "got buffersize=%i samples\n", p->buffersize);
|
||||
|
||||
snd_pcm_uframes_t chunk_size;
|
||||
err = snd_pcm_hw_params_get_period_size(alsa_hwparams, &chunk_size, NULL);
|
||||
err = snd_pcm_hw_params_get_period_size(alsa_hwparams, &p->outburst, NULL);
|
||||
CHECK_ALSA_ERROR("Unable to get period size");
|
||||
|
||||
MP_VERBOSE(ao, "got period size %li\n", chunk_size);
|
||||
p->outburst = chunk_size;
|
||||
p->can_pause = snd_pcm_hw_params_can_pause(alsa_hwparams);
|
||||
|
||||
snd_pcm_sw_params_t *alsa_swparams;
|
||||
snd_pcm_sw_params_alloca(&alsa_swparams);
|
||||
|
||||
/* setting software parameters */
|
||||
err = snd_pcm_sw_params_current(p->alsa, alsa_swparams);
|
||||
CHECK_ALSA_ERROR("Unable to get sw-parameters");
|
||||
|
||||
@@ -674,7 +716,7 @@ static int init_device(struct ao *ao, bool second_try)
|
||||
|
||||
/* start playing when one period has been written */
|
||||
err = snd_pcm_sw_params_set_start_threshold
|
||||
(p->alsa, alsa_swparams, chunk_size);
|
||||
(p->alsa, alsa_swparams, p->outburst);
|
||||
CHECK_ALSA_ERROR("Unable to set start threshold");
|
||||
|
||||
/* disable underrun reporting */
|
||||
@@ -690,15 +732,15 @@ static int init_device(struct ao *ao, bool second_try)
|
||||
err = snd_pcm_sw_params(p->alsa, alsa_swparams);
|
||||
CHECK_ALSA_ERROR("Unable to set sw-parameters");
|
||||
|
||||
/* end setting sw-params */
|
||||
MP_VERBOSE(ao, "hw pausing supported: %s\n", p->can_pause ? "yes" : "no");
|
||||
MP_VERBOSE(ao, "buffersize: %d samples\n", (int)p->buffersize);
|
||||
MP_VERBOSE(ao, "period size: %d samples\n", (int)p->outburst);
|
||||
|
||||
p->can_pause = snd_pcm_hw_params_can_pause(alsa_hwparams);
|
||||
|
||||
return INIT_OK;
|
||||
return 0;
|
||||
|
||||
alsa_error:
|
||||
uninit(ao);
|
||||
return INIT_ERROR;
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int init(struct ao *ao)
|
||||
@@ -709,10 +751,33 @@ static int init(struct ao *ao)
|
||||
|
||||
MP_VERBOSE(ao, "using ALSA version: %s\n", snd_asoundlib_version());
|
||||
|
||||
int r = init_device(ao, false);
|
||||
if (r == INIT_BRAINDEATH)
|
||||
r = init_device(ao, true); // retry with normalized channel layout
|
||||
return r == INIT_OK ? 0 : -1;
|
||||
int r = init_device(ao);
|
||||
|
||||
// Sometimes, ALSA will advertise certain chmaps, but it's not possible to
|
||||
// set them. This can happen with dmix: as of alsa 1.0.29, dmix can do
|
||||
// stereo only, but advertises the surround chmaps of the underlying device.
|
||||
// In this case, e.g. setting 6 channels will succeed, but requesting 5.1
|
||||
// afterwards will fail. Then it will return something like "FL FR NA NA NA NA"
|
||||
// as channel map. This means we would have to pad stereo output to 6
|
||||
// channels with silence, which would require lots of extra processing. You
|
||||
// can't change the number of channels to 2 either, because the hw params
|
||||
// are already set! So just fuck it and reopen the device with the chmap
|
||||
// "cleaned out" of NA entries.
|
||||
if (r >= 0) {
|
||||
struct mp_chmap without_na = ao->channels;
|
||||
mp_chmap_remove_na(&without_na);
|
||||
|
||||
if (mp_chmap_is_valid(&without_na) && without_na.num <= 2 &&
|
||||
ao->channels.num > 2)
|
||||
{
|
||||
MP_VERBOSE(ao, "Working around braindead dmix multichannel behavior.\n");
|
||||
uninit(ao);
|
||||
ao->channels = without_na;
|
||||
r = init_device(ao);
|
||||
}
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
static void drain(struct ao *ao)
|
||||
@@ -730,6 +795,8 @@ static int get_space(struct ao *ao)
|
||||
snd_pcm_status_alloca(&status);
|
||||
|
||||
err = snd_pcm_status(p->alsa, status);
|
||||
if (!check_device_present(ao, err))
|
||||
goto alsa_error;
|
||||
CHECK_ALSA_ERROR("cannot get pcm status");
|
||||
|
||||
unsigned space = snd_pcm_status_get_avail(status);
|
||||
@@ -773,7 +840,6 @@ static void audio_pause(struct ao *ao)
|
||||
CHECK_ALSA_ERROR("pcm pause error");
|
||||
}
|
||||
} else {
|
||||
MP_VERBOSE(ao, "pause not supported by hardware\n");
|
||||
if (snd_pcm_delay(p->alsa, &p->prepause_frames) < 0
|
||||
|| p->prepause_frames < 0)
|
||||
p->prepause_frames = 0;
|
||||
@@ -856,9 +922,8 @@ static int play(struct ao *ao, void **data, int samples, int flags)
|
||||
|
||||
if (res == -EINTR || res == -EAGAIN) { /* retry */
|
||||
res = 0;
|
||||
} else if (res == -ENODEV) {
|
||||
MP_WARN(ao, "Device lost, trying to recover...\n");
|
||||
ao_request_reload(ao);
|
||||
} else if (!check_device_present(ao, res)) {
|
||||
goto alsa_error;
|
||||
} else if (res < 0) {
|
||||
if (res == -ESTRPIPE) { /* suspend */
|
||||
resume_device(ao);
|
||||
@@ -912,6 +977,20 @@ alsa_error:
|
||||
return -1;
|
||||
}
|
||||
|
||||
static bool is_useless_device(char *name)
|
||||
{
|
||||
char *crap[] = {"front", "rear", "center_lfe", "side", "surround21",
|
||||
"surround40", "surround41", "surround50", "surround51", "surround71",
|
||||
"sysdefault", "pulse", "null", "dsnoop", "dmix", "hw", "iec958"};
|
||||
for (int i = 0; i < MP_ARRAY_SIZE(crap); i++) {
|
||||
int l = strlen(crap[i]);
|
||||
if (name && strncmp(name, crap[i], l) == 0 &&
|
||||
(!name[l] || name[l] == ':'))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static void list_devs(struct ao *ao, struct ao_device_list *list)
|
||||
{
|
||||
void **hints;
|
||||
@@ -922,7 +1001,7 @@ static void list_devs(struct ao *ao, struct ao_device_list *list)
|
||||
char *name = snd_device_name_get_hint(hints[n], "NAME");
|
||||
char *desc = snd_device_name_get_hint(hints[n], "DESC");
|
||||
char *io = snd_device_name_get_hint(hints[n], "IOID");
|
||||
if (io && strcmp(io, "Output") == 0) {
|
||||
if (!is_useless_device(name) && (!io || strcmp(io, "Output") == 0)) {
|
||||
char desc2[1024];
|
||||
snprintf(desc2, sizeof(desc2), "%s", desc ? desc : "");
|
||||
for (int i = 0; desc2[i]; i++) {
|
||||
|
||||
@@ -180,6 +180,8 @@ static void init_physical_format(struct ao *ao)
|
||||
struct priv *p = ao->priv;
|
||||
OSErr err;
|
||||
|
||||
void *tmp = talloc_new(NULL);
|
||||
|
||||
AudioStreamBasicDescription asbd;
|
||||
ca_fill_asbd(ao, &asbd);
|
||||
|
||||
@@ -190,6 +192,8 @@ static void init_physical_format(struct ao *ao)
|
||||
&streams, &n_streams);
|
||||
CHECK_CA_ERROR("could not get number of streams");
|
||||
|
||||
talloc_steal(tmp, streams);
|
||||
|
||||
MP_VERBOSE(ao, "Found %zd substream(s).\n", n_streams);
|
||||
|
||||
for (int i = 0; i < n_streams; i++) {
|
||||
@@ -204,6 +208,7 @@ static void init_physical_format(struct ao *ao)
|
||||
if (!CHECK_CA_WARN("could not get number of stream formats"))
|
||||
continue; // try next one
|
||||
|
||||
talloc_steal(tmp, formats);
|
||||
|
||||
uint32_t direction;
|
||||
err = CA_GET(streams[i], kAudioStreamPropertyDirection, &direction);
|
||||
@@ -232,6 +237,12 @@ static void init_physical_format(struct ao *ao)
|
||||
&p->original_asbd);
|
||||
CHECK_CA_WARN("could not get current physical stream format");
|
||||
|
||||
if (ca_asbd_equals(&p->original_asbd, &best_asbd)) {
|
||||
MP_VERBOSE(ao, "Requested format already set, not changing.\n");
|
||||
p->original_asbd.mFormatID = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!ca_change_physical_format_sync(ao, streams[i], best_asbd))
|
||||
p->original_asbd = (AudioStreamBasicDescription){0};
|
||||
break;
|
||||
@@ -239,6 +250,7 @@ static void init_physical_format(struct ao *ao)
|
||||
}
|
||||
|
||||
coreaudio_error:
|
||||
talloc_free(tmp);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -372,8 +384,8 @@ static int hotplug_init(struct ao *ao)
|
||||
err = AudioObjectAddPropertyListener(
|
||||
kAudioObjectSystemObject, &addr, hotplug_cb, (void *)ao);
|
||||
if (err != noErr) {
|
||||
char *c1 = fourcc_repr(hotplug_properties[i]);
|
||||
char *c2 = fourcc_repr(err);
|
||||
char *c1 = mp_tag_str(hotplug_properties[i]);
|
||||
char *c2 = mp_tag_str(err);
|
||||
MP_ERR(ao, "failed to set device listener %s (%s)", c1, c2);
|
||||
goto coreaudio_error;
|
||||
}
|
||||
@@ -397,8 +409,8 @@ static void hotplug_uninit(struct ao *ao)
|
||||
err = AudioObjectRemovePropertyListener(
|
||||
kAudioObjectSystemObject, &addr, hotplug_cb, (void *)ao);
|
||||
if (err != noErr) {
|
||||
char *c1 = fourcc_repr(hotplug_properties[i]);
|
||||
char *c2 = fourcc_repr(err);
|
||||
char *c1 = mp_tag_str(hotplug_properties[i]);
|
||||
char *c2 = mp_tag_str(err);
|
||||
MP_ERR(ao, "failed to set device listener %s (%s)", c1, c2);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -98,6 +98,9 @@ static AudioChannelLayout *ca_layout_to_custom_layout(struct ao *ao,
|
||||
AudioChannelLayout *r;
|
||||
OSStatus err;
|
||||
|
||||
if (tag == kAudioChannelLayoutTag_UseChannelDescriptions)
|
||||
return l;
|
||||
|
||||
if (tag == kAudioChannelLayoutTag_UseChannelBitmap) {
|
||||
uint32_t psize;
|
||||
err = AudioFormatGetPropertyInfo(
|
||||
@@ -109,7 +112,7 @@ static AudioChannelLayout *ca_layout_to_custom_layout(struct ao *ao,
|
||||
kAudioFormatProperty_ChannelLayoutForBitmap,
|
||||
sizeof(uint32_t), &l->mChannelBitmap, &psize, r);
|
||||
CHECK_CA_ERROR("failed to convert channel bitmap to descriptions (get)");
|
||||
} else if (tag != kAudioChannelLayoutTag_UseChannelDescriptions) {
|
||||
} else {
|
||||
uint32_t psize;
|
||||
err = AudioFormatGetPropertyInfo(
|
||||
kAudioFormatProperty_ChannelLayoutForTag,
|
||||
@@ -120,10 +123,11 @@ static AudioChannelLayout *ca_layout_to_custom_layout(struct ao *ao,
|
||||
kAudioFormatProperty_ChannelLayoutForTag,
|
||||
sizeof(AudioChannelLayoutTag), &l->mChannelLayoutTag, &psize, r);
|
||||
CHECK_CA_ERROR("failed to convert channel tag to descriptions (get)");
|
||||
} else {
|
||||
r = l;
|
||||
}
|
||||
|
||||
MP_VERBOSE(ao, "converted input channel layout:\n");
|
||||
ca_log_layout(ao, MSGL_V, l);
|
||||
|
||||
return r;
|
||||
coreaudio_error:
|
||||
return NULL;
|
||||
@@ -134,22 +138,20 @@ static bool ca_layout_to_mp_chmap(struct ao *ao, AudioChannelLayout *layout,
|
||||
{
|
||||
void *talloc_ctx = talloc_new(NULL);
|
||||
|
||||
MP_DBG(ao, "input channel layout:\n");
|
||||
ca_log_layout(ao, MSGL_DEBUG, layout);
|
||||
MP_VERBOSE(ao, "input channel layout:\n");
|
||||
ca_log_layout(ao, MSGL_V, layout);
|
||||
|
||||
AudioChannelLayout *l = ca_layout_to_custom_layout(ao, talloc_ctx, layout);
|
||||
if (!l)
|
||||
goto coreaudio_error;
|
||||
|
||||
MP_VERBOSE(ao, "converted input channel layout:\n");
|
||||
ca_log_layout(ao, MSGL_V, l);
|
||||
|
||||
if (l->mNumberChannelDescriptions > MP_NUM_CHANNELS) {
|
||||
MP_VERBOSE(ao, "layout has too many descriptions (%u, max: %d)\n",
|
||||
(unsigned) l->mNumberChannelDescriptions, MP_NUM_CHANNELS);
|
||||
return false;
|
||||
}
|
||||
|
||||
chmap->num = l->mNumberChannelDescriptions;
|
||||
for (int n = 0; n < l->mNumberChannelDescriptions; n++) {
|
||||
AudioChannelLabel label = l->mChannelDescriptions[n].mChannelLabel;
|
||||
int speaker = ca_label_to_mp_speaker_id(label);
|
||||
@@ -157,14 +159,13 @@ static bool ca_layout_to_mp_chmap(struct ao *ao, AudioChannelLayout *layout,
|
||||
MP_VERBOSE(ao, "channel label=%u unusable to build channel "
|
||||
"bitmap, skipping layout\n", (unsigned) label);
|
||||
goto coreaudio_error;
|
||||
} else {
|
||||
chmap->speaker[n] = speaker;
|
||||
chmap->num = n + 1;
|
||||
}
|
||||
chmap->speaker[n] = speaker;
|
||||
}
|
||||
|
||||
talloc_free(talloc_ctx);
|
||||
return chmap->num > 0;
|
||||
MP_VERBOSE(ao, "mp chmap: %s\n", mp_chmap_to_str(chmap));
|
||||
return mp_chmap_is_valid(chmap) && !mp_chmap_is_unknown(chmap);
|
||||
coreaudio_error:
|
||||
MP_VERBOSE(ao, "converted input channel layout (failed):\n");
|
||||
ca_log_layout(ao, MSGL_V, layout);
|
||||
@@ -234,34 +235,68 @@ coreaudio_error:
|
||||
return r;
|
||||
}
|
||||
|
||||
bool ca_init_chmap(struct ao *ao, AudioDeviceID device)
|
||||
static void ca_retrieve_layouts(struct ao *ao, struct mp_chmap_sel *s,
|
||||
AudioDeviceID device)
|
||||
{
|
||||
void *ta_ctx = talloc_new(NULL);
|
||||
|
||||
struct mp_chmap_sel chmap_sel = {.tmp = ta_ctx};
|
||||
struct mp_chmap chmap = {0};
|
||||
|
||||
mp_chmap_sel_add_map(&chmap_sel, &(struct mp_chmap)MP_CHMAP_INIT_MONO);
|
||||
struct mp_chmap chmap;
|
||||
|
||||
AudioChannelLayout *ml = ca_query_layout(ao, device, ta_ctx);
|
||||
if (ml && ca_layout_to_mp_chmap(ao, ml, &chmap))
|
||||
mp_chmap_sel_add_map(&chmap_sel, &chmap);
|
||||
mp_chmap_sel_add_map(s, &chmap);
|
||||
|
||||
AudioChannelLayout *sl = ca_query_stereo_layout(ao, device, ta_ctx);
|
||||
if (sl && ca_layout_to_mp_chmap(ao, sl, &chmap))
|
||||
mp_chmap_sel_add_map(&chmap_sel, &chmap);
|
||||
mp_chmap_sel_add_map(s, &chmap);
|
||||
|
||||
talloc_free(ta_ctx);
|
||||
}
|
||||
|
||||
bool ca_init_chmap(struct ao *ao, AudioDeviceID device)
|
||||
{
|
||||
struct mp_chmap_sel chmap_sel = {0};
|
||||
ca_retrieve_layouts(ao, &chmap_sel, device);
|
||||
|
||||
if (!chmap_sel.num_chmaps)
|
||||
mp_chmap_sel_add_map(&chmap_sel, &(struct mp_chmap)MP_CHMAP_INIT_STEREO);
|
||||
|
||||
mp_chmap_sel_add_map(&chmap_sel, &(struct mp_chmap)MP_CHMAP_INIT_MONO);
|
||||
|
||||
if (!ao_chmap_sel_adjust(ao, &chmap_sel, &ao->channels)) {
|
||||
MP_ERR(ao, "could not select a suitable channel map among the "
|
||||
"hardware supported ones. Make sure to configure your "
|
||||
"output device correctly in 'Audio MIDI Setup.app'\n");
|
||||
goto coreaudio_error;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void ca_get_active_chmap(struct ao *ao, AudioDeviceID device, int channel_count,
|
||||
struct mp_chmap *out_map)
|
||||
{
|
||||
// Apparently, we have to guess by looking back at the supported layouts,
|
||||
// and I haven't found a property that retrieves the actual currently
|
||||
// active channel layout.
|
||||
|
||||
struct mp_chmap_sel chmap_sel = {0};
|
||||
ca_retrieve_layouts(ao, &chmap_sel, device);
|
||||
|
||||
// Use any exact match.
|
||||
for (int n = 0; n < chmap_sel.num_chmaps; n++) {
|
||||
if (chmap_sel.chmaps[n].num == channel_count) {
|
||||
MP_VERBOSE(ao, "mismatching channels - fallback #%d\n", n);
|
||||
*out_map = chmap_sel.chmaps[n];
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
talloc_free(ta_ctx);
|
||||
return true;
|
||||
|
||||
coreaudio_error:
|
||||
talloc_free(ta_ctx);
|
||||
return false;
|
||||
// Fall back to stereo or mono, and fill the rest with silence. (We don't
|
||||
// know what the device expects. We could use a larger default layout here,
|
||||
// but let's not.)
|
||||
mp_chmap_from_channels(out_map, MPMIN(2, channel_count));
|
||||
out_map->num = channel_count;
|
||||
for (int n = 2; n < out_map->num; n++)
|
||||
out_map->speaker[n] = MP_SPEAKER_ID_NA;
|
||||
MP_WARN(ao, "mismatching channels - falling back to %s\n",
|
||||
mp_chmap_to_str(out_map));
|
||||
}
|
||||
@@ -20,6 +20,10 @@
|
||||
|
||||
#include <AudioToolbox/AudioToolbox.h>
|
||||
|
||||
struct mp_chmap;
|
||||
|
||||
bool ca_init_chmap(struct ao *ao, AudioDeviceID device);
|
||||
void ca_get_active_chmap(struct ao *ao, AudioDeviceID device, int channel_count,
|
||||
struct mp_chmap *out_map);
|
||||
|
||||
#endif
|
||||
@@ -300,6 +300,12 @@ static int init(struct ao *ao)
|
||||
|
||||
ca_print_asbd(ao, "virtual format", &p->stream_asbd);
|
||||
|
||||
if (p->stream_asbd.mChannelsPerFrame > MP_NUM_CHANNELS) {
|
||||
MP_ERR(ao, "unsupported number of channels: %d > %d.\n",
|
||||
p->stream_asbd.mChannelsPerFrame, MP_NUM_CHANNELS);
|
||||
goto coreaudio_error;
|
||||
}
|
||||
|
||||
int new_format = ca_asbd_to_mp_format(&p->stream_asbd);
|
||||
|
||||
// If both old and new formats are spdif, avoid changing it due to the
|
||||
@@ -315,7 +321,10 @@ static int init(struct ao *ao)
|
||||
ao->samplerate = p->stream_asbd.mSampleRate;
|
||||
|
||||
if (ao->channels.num != p->stream_asbd.mChannelsPerFrame) {
|
||||
// We really expect that ca_init_chmap() fixes the layout to the HW's.
|
||||
ca_get_active_chmap(ao, p->device, p->stream_asbd.mChannelsPerFrame,
|
||||
&ao->channels);
|
||||
}
|
||||
if (!ao->channels.num) {
|
||||
MP_ERR(ao, "number of channels changed, and unknown channel layout!\n");
|
||||
goto coreaudio_error;
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
|
||||
#include "audio/out/ao_coreaudio_properties.h"
|
||||
#include "audio/out/ao_coreaudio_utils.h"
|
||||
#include "talloc.h"
|
||||
#include "mpv_talloc.h"
|
||||
|
||||
OSStatus ca_get(AudioObjectID id, ca_scope scope, ca_sel selector,
|
||||
uint32_t size, void *data)
|
||||
|
||||
@@ -51,7 +51,9 @@ static bool ca_is_output_device(struct ao *ao, AudioDeviceID dev)
|
||||
size_t n_buffers;
|
||||
AudioBufferList *buffers;
|
||||
const ca_scope scope = kAudioDevicePropertyStreamConfiguration;
|
||||
CA_GET_ARY_O(dev, scope, &buffers, &n_buffers);
|
||||
OSStatus err = CA_GET_ARY_O(dev, scope, &buffers, &n_buffers);
|
||||
if (err != noErr)
|
||||
return false;
|
||||
talloc_free(buffers);
|
||||
return n_buffers > 0;
|
||||
}
|
||||
@@ -71,11 +73,16 @@ void ca_get_device_list(struct ao *ao, struct ao_device_list *list)
|
||||
char *name;
|
||||
char *desc;
|
||||
err = CA_GET_STR(devs[i], kAudioDevicePropertyDeviceUID, &name);
|
||||
if (err != noErr) {
|
||||
MP_VERBOSE(ao, "skipping device %d, which has no UID\n", i);
|
||||
talloc_free(ta_ctx);
|
||||
continue;
|
||||
}
|
||||
talloc_steal(ta_ctx, name);
|
||||
err = CA_GET_STR(devs[i], kAudioObjectPropertyName, &desc);
|
||||
talloc_steal(ta_ctx, desc);
|
||||
if (err != noErr)
|
||||
desc = "Unknown";
|
||||
desc = talloc_strdup(NULL, "Unknown");
|
||||
talloc_steal(ta_ctx, desc);
|
||||
ao_device_list_add(list, ao, &(struct ao_device_desc){name, desc});
|
||||
talloc_free(ta_ctx);
|
||||
}
|
||||
@@ -129,36 +136,11 @@ coreaudio_error:
|
||||
return err;
|
||||
}
|
||||
|
||||
char *fourcc_repr_buf(char *buf, size_t buf_size, uint32_t code)
|
||||
{
|
||||
// Extract FourCC letters from the uint32_t and finde out if it's a valid
|
||||
// code that is made of letters.
|
||||
unsigned char fcc[4] = {
|
||||
(code >> 24) & 0xFF,
|
||||
(code >> 16) & 0xFF,
|
||||
(code >> 8) & 0xFF,
|
||||
code & 0xFF,
|
||||
};
|
||||
|
||||
bool valid_fourcc = true;
|
||||
for (int i = 0; i < 4; i++) {
|
||||
if (fcc[i] < 32 || fcc[i] >= 128)
|
||||
valid_fourcc = false;
|
||||
}
|
||||
|
||||
if (valid_fourcc)
|
||||
snprintf(buf, buf_size, "'%c%c%c%c'", fcc[0], fcc[1], fcc[2], fcc[3]);
|
||||
else
|
||||
snprintf(buf, buf_size, "%u", (unsigned int)code);
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
bool check_ca_st(struct ao *ao, int level, OSStatus code, const char *message)
|
||||
{
|
||||
if (code == noErr) return true;
|
||||
|
||||
mp_msg(ao->log, level, "%s (%s)\n", message, fourcc_repr(code));
|
||||
mp_msg(ao->log, level, "%s (%s)\n", message, mp_tag_str(code));
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -251,7 +233,7 @@ void ca_print_asbd(struct ao *ao, const char *description,
|
||||
const AudioStreamBasicDescription *asbd)
|
||||
{
|
||||
uint32_t flags = asbd->mFormatFlags;
|
||||
char *format = fourcc_repr(asbd->mFormatID);
|
||||
char *format = mp_tag_str(asbd->mFormatID);
|
||||
int mpfmt = ca_asbd_to_mp_format(asbd);
|
||||
|
||||
MP_VERBOSE(ao,
|
||||
@@ -463,7 +445,7 @@ int64_t ca_get_device_latency_us(struct ao *ao, AudioDeviceID device)
|
||||
if (err == noErr) {
|
||||
latency_frames += temp;
|
||||
MP_VERBOSE(ao, "Latency property %s: %d frames\n",
|
||||
fourcc_repr(latency_properties[n]), (int)temp);
|
||||
mp_tag_str(latency_properties[n]), (int)temp);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -498,6 +480,8 @@ bool ca_change_physical_format_sync(struct ao *ao, AudioStreamID stream,
|
||||
err = CA_GET(stream, kAudioStreamPropertyPhysicalFormat, &prev_format);
|
||||
CHECK_CA_ERROR("can't get current physical format");
|
||||
|
||||
ca_print_asbd(ao, "format in use before switching:", &prev_format);
|
||||
|
||||
/* Install the callback. */
|
||||
AudioObjectPropertyAddress p_addr = {
|
||||
.mSelector = kAudioStreamPropertyPhysicalFormat,
|
||||
@@ -516,7 +500,7 @@ bool ca_change_physical_format_sync(struct ao *ao, AudioStreamID stream,
|
||||
|
||||
/* The AudioStreamSetProperty is not only asynchronous,
|
||||
* it is also not Atomic, in its behaviour. */
|
||||
struct timespec timeout = mp_rel_time_to_timespec(0.5);
|
||||
struct timespec timeout = mp_rel_time_to_timespec(2.0);
|
||||
AudioStreamBasicDescription actual_format = {0};
|
||||
while (1) {
|
||||
err = CA_GET(stream, kAudioStreamPropertyPhysicalFormat, &actual_format);
|
||||
|
||||
@@ -31,9 +31,6 @@
|
||||
CFStringRef cfstr_from_cstr(char *str);
|
||||
char *cfstr_get_cstr(CFStringRef cfstr);
|
||||
|
||||
char *fourcc_repr_buf(char *buf, size_t buf_size, uint32_t code);
|
||||
#define fourcc_repr(code) fourcc_repr_buf((char[40]){0}, 40, code)
|
||||
|
||||
bool check_ca_st(struct ao *ao, int level, OSStatus code, const char *message);
|
||||
|
||||
#define CHECK_CA_ERROR_L(label, message) \
|
||||
|
||||
@@ -1,707 +0,0 @@
|
||||
/*
|
||||
* Windows DirectSound interface
|
||||
*
|
||||
* Copyright (c) 2004 Gabor Szecsi <deje@miki.hu>
|
||||
*
|
||||
* This file is part of mpv.
|
||||
*
|
||||
* mpv is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* mpv is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with mpv. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
\todo verify/extend multichannel support
|
||||
*/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <windows.h>
|
||||
#define DIRECTSOUND_VERSION 0x0600
|
||||
#include <dsound.h>
|
||||
#include <math.h>
|
||||
|
||||
#include <libavutil/avutil.h>
|
||||
#include <libavutil/common.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "audio/format.h"
|
||||
#include "ao.h"
|
||||
#include "internal.h"
|
||||
#include "common/msg.h"
|
||||
#include "osdep/timer.h"
|
||||
#include "osdep/io.h"
|
||||
#include "options/m_option.h"
|
||||
|
||||
/**
|
||||
\todo use the definitions from the win32 api headers when they define these
|
||||
*/
|
||||
#define WAVE_FORMAT_IEEE_FLOAT 0x0003
|
||||
#define WAVE_FORMAT_DOLBY_AC3_SPDIF 0x0092
|
||||
#define WAVE_FORMAT_EXTENSIBLE 0xFFFE
|
||||
|
||||
static const GUID KSDATAFORMAT_SUBTYPE_PCM = {
|
||||
0x1, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
|
||||
};
|
||||
|
||||
#if 0
|
||||
#define DSSPEAKER_HEADPHONE 0x00000001
|
||||
#define DSSPEAKER_MONO 0x00000002
|
||||
#define DSSPEAKER_QUAD 0x00000003
|
||||
#define DSSPEAKER_STEREO 0x00000004
|
||||
#define DSSPEAKER_SURROUND 0x00000005
|
||||
#define DSSPEAKER_5POINT1 0x00000006
|
||||
#endif
|
||||
|
||||
#ifndef _WAVEFORMATEXTENSIBLE_
|
||||
typedef struct {
|
||||
WAVEFORMATEX Format;
|
||||
union {
|
||||
WORD wValidBitsPerSample; /* bits of precision */
|
||||
WORD wSamplesPerBlock; /* valid if wBitsPerSample==0 */
|
||||
WORD wReserved; /* If neither applies, set to zero. */
|
||||
} Samples;
|
||||
DWORD dwChannelMask; /* which channels are */
|
||||
/* present in stream */
|
||||
GUID SubFormat;
|
||||
} WAVEFORMATEXTENSIBLE, *PWAVEFORMATEXTENSIBLE;
|
||||
#endif
|
||||
|
||||
struct priv {
|
||||
HINSTANCE hdsound_dll; ///handle to the dll
|
||||
LPDIRECTSOUND hds; ///direct sound object
|
||||
LPDIRECTSOUNDBUFFER hdspribuf; ///primary direct sound buffer
|
||||
LPDIRECTSOUNDBUFFER hdsbuf; ///secondary direct sound buffer (stream buffer)
|
||||
int buffer_size; ///size in bytes of the direct sound buffer
|
||||
int write_offset; ///offset of the write cursor in the direct sound buffer
|
||||
int min_free_space; ///if the free space is below this value get_space() will return 0
|
||||
///there will always be at least this amout of free space to prevent
|
||||
///get_space() from returning wrong values when buffer is 100% full.
|
||||
///will be replaced with nBlockAlign in init()
|
||||
int underrun_check; ///0 or last reported free space (underrun detection)
|
||||
int device_num; ///wanted device number
|
||||
GUID device; ///guid of the device
|
||||
int audio_volume;
|
||||
|
||||
int device_index;
|
||||
|
||||
int outburst; ///play in multiple of chunks of this size
|
||||
|
||||
int cfg_device;
|
||||
int cfg_buffersize;
|
||||
|
||||
struct ao_device_list *listing; ///temporary during list_devs()
|
||||
};
|
||||
|
||||
/***************************************************************************************/
|
||||
|
||||
/**
|
||||
\brief output error message
|
||||
\param err error code
|
||||
\return string with the error message
|
||||
*/
|
||||
static char * dserr2str(int err)
|
||||
{
|
||||
switch (err) {
|
||||
case DS_OK: return "DS_OK";
|
||||
case DS_NO_VIRTUALIZATION: return "DS_NO_VIRTUALIZATION";
|
||||
case DSERR_ALLOCATED: return "DS_NO_VIRTUALIZATION";
|
||||
case DSERR_CONTROLUNAVAIL: return "DSERR_CONTROLUNAVAIL";
|
||||
case DSERR_INVALIDPARAM: return "DSERR_INVALIDPARAM";
|
||||
case DSERR_INVALIDCALL: return "DSERR_INVALIDCALL";
|
||||
case DSERR_GENERIC: return "DSERR_GENERIC";
|
||||
case DSERR_PRIOLEVELNEEDED: return "DSERR_PRIOLEVELNEEDED";
|
||||
case DSERR_OUTOFMEMORY: return "DSERR_OUTOFMEMORY";
|
||||
case DSERR_BADFORMAT: return "DSERR_BADFORMAT";
|
||||
case DSERR_UNSUPPORTED: return "DSERR_UNSUPPORTED";
|
||||
case DSERR_NODRIVER: return "DSERR_NODRIVER";
|
||||
case DSERR_ALREADYINITIALIZED: return "DSERR_ALREADYINITIALIZED";
|
||||
case DSERR_NOAGGREGATION: return "DSERR_NOAGGREGATION";
|
||||
case DSERR_BUFFERLOST: return "DSERR_BUFFERLOST";
|
||||
case DSERR_OTHERAPPHASPRIO: return "DSERR_OTHERAPPHASPRIO";
|
||||
case DSERR_UNINITIALIZED: return "DSERR_UNINITIALIZED";
|
||||
case DSERR_NOINTERFACE: return "DSERR_NOINTERFACE";
|
||||
case DSERR_ACCESSDENIED: return "DSERR_ACCESSDENIED";
|
||||
}
|
||||
return "unknown";
|
||||
}
|
||||
|
||||
/**
|
||||
\brief uninitialize direct sound
|
||||
*/
|
||||
static void UninitDirectSound(struct ao *ao)
|
||||
{
|
||||
struct priv *p = ao->priv;
|
||||
|
||||
// finally release the DirectSound object
|
||||
if (p->hds) {
|
||||
IDirectSound_Release(p->hds);
|
||||
p->hds = NULL;
|
||||
}
|
||||
// free DSOUND.DLL
|
||||
if (p->hdsound_dll) {
|
||||
FreeLibrary(p->hdsound_dll);
|
||||
p->hdsound_dll = NULL;
|
||||
}
|
||||
MP_VERBOSE(ao, "DirectSound uninitialized\n");
|
||||
}
|
||||
|
||||
/**
|
||||
\brief enumerate direct sound devices
|
||||
\return TRUE to continue with the enumeration
|
||||
*/
|
||||
static BOOL CALLBACK DirectSoundEnum(LPGUID guid, LPCSTR desc, LPCSTR module,
|
||||
LPVOID context)
|
||||
{
|
||||
struct ao *ao = context;
|
||||
struct priv *p = ao->priv;
|
||||
|
||||
MP_VERBOSE(ao, "%i %s ", p->device_index, desc);
|
||||
if (p->device_num == p->device_index) {
|
||||
MP_VERBOSE(ao, "<--");
|
||||
if (guid)
|
||||
memcpy(&p->device, guid, sizeof(GUID));
|
||||
}
|
||||
char *guidstr = talloc_strdup(NULL, "");
|
||||
if (guid) {
|
||||
wchar_t guidwstr[80] = {0};
|
||||
StringFromGUID2(guid, guidwstr, MP_ARRAY_SIZE(guidwstr));
|
||||
char *nstr = mp_to_utf8(NULL, guidwstr);
|
||||
if (nstr) {
|
||||
talloc_free(guidstr);
|
||||
guidstr = nstr;
|
||||
}
|
||||
}
|
||||
if (p->device_num < 0 && ao->device) {
|
||||
if (strcmp(ao->device, guidstr) == 0) {
|
||||
MP_VERBOSE(ao, "<--");
|
||||
p->device_num = p->device_index;
|
||||
if (guid)
|
||||
memcpy(&p->device, guid, sizeof(GUID));
|
||||
}
|
||||
}
|
||||
if (p->listing) {
|
||||
struct ao_device_desc e = {guidstr, desc};
|
||||
ao_device_list_add(p->listing, ao, &e);
|
||||
}
|
||||
talloc_free(guidstr);
|
||||
|
||||
MP_VERBOSE(ao, "\n");
|
||||
p->device_index++;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void EnumDevs(struct ao *ao)
|
||||
{
|
||||
struct priv *p = ao->priv;
|
||||
|
||||
p->device_index = 0;
|
||||
p->device_num = p->cfg_device;
|
||||
|
||||
HRESULT (WINAPI *OurDirectSoundEnumerate)(LPDSENUMCALLBACKA, LPVOID);
|
||||
OurDirectSoundEnumerate = (void *)GetProcAddress(p->hdsound_dll,
|
||||
"DirectSoundEnumerateA");
|
||||
|
||||
if (OurDirectSoundEnumerate == NULL) {
|
||||
MP_ERR(ao, "GetProcAddress FAILED\n");
|
||||
return;
|
||||
}
|
||||
|
||||
// Enumerate all directsound p->devices
|
||||
MP_VERBOSE(ao, "Output Devices:\n");
|
||||
OurDirectSoundEnumerate(DirectSoundEnum, ao);
|
||||
}
|
||||
|
||||
static int LoadDirectSound(struct ao *ao)
|
||||
{
|
||||
struct priv *p = ao->priv;
|
||||
|
||||
// initialize directsound
|
||||
p->hdsound_dll = LoadLibrary(L"DSOUND.DLL");
|
||||
if (p->hdsound_dll == NULL) {
|
||||
MP_ERR(ao, "cannot load DSOUND.DLL\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void list_devs(struct ao *ao, struct ao_device_list *list)
|
||||
{
|
||||
struct priv *p = ao->priv;
|
||||
bool need_init = !p->hdsound_dll;
|
||||
if (need_init && !LoadDirectSound(ao))
|
||||
return;
|
||||
|
||||
p->listing = list;
|
||||
EnumDevs(ao);
|
||||
p->listing = NULL;
|
||||
|
||||
if (need_init)
|
||||
UninitDirectSound(ao);
|
||||
}
|
||||
|
||||
/**
|
||||
\brief initilize direct sound
|
||||
\return 0 if error, 1 if ok
|
||||
*/
|
||||
static int InitDirectSound(struct ao *ao)
|
||||
{
|
||||
struct priv *p = ao->priv;
|
||||
|
||||
DSCAPS dscaps;
|
||||
|
||||
if (!LoadDirectSound(ao))
|
||||
return 0;
|
||||
|
||||
HRESULT (WINAPI *OurDirectSoundCreate)(LPGUID, LPDIRECTSOUND *, LPUNKNOWN);
|
||||
OurDirectSoundCreate =
|
||||
(void *)GetProcAddress(p->hdsound_dll, "DirectSoundCreate");
|
||||
|
||||
if (OurDirectSoundCreate == NULL) {
|
||||
MP_ERR(ao, "GetProcAddress FAILED\n");
|
||||
FreeLibrary(p->hdsound_dll);
|
||||
return 0;
|
||||
}
|
||||
|
||||
EnumDevs(ao);
|
||||
|
||||
// Create the direct sound object
|
||||
if (FAILED(OurDirectSoundCreate((p->device_num > 0) ? &p->device : NULL,
|
||||
&p->hds, NULL)))
|
||||
{
|
||||
MP_ERR(ao, "cannot create a DirectSound device\n");
|
||||
FreeLibrary(p->hdsound_dll);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Set DirectSound Cooperative level, ie what control we want over Windows
|
||||
* sound device. In our case, DSSCL_EXCLUSIVE means that we can modify the
|
||||
* settings of the primary buffer, but also that only the sound of our
|
||||
* application will be audible when it will have the focus.
|
||||
* !!! (this is not really working as intended yet because to set the
|
||||
* cooperative level you need the window handle of your application, and
|
||||
* I don't know of any easy way to get it. Especially since we might play
|
||||
* sound without any video, and so what window handle should we use ???
|
||||
* The hack for now is to use the Desktop window handle - it seems to be
|
||||
* working */
|
||||
if (IDirectSound_SetCooperativeLevel(p->hds, GetDesktopWindow(),
|
||||
DSSCL_EXCLUSIVE))
|
||||
{
|
||||
MP_ERR(ao, "cannot set direct sound cooperative level\n");
|
||||
IDirectSound_Release(p->hds);
|
||||
FreeLibrary(p->hdsound_dll);
|
||||
return 0;
|
||||
}
|
||||
MP_VERBOSE(ao, "DirectSound initialized\n");
|
||||
|
||||
memset(&dscaps, 0, sizeof(DSCAPS));
|
||||
dscaps.dwSize = sizeof(DSCAPS);
|
||||
if (DS_OK == IDirectSound_GetCaps(p->hds, &dscaps)) {
|
||||
if (dscaps.dwFlags & DSCAPS_EMULDRIVER)
|
||||
MP_VERBOSE(ao, "DirectSound is emulated\n");
|
||||
} else {
|
||||
MP_VERBOSE(ao, "cannot get device capabilities\n");
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
\brief destroy the direct sound buffer
|
||||
*/
|
||||
static void DestroyBuffer(struct ao *ao)
|
||||
{
|
||||
struct priv *p = ao->priv;
|
||||
|
||||
if (p->hdsbuf) {
|
||||
IDirectSoundBuffer_Release(p->hdsbuf);
|
||||
p->hdsbuf = NULL;
|
||||
}
|
||||
if (p->hdspribuf) {
|
||||
IDirectSoundBuffer_Release(p->hdspribuf);
|
||||
p->hdspribuf = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
\brief fill sound buffer
|
||||
\param data pointer to the sound data to copy
|
||||
\param len length of the data to copy in bytes
|
||||
\return number of copyed bytes
|
||||
*/
|
||||
static int write_buffer(struct ao *ao, unsigned char *data, int len)
|
||||
{
|
||||
struct priv *p = ao->priv;
|
||||
HRESULT res;
|
||||
LPVOID lpvPtr1;
|
||||
DWORD dwBytes1;
|
||||
LPVOID lpvPtr2;
|
||||
DWORD dwBytes2;
|
||||
|
||||
p->underrun_check = 0;
|
||||
|
||||
// Lock the buffer
|
||||
res = IDirectSoundBuffer_Lock(p->hdsbuf, p->write_offset, len, &lpvPtr1,
|
||||
&dwBytes1, &lpvPtr2, &dwBytes2, 0);
|
||||
// If the buffer was lost, restore and retry lock.
|
||||
if (DSERR_BUFFERLOST == res) {
|
||||
IDirectSoundBuffer_Restore(p->hdsbuf);
|
||||
res = IDirectSoundBuffer_Lock(p->hdsbuf, p->write_offset, len, &lpvPtr1,
|
||||
&dwBytes1, &lpvPtr2, &dwBytes2, 0);
|
||||
}
|
||||
|
||||
|
||||
if (SUCCEEDED(res)) {
|
||||
memcpy(lpvPtr1, data, dwBytes1);
|
||||
if (NULL != lpvPtr2)
|
||||
memcpy(lpvPtr2, data + dwBytes1, dwBytes2);
|
||||
p->write_offset += dwBytes1 + dwBytes2;
|
||||
if (p->write_offset >= p->buffer_size)
|
||||
p->write_offset = dwBytes2;
|
||||
|
||||
// Release the data back to DirectSound.
|
||||
res = IDirectSoundBuffer_Unlock(p->hdsbuf, lpvPtr1, dwBytes1, lpvPtr2,
|
||||
dwBytes2);
|
||||
if (SUCCEEDED(res)) {
|
||||
// Success.
|
||||
DWORD status;
|
||||
IDirectSoundBuffer_GetStatus(p->hdsbuf, &status);
|
||||
if (!(status & DSBSTATUS_PLAYING))
|
||||
res = IDirectSoundBuffer_Play(p->hdsbuf, 0, 0, DSBPLAY_LOOPING);
|
||||
return dwBytes1 + dwBytes2;
|
||||
}
|
||||
}
|
||||
// Lock, Unlock, or Restore failed.
|
||||
return 0;
|
||||
}
|
||||
|
||||
/***************************************************************************************/
|
||||
|
||||
/**
|
||||
\brief handle control commands
|
||||
\param cmd command
|
||||
\param arg argument
|
||||
\return CONTROL_OK or CONTROL_UNKNOWN in case the command is not supported
|
||||
*/
|
||||
static int control(struct ao *ao, enum aocontrol cmd, void *arg)
|
||||
{
|
||||
struct priv *p = ao->priv;
|
||||
DWORD volume;
|
||||
switch (cmd) {
|
||||
case AOCONTROL_GET_VOLUME: {
|
||||
ao_control_vol_t *vol = (ao_control_vol_t *)arg;
|
||||
vol->left = vol->right = p->audio_volume;
|
||||
return CONTROL_OK;
|
||||
}
|
||||
case AOCONTROL_SET_VOLUME: {
|
||||
ao_control_vol_t *vol = (ao_control_vol_t *)arg;
|
||||
volume = p->audio_volume = vol->right;
|
||||
if (volume < 1)
|
||||
volume = 1;
|
||||
volume = (DWORD)(log10(volume) * 5000.0) - 10000;
|
||||
IDirectSoundBuffer_SetVolume(p->hdsbuf, volume);
|
||||
return CONTROL_OK;
|
||||
}
|
||||
case AOCONTROL_HAS_SOFT_VOLUME:
|
||||
return CONTROL_TRUE;
|
||||
}
|
||||
return CONTROL_UNKNOWN;
|
||||
}
|
||||
|
||||
/**
|
||||
\brief setup sound device
|
||||
\param rate samplerate
|
||||
\param channels number of channels
|
||||
\param format format
|
||||
\param flags unused
|
||||
\return 0=success -1=fail
|
||||
*/
|
||||
static int init(struct ao *ao)
|
||||
{
|
||||
struct priv *p = ao->priv;
|
||||
int res;
|
||||
|
||||
if (!InitDirectSound(ao))
|
||||
return -1;
|
||||
|
||||
p->audio_volume = 100;
|
||||
|
||||
// ok, now create the buffers
|
||||
WAVEFORMATEXTENSIBLE wformat;
|
||||
DSBUFFERDESC dsbpridesc;
|
||||
DSBUFFERDESC dsbdesc;
|
||||
int format = af_fmt_from_planar(ao->format);
|
||||
int rate = ao->samplerate;
|
||||
|
||||
if (!af_fmt_is_spdif(format)) {
|
||||
struct mp_chmap_sel sel = {0};
|
||||
mp_chmap_sel_add_waveext(&sel);
|
||||
if (!ao_chmap_sel_adjust(ao, &sel, &ao->channels))
|
||||
return -1;
|
||||
}
|
||||
switch (format) {
|
||||
case AF_FORMAT_S24:
|
||||
case AF_FORMAT_S16:
|
||||
case AF_FORMAT_U8:
|
||||
break;
|
||||
default:
|
||||
if (af_fmt_is_spdif(format))
|
||||
break;
|
||||
MP_VERBOSE(ao, "format %s not supported defaulting to Signed 16-bit Little-Endian\n",
|
||||
af_fmt_to_str(format));
|
||||
format = AF_FORMAT_S16;
|
||||
}
|
||||
//set our audio parameters
|
||||
ao->samplerate = rate;
|
||||
ao->format = format;
|
||||
ao->bps = ao->channels.num * rate * af_fmt_to_bytes(format);
|
||||
int buffersize = ao->bps * p->cfg_buffersize / 1000;
|
||||
MP_VERBOSE(ao, "Samplerate:%iHz Channels:%i Format:%s\n", rate,
|
||||
ao->channels.num, af_fmt_to_str(format));
|
||||
MP_VERBOSE(ao, "Buffersize:%d bytes (%f msec)\n",
|
||||
buffersize, buffersize * 1000.0 / ao->bps);
|
||||
|
||||
//fill waveformatex
|
||||
ZeroMemory(&wformat, sizeof(WAVEFORMATEXTENSIBLE));
|
||||
wformat.Format.cbSize = (ao->channels.num > 2)
|
||||
? sizeof(WAVEFORMATEXTENSIBLE) - sizeof(WAVEFORMATEX) : 0;
|
||||
wformat.Format.nChannels = ao->channels.num;
|
||||
wformat.Format.nSamplesPerSec = rate;
|
||||
if (af_fmt_is_spdif(format)) {
|
||||
// Whether it also works with e.g. DTS is unknown, but probably does.
|
||||
wformat.Format.wFormatTag = WAVE_FORMAT_DOLBY_AC3_SPDIF;
|
||||
wformat.Format.wBitsPerSample = 16;
|
||||
wformat.Format.nBlockAlign = 4;
|
||||
} else {
|
||||
wformat.Format.wFormatTag = (ao->channels.num > 2)
|
||||
? WAVE_FORMAT_EXTENSIBLE : WAVE_FORMAT_PCM;
|
||||
int bps = af_fmt_to_bytes(format);
|
||||
wformat.Format.wBitsPerSample = bps * 8;
|
||||
wformat.Format.nBlockAlign = wformat.Format.nChannels * bps;
|
||||
}
|
||||
|
||||
// fill in primary sound buffer descriptor
|
||||
memset(&dsbpridesc, 0, sizeof(DSBUFFERDESC));
|
||||
dsbpridesc.dwSize = sizeof(DSBUFFERDESC);
|
||||
dsbpridesc.dwFlags = DSBCAPS_PRIMARYBUFFER;
|
||||
dsbpridesc.dwBufferBytes = 0;
|
||||
dsbpridesc.lpwfxFormat = NULL;
|
||||
|
||||
// fill in the secondary sound buffer (=stream buffer) descriptor
|
||||
memset(&dsbdesc, 0, sizeof(DSBUFFERDESC));
|
||||
dsbdesc.dwSize = sizeof(DSBUFFERDESC);
|
||||
dsbdesc.dwFlags = DSBCAPS_GETCURRENTPOSITION2 /** Better position accuracy */
|
||||
| DSBCAPS_GLOBALFOCUS /** Allows background playing */
|
||||
| DSBCAPS_CTRLVOLUME; /** volume control enabled */
|
||||
|
||||
if (ao->channels.num > 2) {
|
||||
wformat.dwChannelMask = mp_chmap_to_waveext(&ao->channels);
|
||||
wformat.SubFormat = KSDATAFORMAT_SUBTYPE_PCM;
|
||||
wformat.Samples.wValidBitsPerSample = wformat.Format.wBitsPerSample;
|
||||
// Needed for 5.1 on emu101k - shit soundblaster
|
||||
dsbdesc.dwFlags |= DSBCAPS_LOCHARDWARE;
|
||||
}
|
||||
wformat.Format.nAvgBytesPerSec = wformat.Format.nSamplesPerSec *
|
||||
wformat.Format.nBlockAlign;
|
||||
|
||||
dsbdesc.dwBufferBytes = buffersize;
|
||||
dsbdesc.lpwfxFormat = (WAVEFORMATEX *)&wformat;
|
||||
p->buffer_size = dsbdesc.dwBufferBytes;
|
||||
p->write_offset = 0;
|
||||
p->min_free_space = wformat.Format.nBlockAlign;
|
||||
p->outburst = wformat.Format.nBlockAlign * 512;
|
||||
|
||||
// create primary buffer and set its format
|
||||
|
||||
res = IDirectSound_CreateSoundBuffer(p->hds, &dsbpridesc, &p->hdspribuf, NULL);
|
||||
if (res != DS_OK) {
|
||||
UninitDirectSound(ao);
|
||||
MP_ERR(ao, "cannot create primary buffer (%s)\n", dserr2str(res));
|
||||
return -1;
|
||||
}
|
||||
res = IDirectSoundBuffer_SetFormat(p->hdspribuf, (WAVEFORMATEX *)&wformat);
|
||||
if (res != DS_OK) {
|
||||
MP_WARN(ao, "cannot set primary buffer format (%s), using "
|
||||
"standard setting (bad quality)", dserr2str(res));
|
||||
}
|
||||
|
||||
MP_VERBOSE(ao, "primary buffer created\n");
|
||||
|
||||
// now create the stream buffer
|
||||
|
||||
res = IDirectSound_CreateSoundBuffer(p->hds, &dsbdesc, &p->hdsbuf, NULL);
|
||||
if (res != DS_OK) {
|
||||
if (dsbdesc.dwFlags & DSBCAPS_LOCHARDWARE) {
|
||||
// Try without DSBCAPS_LOCHARDWARE
|
||||
dsbdesc.dwFlags &= ~DSBCAPS_LOCHARDWARE;
|
||||
res = IDirectSound_CreateSoundBuffer(p->hds, &dsbdesc, &p->hdsbuf, NULL);
|
||||
}
|
||||
if (res != DS_OK) {
|
||||
UninitDirectSound(ao);
|
||||
MP_ERR(ao, "cannot create secondary (stream)buffer (%s)\n",
|
||||
dserr2str(res));
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
MP_VERBOSE(ao, "secondary (stream)buffer created\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
\brief stop playing and empty buffers (for seeking/pause)
|
||||
*/
|
||||
static void reset(struct ao *ao)
|
||||
{
|
||||
struct priv *p = ao->priv;
|
||||
|
||||
IDirectSoundBuffer_Stop(p->hdsbuf);
|
||||
// reset directsound buffer
|
||||
IDirectSoundBuffer_SetCurrentPosition(p->hdsbuf, 0);
|
||||
p->write_offset = 0;
|
||||
p->underrun_check = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
\brief stop playing, keep buffers (for pause)
|
||||
*/
|
||||
static void audio_pause(struct ao *ao)
|
||||
{
|
||||
struct priv *p = ao->priv;
|
||||
|
||||
IDirectSoundBuffer_Stop(p->hdsbuf);
|
||||
}
|
||||
|
||||
/**
|
||||
\brief resume playing, after audio_pause()
|
||||
*/
|
||||
static void audio_resume(struct ao *ao)
|
||||
{
|
||||
struct priv *p = ao->priv;
|
||||
|
||||
IDirectSoundBuffer_Play(p->hdsbuf, 0, 0, DSBPLAY_LOOPING);
|
||||
}
|
||||
|
||||
/**
|
||||
\brief close audio device
|
||||
\param immed stop playback immediately
|
||||
*/
|
||||
static void uninit(struct ao *ao)
|
||||
{
|
||||
reset(ao);
|
||||
|
||||
DestroyBuffer(ao);
|
||||
UninitDirectSound(ao);
|
||||
}
|
||||
|
||||
// return exact number of free (safe to write) bytes
|
||||
static int check_free_buffer_size(struct ao *ao)
|
||||
{
|
||||
struct priv *p = ao->priv;
|
||||
int space;
|
||||
DWORD play_offset;
|
||||
IDirectSoundBuffer_GetCurrentPosition(p->hdsbuf, &play_offset, NULL);
|
||||
space = p->buffer_size - (p->write_offset - play_offset);
|
||||
// | | <-- const --> | | |
|
||||
// buffer start play_cursor write_cursor p->write_offset buffer end
|
||||
// play_cursor is the actual position of the play cursor
|
||||
// write_cursor is the position after which it is assumed to be save to write data
|
||||
// p->write_offset is the position where we actually write the data to
|
||||
if (space > p->buffer_size)
|
||||
space -= p->buffer_size; // p->write_offset < play_offset
|
||||
// Check for buffer underruns. An underrun happens if DirectSound
|
||||
// started to play old data beyond the current p->write_offset. Detect this
|
||||
// by checking whether the free space shrinks, even though no data was
|
||||
// written (i.e. no write_buffer). Doesn't always work, but the only
|
||||
// reason we need this is to deal with the situation when playback ends,
|
||||
// and the buffer is only half-filled.
|
||||
if (space < p->underrun_check) {
|
||||
// there's no useful data in the buffers
|
||||
space = p->buffer_size;
|
||||
reset(ao);
|
||||
}
|
||||
p->underrun_check = space;
|
||||
return space;
|
||||
}
|
||||
|
||||
/**
|
||||
\brief find out how many bytes can be written into the audio buffer without
|
||||
\return free space in bytes, has to return 0 if the buffer is almost full
|
||||
*/
|
||||
static int get_space(struct ao *ao)
|
||||
{
|
||||
struct priv *p = ao->priv;
|
||||
|
||||
int space = check_free_buffer_size(ao);
|
||||
if (space < p->min_free_space)
|
||||
return 0;
|
||||
return (space - p->min_free_space) / p->outburst * p->outburst / ao->sstride;
|
||||
}
|
||||
|
||||
/**
|
||||
\brief play 'len' bytes of 'data'
|
||||
\param data pointer to the data to play
|
||||
\param len size in bytes of the data buffer, gets rounded down to outburst*n
|
||||
\param flags currently unused
|
||||
\return number of played bytes
|
||||
*/
|
||||
static int play(struct ao *ao, void **data, int samples, int flags)
|
||||
{
|
||||
struct priv *p = ao->priv;
|
||||
int len = samples * ao->sstride;
|
||||
|
||||
int space = check_free_buffer_size(ao);
|
||||
if (space < len)
|
||||
len = space;
|
||||
|
||||
if (!(flags & AOPLAY_FINAL_CHUNK))
|
||||
len = (len / p->outburst) * p->outburst;
|
||||
return write_buffer(ao, data[0], len) / ao->sstride;
|
||||
}
|
||||
|
||||
/**
|
||||
\brief get the delay between the first and last sample in the buffer
|
||||
\return delay in seconds
|
||||
*/
|
||||
static double get_delay(struct ao *ao)
|
||||
{
|
||||
struct priv *p = ao->priv;
|
||||
|
||||
int space = check_free_buffer_size(ao);
|
||||
return (p->buffer_size - space) / (double)ao->bps;
|
||||
}
|
||||
|
||||
#define OPT_BASE_STRUCT struct priv
|
||||
|
||||
const struct ao_driver audio_out_dsound = {
|
||||
.description = "Windows DirectSound audio output",
|
||||
.name = "dsound",
|
||||
.init = init,
|
||||
.uninit = uninit,
|
||||
.control = control,
|
||||
.get_space = get_space,
|
||||
.play = play,
|
||||
.get_delay = get_delay,
|
||||
.pause = audio_pause,
|
||||
.resume = audio_resume,
|
||||
.reset = reset,
|
||||
.list_devs = list_devs,
|
||||
.priv_size = sizeof(struct priv),
|
||||
.options = (const struct m_option[]) {
|
||||
OPT_INT("device", cfg_device, 0, OPTDEF_INT(-1)),
|
||||
OPT_INTRANGE("buffersize", cfg_buffersize, 0, 1, 10000, OPTDEF_INT(200)),
|
||||
{0}
|
||||
},
|
||||
};
|
||||
+1
-5
@@ -162,10 +162,6 @@ static int init(struct ao *ao)
|
||||
mp_chmap_sel_add_waveext(&sel);
|
||||
break;
|
||||
|
||||
case 1:
|
||||
mp_chmap_sel_add_alsa_def(&sel);
|
||||
break;
|
||||
|
||||
default:
|
||||
mp_chmap_sel_add_any(&sel);
|
||||
}
|
||||
@@ -236,7 +232,7 @@ const struct ao_driver audio_out_jack = {
|
||||
OPT_FLAG("autostart", autostart, 0),
|
||||
OPT_FLAG("connect", connect, 0),
|
||||
OPT_CHOICE("std-channel-layout", stdlayout, 0,
|
||||
({"waveext", 0}, {"alsa", 1}, {"any", 2})),
|
||||
({"waveext", 0}, {"any", 1})),
|
||||
{0}
|
||||
},
|
||||
};
|
||||
+4
-1
@@ -31,7 +31,7 @@
|
||||
#include "common/common.h"
|
||||
#include "audio/format.h"
|
||||
#include "audio/fmt-conversion.h"
|
||||
#include "talloc.h"
|
||||
#include "mpv_talloc.h"
|
||||
#include "ao.h"
|
||||
#include "internal.h"
|
||||
#include "common/msg.h"
|
||||
@@ -164,6 +164,9 @@ static int init(struct ao *ao)
|
||||
|
||||
ao->untimed = true;
|
||||
|
||||
if (ao->channels.num > AV_NUM_DATA_POINTERS)
|
||||
goto fail;
|
||||
|
||||
pthread_mutex_unlock(&ao->encode_lavc_ctx->lock);
|
||||
return 0;
|
||||
|
||||
|
||||
+1
-1
@@ -26,7 +26,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "talloc.h"
|
||||
#include "mpv_talloc.h"
|
||||
|
||||
#include "config.h"
|
||||
#include "osdep/timer.h"
|
||||
|
||||
+66
-29
@@ -44,8 +44,7 @@
|
||||
|
||||
#define MAX_CHANS MP_NUM_CHANNELS
|
||||
#define NUM_BUF 128
|
||||
#define CHUNK_SIZE 512
|
||||
#define CHUNK_SAMPLES (CHUNK_SIZE / 2)
|
||||
#define CHUNK_SAMPLES 256
|
||||
static ALuint buffers[MAX_CHANS][NUM_BUF];
|
||||
static ALuint sources[MAX_CHANS];
|
||||
|
||||
@@ -56,6 +55,8 @@ static struct ao *ao_data;
|
||||
|
||||
struct priv {
|
||||
char *cfg_device;
|
||||
ALenum al_format;
|
||||
int chunk_size;
|
||||
};
|
||||
|
||||
static void reset(struct ao *ao);
|
||||
@@ -117,22 +118,51 @@ struct speaker {
|
||||
};
|
||||
|
||||
static const struct speaker speaker_pos[] = {
|
||||
{MP_SPEAKER_ID_FL, {-1, 0, 0.5}},
|
||||
{MP_SPEAKER_ID_FR, { 1, 0, 0.5}},
|
||||
{MP_SPEAKER_ID_FC, { 0, 0, 1}},
|
||||
{MP_SPEAKER_ID_LFE, { 0, 0, 0.1}},
|
||||
{MP_SPEAKER_ID_BL, {-1, 0, -1}},
|
||||
{MP_SPEAKER_ID_BR, { 1, 0, -1}},
|
||||
{MP_SPEAKER_ID_BC, { 0, 0, -1}},
|
||||
{MP_SPEAKER_ID_SL, {-1, 0, 0}},
|
||||
{MP_SPEAKER_ID_SR, { 1, 0, 0}},
|
||||
{MP_SPEAKER_ID_FL, {-0.500, 0, -0.866}}, // -30 deg
|
||||
{MP_SPEAKER_ID_FR, { 0.500, 0, -0.866}}, // 30 deg
|
||||
{MP_SPEAKER_ID_FC, { 0, 0, -1}}, // 0 deg
|
||||
{MP_SPEAKER_ID_LFE, { 0, -1, 0}}, // below
|
||||
{MP_SPEAKER_ID_BL, {-0.609, 0, 0.793}}, // -142.5 deg
|
||||
{MP_SPEAKER_ID_BR, { 0.609, 0, 0.793}}, // 142.5 deg
|
||||
{MP_SPEAKER_ID_BC, { 0, 0, 1}}, // 180 deg
|
||||
{MP_SPEAKER_ID_SL, {-0.985, 0, 0.174}}, // -100 deg
|
||||
{MP_SPEAKER_ID_SR, { 0.985, 0, 0.174}}, // 100 deg
|
||||
{-1},
|
||||
};
|
||||
|
||||
static ALenum get_al_format(int format)
|
||||
{
|
||||
switch (format) {
|
||||
case AF_FORMAT_U8P: return AL_FORMAT_MONO8;
|
||||
case AF_FORMAT_S16P: return AL_FORMAT_MONO16;
|
||||
case AF_FORMAT_FLOATP:
|
||||
if (alIsExtensionPresent((ALchar*)"AL_EXT_float32") == AL_TRUE)
|
||||
return AL_FORMAT_MONO_FLOAT32;
|
||||
break;
|
||||
case AF_FORMAT_DOUBLEP:
|
||||
if (alIsExtensionPresent((ALchar*)"AL_EXT_double") == AL_TRUE)
|
||||
return AL_FORMAT_MONO_DOUBLE_EXT;
|
||||
break;
|
||||
}
|
||||
return AL_FALSE;
|
||||
}
|
||||
|
||||
// close audio device
|
||||
static void uninit(struct ao *ao)
|
||||
{
|
||||
ALCcontext *ctx = alcGetCurrentContext();
|
||||
ALCdevice *dev = alcGetContextsDevice(ctx);
|
||||
reset(ao);
|
||||
alcMakeContextCurrent(NULL);
|
||||
alcDestroyContext(ctx);
|
||||
alcCloseDevice(dev);
|
||||
ao_data = NULL;
|
||||
}
|
||||
|
||||
static int init(struct ao *ao)
|
||||
{
|
||||
float position[3] = {0, 0, 0};
|
||||
float direction[6] = {0, 0, 1, 0, -1, 0};
|
||||
float direction[6] = {0, 0, -1, 0, 1, 0};
|
||||
ALCdevice *dev = NULL;
|
||||
ALCcontext *ctx = NULL;
|
||||
ALCint freq = 0;
|
||||
@@ -184,25 +214,31 @@ static int init(struct ao *ao)
|
||||
alcGetIntegerv(dev, ALC_FREQUENCY, 1, &freq);
|
||||
if (alcGetError(dev) == ALC_NO_ERROR && freq)
|
||||
ao->samplerate = freq;
|
||||
ao->format = AF_FORMAT_S16P;
|
||||
|
||||
p->al_format = AL_FALSE;
|
||||
int try_formats[AF_FORMAT_COUNT];
|
||||
af_get_best_sample_formats(ao->format, try_formats);
|
||||
for (int n = 0; try_formats[n]; n++) {
|
||||
p->al_format = get_al_format(try_formats[n]);
|
||||
if (p->al_format != AL_FALSE) {
|
||||
ao->format = try_formats[n];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (p->al_format == AL_FALSE) {
|
||||
MP_FATAL(ao, "Can't find appropriate sample format.\n");
|
||||
uninit(ao);
|
||||
goto err_out;
|
||||
}
|
||||
|
||||
p->chunk_size = CHUNK_SAMPLES * af_fmt_to_bytes(ao->format);
|
||||
return 0;
|
||||
|
||||
err_out:
|
||||
return -1;
|
||||
}
|
||||
|
||||
// close audio device
|
||||
static void uninit(struct ao *ao)
|
||||
{
|
||||
ALCcontext *ctx = alcGetCurrentContext();
|
||||
ALCdevice *dev = alcGetContextsDevice(ctx);
|
||||
reset(ao);
|
||||
alcMakeContextCurrent(NULL);
|
||||
alcDestroyContext(ctx);
|
||||
alcCloseDevice(dev);
|
||||
ao_data = NULL;
|
||||
}
|
||||
|
||||
static void drain(struct ao *ao)
|
||||
{
|
||||
ALint state;
|
||||
@@ -274,14 +310,15 @@ static int get_space(struct ao *ao)
|
||||
*/
|
||||
static int play(struct ao *ao, void **data, int samples, int flags)
|
||||
{
|
||||
struct priv *p = ao->priv;
|
||||
ALint state;
|
||||
int num = samples / CHUNK_SAMPLES;
|
||||
for (int i = 0; i < num; i++) {
|
||||
for (int ch = 0; ch < ao->channels.num; ch++) {
|
||||
int16_t *d = data[ch];
|
||||
d += i * CHUNK_SAMPLES;
|
||||
alBufferData(buffers[ch][cur_buf[ch]], AL_FORMAT_MONO16, d,
|
||||
CHUNK_SIZE, ao->samplerate);
|
||||
char *d = data[ch];
|
||||
d += i * p->chunk_size;
|
||||
alBufferData(buffers[ch][cur_buf[ch]], p->al_format, d,
|
||||
p->chunk_size, ao->samplerate);
|
||||
alSourceQueueBuffers(sources[ch], 1, &buffers[ch][cur_buf[ch]]);
|
||||
cur_buf[ch] = (cur_buf[ch] + 1) % NUM_BUF;
|
||||
}
|
||||
|
||||
+1
-1
@@ -27,7 +27,7 @@
|
||||
|
||||
#include <libavutil/common.h>
|
||||
|
||||
#include "talloc.h"
|
||||
#include "mpv_talloc.h"
|
||||
|
||||
#include "options/m_option.h"
|
||||
#include "audio/format.h"
|
||||
|
||||
+33
-22
@@ -376,22 +376,8 @@ fail:
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int init(struct ao *ao)
|
||||
static bool set_format(struct ao *ao, pa_format_info *format)
|
||||
{
|
||||
struct pa_channel_map map;
|
||||
pa_proplist *proplist = NULL;
|
||||
pa_format_info *format = NULL;
|
||||
struct priv *priv = ao->priv;
|
||||
char *sink = priv->cfg_sink && priv->cfg_sink[0] ? priv->cfg_sink : ao->device;
|
||||
|
||||
if (pa_init_boilerplate(ao) < 0)
|
||||
return -1;
|
||||
|
||||
pa_threaded_mainloop_lock(priv->mainloop);
|
||||
|
||||
if (!(format = pa_format_info_new()))
|
||||
goto unlock_and_fail;
|
||||
|
||||
ao->format = af_fmt_from_planar(ao->format);
|
||||
|
||||
format->encoding = map_digital_format(ao->format);
|
||||
@@ -411,8 +397,29 @@ static int init(struct ao *ao)
|
||||
pa_format_info_set_sample_format(format, fmt_map->pa_format);
|
||||
}
|
||||
|
||||
struct pa_channel_map map;
|
||||
|
||||
if (!select_chmap(ao, &map))
|
||||
goto unlock_and_fail;
|
||||
return false;
|
||||
|
||||
pa_format_info_set_rate(format, ao->samplerate);
|
||||
pa_format_info_set_channels(format, ao->channels.num);
|
||||
pa_format_info_set_channel_map(format, &map);
|
||||
|
||||
return ao->samplerate < PA_RATE_MAX && pa_format_info_valid(format);
|
||||
}
|
||||
|
||||
static int init(struct ao *ao)
|
||||
{
|
||||
pa_proplist *proplist = NULL;
|
||||
pa_format_info *format = NULL;
|
||||
struct priv *priv = ao->priv;
|
||||
char *sink = priv->cfg_sink && priv->cfg_sink[0] ? priv->cfg_sink : ao->device;
|
||||
|
||||
if (pa_init_boilerplate(ao) < 0)
|
||||
return -1;
|
||||
|
||||
pa_threaded_mainloop_lock(priv->mainloop);
|
||||
|
||||
if (!(proplist = pa_proplist_new())) {
|
||||
MP_ERR(ao, "Failed to allocate proplist\n");
|
||||
@@ -420,13 +427,17 @@ static int init(struct ao *ao)
|
||||
}
|
||||
(void)pa_proplist_sets(proplist, PA_PROP_MEDIA_ICON_NAME, ao->client_name);
|
||||
|
||||
pa_format_info_set_rate(format, ao->samplerate);
|
||||
pa_format_info_set_channels(format, ao->channels.num);
|
||||
pa_format_info_set_channel_map(format, &map);
|
||||
|
||||
if (!pa_format_info_valid(format)) {
|
||||
MP_ERR(ao, "Invalid audio format\n");
|
||||
if (!(format = pa_format_info_new()))
|
||||
goto unlock_and_fail;
|
||||
|
||||
if (!set_format(ao, format)) {
|
||||
ao->channels = (struct mp_chmap) MP_CHMAP_INIT_STEREO;
|
||||
ao->samplerate = 48000;
|
||||
ao->format = AF_FORMAT_FLOAT;
|
||||
if (!set_format(ao, format)) {
|
||||
MP_ERR(ao, "Invalid audio format\n");
|
||||
goto unlock_and_fail;
|
||||
}
|
||||
}
|
||||
|
||||
if (!(priv->stream = pa_stream_new_extended(priv->context, "audio stream",
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
#include <unistd.h>
|
||||
#include <rsound.h>
|
||||
|
||||
#include "talloc.h"
|
||||
#include "mpv_talloc.h"
|
||||
|
||||
#include "options/m_option.h"
|
||||
#include "osdep/timer.h"
|
||||
|
||||
+1
-1
@@ -20,7 +20,7 @@
|
||||
|
||||
#include "config.h"
|
||||
#include "audio/format.h"
|
||||
#include "talloc.h"
|
||||
#include "mpv_talloc.h"
|
||||
#include "ao.h"
|
||||
#include "internal.h"
|
||||
#include "common/common.h"
|
||||
|
||||
+192
-119
@@ -17,49 +17,61 @@
|
||||
* with mpv. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include <inttypes.h>
|
||||
#include <process.h>
|
||||
#include <initguid.h>
|
||||
#include <audioclient.h>
|
||||
#include <endpointvolume.h>
|
||||
#include <mmdeviceapi.h>
|
||||
#include <avrt.h>
|
||||
#include <libavutil/mathematics.h>
|
||||
|
||||
#include "audio/out/ao_wasapi.h"
|
||||
#include "audio/out/ao_wasapi_utils.h"
|
||||
|
||||
#include "audio/format.h"
|
||||
#include "options/m_option.h"
|
||||
#include "osdep/timer.h"
|
||||
#include "osdep/io.h"
|
||||
#include "ao_wasapi.h"
|
||||
|
||||
static HRESULT get_device_delay(struct wasapi_state *state, double *delay) {
|
||||
// naive av_rescale for unsigned
|
||||
static UINT64 uint64_scale(UINT64 x, UINT64 num, UINT64 den)
|
||||
{
|
||||
return (x / den) * num
|
||||
+ ((x % den) * (num / den))
|
||||
+ ((x % den) * (num % den)) / den;
|
||||
}
|
||||
|
||||
static HRESULT get_device_delay(struct wasapi_state *state, double *delay_us) {
|
||||
UINT64 sample_count = atomic_load(&state->sample_count);
|
||||
UINT64 position, qpc_position;
|
||||
HRESULT hr;
|
||||
|
||||
hr = IAudioClock_GetPosition(state->pAudioClock, &position, &qpc_position);
|
||||
/* GetPosition succeeded, but the result may be inaccurate due to the length of the call */
|
||||
/* http://msdn.microsoft.com/en-us/library/windows/desktop/dd370889%28v=vs.85%29.aspx */
|
||||
// GetPosition succeeded, but the result may be
|
||||
// inaccurate due to the length of the call
|
||||
// http://msdn.microsoft.com/en-us/library/windows/desktop/dd370889%28v=vs.85%29.aspx
|
||||
if (hr == S_FALSE) {
|
||||
MP_DBG(state, "Possibly inaccurate device position.\n");
|
||||
MP_VERBOSE(state, "Possibly inaccurate device position.\n");
|
||||
hr = S_OK;
|
||||
}
|
||||
EXIT_ON_ERROR(hr);
|
||||
|
||||
LARGE_INTEGER qpc_count;
|
||||
QueryPerformanceCounter(&qpc_count);
|
||||
double qpc_diff = (qpc_count.QuadPart * 1e7 / state->qpc_frequency.QuadPart) - qpc_position;
|
||||
// convert position to number of samples careful to avoid overflow
|
||||
UINT64 sample_position = uint64_scale(position,
|
||||
state->format.Format.nSamplesPerSec,
|
||||
state->clock_frequency);
|
||||
INT64 diff = sample_count - sample_position;
|
||||
*delay_us = diff * 1e6 / state->format.Format.nSamplesPerSec;
|
||||
|
||||
position += state->clock_frequency * (uint64_t) (qpc_diff / 1e7);
|
||||
// Correct for any delay in IAudioClock_GetPosition above.
|
||||
// This should normally be very small (<1 us), but just in case. . .
|
||||
LARGE_INTEGER qpc;
|
||||
QueryPerformanceCounter(&qpc);
|
||||
INT64 qpc_diff = av_rescale(qpc.QuadPart, 10000000, state->qpc_frequency.QuadPart)
|
||||
- qpc_position;
|
||||
// ignore the above calculation if it yeilds more than 10 seconds (due to
|
||||
// possible overflow inside IAudioClock_GetPosition)
|
||||
if (qpc_diff < 10 * 10000000) {
|
||||
*delay_us -= qpc_diff / 10.0; // convert to us
|
||||
} else {
|
||||
MP_VERBOSE(state, "Insane qpc delay correction of %g seconds. "
|
||||
"Ignoring it.\n", qpc_diff / 10000000.0);
|
||||
}
|
||||
|
||||
/* convert position to the same base as sample_count */
|
||||
position = position * state->format.Format.nSamplesPerSec / state->clock_frequency;
|
||||
|
||||
double diff = sample_count - position;
|
||||
*delay = diff / state->format.Format.nSamplesPerSec;
|
||||
|
||||
MP_TRACE(state, "Device delay: %g samples (%g ms)\n", diff, *delay * 1000);
|
||||
MP_TRACE(state, "Device delay: %g us\n", *delay_us);
|
||||
|
||||
return S_OK;
|
||||
exit_label:
|
||||
@@ -80,11 +92,14 @@ static void thread_feed(struct ao *ao)
|
||||
EXIT_ON_ERROR(hr);
|
||||
|
||||
frame_count -= padding;
|
||||
MP_TRACE(ao, "Frame to fill: %"PRIu32". Padding: %"PRIu32"\n", frame_count, padding);
|
||||
MP_TRACE(ao, "Frame to fill: %"PRIu32". Padding: %"PRIu32"\n",
|
||||
frame_count, padding);
|
||||
}
|
||||
double delay;
|
||||
hr = get_device_delay(state, &delay);
|
||||
double delay_us;
|
||||
hr = get_device_delay(state, &delay_us);
|
||||
EXIT_ON_ERROR(hr);
|
||||
// add the buffer delay
|
||||
delay_us += frame_count * 1e6 / state->format.Format.nSamplesPerSec;
|
||||
|
||||
BYTE *pData;
|
||||
hr = IAudioRenderClient_GetBuffer(state->pRenderClient,
|
||||
@@ -93,10 +108,11 @@ static void thread_feed(struct ao *ao)
|
||||
|
||||
BYTE *data[1] = {pData};
|
||||
|
||||
ao_read_data(ao, (void**)data, frame_count, (int64_t) (
|
||||
mp_time_us() + delay * 1e6 +
|
||||
frame_count * 1e6 / state->format.Format.nSamplesPerSec));
|
||||
ao_read_data(ao, (void **)data, frame_count,
|
||||
mp_time_us() + (int64_t)llrint(delay_us));
|
||||
|
||||
// note, we can't use ao_read_data return value here since we already
|
||||
// commited to frame_count above in the GetBuffer call
|
||||
hr = IAudioRenderClient_ReleaseBuffer(state->pRenderClient,
|
||||
frame_count, 0);
|
||||
EXIT_ON_ERROR(hr);
|
||||
@@ -124,17 +140,21 @@ static void thread_resume(struct ao *ao)
|
||||
mp_HRESULT_to_str(hr));
|
||||
}
|
||||
|
||||
/* Fill the buffer before starting, but only if there is no audio queued to play. */
|
||||
/* This prevents overfilling the buffer, which leads to problems in exclusive mode */
|
||||
// Fill the buffer before starting, but only if there is no audio queued to
|
||||
// play. This prevents overfilling the buffer, which leads to problems in
|
||||
// exclusive mode
|
||||
if (padding < (UINT32) state->bufferFrameCount)
|
||||
thread_feed(ao);
|
||||
|
||||
// start feeding next wakeup if something else hasn't been requested
|
||||
int expected = WASAPI_THREAD_RESUME;
|
||||
atomic_compare_exchange_strong(&state->thread_state, &expected, WASAPI_THREAD_FEED);
|
||||
atomic_compare_exchange_strong(&state->thread_state, &expected,
|
||||
WASAPI_THREAD_FEED);
|
||||
hr = IAudioClient_Start(state->pAudioClient);
|
||||
if (hr != S_OK)
|
||||
MP_ERR(state, "IAudioClient_Start returned %s\n", mp_HRESULT_to_str(hr));
|
||||
if (hr != S_OK) {
|
||||
MP_ERR(state, "IAudioClient_Start returned %s\n",
|
||||
mp_HRESULT_to_str(hr));
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -145,11 +165,11 @@ static void thread_reset(struct ao *ao)
|
||||
HRESULT hr;
|
||||
MP_DBG(state, "Thread Reset\n");
|
||||
hr = IAudioClient_Stop(state->pAudioClient);
|
||||
/* we may get S_FALSE if the stream is already stopped */
|
||||
// we may get S_FALSE if the stream is already stopped
|
||||
if (hr != S_OK && hr != S_FALSE)
|
||||
MP_ERR(state, "IAudioClient_Stop returned: %s\n", mp_HRESULT_to_str(hr));
|
||||
|
||||
/* we may get S_FALSE if the stream is already reset */
|
||||
// we may get S_FALSE if the stream is already reset
|
||||
hr = IAudioClient_Reset(state->pAudioClient);
|
||||
if (hr != S_OK && hr != S_FALSE)
|
||||
MP_ERR(state, "IAudioClient_Reset returned: %s\n", mp_HRESULT_to_str(hr));
|
||||
@@ -157,7 +177,8 @@ static void thread_reset(struct ao *ao)
|
||||
atomic_store(&state->sample_count, 0);
|
||||
// start feeding next wakeup if something else hasn't been requested
|
||||
int expected = WASAPI_THREAD_RESET;
|
||||
atomic_compare_exchange_strong(&state->thread_state, &expected, WASAPI_THREAD_FEED);
|
||||
atomic_compare_exchange_strong(&state->thread_state, &expected,
|
||||
WASAPI_THREAD_FEED);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -173,11 +194,12 @@ static DWORD __stdcall AudioThread(void *lpParameter)
|
||||
goto exit_label;
|
||||
|
||||
MP_DBG(ao, "Entering dispatch loop\n");
|
||||
while (true) { /* watch events */
|
||||
while (true) { // watch events
|
||||
HANDLE events[] = {state->hWake};
|
||||
switch (MsgWaitForMultipleObjects(MP_ARRAY_SIZE(events), events, FALSE, INFINITE,
|
||||
switch (MsgWaitForMultipleObjects(MP_ARRAY_SIZE(events), events,
|
||||
FALSE, INFINITE,
|
||||
QS_POSTMESSAGE | QS_SENDMESSAGE)) {
|
||||
/* AudioThread wakeup */
|
||||
// AudioThread wakeup
|
||||
case WAIT_OBJECT_0:
|
||||
switch (atomic_load(&state->thread_state)) {
|
||||
case WASAPI_THREAD_FEED:
|
||||
@@ -198,7 +220,7 @@ static DWORD __stdcall AudioThread(void *lpParameter)
|
||||
goto exit_label;
|
||||
}
|
||||
break;
|
||||
/* messages to dispatch (COM marshalling) */
|
||||
// messages to dispatch (COM marshalling)
|
||||
case (WAIT_OBJECT_0 + MP_ARRAY_SIZE(events)):
|
||||
wasapi_dispatch(ao);
|
||||
break;
|
||||
@@ -215,7 +237,8 @@ exit_label:
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void set_thread_state(struct ao *ao, enum wasapi_thread_state thread_state)
|
||||
static void set_thread_state(struct ao *ao,
|
||||
enum wasapi_thread_state thread_state)
|
||||
{
|
||||
struct wasapi_state *state = ao->priv;
|
||||
atomic_store(&state->thread_state, thread_state);
|
||||
@@ -230,20 +253,22 @@ static void uninit(struct ao *ao)
|
||||
if (state->hWake)
|
||||
set_thread_state(ao, WASAPI_THREAD_SHUTDOWN);
|
||||
|
||||
/* wait up to 10 seconds */
|
||||
// wait up to 10 seconds
|
||||
if (state->hAudioThread &&
|
||||
WaitForSingleObject(state->hAudioThread, 10000) == WAIT_TIMEOUT)
|
||||
{
|
||||
MP_ERR(ao, "Audio loop thread refuses to abort\n");
|
||||
return;
|
||||
}
|
||||
if (state->VistaBlob.hAvrt)
|
||||
FreeLibrary(state->VistaBlob.hAvrt);
|
||||
|
||||
SAFE_RELEASE(state->hInitDone, CloseHandle(state->hInitDone));
|
||||
SAFE_RELEASE(state->hWake, CloseHandle(state->hWake));
|
||||
SAFE_RELEASE(state->hAudioThread,CloseHandle(state->hAudioThread));
|
||||
|
||||
wasapi_change_uninit(ao);
|
||||
|
||||
talloc_free(state->deviceID);
|
||||
|
||||
CoUninitialize();
|
||||
MP_DBG(ao, "Uninit wasapi done\n");
|
||||
}
|
||||
@@ -255,8 +280,14 @@ static int init(struct ao *ao)
|
||||
|
||||
struct wasapi_state *state = ao->priv;
|
||||
state->log = ao->log;
|
||||
if(!wasapi_fill_VistaBlob(state))
|
||||
MP_WARN(ao, "Error loading thread priority functions\n");
|
||||
|
||||
state->deviceID = find_deviceID(ao);
|
||||
if (!state->deviceID) {
|
||||
uninit(ao);
|
||||
return -1;
|
||||
}
|
||||
|
||||
wasapi_change_init(ao, false);
|
||||
|
||||
state->hInitDone = CreateEventW(NULL, FALSE, FALSE, NULL);
|
||||
state->hWake = CreateEventW(NULL, FALSE, FALSE, NULL);
|
||||
@@ -274,7 +305,7 @@ static int init(struct ao *ao)
|
||||
return -1;
|
||||
}
|
||||
|
||||
WaitForSingleObject(state->hInitDone, INFINITE); /* wait on init complete */
|
||||
WaitForSingleObject(state->hInitDone, INFINITE); // wait on init complete
|
||||
SAFE_RELEASE(state->hInitDone,CloseHandle(state->hInitDone));
|
||||
if (state->init_ret != S_OK) {
|
||||
if (!ao->probing)
|
||||
@@ -283,88 +314,135 @@ static int init(struct ao *ao)
|
||||
return -1;
|
||||
}
|
||||
|
||||
wasapi_setup_proxies(state);
|
||||
wasapi_receive_proxies(state);
|
||||
MP_DBG(ao, "Init wasapi done\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int control_exclusive(struct ao *ao, enum aocontrol cmd, void *arg)
|
||||
{
|
||||
struct wasapi_state *state = ao->priv;
|
||||
|
||||
switch (cmd) {
|
||||
case AOCONTROL_GET_VOLUME:
|
||||
case AOCONTROL_SET_VOLUME:
|
||||
if (!state->pEndpointVolumeProxy ||
|
||||
!(state->vol_hw_support & ENDPOINT_HARDWARE_SUPPORT_VOLUME)) {
|
||||
return CONTROL_FALSE;
|
||||
}
|
||||
|
||||
float volume;
|
||||
switch (cmd) {
|
||||
case AOCONTROL_GET_VOLUME:
|
||||
IAudioEndpointVolume_GetMasterVolumeLevelScalar(
|
||||
state->pEndpointVolumeProxy,
|
||||
&volume);
|
||||
*(ao_control_vol_t *)arg = (ao_control_vol_t){
|
||||
.left = 100.0f * volume,
|
||||
.right = 100.0f * volume,
|
||||
};
|
||||
return CONTROL_OK;
|
||||
case AOCONTROL_SET_VOLUME:
|
||||
volume = ((ao_control_vol_t *)arg)->left / 100.f;
|
||||
IAudioEndpointVolume_SetMasterVolumeLevelScalar(
|
||||
state->pEndpointVolumeProxy,
|
||||
volume, NULL);
|
||||
return CONTROL_OK;
|
||||
}
|
||||
case AOCONTROL_GET_MUTE:
|
||||
case AOCONTROL_SET_MUTE:
|
||||
if (!state->pEndpointVolumeProxy ||
|
||||
!(state->vol_hw_support & ENDPOINT_HARDWARE_SUPPORT_MUTE)) {
|
||||
return CONTROL_FALSE;
|
||||
}
|
||||
|
||||
BOOL mute;
|
||||
switch (cmd) {
|
||||
case AOCONTROL_GET_MUTE:
|
||||
IAudioEndpointVolume_GetMute(state->pEndpointVolumeProxy,
|
||||
&mute);
|
||||
*(bool *)arg = mute;
|
||||
return CONTROL_OK;
|
||||
case AOCONTROL_SET_MUTE:
|
||||
mute = *(bool *)arg;
|
||||
IAudioEndpointVolume_SetMute(state->pEndpointVolumeProxy,
|
||||
mute, NULL);
|
||||
return CONTROL_OK;
|
||||
}
|
||||
case AOCONTROL_HAS_PER_APP_VOLUME:
|
||||
return CONTROL_FALSE;
|
||||
default:
|
||||
return CONTROL_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
static int control_shared(struct ao *ao, enum aocontrol cmd, void *arg)
|
||||
{
|
||||
struct wasapi_state *state = ao->priv;
|
||||
if (!state->pAudioVolumeProxy)
|
||||
return CONTROL_UNKNOWN;
|
||||
|
||||
float volume;
|
||||
BOOL mute;
|
||||
switch(cmd) {
|
||||
case AOCONTROL_GET_VOLUME:
|
||||
ISimpleAudioVolume_GetMasterVolume(state->pAudioVolumeProxy,
|
||||
&volume);
|
||||
*(ao_control_vol_t *)arg = (ao_control_vol_t){
|
||||
.left = 100.0f * volume,
|
||||
.right = 100.0f * volume,
|
||||
};
|
||||
return CONTROL_OK;
|
||||
case AOCONTROL_SET_VOLUME:
|
||||
volume = ((ao_control_vol_t *)arg)->left / 100.f;
|
||||
ISimpleAudioVolume_SetMasterVolume(state->pAudioVolumeProxy,
|
||||
volume, NULL);
|
||||
return CONTROL_OK;
|
||||
case AOCONTROL_GET_MUTE:
|
||||
ISimpleAudioVolume_GetMute(state->pAudioVolumeProxy, &mute);
|
||||
*(bool *)arg = mute;
|
||||
return CONTROL_OK;
|
||||
case AOCONTROL_SET_MUTE:
|
||||
mute = *(bool *)arg;
|
||||
ISimpleAudioVolume_SetMute(state->pAudioVolumeProxy, mute, NULL);
|
||||
return CONTROL_OK;
|
||||
case AOCONTROL_HAS_PER_APP_VOLUME:
|
||||
return CONTROL_TRUE;
|
||||
default:
|
||||
return CONTROL_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
static int control(struct ao *ao, enum aocontrol cmd, void *arg)
|
||||
{
|
||||
struct wasapi_state *state = ao->priv;
|
||||
ao_control_vol_t *vol = arg;
|
||||
BOOL mute;
|
||||
|
||||
// common to exclusive and shared
|
||||
switch (cmd) {
|
||||
case AOCONTROL_GET_VOLUME:
|
||||
if (state->opt_exclusive)
|
||||
IAudioEndpointVolume_GetMasterVolumeLevelScalar(state->pEndpointVolumeProxy,
|
||||
&state->audio_volume);
|
||||
else
|
||||
ISimpleAudioVolume_GetMasterVolume(state->pAudioVolumeProxy,
|
||||
&state->audio_volume);
|
||||
case AOCONTROL_UPDATE_STREAM_TITLE:
|
||||
if (!state->pSessionControlProxy)
|
||||
return CONTROL_FALSE;
|
||||
|
||||
/* check to see if user manually changed volume through mixer;
|
||||
this information is used in exclusive mode for restoring the mixer volume on uninit */
|
||||
if (state->audio_volume != state->previous_volume) {
|
||||
MP_VERBOSE(state, "Mixer difference: %.2g now, expected %.2g\n",
|
||||
state->audio_volume, state->previous_volume);
|
||||
state->initial_volume = state->audio_volume;
|
||||
}
|
||||
|
||||
vol->left = vol->right = 100.0f * state->audio_volume;
|
||||
return CONTROL_OK;
|
||||
case AOCONTROL_SET_VOLUME:
|
||||
state->audio_volume = vol->left / 100.f;
|
||||
if (state->opt_exclusive)
|
||||
IAudioEndpointVolume_SetMasterVolumeLevelScalar(state->pEndpointVolumeProxy,
|
||||
state->audio_volume, NULL);
|
||||
else
|
||||
ISimpleAudioVolume_SetMasterVolume(state->pAudioVolumeProxy,
|
||||
state->audio_volume, NULL);
|
||||
|
||||
state->previous_volume = state->audio_volume;
|
||||
return CONTROL_OK;
|
||||
case AOCONTROL_GET_MUTE:
|
||||
if (state->opt_exclusive)
|
||||
IAudioEndpointVolume_GetMute(state->pEndpointVolumeProxy, &mute);
|
||||
else
|
||||
ISimpleAudioVolume_GetMute(state->pAudioVolumeProxy, &mute);
|
||||
*(bool*)arg = mute;
|
||||
|
||||
return CONTROL_OK;
|
||||
case AOCONTROL_SET_MUTE:
|
||||
mute = *(bool*)arg;
|
||||
if (state->opt_exclusive)
|
||||
IAudioEndpointVolume_SetMute(state->pEndpointVolumeProxy, mute, NULL);
|
||||
else
|
||||
ISimpleAudioVolume_SetMute(state->pAudioVolumeProxy, mute, NULL);
|
||||
|
||||
return CONTROL_OK;
|
||||
case AOCONTROL_HAS_PER_APP_VOLUME:
|
||||
return CONTROL_TRUE;
|
||||
case AOCONTROL_UPDATE_STREAM_TITLE: {
|
||||
MP_VERBOSE(state, "Updating stream title to \"%s\"\n", (char*)arg);
|
||||
wchar_t *title = mp_from_utf8(NULL, (char*)arg);
|
||||
|
||||
wchar_t *tmp = NULL;
|
||||
|
||||
/* There is a weird race condition in the IAudioSessionControl itself --
|
||||
it seems that *sometimes* the SetDisplayName does not take effect and it still shows
|
||||
the old title. Use this loop to insist until it works. */
|
||||
// There is a weird race condition in the IAudioSessionControl itself --
|
||||
// it seems that *sometimes* the SetDisplayName does not take effect and
|
||||
// it still shows the old title. Use this loop to insist until it works.
|
||||
do {
|
||||
IAudioSessionControl_SetDisplayName(state->pSessionControlProxy, title, NULL);
|
||||
IAudioSessionControl_SetDisplayName(state->pSessionControlProxy,
|
||||
title, NULL);
|
||||
|
||||
SAFE_RELEASE(tmp, CoTaskMemFree(tmp));
|
||||
IAudioSessionControl_GetDisplayName(state->pSessionControlProxy, &tmp);
|
||||
IAudioSessionControl_GetDisplayName(state->pSessionControlProxy,
|
||||
&tmp);
|
||||
} while (lstrcmpW(title, tmp));
|
||||
SAFE_RELEASE(tmp, CoTaskMemFree(tmp));
|
||||
talloc_free(title);
|
||||
|
||||
return CONTROL_OK;
|
||||
}
|
||||
default:
|
||||
return CONTROL_UNKNOWN;
|
||||
}
|
||||
|
||||
return state->opt_exclusive ?
|
||||
control_exclusive(ao, cmd, arg) : control_shared(ao, cmd, arg);
|
||||
}
|
||||
|
||||
static void audio_reset(struct ao *ao)
|
||||
@@ -380,9 +458,7 @@ static void audio_resume(struct ao *ao)
|
||||
static void hotplug_uninit(struct ao *ao)
|
||||
{
|
||||
MP_DBG(ao, "Hotplug uninit\n");
|
||||
struct wasapi_state *state = ao->priv;
|
||||
wasapi_change_uninit(ao);
|
||||
SAFE_RELEASE(state->pEnumerator, IMMDeviceEnumerator_Release(state->pEnumerator));
|
||||
CoUninitialize();
|
||||
}
|
||||
|
||||
@@ -392,10 +468,7 @@ static int hotplug_init(struct ao *ao)
|
||||
struct wasapi_state *state = ao->priv;
|
||||
state->log = ao->log;
|
||||
CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
|
||||
HRESULT hr = CoCreateInstance(&CLSID_MMDeviceEnumerator, NULL, CLSCTX_ALL,
|
||||
&IID_IMMDeviceEnumerator, (void **)&state->pEnumerator);
|
||||
EXIT_ON_ERROR(hr);
|
||||
hr = wasapi_change_init(ao, true);
|
||||
HRESULT hr = wasapi_change_init(ao, true);
|
||||
EXIT_ON_ERROR(hr);
|
||||
|
||||
return 0;
|
||||
|
||||
Executable → Regular
+63
-58
@@ -20,17 +20,24 @@
|
||||
#ifndef MP_AO_WASAPI_H_
|
||||
#define MP_AO_WASAPI_H_
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
#include <windows.h>
|
||||
#include <mmdeviceapi.h>
|
||||
#include <audioclient.h>
|
||||
#include <audiopolicy.h>
|
||||
#include <mmdeviceapi.h>
|
||||
#include <avrt.h>
|
||||
#include <endpointvolume.h>
|
||||
|
||||
#include "common/msg.h"
|
||||
#include "osdep/atomics.h"
|
||||
#include "osdep/windows_utils.h"
|
||||
#include "internal.h"
|
||||
#include "ao.h"
|
||||
|
||||
typedef struct change_notify {
|
||||
IMMNotificationClient client; /* this must be first in the structure! */
|
||||
LPWSTR monitored; /* Monitored device */
|
||||
IMMNotificationClient client; // this must be first in the structure!
|
||||
IMMDeviceEnumerator *pEnumerator; // object where client is registered
|
||||
LPWSTR monitored; // Monitored device
|
||||
bool is_hotplug;
|
||||
struct ao *ao;
|
||||
} change_notify;
|
||||
@@ -52,75 +59,73 @@ enum wasapi_thread_state {
|
||||
|
||||
typedef struct wasapi_state {
|
||||
struct mp_log *log;
|
||||
/* Init phase */
|
||||
HRESULT init_ret;
|
||||
HANDLE hInitDone;
|
||||
int share_mode;
|
||||
|
||||
/* volume control */
|
||||
DWORD vol_hw_support;
|
||||
float audio_volume;
|
||||
float previous_volume;
|
||||
float initial_volume;
|
||||
// Thread handles
|
||||
HRESULT init_ret; // status of init phase
|
||||
HANDLE hInitDone; // set when init is complete in audio thread
|
||||
HANDLE hAudioThread; // the audio thread itself
|
||||
HANDLE hWake; // thread wakeup event
|
||||
atomic_int thread_state; // enum wasapi_thread_state (what to do on wakeup)
|
||||
|
||||
/* WASAPI handles, owned by audio thread */
|
||||
// for setting the audio thread priority
|
||||
HANDLE hTask;
|
||||
|
||||
// ID of the device to use
|
||||
LPWSTR deviceID;
|
||||
// WASAPI object handles owned and used by audio thread
|
||||
IMMDevice *pDevice;
|
||||
IAudioClient *pAudioClient;
|
||||
IAudioRenderClient *pRenderClient;
|
||||
ISimpleAudioVolume *pAudioVolume;
|
||||
IAudioEndpointVolume *pEndpointVolume;
|
||||
IAudioSessionControl *pSessionControl;
|
||||
IMMDeviceEnumerator *pEnumerator;
|
||||
|
||||
/* thread handles */
|
||||
HANDLE hAudioThread; /* the thread itself */
|
||||
HANDLE hWake; /* thread wakeup event */
|
||||
atomic_int thread_state; /* enum wasapi_thread_state */
|
||||
|
||||
/* for setting the audio thread priority */
|
||||
HANDLE hTask; /* AV thread */
|
||||
DWORD taskIndex; /* AV task ID */
|
||||
|
||||
/* WASAPI proxy handles, for Single-Threaded Apartment communication.
|
||||
One is needed for each audio thread object that's accessed from the main thread. */
|
||||
ISimpleAudioVolume *pAudioVolumeProxy;
|
||||
IAudioEndpointVolume *pEndpointVolumeProxy;
|
||||
IAudioSessionControl *pSessionControlProxy;
|
||||
|
||||
/* Streams used to marshal the proxy objects. The thread owning the actual objects
|
||||
needs to marshal proxy objects into these streams, and the thread that wants the
|
||||
proxies unmarshals them from here. */
|
||||
IStream *sAudioVolume;
|
||||
IStream *sEndpointVolume;
|
||||
IStream *sSessionControl;
|
||||
|
||||
/* WASAPI internal clock information, for estimating delay */
|
||||
// WASAPI internal clock information, for estimating delay
|
||||
IAudioClock *pAudioClock;
|
||||
UINT64 clock_frequency; /* scale for the "samples" returned by the clock */
|
||||
atomic_ullong sample_count; /* the amount of samples per channel written to a GetBuffer buffer */
|
||||
LARGE_INTEGER qpc_frequency; /* frequency of windows' high resolution timer */
|
||||
atomic_ullong sample_count; // samples per channel written by GetBuffer
|
||||
UINT64 clock_frequency; // scale for position returned by GetPosition
|
||||
LARGE_INTEGER qpc_frequency; // frequency of Windows' high resolution timer
|
||||
|
||||
/* ao options */
|
||||
// WASAPI control (handles owned by audio thread but used by main thread)
|
||||
IAudioSessionControl *pSessionControl; // setting the stream title
|
||||
IAudioEndpointVolume *pEndpointVolume; // exclusive mode volume/mute
|
||||
ISimpleAudioVolume *pAudioVolume; // shared mode volume/mute
|
||||
DWORD vol_hw_support; // is hardware volume supported for exclusive-mode?
|
||||
|
||||
// Streams used to marshal the proxy objects. The thread owning the actual
|
||||
// objects needs to marshal proxy objects into these streams, and the thread
|
||||
// that wants the proxies unmarshals them from here.
|
||||
IStream *sSessionControl;
|
||||
IStream *sEndpointVolume;
|
||||
IStream *sAudioVolume;
|
||||
|
||||
// WASAPI proxy handles, for Single-Threaded Apartment communication. One is
|
||||
// needed for each audio thread object that's accessed from the main thread.
|
||||
IAudioSessionControl *pSessionControlProxy;
|
||||
IAudioEndpointVolume *pEndpointVolumeProxy;
|
||||
ISimpleAudioVolume *pAudioVolumeProxy;
|
||||
|
||||
// ao options
|
||||
int opt_exclusive;
|
||||
int opt_list;
|
||||
char *opt_device;
|
||||
|
||||
/* format info */
|
||||
// format info
|
||||
WAVEFORMATEXTENSIBLE format;
|
||||
size_t buffer_block_size; /* Size of each block in bytes */
|
||||
UINT32 bufferFrameCount; /* wasapi buffer block size, number of frames, frame size at format.nBlockAlign */
|
||||
|
||||
/* Don't use these functions directly in case
|
||||
they are unimplemented for some reason.
|
||||
(XP shouldn't be an issue since it doesn't support wasapi, maybe wine?)
|
||||
Blob is owned by the main thread */
|
||||
struct {
|
||||
HMODULE hAvrt;
|
||||
HANDLE (WINAPI *pAvSetMmThreadCharacteristicsW)(LPCWSTR, LPDWORD);
|
||||
WINBOOL (WINAPI *pAvRevertMmThreadCharacteristics)(HANDLE);
|
||||
} VistaBlob;
|
||||
AUDCLNT_SHAREMODE share_mode; // AUDCLNT_SHAREMODE_EXCLUSIVE / SHARED
|
||||
UINT32 bufferFrameCount; // number of frames in buffer
|
||||
|
||||
change_notify change;
|
||||
} wasapi_state;
|
||||
|
||||
char *mp_PKEY_to_str_buf(char *buf, size_t buf_size, const PROPERTYKEY *pkey);
|
||||
#define mp_PKEY_to_str(pkey) mp_PKEY_to_str_buf((char[42]){0}, 42, (pkey))
|
||||
|
||||
void wasapi_list_devs(struct ao *ao, struct ao_device_list *list);
|
||||
LPWSTR find_deviceID(struct ao *ao);
|
||||
|
||||
void wasapi_dispatch(struct ao *ao);
|
||||
HRESULT wasapi_thread_init(struct ao *ao);
|
||||
void wasapi_thread_uninit(struct ao *ao);
|
||||
|
||||
void wasapi_receive_proxies(wasapi_state *state);
|
||||
void wasapi_release_proxies(wasapi_state *state);
|
||||
|
||||
#endif
|
||||
Executable → Regular
+33
-33
@@ -17,20 +17,14 @@
|
||||
* with mpv. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <initguid.h>
|
||||
#include <audioclient.h>
|
||||
#include <endpointvolume.h>
|
||||
#include <mmdeviceapi.h>
|
||||
#include <wchar.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "ao_wasapi.h"
|
||||
#include "ao_wasapi_utils.h"
|
||||
|
||||
static HRESULT STDMETHODCALLTYPE sIMMNotificationClient_QueryInterface(
|
||||
IMMNotificationClient* This, REFIID riid, void **ppvObject)
|
||||
{
|
||||
/* Compatible with IMMNotificationClient and IUnknown */
|
||||
// Compatible with IMMNotificationClient and IUnknown
|
||||
if (IsEqualGUID(&IID_IMMNotificationClient, riid) ||
|
||||
IsEqualGUID(&IID_IUnknown, riid))
|
||||
{
|
||||
@@ -42,14 +36,14 @@ static HRESULT STDMETHODCALLTYPE sIMMNotificationClient_QueryInterface(
|
||||
}
|
||||
}
|
||||
|
||||
/* these are required, but not actually used */
|
||||
// these are required, but not actually used
|
||||
static ULONG STDMETHODCALLTYPE sIMMNotificationClient_AddRef(
|
||||
IMMNotificationClient *This)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* MSDN says it should free itself, but we're static */
|
||||
// MSDN says it should free itself, but we're static
|
||||
static ULONG STDMETHODCALLTYPE sIMMNotificationClient_Release(
|
||||
IMMNotificationClient *This)
|
||||
{
|
||||
@@ -65,7 +59,8 @@ static HRESULT STDMETHODCALLTYPE sIMMNotificationClient_OnDeviceStateChanged(
|
||||
struct ao *ao = change->ao;
|
||||
|
||||
if (change->is_hotplug) {
|
||||
MP_VERBOSE(ao, "OnDeviceStateChanged triggered: sending hotplug event\n");
|
||||
MP_VERBOSE(ao,
|
||||
"OnDeviceStateChanged triggered: sending hotplug event\n");
|
||||
ao_hotplug_event(ao);
|
||||
} else if (pwstrDeviceId && !wcscmp(pwstrDeviceId, change->monitored)) {
|
||||
switch (dwNewState) {
|
||||
@@ -99,7 +94,7 @@ static HRESULT STDMETHODCALLTYPE sIMMNotificationClient_OnDeviceAdded(
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
/* maybe MPV can go over to the prefered device once it is plugged in? */
|
||||
// maybe MPV can go over to the prefered device once it is plugged in?
|
||||
static HRESULT STDMETHODCALLTYPE sIMMNotificationClient_OnDeviceRemoved(
|
||||
IMMNotificationClient *This,
|
||||
LPCWSTR pwstrDeviceId)
|
||||
@@ -129,29 +124,31 @@ static HRESULT STDMETHODCALLTYPE sIMMNotificationClient_OnDefaultDeviceChanged(
|
||||
struct ao *ao = change->ao;
|
||||
struct wasapi_state *state = ao->priv;
|
||||
|
||||
/* don't care about "eCapture" or non-"eMultimedia" roles */
|
||||
// don't care about "eCapture" or non-"eMultimedia" roles
|
||||
if (flow == eCapture || role != eMultimedia) return S_OK;
|
||||
|
||||
if (change->is_hotplug) {
|
||||
MP_VERBOSE(ao, "OnDefaultDeviceChanged triggered: sending hotplug event\n");
|
||||
MP_VERBOSE(ao,
|
||||
"OnDefaultDeviceChanged triggered: sending hotplug event\n");
|
||||
ao_hotplug_event(ao);
|
||||
} else {
|
||||
/* stay on the device the user specified */
|
||||
// stay on the device the user specified
|
||||
if (state->opt_device) {
|
||||
MP_VERBOSE(ao, "OnDefaultDeviceChanged triggered: "
|
||||
"staying on specified device %s\n", state->opt_device);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
/* don't reload if already on the new default */
|
||||
// don't reload if already on the new default
|
||||
if (pwstrDeviceId && !wcscmp(pwstrDeviceId, change->monitored)) {
|
||||
MP_VERBOSE(ao, "OnDefaultDeviceChanged triggered: "
|
||||
"already using default device, no reload required\n");
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
/* if we got here, we need to reload */
|
||||
MP_VERBOSE(ao, "OnDefaultDeviceChanged triggered: requesting ao reload\n");
|
||||
// if we got here, we need to reload
|
||||
MP_VERBOSE(ao,
|
||||
"OnDefaultDeviceChanged triggered: requesting ao reload\n");
|
||||
ao_request_reload(ao);
|
||||
}
|
||||
|
||||
@@ -184,7 +181,7 @@ static HRESULT STDMETHODCALLTYPE sIMMNotificationClient_OnPropertyValueChanged(
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static CONST_VTBL IMMNotificationClientVtbl sIMMDeviceEnumeratorVtbl_vtbl = {
|
||||
static CONST_VTBL IMMNotificationClientVtbl sIMMNotificationClientVtbl = {
|
||||
.QueryInterface = sIMMNotificationClient_QueryInterface,
|
||||
.AddRef = sIMMNotificationClient_AddRef,
|
||||
.Release = sIMMNotificationClient_Release,
|
||||
@@ -200,27 +197,30 @@ HRESULT wasapi_change_init(struct ao *ao, bool is_hotplug)
|
||||
{
|
||||
struct wasapi_state *state = ao->priv;
|
||||
struct change_notify *change = &state->change;
|
||||
HRESULT hr;
|
||||
/* COM voodoo to emulate c++ class */
|
||||
change->client.lpVtbl = &sIMMDeviceEnumeratorVtbl_vtbl;
|
||||
|
||||
/* register the change notification client */
|
||||
hr = IMMDeviceEnumerator_RegisterEndpointNotificationCallback(
|
||||
state->pEnumerator, (IMMNotificationClient *)change);
|
||||
HRESULT hr = CoCreateInstance(&CLSID_MMDeviceEnumerator, NULL, CLSCTX_ALL,
|
||||
&IID_IMMDeviceEnumerator,
|
||||
(void **)&change->pEnumerator);
|
||||
EXIT_ON_ERROR(hr);
|
||||
|
||||
/* so the callbacks can access the ao */
|
||||
// COM voodoo to emulate c++ class
|
||||
change->client.lpVtbl = &sIMMNotificationClientVtbl;
|
||||
|
||||
// register the change notification client
|
||||
hr = IMMDeviceEnumerator_RegisterEndpointNotificationCallback(
|
||||
change->pEnumerator, (IMMNotificationClient *)change);
|
||||
EXIT_ON_ERROR(hr);
|
||||
|
||||
// so the callbacks can access the ao
|
||||
change->ao = ao;
|
||||
|
||||
/* whether or not this is the hotplug instance */
|
||||
// whether or not this is the hotplug instance
|
||||
change->is_hotplug = is_hotplug;
|
||||
|
||||
if (is_hotplug) {
|
||||
MP_DBG(ao, "Monitoring for hotplug events\n");
|
||||
} else {
|
||||
/* Get the device string to compare with the pwstrDeviceId */
|
||||
hr = IMMDevice_GetId(state->pDevice, &change->monitored);
|
||||
EXIT_ON_ERROR(hr);
|
||||
// Get the device string to compare with the pwstrDeviceId
|
||||
change->monitored = state->deviceID;
|
||||
MP_VERBOSE(ao, "Monitoring changes in device %S\n", change->monitored);
|
||||
}
|
||||
|
||||
@@ -237,10 +237,10 @@ void wasapi_change_uninit(struct ao *ao)
|
||||
struct wasapi_state *state = ao->priv;
|
||||
struct change_notify *change = &state->change;
|
||||
|
||||
if (state->pEnumerator && change->client.lpVtbl) {
|
||||
if (change->pEnumerator && change->client.lpVtbl) {
|
||||
IMMDeviceEnumerator_UnregisterEndpointNotificationCallback(
|
||||
state->pEnumerator, (IMMNotificationClient *)change);
|
||||
change->pEnumerator, (IMMNotificationClient *)change);
|
||||
}
|
||||
|
||||
if (change->monitored) CoTaskMemFree(change->monitored);
|
||||
SAFE_RELEASE(change->pEnumerator, IMMDeviceEnumerator_Release(change->pEnumerator));
|
||||
}
|
||||
Executable → Regular
+391
-498
File diff suppressed because it is too large.
Load diff
@@ -1,48 +0,0 @@
|
||||
/*
|
||||
* This file is part of mpv.
|
||||
*
|
||||
* Original author: Jonathan Yong <10walls@gmail.com>
|
||||
*
|
||||
* mpv is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* mpv is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with mpv. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef MP_AO_WASAPI_UTILS_H_
|
||||
#define MP_AO_WASAPI_UTILS_H_
|
||||
|
||||
#include "audio/out/ao_wasapi.h"
|
||||
|
||||
#include "options/m_option.h"
|
||||
#include "common/msg.h"
|
||||
#include "ao.h"
|
||||
#include "internal.h"
|
||||
|
||||
char *mp_GUID_to_str_buf(char *buf, size_t buf_size, const GUID *guid);
|
||||
char *mp_PKEY_to_str_buf(char *buf, size_t buf_size, const PROPERTYKEY *pkey);
|
||||
char *mp_HRESULT_to_str_buf(char *buf, size_t buf_size, HRESULT hr);
|
||||
#define mp_GUID_to_str(guid) mp_GUID_to_str_buf((char[40]){0}, 40, (guid))
|
||||
#define mp_PKEY_to_str(pkey) mp_PKEY_to_str_buf((char[42]){0}, 42, (pkey))
|
||||
#define mp_HRESULT_to_str(hr) mp_HRESULT_to_str_buf((char[60]){0}, 60, (hr))
|
||||
|
||||
bool wasapi_fill_VistaBlob(wasapi_state *state);
|
||||
|
||||
void wasapi_list_devs(struct ao *ao, struct ao_device_list *list);
|
||||
|
||||
void wasapi_dispatch(struct ao *ao);
|
||||
HRESULT wasapi_thread_init(struct ao *ao);
|
||||
void wasapi_thread_uninit(struct ao *ao);
|
||||
|
||||
HRESULT wasapi_setup_proxies(wasapi_state *state);
|
||||
void wasapi_release_proxies(wasapi_state *state);
|
||||
|
||||
#endif
|
||||
+1
-1
@@ -113,7 +113,7 @@ static int play(struct ao *ao, void **data, int samples, int flags)
|
||||
// rest of the user-provided buffer with silence.
|
||||
// This basically assumes that the audio device doesn't care about underruns.
|
||||
// If this is called in paused mode, it will always return 0.
|
||||
// The caller should set out_time_us to the expected delay the last sample
|
||||
// The caller should set out_time_us to the expected delay until the last sample
|
||||
// reaches the speakers, in microseconds, using mp_time_us() as reference.
|
||||
int ao_read_data(struct ao *ao, void **data, int samples, int64_t out_time_us)
|
||||
{
|
||||
|
||||
@@ -65,6 +65,7 @@ void mp_copy_lav_codec_headers(AVCodecContext *avctx, AVCodecContext *st)
|
||||
avctx->block_align = st->block_align;
|
||||
avctx->channel_layout = st->channel_layout;
|
||||
avctx->bits_per_coded_sample = st->bits_per_coded_sample;
|
||||
avctx->has_b_frames = st->has_b_frames;
|
||||
}
|
||||
|
||||
// We merely pass-through our PTS/DTS as an int64_t; libavcodec won't use it.
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
#include "talloc.h"
|
||||
#include "mpv_talloc.h"
|
||||
#include "misc/bstr.h"
|
||||
#include "common/msg.h"
|
||||
#include "codecs.h"
|
||||
|
||||
+20
-2
@@ -21,8 +21,9 @@
|
||||
#include <libavutil/common.h>
|
||||
#include <libavutil/error.h>
|
||||
|
||||
#include "talloc.h"
|
||||
#include "mpv_talloc.h"
|
||||
#include "misc/bstr.h"
|
||||
#include "misc/ctype.h"
|
||||
#include "common/common.h"
|
||||
|
||||
#define appendf(ptr, ...) \
|
||||
@@ -148,7 +149,7 @@ void mp_append_utf8_bstr(void *talloc_ctx, struct bstr *buf, uint32_t codepoint)
|
||||
bstr_xappend(talloc_ctx, buf, (bstr){data, output - data});
|
||||
}
|
||||
|
||||
// Parse a C-style escape beginning at code, and append the result to *str
|
||||
// Parse a C/JSON-style escape beginning at code, and append the result to *str
|
||||
// using talloc. The input string (*code) must point to the first character
|
||||
// after the initial '\', and after parsing *code is set to the first character
|
||||
// after the current escape.
|
||||
@@ -161,6 +162,7 @@ static bool mp_parse_escape(void *talloc_ctx, bstr *dst, bstr *code)
|
||||
switch (code->start[0]) {
|
||||
case '"': replace = '"'; break;
|
||||
case '\\': replace = '\\'; break;
|
||||
case '/': replace = '/'; break;
|
||||
case 'b': replace = '\b'; break;
|
||||
case 'f': replace = '\f'; break;
|
||||
case 'n': replace = '\n'; break;
|
||||
@@ -257,3 +259,19 @@ char *mp_strerror_buf(char *buf, size_t buf_size, int errnum)
|
||||
av_strerror(AVERROR(errnum), buf, buf_size);
|
||||
return buf;
|
||||
}
|
||||
|
||||
char *mp_tag_str_buf(char *buf, size_t buf_size, uint32_t tag)
|
||||
{
|
||||
if (buf_size < 1)
|
||||
return buf;
|
||||
buf[0] = '\0';
|
||||
for (int n = 0; n < 4; n++) {
|
||||
uint8_t val = (tag >> (n * 8)) & 0xFF;
|
||||
if (mp_isalnum(val) || val == '_' || val == ' ') {
|
||||
mp_snprintf_cat(buf, buf_size, "%c", val);
|
||||
} else {
|
||||
mp_snprintf_cat(buf, buf_size, "[%d]", val);
|
||||
}
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
+4
-3
@@ -24,7 +24,7 @@
|
||||
#include <stdint.h>
|
||||
|
||||
#include "osdep/compiler.h"
|
||||
#include "talloc.h"
|
||||
#include "mpv_talloc.h"
|
||||
|
||||
// double should be able to represent this exactly
|
||||
#define MP_NOPTS_VALUE (-0x1p+63)
|
||||
@@ -32,8 +32,6 @@
|
||||
#define MP_CONCAT_(a, b) a ## b
|
||||
#define MP_CONCAT(a, b) MP_CONCAT_(a, b)
|
||||
|
||||
#define ROUND(x) ((int)((x) < 0 ? (x) - 0.5 : (x) + 0.5))
|
||||
|
||||
#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
|
||||
#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
|
||||
#define MPCLAMP(a, min, max) (((a) < (min)) ? (min) : (((a) > (max)) ? (max) : (a)))
|
||||
@@ -92,4 +90,7 @@ bool mp_append_escaped_string(void *talloc_ctx, struct bstr *dst,
|
||||
char *mp_strerror_buf(char *buf, size_t buf_size, int errnum);
|
||||
#define mp_strerror(e) mp_strerror_buf((char[80]){0}, 80, e)
|
||||
|
||||
char *mp_tag_str_buf(char *buf, size_t buf_size, uint32_t tag);
|
||||
#define mp_tag_str(t) mp_tag_str_buf((char[22]){0}, 22, t)
|
||||
|
||||
#endif /* MPLAYER_MPCOMMON_H */
|
||||
@@ -29,7 +29,7 @@
|
||||
#include "options/options.h"
|
||||
#include "osdep/timer.h"
|
||||
#include "video/out/vo.h"
|
||||
#include "talloc.h"
|
||||
#include "mpv_talloc.h"
|
||||
#include "stream/stream.h"
|
||||
|
||||
#define OPT_BASE_STRUCT struct encode_opts
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
struct mpv_global {
|
||||
struct MPOpts *opts;
|
||||
struct mp_log *log;
|
||||
struct mp_client_api *client_api;
|
||||
};
|
||||
|
||||
#endif
|
||||
+4
-6
@@ -24,7 +24,7 @@
|
||||
#include <pthread.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "talloc.h"
|
||||
#include "mpv_talloc.h"
|
||||
|
||||
#include "misc/bstr.h"
|
||||
#include "osdep/atomics.h"
|
||||
@@ -326,10 +326,8 @@ static void write_msg_to_buffers(struct mp_log *log, int lev, char *text)
|
||||
static void dump_stats(struct mp_log *log, int lev, char *text)
|
||||
{
|
||||
struct mp_log_root *root = log->root;
|
||||
if (lev == MSGL_STATS && root->stats_file) {
|
||||
fprintf(root->stats_file, "%"PRId64" %s #%s\n", mp_time_us(), text,
|
||||
log->verbose_prefix);
|
||||
}
|
||||
if (lev == MSGL_STATS && root->stats_file)
|
||||
fprintf(root->stats_file, "%"PRId64" %s\n", mp_time_us(), text);
|
||||
}
|
||||
|
||||
void mp_msg_va(struct mp_log *log, int lev, const char *format, va_list va)
|
||||
@@ -634,7 +632,7 @@ const int mp_mpv_log_levels[MSGL_MAX + 1] = {
|
||||
int mp_msg_find_level(const char *s)
|
||||
{
|
||||
for (int n = 0; n < MP_ARRAY_SIZE(mp_log_levels); n++) {
|
||||
if (mp_log_levels[n] && mp_log_levels[n] && !strcmp(s, mp_log_levels[n]))
|
||||
if (mp_log_levels[n] && !strcmp(s, mp_log_levels[n]))
|
||||
return n;
|
||||
}
|
||||
return -1;
|
||||
|
||||
+13
-1
@@ -21,7 +21,7 @@
|
||||
#include "common/common.h"
|
||||
#include "common/global.h"
|
||||
#include "common/msg.h"
|
||||
#include "talloc.h"
|
||||
#include "mpv_talloc.h"
|
||||
#include "options/path.h"
|
||||
|
||||
#include "demux/demux.h"
|
||||
@@ -206,6 +206,18 @@ void playlist_add_base_path(struct playlist *pl, bstr base_path)
|
||||
}
|
||||
}
|
||||
|
||||
// Add redirected_from as new redirect entry to each item in pl.
|
||||
void playlist_add_redirect(struct playlist *pl, const char *redirected_from)
|
||||
{
|
||||
for (struct playlist_entry *e = pl->first; e; e = e->next) {
|
||||
if (e->num_redirects >= 10) // arbitrary limit for sanity
|
||||
break;
|
||||
char *s = talloc_strdup(e, redirected_from);
|
||||
if (s)
|
||||
MP_TARRAY_APPEND(e, e->redirects, e->num_redirects, s);
|
||||
}
|
||||
}
|
||||
|
||||
// Move all entries from source_pl to pl, appending them after the current entry
|
||||
// of pl. source_pl will be empty, and all entries have changed ownership to pl.
|
||||
void playlist_transfer_entries(struct playlist *pl, struct playlist *source_pl)
|
||||
|
||||
@@ -36,6 +36,11 @@ struct playlist_entry {
|
||||
|
||||
char *title;
|
||||
|
||||
// If the user plays a playlist, then the playlist's URL will be appended
|
||||
// as redirect to each entry. (Same for directories etc.)
|
||||
char **redirects;
|
||||
int num_redirects;
|
||||
|
||||
// Set to true if playback didn't seem to work, or if the file could be
|
||||
// played only for a very short time. This is used to make playlist
|
||||
// navigation just work in case the user has unplayable files in the
|
||||
@@ -88,6 +93,7 @@ void playlist_add_file(struct playlist *pl, const char *filename);
|
||||
void playlist_shuffle(struct playlist *pl);
|
||||
struct playlist_entry *playlist_get_next(struct playlist *pl, int direction);
|
||||
void playlist_add_base_path(struct playlist *pl, bstr base_path);
|
||||
void playlist_add_redirect(struct playlist *pl, const char *redirected_from);
|
||||
void playlist_transfer_entries(struct playlist *pl, struct playlist *source_pl);
|
||||
void playlist_append_entries(struct playlist *pl, struct playlist *source_pl);
|
||||
|
||||
|
||||
+8
-8
@@ -70,20 +70,20 @@ static const char *map_audio_pcm_tag(uint32_t tag, int bits)
|
||||
}
|
||||
}
|
||||
|
||||
void mp_set_codec_from_tag(struct sh_stream *sh)
|
||||
void mp_set_codec_from_tag(struct mp_codec_params *c)
|
||||
{
|
||||
sh->codec = lookup_tag(sh->type, sh->codec_tag);
|
||||
c->codec = lookup_tag(c->type, c->codec_tag);
|
||||
|
||||
if (sh->audio && sh->audio->bits_per_coded_sample) {
|
||||
if (c->type == STREAM_AUDIO && c->bits_per_coded_sample) {
|
||||
const char *codec =
|
||||
map_audio_pcm_tag(sh->codec_tag, sh->audio->bits_per_coded_sample);
|
||||
map_audio_pcm_tag(c->codec_tag, c->bits_per_coded_sample);
|
||||
if (codec)
|
||||
sh->codec = codec;
|
||||
c->codec = codec;
|
||||
}
|
||||
}
|
||||
|
||||
void mp_set_pcm_codec(struct sh_stream *sh, bool sign, bool is_float, int bits,
|
||||
bool is_be)
|
||||
void mp_set_pcm_codec(struct mp_codec_params *c, bool sign, bool is_float,
|
||||
int bits, bool is_be)
|
||||
{
|
||||
// This uses libavcodec pcm codec names, e.g. "pcm_u16le".
|
||||
char codec[64] = "pcm_";
|
||||
@@ -95,7 +95,7 @@ void mp_set_pcm_codec(struct sh_stream *sh, bool sign, bool is_float, int bits,
|
||||
mp_snprintf_cat(codec, sizeof(codec), "%d", bits);
|
||||
if (bits != 8)
|
||||
mp_snprintf_cat(codec, sizeof(codec), is_be ? "be" : "le");
|
||||
sh->codec = talloc_strdup(sh->audio, codec);
|
||||
c->codec = talloc_strdup(c, codec);
|
||||
}
|
||||
|
||||
static const char *const mimetype_to_codec[][2] = {
|
||||
|
||||
+4
-4
@@ -21,12 +21,12 @@
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
struct sh_stream;
|
||||
struct mp_codec_params;
|
||||
|
||||
void mp_set_codec_from_tag(struct sh_stream *sh);
|
||||
void mp_set_codec_from_tag(struct mp_codec_params *c);
|
||||
|
||||
void mp_set_pcm_codec(struct sh_stream *sh, bool sign, bool is_float, int bits,
|
||||
bool is_be);
|
||||
void mp_set_pcm_codec(struct mp_codec_params *c, bool sign, bool is_float,
|
||||
int bits, bool is_be);
|
||||
|
||||
const char *mp_map_mimetype_to_video_codec(const char *mimetype);
|
||||
|
||||
|
||||
+39
-10
@@ -20,10 +20,11 @@
|
||||
#include <string.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
#include "talloc.h"
|
||||
#include "mpv_talloc.h"
|
||||
|
||||
#include "misc/bstr.h"
|
||||
#include "common/common.h"
|
||||
#include "common/tags.h"
|
||||
|
||||
#include "cue.h"
|
||||
|
||||
@@ -37,6 +38,7 @@ enum cue_command {
|
||||
CUE_TRACK,
|
||||
CUE_INDEX,
|
||||
CUE_TITLE,
|
||||
CUE_PERFORMER,
|
||||
};
|
||||
|
||||
static const struct {
|
||||
@@ -51,7 +53,7 @@ static const struct {
|
||||
{ CUE_UNUSED, "CDTEXTFILE" },
|
||||
{ CUE_UNUSED, "FLAGS" },
|
||||
{ CUE_UNUSED, "ISRC" },
|
||||
{ CUE_UNUSED, "PERFORMER" },
|
||||
{ CUE_PERFORMER, "PERFORMER" },
|
||||
{ CUE_UNUSED, "POSTGAP" },
|
||||
{ CUE_UNUSED, "PREGAP" },
|
||||
{ CUE_UNUSED, "REM" },
|
||||
@@ -160,17 +162,19 @@ bool mp_probe_cue(struct bstr data)
|
||||
struct cue_file *mp_parse_cue(struct bstr data)
|
||||
{
|
||||
struct cue_file *f = talloc_zero(NULL, struct cue_file);
|
||||
f->tags = talloc_zero(f, struct mp_tags);
|
||||
|
||||
data = skip_utf8_bom(data);
|
||||
|
||||
char *filename = NULL;
|
||||
// Global metadata, and copied into new tracks.
|
||||
struct cue_track proto_track = {0};
|
||||
struct cue_track *cur_track = &proto_track;
|
||||
struct cue_track *cur_track = NULL;
|
||||
|
||||
while (data.len) {
|
||||
struct bstr param;
|
||||
switch (read_cmd(&data, ¶m)) {
|
||||
int cmd = read_cmd(&data, ¶m);
|
||||
switch (cmd) {
|
||||
case CUE_ERROR:
|
||||
talloc_free(f);
|
||||
return NULL;
|
||||
@@ -179,19 +183,29 @@ struct cue_file *mp_parse_cue(struct bstr data)
|
||||
f->num_tracks += 1;
|
||||
cur_track = &f->tracks[f->num_tracks - 1];
|
||||
*cur_track = proto_track;
|
||||
cur_track->tags = talloc_zero(f, struct mp_tags);
|
||||
break;
|
||||
}
|
||||
case CUE_TITLE:
|
||||
cur_track->title = read_quoted(f, ¶m);
|
||||
case CUE_PERFORMER: {
|
||||
static const char *metanames[] = {
|
||||
[CUE_TITLE] = "title",
|
||||
[CUE_PERFORMER] = "performer",
|
||||
};
|
||||
struct mp_tags *tags = cur_track ? cur_track->tags : f->tags;
|
||||
mp_tags_set_bstr(tags, bstr0(metanames[cmd]), param);
|
||||
break;
|
||||
}
|
||||
case CUE_INDEX: {
|
||||
int type = read_int_2(¶m);
|
||||
double time = read_time(¶m);
|
||||
if (type == 1) {
|
||||
cur_track->start = time;
|
||||
cur_track->filename = filename;
|
||||
} else if (type == 0) {
|
||||
cur_track->pregap_start = time;
|
||||
if (cur_track) {
|
||||
if (type == 1) {
|
||||
cur_track->start = time;
|
||||
cur_track->filename = filename;
|
||||
} else if (type == 0) {
|
||||
cur_track->pregap_start = time;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -204,3 +218,18 @@ struct cue_file *mp_parse_cue(struct bstr data)
|
||||
|
||||
return f;
|
||||
}
|
||||
|
||||
int mp_check_embedded_cue(struct cue_file *f)
|
||||
{
|
||||
char *fn0 = f->tracks[0].filename;
|
||||
for (int n = 1; n < f->num_tracks; n++) {
|
||||
char *fn = f->tracks[n].filename;
|
||||
// both filenames have the same address (including NULL)
|
||||
if (fn0 == fn)
|
||||
continue;
|
||||
// only one filename is NULL, or the strings don't match
|
||||
if (!fn0 || !fn || strcmp(fn0, fn) != 0)
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
+3
-1
@@ -25,6 +25,7 @@
|
||||
struct cue_file {
|
||||
struct cue_track *tracks;
|
||||
int num_tracks;
|
||||
struct mp_tags *tags;
|
||||
};
|
||||
|
||||
struct cue_track {
|
||||
@@ -32,10 +33,11 @@ struct cue_track {
|
||||
double start; // corresponds to INDEX 01
|
||||
char *filename;
|
||||
int source;
|
||||
char *title;
|
||||
struct mp_tags *tags;
|
||||
};
|
||||
|
||||
bool mp_probe_cue(struct bstr data);
|
||||
struct cue_file *mp_parse_cue(struct bstr data);
|
||||
int mp_check_embedded_cue(struct cue_file *f);
|
||||
|
||||
#endif
|
||||
+183
-109
@@ -29,7 +29,7 @@
|
||||
|
||||
#include "config.h"
|
||||
#include "options/options.h"
|
||||
#include "talloc.h"
|
||||
#include "mpv_talloc.h"
|
||||
#include "common/msg.h"
|
||||
#include "common/global.h"
|
||||
#include "osdep/threads.h"
|
||||
@@ -48,8 +48,6 @@ extern const demuxer_desc_t demuxer_desc_tv;
|
||||
extern const demuxer_desc_t demuxer_desc_mf;
|
||||
extern const demuxer_desc_t demuxer_desc_matroska;
|
||||
extern const demuxer_desc_t demuxer_desc_lavf;
|
||||
extern const demuxer_desc_t demuxer_desc_libass;
|
||||
extern const demuxer_desc_t demuxer_desc_subreader;
|
||||
extern const demuxer_desc_t demuxer_desc_playlist;
|
||||
extern const demuxer_desc_t demuxer_desc_disc;
|
||||
extern const demuxer_desc_t demuxer_desc_rar;
|
||||
@@ -67,9 +65,6 @@ const demuxer_desc_t *const demuxer_list[] = {
|
||||
&demuxer_desc_rawvideo,
|
||||
#if HAVE_TV
|
||||
&demuxer_desc_tv,
|
||||
#endif
|
||||
#if HAVE_LIBASS
|
||||
&demuxer_desc_libass,
|
||||
#endif
|
||||
&demuxer_desc_matroska,
|
||||
#if HAVE_LIBARCHIVE
|
||||
@@ -79,8 +74,6 @@ const demuxer_desc_t *const demuxer_list[] = {
|
||||
&demuxer_desc_lavf,
|
||||
&demuxer_desc_mf,
|
||||
&demuxer_desc_playlist,
|
||||
// Pretty aggressive, so should be last.
|
||||
&demuxer_desc_subreader,
|
||||
NULL
|
||||
};
|
||||
|
||||
@@ -110,6 +103,11 @@ struct demux_internal {
|
||||
void (*wakeup_cb)(void *ctx);
|
||||
void *wakeup_cb_ctx;
|
||||
|
||||
struct sh_stream **streams;
|
||||
int num_streams;
|
||||
|
||||
int events;
|
||||
|
||||
bool warned_queue_overflow;
|
||||
bool last_eof; // last actual global EOF status
|
||||
bool eof; // whether we're in EOF state (reset for retry)
|
||||
@@ -128,6 +126,8 @@ struct demux_internal {
|
||||
bool refresh_seeks_enabled;
|
||||
bool start_refresh_seek;
|
||||
|
||||
double ts_offset; // timestamp offset to apply everything
|
||||
|
||||
// Cached state.
|
||||
bool force_cache_update;
|
||||
double time_length;
|
||||
@@ -168,6 +168,8 @@ struct demux_stream {
|
||||
#define MP_PTS_MIN(a, b) MPMIN(PTS_OR_DEF(a, b), PTS_OR_DEF(b, a))
|
||||
#define MP_PTS_MAX(a, b) MPMAX(PTS_OR_DEF(a, b), PTS_OR_DEF(b, a))
|
||||
|
||||
#define MP_ADD_PTS(a, b) ((a) == MP_NOPTS_VALUE ? (a) : ((a) + (b)))
|
||||
|
||||
static void demuxer_sort_chapters(demuxer_t *demuxer);
|
||||
static void *demux_thread(void *pctx);
|
||||
static void update_cache(struct demux_internal *in);
|
||||
@@ -193,42 +195,92 @@ static void ds_flush(struct demux_stream *ds)
|
||||
ds->last_pos = -1;
|
||||
}
|
||||
|
||||
struct sh_stream *new_sh_stream(demuxer_t *demuxer, enum stream_type type)
|
||||
void demux_set_ts_offset(struct demuxer *demuxer, double offset)
|
||||
{
|
||||
assert(demuxer == demuxer->in->d_thread);
|
||||
struct demux_internal *in = demuxer->in;
|
||||
pthread_mutex_lock(&in->lock);
|
||||
in->ts_offset = offset;
|
||||
pthread_mutex_unlock(&in->lock);
|
||||
}
|
||||
|
||||
if (demuxer->num_streams > MAX_SH_STREAMS) {
|
||||
MP_WARN(demuxer, "Too many streams.\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int demuxer_id = 0;
|
||||
for (int n = 0; n < demuxer->num_streams; n++) {
|
||||
if (demuxer->streams[n]->type == type)
|
||||
demuxer_id++;
|
||||
}
|
||||
|
||||
struct sh_stream *sh = talloc_ptrtype(demuxer, sh);
|
||||
// Allocate a new sh_stream of the given type. It either has to be released
|
||||
// with talloc_free(), or added to a demuxer with demux_add_sh_stream(). You
|
||||
// cannot add or read packets from the stream before it has been added.
|
||||
struct sh_stream *demux_alloc_sh_stream(enum stream_type type)
|
||||
{
|
||||
struct sh_stream *sh = talloc_ptrtype(NULL, sh);
|
||||
*sh = (struct sh_stream) {
|
||||
.type = type,
|
||||
.index = demuxer->num_streams,
|
||||
.ff_index = demuxer->num_streams,
|
||||
.demuxer_id = demuxer_id, // may be overwritten by demuxer
|
||||
.ds = talloc(sh, struct demux_stream),
|
||||
.index = -1,
|
||||
.ff_index = -1, // may be overwritten by demuxer
|
||||
.demuxer_id = -1, // ... same
|
||||
.codec = talloc_zero(sh, struct mp_codec_params),
|
||||
};
|
||||
sh->codec->type = type;
|
||||
return sh;
|
||||
}
|
||||
|
||||
// Add a new sh_stream to the demuxer. Note that as soon as the stream has been
|
||||
// added, it must be immutable, and must not be released (this will happen when
|
||||
// the demuxer is destroyed).
|
||||
void demux_add_sh_stream(struct demuxer *demuxer, struct sh_stream *sh)
|
||||
{
|
||||
struct demux_internal *in = demuxer->in;
|
||||
pthread_mutex_lock(&in->lock);
|
||||
|
||||
assert(!sh->ds); // must not be added yet
|
||||
|
||||
sh->ds = talloc(sh, struct demux_stream);
|
||||
*sh->ds = (struct demux_stream) {
|
||||
.in = demuxer->in,
|
||||
.in = in,
|
||||
.type = sh->type,
|
||||
.selected = demuxer->in->autoselect,
|
||||
.selected = in->autoselect,
|
||||
};
|
||||
MP_TARRAY_APPEND(demuxer, demuxer->streams, demuxer->num_streams, sh);
|
||||
switch (sh->type) {
|
||||
case STREAM_VIDEO: sh->video = talloc_zero(demuxer, struct sh_video); break;
|
||||
case STREAM_AUDIO: sh->audio = talloc_zero(demuxer, struct sh_audio); break;
|
||||
case STREAM_SUB: sh->sub = talloc_zero(demuxer, struct sh_sub); break;
|
||||
|
||||
if (!sh->codec->codec)
|
||||
sh->codec->codec = "";
|
||||
|
||||
sh->index = in->num_streams;
|
||||
if (sh->ff_index < 0)
|
||||
sh->ff_index = sh->index;
|
||||
if (sh->demuxer_id < 0) {
|
||||
sh->demuxer_id = 0;
|
||||
for (int n = 0; n < in->num_streams; n++) {
|
||||
if (in->streams[n]->type == sh->type)
|
||||
sh->demuxer_id += 1;
|
||||
}
|
||||
}
|
||||
|
||||
return sh;
|
||||
MP_TARRAY_APPEND(in, in->streams, in->num_streams, sh);
|
||||
|
||||
in->events |= DEMUX_EVENT_STREAMS;
|
||||
if (in->wakeup_cb)
|
||||
in->wakeup_cb(in->wakeup_cb_ctx);
|
||||
pthread_mutex_unlock(&in->lock);
|
||||
}
|
||||
|
||||
// Return a stream with the given index. Since streams can only be added during
|
||||
// the lifetime of the demuxer, it is guaranteed that an index within the valid
|
||||
// range [0, demux_get_num_stream()) always returns a valid sh_stream pointer,
|
||||
// which will be valid until the demuxer is destroyed.
|
||||
struct sh_stream *demux_get_stream(struct demuxer *demuxer, int index)
|
||||
{
|
||||
struct demux_internal *in = demuxer->in;
|
||||
pthread_mutex_lock(&in->lock);
|
||||
assert(index >= 0 && index < in->num_streams);
|
||||
struct sh_stream *r = in->streams[index];
|
||||
pthread_mutex_unlock(&in->lock);
|
||||
return r;
|
||||
}
|
||||
|
||||
// See demux_get_stream().
|
||||
int demux_get_num_stream(struct demuxer *demuxer)
|
||||
{
|
||||
struct demux_internal *in = demuxer->in;
|
||||
pthread_mutex_lock(&in->lock);
|
||||
int r = in->num_streams;
|
||||
pthread_mutex_unlock(&in->lock);
|
||||
return r;
|
||||
}
|
||||
|
||||
void free_demuxer(demuxer_t *demuxer)
|
||||
@@ -242,8 +294,10 @@ void free_demuxer(demuxer_t *demuxer)
|
||||
|
||||
if (demuxer->desc->close)
|
||||
demuxer->desc->close(in->d_thread);
|
||||
for (int n = 0; n < demuxer->num_streams; n++)
|
||||
ds_flush(demuxer->streams[n]->ds);
|
||||
for (int n = in->num_streams - 1; n >= 0; n--) {
|
||||
ds_flush(in->streams[n]->ds);
|
||||
talloc_free(in->streams[n]);
|
||||
}
|
||||
pthread_mutex_destroy(&in->lock);
|
||||
pthread_cond_destroy(&in->wakeup);
|
||||
talloc_free(demuxer);
|
||||
@@ -307,13 +361,12 @@ const char *stream_type_name(enum stream_type type)
|
||||
}
|
||||
}
|
||||
|
||||
// Returns the same value as demuxer->fill_buffer: 1 ok, 0 EOF/not selected.
|
||||
int demux_add_packet(struct sh_stream *stream, demux_packet_t *dp)
|
||||
void demux_add_packet(struct sh_stream *stream, demux_packet_t *dp)
|
||||
{
|
||||
struct demux_stream *ds = stream ? stream->ds : NULL;
|
||||
if (!dp || !ds) {
|
||||
talloc_free(dp);
|
||||
return 0;
|
||||
return;
|
||||
}
|
||||
struct demux_internal *in = ds->in;
|
||||
pthread_mutex_lock(&in->lock);
|
||||
@@ -330,7 +383,7 @@ int demux_add_packet(struct sh_stream *stream, demux_packet_t *dp)
|
||||
if (!ds->selected || in->seeking || drop) {
|
||||
pthread_mutex_unlock(&in->lock);
|
||||
talloc_free(dp);
|
||||
return 0;
|
||||
return;
|
||||
}
|
||||
|
||||
dp->stream = stream->index;
|
||||
@@ -371,7 +424,6 @@ int demux_add_packet(struct sh_stream *stream, demux_packet_t *dp)
|
||||
ds->in->wakeup_cb(ds->in->wakeup_cb_ctx);
|
||||
pthread_cond_signal(&in->wakeup);
|
||||
pthread_mutex_unlock(&in->lock);
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Returns true if there was "progress" (lock was released temporarily).
|
||||
@@ -385,8 +437,8 @@ static bool read_packet(struct demux_internal *in)
|
||||
// safe-guards against packet queue overflow.
|
||||
bool active = false, read_more = false;
|
||||
size_t packs = 0, bytes = 0;
|
||||
for (int n = 0; n < in->d_buffer->num_streams; n++) {
|
||||
struct demux_stream *ds = in->d_buffer->streams[n]->ds;
|
||||
for (int n = 0; n < in->num_streams; n++) {
|
||||
struct demux_stream *ds = in->streams[n]->ds;
|
||||
active |= ds->active;
|
||||
read_more |= ds->active && !ds->head;
|
||||
packs += ds->packs;
|
||||
@@ -401,16 +453,16 @@ static bool read_packet(struct demux_internal *in)
|
||||
if (!in->warned_queue_overflow) {
|
||||
in->warned_queue_overflow = true;
|
||||
MP_ERR(in, "Too many packets in the demuxer packet queues:\n");
|
||||
for (int n = 0; n < in->d_buffer->num_streams; n++) {
|
||||
struct demux_stream *ds = in->d_buffer->streams[n]->ds;
|
||||
for (int n = 0; n < in->num_streams; n++) {
|
||||
struct demux_stream *ds = in->streams[n]->ds;
|
||||
if (ds->selected) {
|
||||
MP_ERR(in, " %s/%d: %zd packets, %zd bytes\n",
|
||||
stream_type_name(ds->type), n, ds->packs, ds->bytes);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int n = 0; n < in->d_buffer->num_streams; n++) {
|
||||
struct demux_stream *ds = in->d_buffer->streams[n]->ds;
|
||||
for (int n = 0; n < in->num_streams; n++) {
|
||||
struct demux_stream *ds = in->streams[n]->ds;
|
||||
ds->eof |= !ds->head;
|
||||
}
|
||||
pthread_cond_signal(&in->wakeup);
|
||||
@@ -430,10 +482,8 @@ static bool read_packet(struct demux_internal *in)
|
||||
pthread_mutex_lock(&in->lock);
|
||||
|
||||
if (eof) {
|
||||
for (int n = 0; n < in->d_buffer->num_streams; n++) {
|
||||
struct demux_stream *ds = in->d_buffer->streams[n]->ds;
|
||||
ds->eof = true;
|
||||
}
|
||||
for (int n = 0; n < in->num_streams; n++)
|
||||
in->streams[n]->ds->eof = true;
|
||||
// If we had EOF previously, then don't wakeup (avoids wakeup loop)
|
||||
if (!in->last_eof) {
|
||||
if (in->wakeup_cb)
|
||||
@@ -477,8 +527,8 @@ static void start_refreshing(struct demux_internal *in)
|
||||
in->start_refresh_seek = false;
|
||||
|
||||
double start_ts = MP_NOPTS_VALUE;
|
||||
for (int n = 0; n < demux->num_streams; n++) {
|
||||
struct demux_stream *ds = demux->streams[n]->ds;
|
||||
for (int n = 0; n < in->num_streams; n++) {
|
||||
struct demux_stream *ds = in->streams[n]->ds;
|
||||
if (ds->type == STREAM_VIDEO || ds->type == STREAM_AUDIO)
|
||||
start_ts = MP_PTS_MIN(start_ts, ds->base_ts);
|
||||
}
|
||||
@@ -487,8 +537,8 @@ static void start_refreshing(struct demux_internal *in)
|
||||
demux->partially_seekable || !demux->allow_refresh_seeks)
|
||||
return;
|
||||
|
||||
for (int n = 0; n < demux->num_streams; n++) {
|
||||
struct demux_stream *ds = demux->streams[n]->ds;
|
||||
for (int n = 0; n < in->num_streams; n++) {
|
||||
struct demux_stream *ds = in->streams[n]->ds;
|
||||
// Streams which didn't read any packets yet can return all packets,
|
||||
// or they'd be stuck forever; affects newly selected streams too.
|
||||
if (ds->last_pos != -1)
|
||||
@@ -611,6 +661,9 @@ static struct demux_packet *dequeue_packet(struct demux_stream *ds)
|
||||
if (pkt->pos >= ds->in->d_user->filepos)
|
||||
ds->in->d_user->filepos = pkt->pos;
|
||||
|
||||
pkt->pts = MP_ADD_PTS(pkt->pts, ds->in->ts_offset);
|
||||
pkt->dts = MP_ADD_PTS(pkt->dts, ds->in->ts_offset);
|
||||
|
||||
return pkt;
|
||||
}
|
||||
|
||||
@@ -631,15 +684,33 @@ struct demux_packet *demux_read_packet(struct sh_stream *sh)
|
||||
return pkt;
|
||||
}
|
||||
|
||||
// Sparse packets (Subtitles) interleaved with other non-sparse packets (video,
|
||||
// audio) should never be read actively, meaning the demuxer thread does not
|
||||
// try to exceed default readahead in order to find a new packet.
|
||||
static bool use_lazy_subtitle_reading(struct demux_stream *ds)
|
||||
{
|
||||
if (ds->type != STREAM_SUB)
|
||||
return false;
|
||||
for (int n = 0; n < ds->in->num_streams; n++) {
|
||||
struct demux_stream *s = ds->in->streams[n]->ds;
|
||||
if (s->type != STREAM_SUB && s->selected && !s->eof)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Poll the demuxer queue, and if there's a packet, return it. Otherwise, just
|
||||
// make the demuxer thread read packets for this stream, and if there's at
|
||||
// least one packet, call the wakeup callback.
|
||||
// Unlike demux_read_packet(), this always enables readahead (which means you
|
||||
// must not use it on interleaved subtitle streams).
|
||||
// Unlike demux_read_packet(), this always enables readahead (except for
|
||||
// interleaved subtitles).
|
||||
// Returns:
|
||||
// < 0: EOF was reached, *out_pkt=NULL
|
||||
// == 0: no new packet yet, but maybe later, *out_pkt=NULL
|
||||
// > 0: new packet read, *out_pkt is set
|
||||
// Note: when reading interleaved subtitles, the demuxer won't try to forcibly
|
||||
// read ahead to get the next subtitle packet (as the next packet could be
|
||||
// minutes away). In this situation, this function will just return -1.
|
||||
int demux_read_packet_async(struct sh_stream *sh, struct demux_packet **out_pkt)
|
||||
{
|
||||
struct demux_stream *ds = sh ? sh->ds : NULL;
|
||||
@@ -649,10 +720,14 @@ int demux_read_packet_async(struct sh_stream *sh, struct demux_packet **out_pkt)
|
||||
if (ds->in->threading) {
|
||||
pthread_mutex_lock(&ds->in->lock);
|
||||
*out_pkt = dequeue_packet(ds);
|
||||
r = *out_pkt ? 1 : ((ds->eof || !ds->selected) ? -1 : 0);
|
||||
ds->active = ds->selected; // enable readahead
|
||||
ds->in->eof = false; // force retry
|
||||
pthread_cond_signal(&ds->in->wakeup); // possibly read more
|
||||
if (use_lazy_subtitle_reading(ds)) {
|
||||
r = *out_pkt ? 1 : -1;
|
||||
} else {
|
||||
r = *out_pkt ? 1 : ((ds->eof || !ds->selected) ? -1 : 0);
|
||||
ds->active = ds->selected; // enable readahead
|
||||
ds->in->eof = false; // force retry
|
||||
pthread_cond_signal(&ds->in->wakeup); // possibly read more
|
||||
}
|
||||
pthread_mutex_unlock(&ds->in->lock);
|
||||
} else {
|
||||
*out_pkt = demux_read_packet(sh);
|
||||
@@ -662,22 +737,6 @@ int demux_read_packet_async(struct sh_stream *sh, struct demux_packet **out_pkt)
|
||||
return r;
|
||||
}
|
||||
|
||||
// Return the pts of the next packet that demux_read_packet() would return.
|
||||
// Might block. Sometimes used to force a packet read, without removing any
|
||||
// packets from the queue.
|
||||
double demux_get_next_pts(struct sh_stream *sh)
|
||||
{
|
||||
double res = MP_NOPTS_VALUE;
|
||||
if (sh) {
|
||||
pthread_mutex_lock(&sh->ds->in->lock);
|
||||
ds_get_packets(sh->ds);
|
||||
if (sh->ds->head)
|
||||
res = sh->ds->head->pts;
|
||||
pthread_mutex_unlock(&sh->ds->in->lock);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
// Return whether a packet is queued. Never blocks, never forces any reads.
|
||||
bool demux_has_packet(struct sh_stream *sh)
|
||||
{
|
||||
@@ -693,21 +752,22 @@ bool demux_has_packet(struct sh_stream *sh)
|
||||
// Read and return any packet we find.
|
||||
struct demux_packet *demux_read_any_packet(struct demuxer *demuxer)
|
||||
{
|
||||
assert(!demuxer->in->threading); // doesn't work with threading
|
||||
struct demux_internal *in = demuxer->in;
|
||||
assert(!in->threading); // doesn't work with threading
|
||||
bool read_more = true;
|
||||
while (read_more) {
|
||||
for (int n = 0; n < demuxer->num_streams; n++) {
|
||||
struct sh_stream *sh = demuxer->streams[n];
|
||||
for (int n = 0; n < in->num_streams; n++) {
|
||||
struct sh_stream *sh = in->streams[n];
|
||||
sh->ds->active = sh->ds->selected; // force read_packet() to read
|
||||
struct demux_packet *pkt = dequeue_packet(sh->ds);
|
||||
if (pkt)
|
||||
return pkt;
|
||||
}
|
||||
// retry after calling this
|
||||
pthread_mutex_lock(&demuxer->in->lock);
|
||||
read_more = read_packet(demuxer->in);
|
||||
read_more &= !demuxer->in->eof;
|
||||
pthread_mutex_unlock(&demuxer->in->lock);
|
||||
pthread_mutex_lock(&in->lock); // lock only because read_packet unlocks
|
||||
read_more = read_packet(in);
|
||||
read_more &= !in->eof;
|
||||
pthread_mutex_unlock(&in->lock);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
@@ -791,13 +851,14 @@ static int decode_peak(demuxer_t *demuxer, const char *tag, float *out)
|
||||
|
||||
static void apply_replaygain(demuxer_t *demuxer, struct replaygain_data *rg)
|
||||
{
|
||||
for (int n = 0; n < demuxer->num_streams; n++) {
|
||||
struct sh_stream *sh = demuxer->streams[n];
|
||||
if (sh->audio && !sh->audio->replaygain_data) {
|
||||
struct demux_internal *in = demuxer->in;
|
||||
for (int n = 0; n < in->num_streams; n++) {
|
||||
struct sh_stream *sh = in->streams[n];
|
||||
if (sh->type == STREAM_AUDIO && !sh->codec->replaygain_data) {
|
||||
MP_VERBOSE(demuxer, "Replaygain: Track=%f/%f Album=%f/%f\n",
|
||||
rg->track_gain, rg->track_peak,
|
||||
rg->album_gain, rg->album_peak);
|
||||
sh->audio->replaygain_data = talloc_memdup(demuxer, rg, sizeof(*rg));
|
||||
sh->codec->replaygain_data = talloc_memdup(in, rg, sizeof(*rg));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -849,11 +910,6 @@ static void demux_copy(struct demuxer *dst, struct demuxer *src)
|
||||
dst->start_time = src->start_time;
|
||||
dst->priv = src->priv;
|
||||
}
|
||||
if (src->events & DEMUX_EVENT_STREAMS) {
|
||||
// The stream structs themselves are immutable.
|
||||
for (int n = dst->num_streams; n < src->num_streams; n++)
|
||||
MP_TARRAY_APPEND(dst, dst->streams, dst->num_streams, src->streams[n]);
|
||||
}
|
||||
if (src->events & DEMUX_EVENT_METADATA) {
|
||||
talloc_free(dst->metadata);
|
||||
dst->metadata = mp_tags_dup(dst, src->metadata);
|
||||
@@ -901,6 +957,8 @@ void demux_update(demuxer_t *demuxer)
|
||||
|
||||
pthread_mutex_lock(&in->lock);
|
||||
demux_copy(demuxer, in->d_buffer);
|
||||
demuxer->events |= in->events;
|
||||
in->events = 0;
|
||||
if (in->stream_metadata && (demuxer->events & DEMUX_EVENT_METADATA))
|
||||
mp_tags_merge(demuxer->metadata, in->stream_metadata);
|
||||
pthread_mutex_unlock(&in->lock);
|
||||
@@ -922,9 +980,15 @@ static void demux_init_cuesheet(struct demuxer *demuxer)
|
||||
if (cue && !demuxer->num_chapters) {
|
||||
struct cue_file *f = mp_parse_cue(bstr0(cue));
|
||||
if (f) {
|
||||
for (int n = 0; n < f->num_tracks; n++) {
|
||||
struct cue_track *t = &f->tracks[n];
|
||||
demuxer_add_chapter(demuxer, t->title, t->start, -1);
|
||||
if (mp_check_embedded_cue(f) < 0) {
|
||||
MP_WARN(demuxer, "Embedded cue sheet references more than one file. "
|
||||
"Ignoring it.\n");
|
||||
} else {
|
||||
for (int n = 0; n < f->num_tracks; n++) {
|
||||
struct cue_track *t = &f->tracks[n];
|
||||
int idx = demuxer_add_chapter(demuxer, "", t->start, -1);
|
||||
mp_tags_merge(demuxer->chapters[idx].metadata, t->tags);
|
||||
}
|
||||
}
|
||||
}
|
||||
talloc_free(f);
|
||||
@@ -938,6 +1002,9 @@ static struct demuxer *open_given_type(struct mpv_global *global,
|
||||
struct demuxer_params *params,
|
||||
enum demux_check check)
|
||||
{
|
||||
if (mp_cancel_test(stream->cancel))
|
||||
return NULL;
|
||||
|
||||
struct demuxer *demuxer = talloc_ptrtype(NULL, demuxer);
|
||||
*demuxer = (struct demuxer) {
|
||||
.desc = desc,
|
||||
@@ -1100,8 +1167,8 @@ struct demuxer *demux_open_url(const char *url,
|
||||
|
||||
static void flush_locked(demuxer_t *demuxer)
|
||||
{
|
||||
for (int n = 0; n < demuxer->num_streams; n++)
|
||||
ds_flush(demuxer->streams[n]->ds);
|
||||
for (int n = 0; n < demuxer->in->num_streams; n++)
|
||||
ds_flush(demuxer->in->streams[n]->ds);
|
||||
demuxer->in->warned_queue_overflow = false;
|
||||
demuxer->in->eof = false;
|
||||
demuxer->in->last_eof = false;
|
||||
@@ -1152,6 +1219,8 @@ int demux_seek(demuxer_t *demuxer, double rel_seek_secs, int flags)
|
||||
in->seeking = true;
|
||||
in->seek_flags = flags;
|
||||
in->seek_pts = rel_seek_secs;
|
||||
if ((flags & SEEK_ABSOLUTE) && !(flags & SEEK_FACTOR))
|
||||
in->seek_pts = MP_ADD_PTS(in->seek_pts, -in->ts_offset);
|
||||
|
||||
if (!in->threading)
|
||||
execute_seek(in);
|
||||
@@ -1177,10 +1246,11 @@ void demux_set_enable_refresh_seeks(struct demuxer *demuxer, bool enabled)
|
||||
struct sh_stream *demuxer_stream_by_demuxer_id(struct demuxer *d,
|
||||
enum stream_type t, int id)
|
||||
{
|
||||
for (int n = 0; n < d->num_streams; n++) {
|
||||
struct sh_stream *s = d->streams[n];
|
||||
int num = demux_get_num_stream(d);
|
||||
for (int n = 0; n < num; n++) {
|
||||
struct sh_stream *s = demux_get_stream(d, n);
|
||||
if (s->type == t && s->demuxer_id == id)
|
||||
return d->streams[n];
|
||||
return s;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
@@ -1190,8 +1260,9 @@ void demuxer_switch_track(struct demuxer *demuxer, enum stream_type type,
|
||||
{
|
||||
assert(!stream || stream->type == type);
|
||||
|
||||
for (int n = 0; n < demuxer->num_streams; n++) {
|
||||
struct sh_stream *cur = demuxer->streams[n];
|
||||
int num = demux_get_num_stream(demuxer);
|
||||
for (int n = 0; n < num; n++) {
|
||||
struct sh_stream *cur = demux_get_stream(demuxer, n);
|
||||
if (cur->type == type)
|
||||
demuxer_select_track(demuxer, cur, cur == stream);
|
||||
}
|
||||
@@ -1392,10 +1463,11 @@ static int cached_demux_control(struct demux_internal *in, int cmd, void *arg)
|
||||
case DEMUXER_CTRL_GET_BITRATE_STATS: {
|
||||
double *rates = arg;
|
||||
for (int n = 0; n < STREAM_TYPE_COUNT; n++)
|
||||
rates[n] = 0;
|
||||
for (int n = 0; n < in->d_user->num_streams; n++) {
|
||||
struct demux_stream *ds = in->d_user->streams[n]->ds;
|
||||
rates[ds->type] += MPMAX(0, ds->bitrate);
|
||||
rates[n] = -1;
|
||||
for (int n = 0; n < in->num_streams; n++) {
|
||||
struct demux_stream *ds = in->streams[n]->ds;
|
||||
if (ds->selected && ds->bitrate >= 0)
|
||||
rates[ds->type] = MPMAX(0, rates[ds->type]) + ds->bitrate;
|
||||
}
|
||||
return DEMUXER_CTRL_OK;
|
||||
}
|
||||
@@ -1407,8 +1479,8 @@ static int cached_demux_control(struct demux_internal *in, int cmd, void *arg)
|
||||
.ts_duration = -1,
|
||||
};
|
||||
int num_packets = 0;
|
||||
for (int n = 0; n < in->d_user->num_streams; n++) {
|
||||
struct demux_stream *ds = in->d_user->streams[n]->ds;
|
||||
for (int n = 0; n < in->num_streams; n++) {
|
||||
struct demux_stream *ds = in->streams[n]->ds;
|
||||
if (ds->active) {
|
||||
r->underrun |= !ds->head && !ds->eof;
|
||||
r->ts_range[0] = MP_PTS_MAX(r->ts_range[0], ds->base_ts);
|
||||
@@ -1422,6 +1494,8 @@ static int cached_demux_control(struct demux_internal *in, int cmd, void *arg)
|
||||
r->ts_duration = MPMAX(0, r->ts_range[1] - r->ts_range[0]);
|
||||
if (!num_packets || in->seeking)
|
||||
r->ts_duration = 0;
|
||||
r->ts_range[0] = MP_ADD_PTS(r->ts_range[0], in->ts_offset);
|
||||
r->ts_range[1] = MP_ADD_PTS(r->ts_range[1], in->ts_offset);
|
||||
return DEMUXER_CTRL_OK;
|
||||
}
|
||||
}
|
||||
|
||||
+7
-8
@@ -86,8 +86,6 @@ enum demux_event {
|
||||
DEMUX_EVENT_ALL = 0xFFFF,
|
||||
};
|
||||
|
||||
#define MAX_SH_STREAMS 256
|
||||
|
||||
struct demuxer;
|
||||
struct timeline;
|
||||
|
||||
@@ -199,9 +197,6 @@ typedef struct demuxer {
|
||||
// Bitmask of DEMUX_EVENT_*
|
||||
int events;
|
||||
|
||||
struct sh_stream **streams;
|
||||
int num_streams;
|
||||
|
||||
struct demux_edition *editions;
|
||||
int num_editions;
|
||||
int edition;
|
||||
@@ -242,16 +237,19 @@ typedef struct {
|
||||
void free_demuxer(struct demuxer *demuxer);
|
||||
void free_demuxer_and_stream(struct demuxer *demuxer);
|
||||
|
||||
int demux_add_packet(struct sh_stream *stream, demux_packet_t *dp);
|
||||
void demux_add_packet(struct sh_stream *stream, demux_packet_t *dp);
|
||||
|
||||
struct demux_packet *demux_read_packet(struct sh_stream *sh);
|
||||
int demux_read_packet_async(struct sh_stream *sh, struct demux_packet **out_pkt);
|
||||
bool demux_stream_is_selected(struct sh_stream *stream);
|
||||
double demux_get_next_pts(struct sh_stream *sh);
|
||||
bool demux_has_packet(struct sh_stream *sh);
|
||||
struct demux_packet *demux_read_any_packet(struct demuxer *demuxer);
|
||||
|
||||
struct sh_stream *new_sh_stream(struct demuxer *demuxer, enum stream_type type);
|
||||
struct sh_stream *demux_get_stream(struct demuxer *demuxer, int index);
|
||||
int demux_get_num_stream(struct demuxer *demuxer);
|
||||
|
||||
struct sh_stream *demux_alloc_sh_stream(enum stream_type type);
|
||||
void demux_add_sh_stream(struct demuxer *demuxer, struct sh_stream *sh);
|
||||
|
||||
struct demuxer *demux_open(struct stream *stream, struct demuxer_params *params,
|
||||
struct mpv_global *global);
|
||||
@@ -271,6 +269,7 @@ bool demux_cancel_test(struct demuxer *demuxer);
|
||||
void demux_flush(struct demuxer *demuxer);
|
||||
int demux_seek(struct demuxer *demuxer, double rel_seek_secs, int flags);
|
||||
void demux_set_enable_refresh_seeks(struct demuxer *demuxer, bool enabled);
|
||||
void demux_set_ts_offset(struct demuxer *demuxer, double offset);
|
||||
|
||||
int demux_control(struct demuxer *demuxer, int cmd, void *arg);
|
||||
|
||||
|
||||
+25
-15
@@ -23,7 +23,7 @@
|
||||
#include <dirent.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
#include "talloc.h"
|
||||
#include "mpv_talloc.h"
|
||||
|
||||
#include "misc/bstr.h"
|
||||
#include "common/msg.h"
|
||||
@@ -38,7 +38,7 @@
|
||||
#define PROBE_SIZE 512
|
||||
|
||||
struct priv {
|
||||
bstr data;
|
||||
struct cue_file *f;
|
||||
};
|
||||
|
||||
static void add_source(struct timeline *tl, struct demuxer *d)
|
||||
@@ -150,15 +150,18 @@ static void build_timeline(struct timeline *tl)
|
||||
|
||||
add_source(tl, tl->demuxer);
|
||||
|
||||
struct cue_file *f = mp_parse_cue(p->data);
|
||||
if (!f) {
|
||||
MP_ERR(tl, "CUE: error parsing input file!\n");
|
||||
goto out;
|
||||
}
|
||||
talloc_steal(ctx, f);
|
||||
struct cue_track *tracks = NULL;
|
||||
size_t track_count = 0;
|
||||
|
||||
struct cue_track *tracks = f->tracks;
|
||||
size_t track_count = f->num_tracks;
|
||||
for (size_t n = 0; n < p->f->num_tracks; n++) {
|
||||
struct cue_track *track = &p->f->tracks[n];
|
||||
if (track->filename) {
|
||||
MP_TARRAY_APPEND(ctx, tracks, track_count, *track);
|
||||
} else {
|
||||
MP_WARN(tl->demuxer, "No file specified for track entry %zd. "
|
||||
"It will be removed\n", n + 1);
|
||||
}
|
||||
}
|
||||
|
||||
if (track_count == 0) {
|
||||
MP_ERR(tl, "CUE: no tracks found!\n");
|
||||
@@ -224,10 +227,8 @@ static void build_timeline(struct timeline *tl)
|
||||
};
|
||||
chapters[i] = (struct demux_chapter) {
|
||||
.pts = timeline[i].start,
|
||||
.metadata = talloc_zero(tl, struct mp_tags),
|
||||
.metadata = mp_tags_dup(tl, tracks[i].tags),
|
||||
};
|
||||
// might want to include other metadata here
|
||||
mp_tags_set_str(chapters[i].metadata, "title", tracks[i].title);
|
||||
starttime += duration;
|
||||
}
|
||||
|
||||
@@ -261,9 +262,18 @@ static int try_open_file(struct demuxer *demuxer, enum demux_check check)
|
||||
struct priv *p = talloc_zero(demuxer, struct priv);
|
||||
demuxer->priv = p;
|
||||
demuxer->fully_read = true;
|
||||
p->data = stream_read_complete(s, demuxer, 1000000);
|
||||
if (p->data.start == NULL)
|
||||
|
||||
bstr data = stream_read_complete(s, p, 1000000);
|
||||
if (data.start == NULL)
|
||||
return -1;
|
||||
p->f = mp_parse_cue(data);
|
||||
talloc_steal(p, p->f);
|
||||
if (!p->f) {
|
||||
MP_ERR(demuxer, "error parsing input file!\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
mp_tags_merge(demuxer->metadata, p->f->tags);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
+28
-26
@@ -23,6 +23,7 @@
|
||||
#include "common/msg.h"
|
||||
|
||||
#include "stream/stream.h"
|
||||
#include "video/mp_image.h"
|
||||
#include "demux.h"
|
||||
#include "stheader.h"
|
||||
|
||||
@@ -53,9 +54,10 @@ struct priv {
|
||||
static void reselect_streams(demuxer_t *demuxer)
|
||||
{
|
||||
struct priv *p = demuxer->priv;
|
||||
for (int n = 0; n < MPMIN(p->slave->num_streams, p->num_streams); n++) {
|
||||
int num_slave = demux_get_num_stream(p->slave);
|
||||
for (int n = 0; n < MPMIN(num_slave, p->num_streams); n++) {
|
||||
if (p->streams[n]) {
|
||||
demuxer_select_track(p->slave, p->slave->streams[n],
|
||||
demuxer_select_track(p->slave, demux_get_stream(p->slave, n),
|
||||
demux_stream_is_selected(p->streams[n]));
|
||||
}
|
||||
}
|
||||
@@ -80,11 +82,9 @@ static void add_dvd_streams(demuxer_t *demuxer)
|
||||
struct stream_dvd_info_req info;
|
||||
if (stream_control(stream, STREAM_CTRL_GET_DVD_INFO, &info) > 0) {
|
||||
for (int n = 0; n < MPMIN(32, info.num_subs); n++) {
|
||||
struct sh_stream *sh = new_sh_stream(demuxer, STREAM_SUB);
|
||||
if (!sh)
|
||||
break;
|
||||
struct sh_stream *sh = demux_alloc_sh_stream(STREAM_SUB);
|
||||
sh->demuxer_id = n + 0x20;
|
||||
sh->codec = "dvd_subtitle";
|
||||
sh->codec->codec = "dvd_subtitle";
|
||||
get_disc_lang(stream, sh);
|
||||
// p->streams _must_ match with p->slave->streams, so we can't add
|
||||
// it yet - it has to be done when the real stream appears, which
|
||||
@@ -93,17 +93,16 @@ static void add_dvd_streams(demuxer_t *demuxer)
|
||||
|
||||
// emulate the extradata
|
||||
struct mp_csp_params csp = MP_CSP_PARAMS_DEFAULTS;
|
||||
csp.int_bits_in = 8;
|
||||
csp.int_bits_out = 8;
|
||||
struct mp_cmat cmatrix;
|
||||
mp_get_yuv2rgb_coeffs(&csp, &cmatrix);
|
||||
mp_get_csp_matrix(&csp, &cmatrix);
|
||||
|
||||
char *s = talloc_strdup(sh, "");
|
||||
s = talloc_asprintf_append(s, "palette: ");
|
||||
for (int i = 0; i < 16; i++) {
|
||||
int color = info.palette[i];
|
||||
int c[3] = {(color >> 16) & 0xff, (color >> 8) & 0xff, color & 0xff};
|
||||
mp_map_int_color(&cmatrix, 8, c);
|
||||
int y[3] = {(color >> 16) & 0xff, (color >> 8) & 0xff, color & 0xff};
|
||||
int c[3];
|
||||
mp_map_fixp_color(&cmatrix, 8, y, 8, c);
|
||||
color = (c[2] << 16) | (c[1] << 8) | c[0];
|
||||
|
||||
if (i != 0)
|
||||
@@ -112,8 +111,10 @@ static void add_dvd_streams(demuxer_t *demuxer)
|
||||
}
|
||||
s = talloc_asprintf_append(s, "\n");
|
||||
|
||||
sh->extradata = s;
|
||||
sh->extradata_size = strlen(s);
|
||||
sh->codec->extradata = s;
|
||||
sh->codec->extradata_size = strlen(s);
|
||||
|
||||
demux_add_sh_stream(demuxer, sh);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -122,9 +123,9 @@ static void add_streams(demuxer_t *demuxer)
|
||||
{
|
||||
struct priv *p = demuxer->priv;
|
||||
|
||||
for (int n = p->num_streams; n < p->slave->num_streams; n++) {
|
||||
struct sh_stream *src = p->slave->streams[n];
|
||||
if (src->sub) {
|
||||
for (int n = p->num_streams; n < demux_get_num_stream(p->slave); n++) {
|
||||
struct sh_stream *src = demux_get_stream(p->slave, n);
|
||||
if (src->type == STREAM_SUB) {
|
||||
struct sh_stream *sub = NULL;
|
||||
if (src->demuxer_id >= 0x20 && src->demuxer_id <= 0x3F)
|
||||
sub = p->dvd_subs[src->demuxer_id - 0x20];
|
||||
@@ -134,25 +135,26 @@ static void add_streams(demuxer_t *demuxer)
|
||||
continue;
|
||||
}
|
||||
}
|
||||
struct sh_stream *sh = new_sh_stream(demuxer, src->type);
|
||||
if (!sh)
|
||||
break;
|
||||
struct sh_stream *sh = demux_alloc_sh_stream(src->type);
|
||||
assert(p->num_streams == n); // directly mapped
|
||||
MP_TARRAY_APPEND(p, p->streams, p->num_streams, sh);
|
||||
// Copy all stream fields that might be relevant
|
||||
sh->codec = talloc_strdup(sh, src->codec);
|
||||
sh->codec_tag = src->codec_tag;
|
||||
sh->lav_headers = src->lav_headers;
|
||||
*sh->codec = *src->codec;
|
||||
sh->demuxer_id = src->demuxer_id;
|
||||
if (src->video) {
|
||||
if (src->type == STREAM_VIDEO) {
|
||||
double ar;
|
||||
if (stream_control(demuxer->stream, STREAM_CTRL_GET_ASPECT_RATIO, &ar)
|
||||
== STREAM_OK)
|
||||
sh->video->aspect = ar;
|
||||
{
|
||||
struct mp_image_params f = {.w = src->codec->disp_w,
|
||||
.h = src->codec->disp_h};
|
||||
mp_image_params_set_dsize(&f, 1728 * ar, 1728);
|
||||
sh->codec->par_w = f.p_w;
|
||||
sh->codec->par_h = f.p_h;
|
||||
}
|
||||
}
|
||||
if (src->audio)
|
||||
sh->audio = src->audio;
|
||||
get_disc_lang(demuxer->stream, sh);
|
||||
demux_add_sh_stream(demuxer, sh);
|
||||
}
|
||||
reselect_streams(demuxer);
|
||||
}
|
||||
|
||||
+1
-1
@@ -23,7 +23,7 @@
|
||||
#include <inttypes.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "talloc.h"
|
||||
#include "mpv_talloc.h"
|
||||
|
||||
#include "demux.h"
|
||||
#include "timeline.h"
|
||||
|
||||
+116
-78
@@ -40,6 +40,7 @@
|
||||
#include "common/tags.h"
|
||||
#include "common/av_common.h"
|
||||
#include "misc/bstr.h"
|
||||
#include "misc/charset_conv.h"
|
||||
|
||||
#include "stream/stream.h"
|
||||
#include "demux.h"
|
||||
@@ -108,6 +109,7 @@ struct format_hack {
|
||||
bool no_stream : 1; // do not wrap struct stream as AVIOContext
|
||||
bool use_stream_ids : 1; // export the native stream IDs
|
||||
bool fully_read : 1; // set demuxer.fully_read flag
|
||||
bool detect_charset : 1; // format is a small text file, possibly not UTF8
|
||||
bool image_format : 1; // expected to contain exactly 1 frame
|
||||
// Do not confuse player's position estimation (position is into external
|
||||
// segment, with e.g. HLS, player knows about the playlist main file only).
|
||||
@@ -115,8 +117,8 @@ struct format_hack {
|
||||
};
|
||||
|
||||
#define BLACKLIST(fmt) {fmt, .ignore = true}
|
||||
#define TEXTSUB(fmt) {fmt, .fully_read = true}
|
||||
#define IMAGEFMT(fmt) {fmt, .image_format = true}
|
||||
#define TEXTSUB(fmt) {fmt, .fully_read = true, .detect_charset = true}
|
||||
#define TEXTSUB_UTF8(fmt) {fmt, .fully_read = true}
|
||||
|
||||
static const struct format_hack format_hacks[] = {
|
||||
// for webradios
|
||||
@@ -135,10 +137,12 @@ static const struct format_hack format_hacks[] = {
|
||||
{"h264", .if_flags = AVFMT_NOTIMESTAMPS },
|
||||
{"hevc", .if_flags = AVFMT_NOTIMESTAMPS },
|
||||
|
||||
TEXTSUB("aqtitle"), TEXTSUB("ass"), TEXTSUB("jacosub"), TEXTSUB("microdvd"),
|
||||
TEXTSUB("aqtitle"), TEXTSUB("jacosub"), TEXTSUB("microdvd"),
|
||||
TEXTSUB("mpl2"), TEXTSUB("mpsub"), TEXTSUB("pjs"), TEXTSUB("realtext"),
|
||||
TEXTSUB("sami"), TEXTSUB("srt"), TEXTSUB("stl"), TEXTSUB("subviewer"),
|
||||
TEXTSUB("subviewer1"), TEXTSUB("vplayer"), TEXTSUB("webvtt"),
|
||||
TEXTSUB("subviewer1"), TEXTSUB("vplayer"), TEXTSUB("ass"),
|
||||
|
||||
TEXTSUB_UTF8("webvtt"),
|
||||
|
||||
// Useless non-sense, sometimes breaks MLP2 subreader.c fallback
|
||||
BLACKLIST("tty"),
|
||||
@@ -148,11 +152,12 @@ static const struct format_hack format_hacks[] = {
|
||||
// Useless, does not work with custom streams.
|
||||
BLACKLIST("image2"),
|
||||
// Image demuxers ("<name>_pipe" is detected explicitly)
|
||||
IMAGEFMT("image2pipe"),
|
||||
{"image2pipe", .image_format = true},
|
||||
{0}
|
||||
};
|
||||
|
||||
typedef struct lavf_priv {
|
||||
struct stream *stream;
|
||||
char *filename;
|
||||
struct format_hack format_hack;
|
||||
AVInputFormat *avif;
|
||||
@@ -187,7 +192,8 @@ static bool matches_avinputformat_name(struct lavf_priv *priv,
|
||||
static int mp_read(void *opaque, uint8_t *buf, int size)
|
||||
{
|
||||
struct demuxer *demuxer = opaque;
|
||||
struct stream *stream = demuxer->stream;
|
||||
lavf_priv_t *priv = demuxer->priv;
|
||||
struct stream *stream = priv->stream;
|
||||
int ret;
|
||||
|
||||
ret = stream_read(stream, buf, size);
|
||||
@@ -200,9 +206,13 @@ static int mp_read(void *opaque, uint8_t *buf, int size)
|
||||
static int64_t mp_seek(void *opaque, int64_t pos, int whence)
|
||||
{
|
||||
struct demuxer *demuxer = opaque;
|
||||
struct stream *stream = demuxer->stream;
|
||||
lavf_priv_t *priv = demuxer->priv;
|
||||
struct stream *stream = priv->stream;
|
||||
int64_t current_pos;
|
||||
MP_TRACE(demuxer, "mp_seek(%p, %"PRId64", %d)\n", stream, pos, whence);
|
||||
MP_TRACE(demuxer, "mp_seek(%p, %"PRId64", %s)\n", stream, pos,
|
||||
whence == SEEK_END ? "end" :
|
||||
whence == SEEK_CUR ? "cur" :
|
||||
whence == SEEK_SET ? "set" : "size");
|
||||
if (whence == SEEK_END || whence == AVSEEK_SIZE) {
|
||||
int64_t end = stream_get_size(stream);
|
||||
if (end < 0)
|
||||
@@ -230,7 +240,8 @@ static int64_t mp_seek(void *opaque, int64_t pos, int whence)
|
||||
static int64_t mp_read_seek(void *opaque, int stream_idx, int64_t ts, int flags)
|
||||
{
|
||||
struct demuxer *demuxer = opaque;
|
||||
struct stream *stream = demuxer->stream;
|
||||
lavf_priv_t *priv = demuxer->priv;
|
||||
struct stream *stream = priv->stream;
|
||||
|
||||
struct stream_avseek cmd = {
|
||||
.stream_index = stream_idx,
|
||||
@@ -253,6 +264,32 @@ static void list_formats(struct demuxer *demuxer)
|
||||
MP_INFO(demuxer, "%15s : %s\n", fmt->name, fmt->long_name);
|
||||
}
|
||||
|
||||
static void convert_charset(struct demuxer *demuxer)
|
||||
{
|
||||
lavf_priv_t *priv = demuxer->priv;
|
||||
char *cp = demuxer->opts->sub_cp;
|
||||
if (!cp || mp_charset_is_utf8(cp))
|
||||
return;
|
||||
bstr data = stream_read_complete(priv->stream, NULL, 128 * 1024 * 1024);
|
||||
if (!data.start) {
|
||||
MP_WARN(demuxer, "File too big (or error reading) - skip charset probing.\n");
|
||||
return;
|
||||
}
|
||||
void *alloc = data.start;
|
||||
cp = (char *)mp_charset_guess(priv, demuxer->log, data, cp, 0);
|
||||
if (cp && !mp_charset_is_utf8(cp))
|
||||
MP_INFO(demuxer, "Using subtitle charset: %s\n", cp);
|
||||
// libavformat transparently converts UTF-16 to UTF-8
|
||||
if (!mp_charset_is_utf16(cp) && !mp_charset_is_utf8(cp)) {
|
||||
bstr conv = mp_iconv_to_utf8(demuxer->log, data, cp, MP_ICONV_VERBOSE);
|
||||
if (conv.start)
|
||||
data = conv;
|
||||
}
|
||||
if (data.start)
|
||||
priv->stream = open_memory_stream(data.start, data.len);
|
||||
talloc_free(alloc);
|
||||
}
|
||||
|
||||
static char *remove_prefix(char *s, const char *const *prefixes)
|
||||
{
|
||||
for (int n = 0; prefixes[n]; n++) {
|
||||
@@ -270,12 +307,8 @@ static int lavf_check_file(demuxer_t *demuxer, enum demux_check check)
|
||||
{
|
||||
struct MPOpts *opts = demuxer->opts;
|
||||
struct demux_lavf_opts *lavfdopts = opts->demux_lavf;
|
||||
struct stream *s = demuxer->stream;
|
||||
lavf_priv_t *priv;
|
||||
|
||||
assert(!demuxer->priv);
|
||||
demuxer->priv = talloc_zero(NULL, lavf_priv_t);
|
||||
priv = demuxer->priv;
|
||||
lavf_priv_t *priv = demuxer->priv;
|
||||
struct stream *s = priv->stream;
|
||||
|
||||
priv->filename = remove_prefix(s->url, prefixes);
|
||||
|
||||
@@ -292,7 +325,7 @@ static int lavf_check_file(demuxer_t *demuxer, enum demux_check check)
|
||||
priv->filename = sep + 1;
|
||||
}
|
||||
|
||||
char *mime_type = demuxer->stream->mime_type;
|
||||
char *mime_type = s->mime_type;
|
||||
if (!lavfdopts->allow_mimetype || !mime_type)
|
||||
mime_type = "";
|
||||
|
||||
@@ -393,6 +426,9 @@ static int lavf_check_file(demuxer_t *demuxer, enum demux_check check)
|
||||
|
||||
demuxer->filetype = priv->avif->name;
|
||||
|
||||
if (priv->format_hack.detect_charset)
|
||||
convert_charset(demuxer);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -464,7 +500,8 @@ static void select_tracks(struct demuxer *demuxer, int start)
|
||||
}
|
||||
}
|
||||
|
||||
static void export_replaygain(demuxer_t *demuxer, sh_audio_t *sh, AVStream *st)
|
||||
static void export_replaygain(demuxer_t *demuxer, struct mp_codec_params *c,
|
||||
AVStream *st)
|
||||
{
|
||||
for (int i = 0; i < st->nb_side_data; i++) {
|
||||
AVReplayGain *av_rgain;
|
||||
@@ -489,7 +526,7 @@ static void export_replaygain(demuxer_t *demuxer, sh_audio_t *sh, AVStream *st)
|
||||
rgain->album_peak = (av_rgain->album_peak != 0.0) ?
|
||||
av_rgain->album_peak / 100000.0f : 1.0;
|
||||
|
||||
sh->replaygain_data = rgain;
|
||||
c->replaygain_data = rgain;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -506,7 +543,7 @@ static int dict_get_decimal(AVDictionary *dict, const char *entry, int def)
|
||||
return def;
|
||||
}
|
||||
|
||||
static void handle_stream(demuxer_t *demuxer, int i)
|
||||
static void handle_new_stream(demuxer_t *demuxer, int i)
|
||||
{
|
||||
lavf_priv_t *priv = demuxer->priv;
|
||||
AVFormatContext *avfc = priv->avfc;
|
||||
@@ -516,27 +553,21 @@ static void handle_stream(demuxer_t *demuxer, int i)
|
||||
|
||||
switch (codec->codec_type) {
|
||||
case AVMEDIA_TYPE_AUDIO: {
|
||||
sh = new_sh_stream(demuxer, STREAM_AUDIO);
|
||||
if (!sh)
|
||||
break;
|
||||
sh_audio_t *sh_audio = sh->audio;
|
||||
sh = demux_alloc_sh_stream(STREAM_AUDIO);
|
||||
|
||||
// probably unneeded
|
||||
mp_chmap_set_unknown(&sh_audio->channels, codec->channels);
|
||||
mp_chmap_set_unknown(&sh->codec->channels, codec->channels);
|
||||
if (codec->channel_layout)
|
||||
mp_chmap_from_lavc(&sh_audio->channels, codec->channel_layout);
|
||||
sh_audio->samplerate = codec->sample_rate;
|
||||
sh_audio->bitrate = codec->bit_rate;
|
||||
mp_chmap_from_lavc(&sh->codec->channels, codec->channel_layout);
|
||||
sh->codec->samplerate = codec->sample_rate;
|
||||
sh->codec->bitrate = codec->bit_rate;
|
||||
|
||||
export_replaygain(demuxer, sh_audio, st);
|
||||
export_replaygain(demuxer, sh->codec, st);
|
||||
|
||||
break;
|
||||
}
|
||||
case AVMEDIA_TYPE_VIDEO: {
|
||||
sh = new_sh_stream(demuxer, STREAM_VIDEO);
|
||||
if (!sh)
|
||||
break;
|
||||
sh_video_t *sh_video = sh->video;
|
||||
sh = demux_alloc_sh_stream(STREAM_VIDEO);
|
||||
|
||||
if (st->disposition & AV_DISPOSITION_ATTACHED_PIC) {
|
||||
sh->attached_picture = new_demux_packet_from(st->attached_pic.data,
|
||||
@@ -548,8 +579,8 @@ static void handle_stream(demuxer_t *demuxer, int i)
|
||||
}
|
||||
}
|
||||
|
||||
sh_video->disp_w = codec->width;
|
||||
sh_video->disp_h = codec->height;
|
||||
sh->codec->disp_w = codec->width;
|
||||
sh->codec->disp_h = codec->height;
|
||||
/* Try to make up some frame rate value, even if it's not reliable.
|
||||
* FPS information is needed to support subtitle formats which base
|
||||
* timing on frame numbers.
|
||||
@@ -564,39 +595,31 @@ static void handle_stream(demuxer_t *demuxer, int i)
|
||||
fps = 1.0 / FFMAX(av_q2d(st->time_base),
|
||||
av_q2d(st->codec->time_base) *
|
||||
st->codec->ticks_per_frame);
|
||||
sh_video->fps = fps;
|
||||
sh->codec->fps = fps;
|
||||
if (priv->format_hack.image_format)
|
||||
sh_video->fps = demuxer->opts->mf_fps;
|
||||
if (st->sample_aspect_ratio.num)
|
||||
sh_video->aspect = codec->width * st->sample_aspect_ratio.num
|
||||
/ (float)(codec->height * st->sample_aspect_ratio.den);
|
||||
else
|
||||
sh_video->aspect = codec->width * codec->sample_aspect_ratio.num
|
||||
/ (float)(codec->height * codec->sample_aspect_ratio.den);
|
||||
sh->codec->fps = demuxer->opts->mf_fps;
|
||||
sh->codec->par_w = st->sample_aspect_ratio.num;
|
||||
sh->codec->par_h = st->sample_aspect_ratio.den;
|
||||
|
||||
uint8_t *sd = av_stream_get_side_data(st, AV_PKT_DATA_DISPLAYMATRIX, NULL);
|
||||
if (sd) {
|
||||
double r = av_display_rotation_get((uint32_t *)sd);
|
||||
if (!isnan(r))
|
||||
sh_video->rotate = (((int)(-r) % 360) + 360) % 360;
|
||||
sh->codec->rotate = (((int)(-r) % 360) + 360) % 360;
|
||||
}
|
||||
|
||||
// This also applies to vfw-muxed mkv, but we can't detect these easily.
|
||||
sh_video->avi_dts = matches_avinputformat_name(priv, "avi");
|
||||
sh->codec->avi_dts = matches_avinputformat_name(priv, "avi");
|
||||
|
||||
break;
|
||||
}
|
||||
case AVMEDIA_TYPE_SUBTITLE: {
|
||||
sh_sub_t *sh_sub;
|
||||
sh = new_sh_stream(demuxer, STREAM_SUB);
|
||||
if (!sh)
|
||||
break;
|
||||
sh_sub = sh->sub;
|
||||
sh = demux_alloc_sh_stream(STREAM_SUB);
|
||||
|
||||
if (codec->extradata_size) {
|
||||
sh->extradata = talloc_size(sh, codec->extradata_size);
|
||||
memcpy(sh->extradata, codec->extradata, codec->extradata_size);
|
||||
sh->extradata_size = codec->extradata_size;
|
||||
sh->codec->extradata = talloc_size(sh, codec->extradata_size);
|
||||
memcpy(sh->codec->extradata, codec->extradata, codec->extradata_size);
|
||||
sh->codec->extradata_size = codec->extradata_size;
|
||||
}
|
||||
|
||||
if (matches_avinputformat_name(priv, "microdvd")) {
|
||||
@@ -604,12 +627,12 @@ static void handle_stream(demuxer_t *demuxer, int i)
|
||||
if (av_opt_get_q(avfc, "subfps", AV_OPT_SEARCH_CHILDREN, &r) >= 0) {
|
||||
// File headers don't have a FPS set.
|
||||
if (r.num < 1 || r.den < 1)
|
||||
sh_sub->frame_based = av_q2d(av_inv_q(codec->time_base));
|
||||
sh->codec->frame_based = av_q2d(av_inv_q(codec->time_base));
|
||||
} else {
|
||||
// Older libavformat versions. If the FPS matches the microdvd
|
||||
// reader's default, assume it uses frame based timing.
|
||||
if (codec->time_base.num == 125 && codec->time_base.den == 2997)
|
||||
sh_sub->frame_based = 23.976;
|
||||
sh->codec->frame_based = 23.976;
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -633,9 +656,11 @@ static void handle_stream(demuxer_t *demuxer, int i)
|
||||
|
||||
if (sh) {
|
||||
sh->ff_index = st->index;
|
||||
sh->codec = mp_codec_from_av_codec_id(codec->codec_id);
|
||||
sh->codec_tag = codec->codec_tag;
|
||||
sh->lav_headers = codec;
|
||||
sh->codec->codec = mp_codec_from_av_codec_id(codec->codec_id);
|
||||
sh->codec->codec_tag = codec->codec_tag;
|
||||
sh->codec->lav_headers = avcodec_alloc_context3(NULL);
|
||||
if (sh->codec->lav_headers)
|
||||
mp_copy_lav_codec_headers(sh->codec->lav_headers, codec);
|
||||
|
||||
if (st->disposition & AV_DISPOSITION_DEFAULT)
|
||||
sh->default_track = true;
|
||||
@@ -653,10 +678,10 @@ static void handle_stream(demuxer_t *demuxer, int i)
|
||||
if (!sh->title && sh->hls_bitrate > 0)
|
||||
sh->title = talloc_asprintf(sh, "bitrate %d", sh->hls_bitrate);
|
||||
sh->missing_timestamps = !!(priv->avif_flags & AVFMT_NOTIMESTAMPS);
|
||||
demux_add_sh_stream(demuxer, sh);
|
||||
}
|
||||
|
||||
select_tracks(demuxer, i);
|
||||
demux_changed(demuxer, DEMUX_EVENT_STREAMS);
|
||||
}
|
||||
|
||||
// Add any new streams that might have been added
|
||||
@@ -664,7 +689,7 @@ static void add_new_streams(demuxer_t *demuxer)
|
||||
{
|
||||
lavf_priv_t *priv = demuxer->priv;
|
||||
while (priv->num_streams < priv->avfc->nb_streams)
|
||||
handle_stream(demuxer, priv->num_streams);
|
||||
handle_new_stream(demuxer, priv->num_streams);
|
||||
}
|
||||
|
||||
static void update_metadata(demuxer_t *demuxer, AVPacket *pkt)
|
||||
@@ -690,7 +715,8 @@ static void update_metadata(demuxer_t *demuxer, AVPacket *pkt)
|
||||
static int interrupt_cb(void *ctx)
|
||||
{
|
||||
struct demuxer *demuxer = ctx;
|
||||
return mp_cancel_test(demuxer->stream->cancel);
|
||||
lavf_priv_t *priv = demuxer->priv;
|
||||
return mp_cancel_test(priv->stream->cancel);
|
||||
}
|
||||
|
||||
static int demux_open_lavf(demuxer_t *demuxer, enum demux_check check)
|
||||
@@ -700,15 +726,13 @@ static int demux_open_lavf(demuxer_t *demuxer, enum demux_check check)
|
||||
AVFormatContext *avfc;
|
||||
AVDictionaryEntry *t = NULL;
|
||||
float analyze_duration = 0;
|
||||
int i;
|
||||
lavf_priv_t *priv = talloc_zero(NULL, lavf_priv_t);
|
||||
demuxer->priv = priv;
|
||||
priv->stream = demuxer->stream;
|
||||
|
||||
if (lavf_check_file(demuxer, check) < 0)
|
||||
return -1;
|
||||
|
||||
lavf_priv_t *priv = demuxer->priv;
|
||||
if (!priv)
|
||||
return -1;
|
||||
|
||||
avfc = avformat_alloc_context();
|
||||
if (!avfc)
|
||||
return -1;
|
||||
@@ -747,7 +771,7 @@ static int demux_open_lavf(demuxer_t *demuxer, enum demux_check check)
|
||||
AVDictionary *dopts = NULL;
|
||||
|
||||
if ((priv->avif_flags & AVFMT_NOFILE) ||
|
||||
demuxer->stream->type == STREAMTYPE_AVDEVICE ||
|
||||
priv->stream->type == STREAMTYPE_AVDEVICE ||
|
||||
priv->format_hack.no_stream)
|
||||
{
|
||||
mp_setup_av_network_options(&dopts, demuxer->global, demuxer->log, opts);
|
||||
@@ -766,7 +790,7 @@ static int demux_open_lavf(demuxer_t *demuxer, enum demux_check check)
|
||||
priv->pb->read_seek = mp_read_seek;
|
||||
priv->pb->seekable = demuxer->seekable ? AVIO_SEEKABLE_NORMAL : 0;
|
||||
avfc->pb = priv->pb;
|
||||
if (stream_control(demuxer->stream, STREAM_CTRL_HAS_AVSEEK, NULL) > 0)
|
||||
if (stream_control(priv->stream, STREAM_CTRL_HAS_AVSEEK, NULL) > 0)
|
||||
demuxer->seekable = true;
|
||||
}
|
||||
|
||||
@@ -806,9 +830,9 @@ static int demux_open_lavf(demuxer_t *demuxer, enum demux_check check)
|
||||
}
|
||||
|
||||
MP_VERBOSE(demuxer, "avformat_find_stream_info() finished after %"PRId64
|
||||
" bytes.\n", stream_tell(demuxer->stream));
|
||||
" bytes.\n", stream_tell(priv->stream));
|
||||
|
||||
for (i = 0; i < avfc->nb_chapters; i++) {
|
||||
for (int i = 0; i < avfc->nb_chapters; i++) {
|
||||
AVChapter *c = avfc->chapters[i];
|
||||
t = av_dict_get(c->metadata, "title", NULL, 0);
|
||||
int index = demuxer_add_chapter(demuxer, t ? t->value : "",
|
||||
@@ -820,7 +844,7 @@ static int demux_open_lavf(demuxer_t *demuxer, enum demux_check check)
|
||||
|
||||
// Often useful with OGG audio-only files, which have metadata in the audio
|
||||
// track metadata instead of the main metadata.
|
||||
if (demuxer->num_streams == 1) {
|
||||
if (demux_get_num_stream(demuxer) == 1) {
|
||||
priv->merge_track_metadata = true;
|
||||
for (int n = 0; n < priv->num_streams; n++) {
|
||||
if (priv->streams[n])
|
||||
@@ -850,7 +874,7 @@ static int demux_lavf_fill_buffer(demuxer_t *demux)
|
||||
AVPacket *pkt = &(AVPacket){0};
|
||||
int r = av_read_frame(priv->avfc, pkt);
|
||||
if (r < 0) {
|
||||
av_free_packet(pkt);
|
||||
av_packet_unref(pkt);
|
||||
if (r == AVERROR(EAGAIN))
|
||||
return 1;
|
||||
if (r == AVERROR_EOF)
|
||||
@@ -867,13 +891,13 @@ static int demux_lavf_fill_buffer(demuxer_t *demux)
|
||||
AVStream *st = priv->avfc->streams[pkt->stream_index];
|
||||
|
||||
if (!demux_stream_is_selected(stream)) {
|
||||
av_free_packet(pkt);
|
||||
av_packet_unref(pkt);
|
||||
return 1; // don't signal EOF if skipping a packet
|
||||
}
|
||||
|
||||
struct demux_packet *dp = new_demux_packet_from_avpacket(pkt);
|
||||
if (!dp) {
|
||||
av_free_packet(pkt);
|
||||
av_packet_unref(pkt);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -882,8 +906,10 @@ static int demux_lavf_fill_buffer(demuxer_t *demux)
|
||||
if (pkt->dts != AV_NOPTS_VALUE)
|
||||
dp->dts = pkt->dts * av_q2d(st->time_base);
|
||||
dp->duration = pkt->duration * av_q2d(st->time_base);
|
||||
#if !HAVE_AV_AVPACKET_INT64_DURATION
|
||||
if (pkt->convergence_duration > 0)
|
||||
dp->duration = pkt->convergence_duration * av_q2d(st->time_base);
|
||||
#endif
|
||||
dp->pos = pkt->pos;
|
||||
dp->keyframe = pkt->flags & AV_PKT_FLAG_KEY;
|
||||
if (dp->pts != MP_NOPTS_VALUE) {
|
||||
@@ -891,7 +917,7 @@ static int demux_lavf_fill_buffer(demuxer_t *demux)
|
||||
} else if (dp->dts != MP_NOPTS_VALUE) {
|
||||
priv->last_pts = dp->dts * AV_TIME_BASE;
|
||||
}
|
||||
av_free_packet(pkt);
|
||||
av_packet_unref(pkt);
|
||||
|
||||
if (priv->format_hack.clear_filepos)
|
||||
dp->pos = -1;
|
||||
@@ -916,7 +942,7 @@ static void demux_seek_lavf(demuxer_t *demuxer, double rel_seek_secs, int flags)
|
||||
avsflags = AVSEEK_FLAG_BACKWARD;
|
||||
|
||||
if (flags & SEEK_FACTOR) {
|
||||
struct stream *s = demuxer->stream;
|
||||
struct stream *s = priv->stream;
|
||||
int64_t end = stream_get_size(s);
|
||||
if (end > 0 && demuxer->ts_resets_possible &&
|
||||
!(priv->avif_flags & AVFMT_NO_BYTE_SEEK))
|
||||
@@ -1036,6 +1062,12 @@ redo:
|
||||
goto redo;
|
||||
}
|
||||
priv->cur_program = prog->progid = program->id;
|
||||
|
||||
mp_tags_copy_from_av_dictionary(demuxer->metadata, priv->avfc->programs[p]->metadata);
|
||||
update_metadata(demuxer, NULL);
|
||||
// Enforce metadata update even if no explicit METADATA_UPDATED since we switched program.
|
||||
demux_changed(demuxer, DEMUX_EVENT_METADATA);
|
||||
|
||||
return DEMUXER_CTRL_OK;
|
||||
}
|
||||
case DEMUXER_CTRL_RESYNC:
|
||||
@@ -1052,10 +1084,10 @@ redo:
|
||||
*/
|
||||
// avio_flush() is designed for write-only streams, and does the wrong
|
||||
// thing when reading. Flush it manually instead.
|
||||
stream_drop_buffers(demuxer->stream);
|
||||
stream_drop_buffers(priv->stream);
|
||||
priv->avfc->pb->buf_ptr = priv->avfc->pb->buf_end = priv->avfc->pb->buffer;
|
||||
priv->avfc->pb->pos = stream_tell(demuxer->stream);
|
||||
av_seek_frame(priv->avfc, 0, stream_tell(demuxer->stream),
|
||||
priv->avfc->pb->pos = stream_tell(priv->stream);
|
||||
av_seek_frame(priv->avfc, 0, stream_tell(priv->stream),
|
||||
AVSEEK_FLAG_BYTE);
|
||||
return DEMUXER_CTRL_OK;
|
||||
default:
|
||||
@@ -1074,6 +1106,12 @@ static void demux_close_lavf(demuxer_t *demuxer)
|
||||
if (priv->pb)
|
||||
av_freep(&priv->pb->buffer);
|
||||
av_freep(&priv->pb);
|
||||
for (int n = 0; n < priv->num_streams; n++) {
|
||||
if (priv->streams[n])
|
||||
avcodec_free_context(&priv->streams[n]->codec->lav_headers);
|
||||
}
|
||||
if (priv->stream != demuxer->stream)
|
||||
free_stream(priv->stream);
|
||||
talloc_free(priv);
|
||||
demuxer->priv = NULL;
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ static int open_file(struct demuxer *demuxer, enum demux_check check)
|
||||
if (r == ARCHIVE_EOF)
|
||||
break;
|
||||
if (r < ARCHIVE_OK)
|
||||
MP_ERR(demuxer, "libarchive: %s\n", archive_error_string(mpa->arch));
|
||||
MP_ERR(demuxer, "%s\n", archive_error_string(mpa->arch));
|
||||
if (r < ARCHIVE_WARN)
|
||||
break;
|
||||
if (archive_entry_filetype(entry) != AE_IFREG)
|
||||
|
||||
Loaded 100 of 327 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user