1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
|
/*
** .WV input plug-in for WavPack
** Copyright (c) 2000 - 2006, Conifer Software, All Rights Reserved
*/
#include <windows.h>
#include <fcntl.h>
#include <stdio.h>
#include <mmreg.h>
#include <msacm.h>
#include <math.h>
#include <sys/stat.h>
#include <io.h>
#include <strsafe.h>
#include "in2.h"
#include "wavpack.h"
#include "resource.h"
#include "wasabi/winamp/wa_ipc.h"
#include "wasabi/wasabi.h"
#include "wasabi/nu/autochar.h"
#include "wasabi/nu/autowide.h"
#define fileno _fileno
static float calculate_gain(WavpackContext *wpc, bool allowDefault=true);
#define PLUGIN_VERSION "2.8.1"
//#define DEBUG_CONSOLE
//#define ANSI_METADATA
#define UNICODE_METADATA
//#define OLD_INFO_DIALOG
// post this to the main window at end of file (after playback as stopped)
#define WM_WA_MPEG_EOF WM_USER+2
#define MAX_NCH 8
static struct wpcnxt {
WavpackContext *wpc; // WavPack context provided by library
float play_gain; // playback gain (for replaygain support)
//int soft_clipping; // soft clipping active for playback
int output_bits; // 16, 24, or 32 bits / sample
long sample_buffer[576*MAX_NCH*2]; // sample buffer
float error [MAX_NCH]; // error term for noise shaping
char lastfn[MAX_PATH]; // filename stored for comparisons only
wchar_t w_lastfn[MAX_PATH]; // w_filename stored for comparisons only
FILE *wv_id, *wvc_id; // file pointer when we use reader callbacks
} curr, edit, info;
int decode_pos_ms; // current decoding position, in milliseconds
int paused; // are we paused?
int seek_needed; // if != -1, it is the point that the decode thread should seek to, in ms.
#define ALLOW_WVC 0x1
#define REPLAYGAIN_TRACK 0x2
#define REPLAYGAIN_ALBUM 0x4
#define SOFTEN_CLIPPING 0x8
#define PREVENT_CLIPPING 0x10
#define ALWAYS_16BIT 0x20 // new flags added for version 2.5
#define ALLOW_MULTICHANNEL 0x40
#define REPLAYGAIN_24BIT 0x80
int config_bits = ALLOW_WVC | ALLOW_MULTICHANNEL; // all configuration goes here
int killDecodeThread=0; // the kill switch for the decode thread
HANDLE thread_handle=INVALID_HANDLE_VALUE; // the handle to the decode thread
DWORD WINAPI __stdcall DecodeThread(void *b); // the decode thread procedure
static api_service* WASABI_API_SVC;
static api_language* WASABI_API_LNG;
static api_config *AGAVE_API_CONFIG;
static api_memmgr *WASABI_API_MEMMGR;
HINSTANCE WASABI_API_LNG_HINST = 0, WASABI_API_ORIG_HINST = 0;
static char file_extensions[128] = {"WV\0WavPack Files (*.WV)\0"};
// function definitions for the In_Module stucture
void about (HWND hwndParent);
void init();
void quit();
void getfileinfo(const char *filename, char *title, int *length_in_ms);
int infoDlg(const char *fn, HWND hwnd);
int isourfile(const char *fn);
int play(const char *fn);
void pause();
void unpause();
int ispaused();
void stop();
int getlength();
int getoutputtime();
void setoutputtime(int time_in_ms);
void setvolume(int volume);
void setpan(int pan);
void eq_set(int on, char data [10], int preamp);
In_Module mod = // the output module
{
IN_VER,
"WavPack Decoder v"PLUGIN_VERSION,
0, // hMainWindow
0, // hDllInstance
file_extensions,
1, // is_seekable
1, // uses output
about,
about,
init,
quit,
getfileinfo,
infoDlg,
isourfile,
play,
pause,
unpause,
ispaused,
stop,
getlength,
getoutputtime,
setoutputtime,
setvolume,
setpan,
0,0,0,0,0,0,0,0,0, // vis stuff
0,0, // dsp
eq_set,
NULL, // setinfo
0 // out_mod
};
static BOOL CALLBACK WavPackDlgProc(HWND, UINT, WPARAM, LPARAM);
extern long dump_alloc (void);
int DoAboutMessageBox(HWND parent, wchar_t* title, wchar_t* message)
{
MSGBOXPARAMSW msgbx = {sizeof(MSGBOXPARAMSW),0};
msgbx.lpszText = message;
msgbx.lpszCaption = title;
msgbx.lpszIcon = MAKEINTRESOURCEW(102);
msgbx.hInstance = GetModuleHandle(0);
msgbx.dwStyle = MB_USERICON;
msgbx.hwndOwner = parent;
return MessageBoxIndirectW(&msgbx);
}
void about(HWND hwndParent)
{
wchar_t about_string[512];
#ifdef DEBUG_ALLOC
sprintf (about_string, "alloc_count = %d", dump_alloc ());
#else
StringCchPrintfW(about_string, 512, WASABI_API_LNGSTRINGW(IDS_ABOUT_MESSAGE), PLUGIN_VERSION, "1998-2010", __DATE__);
#endif
DoAboutMessageBox(hwndParent, WASABI_API_LNGSTRINGW(IDS_ABOUT), about_string);
}
void init() /* any one-time initialization goes here (configuration reading, etc) */
{
if (mod.hMainWindow)
{
// load all of the required wasabi services from the winamp client
WASABI_API_SVC = (api_service *)SendMessage(mod.hMainWindow, WM_WA_IPC, 0, IPC_GET_API_SERVICE);
if (WASABI_API_SVC == (api_service *)1)
WASABI_API_SVC=0;
WASABI_API_SVC->service_register(&albumArtFactory);
}
ServiceBuild(AGAVE_API_CONFIG, AgaveConfigGUID);
ServiceBuild(WASABI_API_LNG, languageApiGUID);
ServiceBuild(WASABI_API_MEMMGR, memMgrApiServiceGuid);
// need to have this initialised before we try to do anything with localisation features
WASABI_API_START_LANG(mod.hDllInstance,InWvLangGuid);
static char szDescription[256];
StringCchPrintfA(szDescription,256,WASABI_API_LNGSTRING(IDS_DESCRIPTION),PLUGIN_VERSION);
mod.description = szDescription;
// set the file extension to the localised version
char tmp [64], *tmp_ptr = tmp, *fex_ptr = file_extensions;
WASABI_API_LNGSTRING_BUF(IDS_FILETYPE, tmp, sizeof (tmp));
*fex_ptr++ = 'W';
*fex_ptr++ = 'V';
*fex_ptr++ = 0;
while (*tmp_ptr)
*fex_ptr++ = *tmp_ptr++;
*fex_ptr++ = 0;
*fex_ptr++ = 0;
}
#ifdef DEBUG_CONSOLE
HANDLE debug_console=INVALID_HANDLE_VALUE; // debug console
void debug_write (char *str)
{
static int cant_debug;
if (cant_debug)
return;
if (debug_console == INVALID_HANDLE_VALUE) {
AllocConsole ();
#if 1
debug_console = GetStdHandle (STD_OUTPUT_HANDLE);
#else
debug_console = CreateConsoleScreenBuffer (GENERIC_WRITE, FILE_SHARE_WRITE,
NULL, CONSOLE_TEXTMODE_BUFFER, NULL);
#endif
if (debug_console == INVALID_HANDLE_VALUE) {
MessageBox(NULL, "Can't get a console handle", "WavPack",MB_OK);
cant_debug = 1;
return;
}
else if (!SetConsoleActiveScreenBuffer (debug_console)) {
MessageBox(NULL, "Can't activate console buffer", "WavPack",MB_OK);
cant_debug = 1;
return;
}
}
WriteConsole (debug_console, str, strlen (str), NULL, NULL);
}
#endif
void quit() /* one-time deinit, such as memory freeing */
{
#ifdef DEBUG_CONSOLE
if (debug_console != INVALID_HANDLE_VALUE) {
FreeConsole ();
if (debug_console != GetStdHandle (STD_OUTPUT_HANDLE))
CloseHandle (debug_console);
debug_console = INVALID_HANDLE_VALUE;
}
#endif
ServiceRelease(AGAVE_API_CONFIG, AgaveConfigGUID);
ServiceRelease(WASABI_API_LNG, languageApiGUID);
ServiceRelease(WASABI_API_MEMMGR, memMgrApiServiceGuid);
WASABI_API_SVC->service_deregister(&albumArtFactory);
}
// used for detecting URL streams.. unused here. strncmp(fn,"http://",7) to detect HTTP streams, etc
int isourfile(const char *fn)
{
return 0;
}
int play(const char *fn)
{
int num_chans, sample_rate;
char error[128];
int maxlatency;
int thread_id;
int open_flags;
#ifdef DEBUG_CONSOLE
sprintf (error, "play (%s)\n", fn);
debug_write (error);
#endif
open_flags = OPEN_TAGS | OPEN_NORMALIZE;
if (config_bits & ALLOW_WVC)
open_flags |= OPEN_WVC;
if (!(config_bits & ALLOW_MULTICHANNEL))
open_flags |= OPEN_2CH_MAX;
curr.wpc = WavpackOpenFileInput(fn, error, open_flags, 0);
if (!curr.wpc) // error opening file, just return error
return -1;
num_chans = WavpackGetReducedChannels(curr.wpc);
sample_rate = WavpackGetSampleRate(curr.wpc);
curr.output_bits = WavpackGetBitsPerSample(curr.wpc) > 16 ? 24 : 16;
if (config_bits & ALWAYS_16BIT)
curr.output_bits = 16;
else if ((config_bits & (REPLAYGAIN_TRACK | REPLAYGAIN_ALBUM)) &&
(config_bits & REPLAYGAIN_24BIT))
curr.output_bits = 24;
if (num_chans > MAX_NCH) // don't allow too many channels!
{
WavpackCloseFile(curr.wpc);
return -1;
}
curr.play_gain = calculate_gain(curr.wpc);
lstrcpyn(curr.lastfn, fn, MAX_PATH);
paused = 0;
decode_pos_ms = 0;
seek_needed = -1;
maxlatency = mod.outMod->Open(sample_rate, num_chans, curr.output_bits, -1, -1);
if (maxlatency < 0) // error opening device
{
curr.wpc = WavpackCloseFile(curr.wpc);
return -1;
}
// dividing by 1000 for the first parameter of setinfo makes it
// display 'H'... for hundred.. i.e. 14H Kbps.
mod.SetInfo(0, (sample_rate + 500) / 1000, num_chans, 1);
// initialize vis stuff
mod.SAVSAInit(maxlatency, sample_rate);
mod.VSASetInfo(sample_rate, num_chans);
mod.outMod->SetVolume(-666); // set the output plug-ins default volume
killDecodeThread=0;
thread_handle = (HANDLE)CreateThread (NULL, 0, (LPTHREAD_START_ROUTINE) DecodeThread, (void *) &killDecodeThread, 0, (LPDWORD)&thread_id);
if (SetThreadPriority(thread_handle, THREAD_PRIORITY_HIGHEST) == 0) {
curr.wpc = WavpackCloseFile(curr.wpc);
return -1;
}
return 0;
}
void pause()
{
#ifdef DEBUG_CONSOLE
debug_write ("pause ()\n");
#endif
paused = 1;
mod.outMod->Pause(1);
}
void unpause()
{
#ifdef DEBUG_CONSOLE
debug_write ("unpause ()\n");
#endif
paused = 0;
mod.outMod->Pause(0);
}
int ispaused()
{
return paused;
}
void stop()
{
#ifdef DEBUG_CONSOLE
debug_write ("stop ()\n");
#endif
if (thread_handle != INVALID_HANDLE_VALUE)
{
killDecodeThread = 1;
if (WaitForSingleObject(thread_handle, INFINITE) == WAIT_TIMEOUT)
{
MessageBox(mod.hMainWindow,"error asking thread to die!\n", "error killing decode thread", 0);
TerminateThread(thread_handle,0);
}
CloseHandle(thread_handle);
thread_handle = INVALID_HANDLE_VALUE;
}
if (curr.wpc)
curr.wpc = WavpackCloseFile(curr.wpc);
mod.outMod->Close();
mod.SAVSADeInit();
}
int getlength()
{
return (int)(WavpackGetNumSamples (curr.wpc) * 1000.0 / WavpackGetSampleRate (curr.wpc));
}
int getoutputtime()
{
if (seek_needed == -1)
return decode_pos_ms + (mod.outMod->GetOutputTime () - mod.outMod->GetWrittenTime ());
else
return seek_needed;
}
void setoutputtime (int time_in_ms)
{
#ifdef DEBUG_CONSOLE
char str [40];
sprintf (str, "setoutputtime (%d)\n", time_in_ms);
debug_write (str);
#endif
seek_needed = time_in_ms;
}
void setvolume (int volume)
{
mod.outMod->SetVolume(volume);
}
void setpan (int pan)
{
mod.outMod->SetPan(pan);
}
static void generate_format_string(WavpackContext *wpc, wchar_t *string, int maxlen, int wide);
static void AnsiToUTF8(char *string, int len);
static int UTF8ToWideChar(const char *pUTF8, wchar_t *pWide);
static void UTF8ToAnsi(char *string, int len);
int infoDlg(const char *fn, HWND hwnd)
{
#ifdef OLD_INFO_DIALOG
char string[2048];
wchar_t w_string[2048];
WavpackContext *wpc;
int open_flags;
open_flags = OPEN_TAGS | OPEN_NORMALIZE;
if (config_bits & ALLOW_WVC)
open_flags |= OPEN_WVC;
if (!(config_bits & ALLOW_MULTICHANNEL))
open_flags |= OPEN_2CH_MAX;
wpc = WavpackOpenFileInput(fn, string, open_flags, 0);
if (wpc)
{
int mode = WavpackGetMode(wpc);
//generate_format_string(wpc, string, sizeof (string), 1);
wchar_t *temp = (wchar_t *)malloc(sizeof(string) * sizeof(wchar_t));
generate_format_string(wpc, temp, sizeof(string), 0);
lstrcpyn(string, AutoChar(temp, CP_UTF8), sizeof(string));
free(temp);
if (WavpackGetMode(wpc) & MODE_VALID_TAG)
{
char value [128];
if (config_bits & (REPLAYGAIN_TRACK | REPLAYGAIN_ALBUM))
{
int local_clipping = 0;
float local_gain;
local_gain = calculate_gain(wpc);
if (local_gain != 1.0)
StringCchPrintf(string + strlen (string), 2048, "Gain: %+.2f dB %s\n",
log10 (local_gain) * 20.0, local_clipping ? "(w/soft clipping)" : "");
}
if (WavpackGetTagItem(wpc, "title", value, sizeof (value)))
{
if (!(mode & MODE_APETAG))
AnsiToUTF8(value, sizeof (value));
StringCchPrintf(string + strlen (string), 2048, "\nTitle: %s", value);
}
if (WavpackGetTagItem(wpc, "artist", value, sizeof (value)))
{
if (!(mode & MODE_APETAG))
AnsiToUTF8(value, sizeof (value));
StringCchPrintf(string + strlen (string), 2048, "\nArtist: %s", value);
}
if (WavpackGetTagItem (wpc, "album", value, sizeof (value)))
{
if (!(mode & MODE_APETAG))
AnsiToUTF8(value, sizeof (value));
StringCchPrintf (string + strlen (string), 2048, "\nAlbum: %s", value);
}
if (WavpackGetTagItem (wpc, "genre", value, sizeof (value)))
{
if (!(mode & MODE_APETAG))
AnsiToUTF8(value, sizeof (value));
StringCchPrintf(string + strlen (string), 2048, "\nGenre: %s", value);
}
if (WavpackGetTagItem (wpc, "comment", value, sizeof (value)))
{
if (!(mode & MODE_APETAG))
AnsiToUTF8(value, sizeof (value));
StringCchPrintf(string + strlen (string), 2048, "\nComment: %s", value);
}
if (WavpackGetTagItem(wpc, "year", value, sizeof (value)))
StringCchPrintf(string + strlen (string), 2048, "\nYear: %s", value);
if (WavpackGetTagItem(wpc, "track", value, sizeof (value)))
StringCchPrintf(string + strlen (string), 2048, "\nTrack: %s", value);
StringCchCat(string, 2048, "\n");
}
UTF8ToWideChar(string, w_string);
MessageBoxW(hwnd, w_string, L"WavPack File Info Box", MB_OK);
wpc = WavpackCloseFile(wpc);
}
else
MessageBox(hwnd, string, "WavPack Decoder", MB_OK);
return 0;
#else
return 1;
#endif
}
void getfileinfo(const char *filename, char *title, int *length_in_ms)
{
if (!filename || !*filename) // currently playing file
{
if (length_in_ms)
*length_in_ms = getlength ();
if (title)
{
if (WavpackGetTagItem(curr.wpc, "title", NULL, 0))
{
char art [128], ttl [128];
WavpackGetTagItem(curr.wpc, "title", ttl, sizeof (ttl));
if (WavpackGetMode(curr.wpc) & MODE_APETAG)
UTF8ToAnsi(ttl, sizeof (ttl));
if (WavpackGetTagItem(curr.wpc, "artist", art, sizeof (art)))
{
if (WavpackGetMode(curr.wpc) & MODE_APETAG)
UTF8ToAnsi(art, sizeof (art));
StringCchPrintf(title, GETFILEINFO_TITLE_LENGTH, "%s - %s", art, ttl);
}
else
lstrcpyn(title, ttl, GETFILEINFO_TITLE_LENGTH);
}
else
{
char *p = curr.lastfn + strlen (curr.lastfn);
while (*p != '\\' && p >= curr.lastfn)
p--;
lstrcpyn(title, ++p, GETFILEINFO_TITLE_LENGTH);
}
}
}
else // some other file
{
WavpackContext *wpc;
char error [128];
int open_flags;
if (length_in_ms)
*length_in_ms = -1000;
if (title)
*title = 0;
open_flags = OPEN_TAGS | OPEN_NORMALIZE;
if (config_bits & ALLOW_WVC)
open_flags |= OPEN_WVC;
if (!(config_bits & ALLOW_MULTICHANNEL))
open_flags |= OPEN_2CH_MAX;
wpc = WavpackOpenFileInput(filename, error, open_flags, 0);
if (wpc)
{
if (length_in_ms)
*length_in_ms = (int)(WavpackGetNumSamples(wpc) * 1000.0 / WavpackGetSampleRate(wpc));
if (title && WavpackGetTagItem(wpc, "title", NULL, 0))
{
char art [128], ttl [128];
WavpackGetTagItem(wpc, "title", ttl, sizeof (ttl));
if (WavpackGetMode(wpc) & MODE_APETAG)
UTF8ToAnsi(ttl, sizeof (ttl));
if (WavpackGetTagItem(wpc, "artist", art, sizeof (art)))
{
if (WavpackGetMode(wpc) & MODE_APETAG)
UTF8ToAnsi(art, sizeof (art));
StringCchPrintf(title, GETFILEINFO_TITLE_LENGTH, "%s - %s", art, ttl);
}
else
lstrcpyn(title, ttl, GETFILEINFO_TITLE_LENGTH);
}
wpc = WavpackCloseFile(wpc);
}
if (title && !*title)
{
char *p = (char*)filename + strlen (filename);
while (*p != '\\' && p >= filename) p--;
lstrcpyn(title, ++p, GETFILEINFO_TITLE_LENGTH);
}
}
}
void eq_set(int on, char data [10], int preamp)
{
// most plug-ins can't even do an EQ anyhow.. I'm working on writing
// a generic PCM EQ, but it looks like it'll be a little too CPU
// consuming to be useful :)
}
static int read_samples(struct wpcnxt *cnxt, int num_samples);
DWORD WINAPI __stdcall DecodeThread(void *b)
{
int num_chans, sample_rate;
int done = 0;
memset(curr.error, 0, sizeof (curr.error));
num_chans = WavpackGetReducedChannels(curr.wpc);
sample_rate = WavpackGetSampleRate(curr.wpc);
while (!*((int *)b) )
{
if (seek_needed != -1)
{
int seek_position = seek_needed;
int bc = 0;
seek_needed = -1;
if (seek_position > getlength() - 1000 && getlength() > 1000)
seek_position = getlength() - 1000; // don't seek to last second
mod.outMod->Flush(decode_pos_ms = seek_position);
if (WavpackSeekSample(curr.wpc, (int)(sample_rate / 1000.0 * seek_position))) {
decode_pos_ms = (int)(WavpackGetSampleIndex(curr.wpc) * 1000.0 / sample_rate);
mod.outMod->Flush(decode_pos_ms);
continue;
}
else
done = 1;
}
if (done) {
mod.outMod->CanWrite();
if (!mod.outMod->IsPlaying()) {
PostMessage(mod.hMainWindow, WM_WA_MPEG_EOF, 0, 0);
return 0;
}
Sleep(10);
}
else if (mod.outMod->CanWrite() >= ((576 * num_chans * (curr.output_bits / 8)) << (mod.dsp_isactive () ? 1 : 0)))
{
int tsamples = read_samples (&curr, 576) * num_chans;
int tbytes = tsamples * (curr.output_bits/8);
if (tsamples)
{
mod.SAAddPCMData((char *) curr.sample_buffer, num_chans, curr.output_bits, decode_pos_ms);
mod.VSAAddPCMData((char *) curr.sample_buffer, num_chans, curr.output_bits, decode_pos_ms);
decode_pos_ms = (int)(WavpackGetSampleIndex(curr.wpc) * 1000.0 / sample_rate);
if (mod.dsp_isactive())
tbytes = mod.dsp_dosamples ((short *) curr.sample_buffer,
tsamples / num_chans, curr.output_bits, num_chans, sample_rate) * (num_chans * (curr.output_bits/8));
mod.outMod->Write ((char *) curr.sample_buffer, tbytes);
}
else
done = 1;
}
else
{
mod.SetInfo((int) ((WavpackGetInstantBitrate (curr.wpc) + 500.0) / 1000.0), -1, -1, 1);
Sleep(20);
}
}
return 0;
}
/********* These functions provide the "transcoding" mode of winamp. *********/
extern "C" __declspec (dllexport) intptr_t winampGetExtendedRead_open (const char *fn, int *size, int *bps, int *nch, int *srate)
{
struct wpcnxt *cnxt = (struct wpcnxt *)malloc(sizeof (struct wpcnxt));
int num_chans, sample_rate, open_flags;
char error[128];
#ifdef DEBUG_CONSOLE
sprintf (error, "Read_open (%s)\n", fn);
debug_write (error);
#endif
if (!cnxt)
return 0;
memset(cnxt, 0, sizeof (struct wpcnxt));
open_flags = OPEN_NORMALIZE | OPEN_WVC;
if (!(config_bits & ALLOW_MULTICHANNEL) || *nch == 2)
open_flags |= OPEN_2CH_MAX;
if (config_bits & (REPLAYGAIN_TRACK | REPLAYGAIN_ALBUM))
open_flags |= OPEN_TAGS;
cnxt->wpc = WavpackOpenFileInput(fn, error, open_flags, 0);
if (!cnxt->wpc) // error opening file, just return error
{
free (cnxt);
return 0;
}
num_chans = WavpackGetReducedChannels(cnxt->wpc);
sample_rate = WavpackGetSampleRate(cnxt->wpc);
if (num_chans > MAX_NCH)
{
WavpackCloseFile(cnxt->wpc);
free (cnxt);
return 0;
}
if (*bps != 16 && *bps != 24 && *bps != 32)
{
cnxt->output_bits = WavpackGetBitsPerSample(cnxt->wpc) > 16 ? 24 : 16;
if (config_bits & ALWAYS_16BIT)
cnxt->output_bits = 16;
else if ((config_bits & (REPLAYGAIN_TRACK | REPLAYGAIN_ALBUM)) &&
(config_bits & REPLAYGAIN_24BIT))
cnxt->output_bits = 24;
}
else
cnxt->output_bits = *bps;
if (num_chans > MAX_NCH) // don't allow too many channels!
{
WavpackCloseFile(cnxt->wpc);
free (cnxt);
return 0;
}
*nch = num_chans;
*srate = sample_rate;
*bps = cnxt->output_bits;
*size = WavpackGetNumSamples(cnxt->wpc) * (*bps / 8) * (*nch);
cnxt->play_gain = calculate_gain(cnxt->wpc);
#ifdef DEBUG_CONSOLE
sprintf (error, "Read_open success! nch=%d, srate=%d, bps=%d, size=%d\n",
*nch, *srate, *bps, *size);
debug_write (error);
#endif
return (intptr_t) cnxt;
}
extern "C" __declspec (dllexport) intptr_t winampGetExtendedRead_getData (intptr_t handle, char *dest, int len, int *killswitch)
{
struct wpcnxt *cnxt = (struct wpcnxt *)handle;
int num_chans = WavpackGetReducedChannels(cnxt->wpc);
int bytes_per_sample = num_chans * cnxt->output_bits / 8;
int used = 0;
#ifdef DEBUG_CONSOLE
char error [128];
#endif
while (used < len && !*killswitch)
{
int nsamples = (len - used) / bytes_per_sample, tsamples;
if (!nsamples)
break;
else if (nsamples > 576)
nsamples = 576;
tsamples = read_samples(cnxt, nsamples) * num_chans;
if (tsamples)
{
int tbytes = tsamples * (cnxt->output_bits/8);
memcpy (dest + used, cnxt->sample_buffer, tbytes);
used += tbytes;
}
else
break;
}
#ifdef DEBUG_CONSOLE
sprintf (error, "Read_getData (%d), actualy read %d\n", len, used);
debug_write (error);
#endif
return used;
}
extern "C" __declspec (dllexport) int winampGetExtendedRead_setTime (intptr_t handle, int millisecs)
{
struct wpcnxt *cnxt = (struct wpcnxt *) handle;
int sample_rate = WavpackGetSampleRate(cnxt->wpc);
return WavpackSeekSample(cnxt->wpc, (int)(sample_rate / 1000.0 * millisecs));
}
extern "C" __declspec (dllexport) void winampGetExtendedRead_close (intptr_t handle)
{
struct wpcnxt *cnxt = (struct wpcnxt *) handle;
#ifdef DEBUG_CONSOLE
char error [128];
sprintf (error, "Read_close ()\n");
debug_write (error);
#endif
WavpackCloseFile(cnxt->wpc);
free (cnxt);
}
/* This is a generic function to read WavPack samples and convert them to a
* form usable by winamp. It includes conversion of any WavPack format
* (including ieee float) to 16, 24, or 32-bit integers (with noise shaping
* for the 16-bit case) and replay gain implementation (with optional soft
* clipping). It is used by both the regular "play" code and the newer
* transcoding functions.
*
* The num_samples parameter is the number of "composite" samples to
* convert and is limited currently to 576 samples for legacy reasons. The
* return value is the number of samples actually converted and will be
* equal to the number requested unless an error occurs or the end-of-file
* is encountered. The converted samples are stored (interleaved) at
* cnxt->sample_buffer[].
*/
static int read_samples (struct wpcnxt *cnxt, int num_samples)
{
int num_chans = WavpackGetReducedChannels(cnxt->wpc), samples, tsamples;
samples = WavpackUnpackSamples(cnxt->wpc, (int32_t*) cnxt->sample_buffer, num_samples);
tsamples = samples * num_chans;
if (tsamples)
{
if (!(WavpackGetMode(cnxt->wpc) & MODE_FLOAT))
{
float scaler = (float) (1.0 / ((unsigned long) 1 << (WavpackGetBytesPerSample(cnxt->wpc) * 8 - 1)));
float *fptr = (float *) cnxt->sample_buffer;
long *lptr = cnxt->sample_buffer;
int cnt = tsamples;
while (cnt--)
*fptr++ = *lptr++ * scaler;
}
if (cnxt->play_gain != 1.0)
{
float *fptr = (float *) cnxt->sample_buffer;
int cnt = tsamples;
double outval;
while (cnt--)
{
outval = *fptr * cnxt->play_gain;
/*if (cnxt->soft_clipping)
{
if (outval > 0.75)
outval = 1.0 - (0.0625 / (outval - 0.5));
else if (outval < -0.75)
outval = -1.0 - (0.0625 / (outval + 0.5));
}*/
*fptr++ = (float) outval;
}
}
if (cnxt->output_bits == 16)
{
float *fptr = (float *) cnxt->sample_buffer;
short *sptr = (short *) cnxt->sample_buffer;
int cnt = samples, ch;
while (cnt--)
for (ch = 0; ch < num_chans; ++ch)
{
int dst;
*fptr -= cnxt->error [ch];
if (*fptr >= 1.0)
dst = 32767;
else if (*fptr <= -1.0)
dst = -32768;
else
dst = (int) floor (*fptr * 32768.0);
cnxt->error [ch] = (float)(dst / 32768.0 - *fptr++);
*sptr++ = dst;
}
}
else if (cnxt->output_bits == 24)
{
unsigned char *cptr = (unsigned char *) cnxt->sample_buffer;
float *fptr = (float *) cnxt->sample_buffer;
int cnt = tsamples;
long outval;
while (cnt--) {
if (*fptr >= 1.0)
outval = 8388607;
else if (*fptr <= -1.0)
outval = -8388608;
else
outval = (int) floor (*fptr * 8388608.0);
*cptr++ = (unsigned char) outval;
*cptr++ = (unsigned char) (outval >> 8);
*cptr++ = (unsigned char) (outval >> 16);
fptr++;
}
}
else if (cnxt->output_bits == 32)
{
float *fptr = (float *) cnxt->sample_buffer;
long *sptr = (long *) cnxt->sample_buffer;
int cnt = tsamples;
while (cnt--)
{
if (*fptr >= 1.0)
*sptr++ = 8388607 << 8;
else if (*fptr <= -1.0)
*sptr++ = -8388608 << 8;
else
*sptr++ = ((int) floor (*fptr * 8388608.0)) << 8;
fptr++;
}
}
}
return samples;
}
extern "C" __declspec (dllexport) In_Module * winampGetInModule2()
{
return &mod;
}
// This code provides an interface between the reader callback mechanism that
// WavPack uses internally and the standard fstream C library.
static int32_t read_bytes(void *id, void *data, int32_t bcount)
{
FILE *file = id ? *(FILE**)id : NULL;
if (file)
return (int32_t) fread(data, 1, bcount, file);
else
return 0;
}
static uint32_t get_pos(void *id)
{
FILE *file = id ? *(FILE**)id : NULL;
if (file)
return ftell(file);
else
return -1;
}
static int set_pos_abs(void *id, uint32_t pos)
{
FILE *file = id ? *(FILE**)id : NULL;
if (file)
return fseek(file, pos, SEEK_SET);
else
return 0;
}
static int set_pos_rel(void *id, int32_t delta, int mode)
{
FILE *file = id ? *(FILE**)id : NULL;
if (file)
return fseek(file, delta, mode);
else
return -1;
}
static int push_back_byte(void *id, int c)
{
FILE *file = id ? *(FILE**)id : NULL;
if (file)
return ungetc(c, file);
else
return EOF;
}
static uint32_t get_length(void *id)
{
FILE *file = id ? *(FILE**)id : NULL;
struct stat statbuf;
if (!file || fstat (fileno (file), &statbuf) || !(statbuf.st_mode & S_IFREG))
return 0;
else
return statbuf.st_size;
}
static int can_seek(void *id)
{
FILE *file = id ? *(FILE**)id : NULL;
struct stat statbuf;
return file && !fstat (fileno (file), &statbuf) && (statbuf.st_mode & S_IFREG);
}
static int32_t write_bytes(void *id, void *data, int32_t bcount)
{
FILE *file = id ? *(FILE**)id : NULL;
if (file)
return (int32_t) fwrite (data, 1, bcount, file);
else
return 0;
}
static WavpackStreamReader freader = {
read_bytes, get_pos, set_pos_abs,
set_pos_rel, push_back_byte,
get_length, can_seek, write_bytes
};
/* These functions provide UNICODE support for the winamp media library */
static int metadata_we_can_write(const char *metadata);
static void close_context(struct wpcnxt *cxt)
{
if (cxt->wpc)
WavpackCloseFile(cxt->wpc);
if (cxt->wv_id)
fclose(cxt->wv_id);
if (cxt->wvc_id)
fclose(cxt->wvc_id);
memset(cxt, 0, sizeof (*cxt));
}
#ifdef ANSI_METADATA
extern "C" __declspec (dllexport) int winampGetExtendedFileInfo(char *filename, char *metadata, char *ret, int retlen)
{
int open_flags = OPEN_TAGS;
char error[128];
int retval = 0;
#ifdef DEBUG_CONSOLE
sprintf (error, "winampGetExtendedFileInfo (%s)\n", metadata);
debug_write (error);
#endif
if (!_stricmp(metadata, "type"))
{
ret[0] = '0';
ret[1] = 0;
return 1;
}
else if (!_stricmp(metadata, "family"))
{
int len;
const char *p;
if (!filename || !filename[0]) return 0;
len = lstrlen(filename);
if (len < 3 || '.' != filename[len - 3]) return 0;
p = &filename[len - 2];
if (!_stricmp(p, "wv")) { WASABI_API_LNGSTRING_BUF(IDS_FAMILY_STRING, ret, retlen); return 1; }
return 0;
}
if (!filename || !*filename)
return retval;
if (!_stricmp(metadata, "length")) { /* even if no file, return a 1 and write "0" */
StringCchPrintf(ret, retlen, "%d", 0);
retval = 1;
}
if (!info.wpc || strcmp(filename, info.lastfn) || !_stricmp(metadata, "formatinformation"))
{
close_context(&info);
if (!(info.wv_id = fopen(filename, "rb")))
return retval;
if (config_bits & ALLOW_WVC)
{
int length = strlen(filename) + 10;
char *wvc_name = (char *)malloc(length);
if (wvc_name)
{
lstrcpyn(wvc_name, filename, length);
StringCchCat(wvc_name, length, "c");
info.wvc_id = fopen(wvc_name, "rb");
free(wvc_name);
}
}
info.wpc = WavpackOpenFileInputEx(&freader, &info.wv_id, info.wvc_id ? &info.wvc_id : NULL, error, open_flags, 0);
if (!info.wpc)
{
close_context(&info);
return retval;
}
lstrcpyn(info.lastfn, filename, MAX_PATH);
info.w_lastfn [0] = 0;
}
if (!_stricmp(metadata, "formatinformation"))
{
wchar_t *temp = (wchar_t *)malloc(retlen * sizeof(wchar_t));
generate_format_string(info.wpc, temp, retlen, 0);
lstrcpyn(ret, AutoChar(temp), retlen);
free(temp);
retval = 1;
}
else if (!_stricmp(metadata, "length"))
{
StringCchPrintf(ret, retlen, "%d", (int)(WavpackGetNumSamples(info.wpc) * 1000.0 / WavpackGetSampleRate(info.wpc)));
retval = 1;
}
else if (!_stricmp(metadata, "lossless"))
{
StringCchPrintf (ret, retlen, "%d", (WavpackGetMode(info.wpc) & MODE_LOSSLESS) ? 1 : 0);
retval = 1;
}
else if (!_stricmp(metadata, "numsamples"))
{
StringCchPrintf(ret, retlen, "%d", WavpackGetNumSamples(info.wpc));
retval = 1;
}
else if (!_stricmp(metadata, "mime"))
{
lstrcpyn(ret, L"audio/x-wavpack", retlen);
retval = 1;
}
else if (!_stricmp(metadata, "gain"))
{
StringCchPrintf(ret, retlen, "%-+.2f dB", calculate_gain(info.wpc, false));
retval = 1;
}
else if (WavpackGetTagItem(info.wpc, metadata, ret, retlen))
{
if (!_stricmp(metadata, "rating"))
{
int rating = atoi(ret);
// appears to be generally 0-5 or 0-100
if (rating > 10) {
rating /= 20;
}
// or maybe we're dealing with a 1-10 range
else if (rating > 5) {
rating /= 2;
}
// otherwise it is hopefully in the 0-5 range
StringCchPrintf(ret, retlen, "%u", rating);
}
else
{
if (WavpackGetMode(info.wpc) & MODE_APETAG)
{
UTF8ToAnsi(ret, retlen);
}
}
retval = 1;
}
else if (metadata_we_can_write(metadata))
{
if (retlen)
*ret = 0;
retval = 1;
}
// This is a little ugly, but since the WavPack library has read the tags off the
// files, we can close the files (but not the WavPack context) now so that we don't
// leave handles open. We may access the file again for the "formatinformation"
// field, so we reopen the file if we get that one.
if (info.wv_id)
{
fclose(info.wv_id);
info.wv_id = NULL;
}
if (info.wvc_id)
{
fclose(info.wvc_id);
info.wvc_id = NULL;
}
return retval;
}
#endif
#ifdef UNICODE_METADATA
extern "C" __declspec (dllexport) int winampGetExtendedFileInfoW (wchar_t *filename, char *metadata, wchar_t *ret, int retlen)
{
char error[128], res[256];
int open_flags = OPEN_TAGS;
int retval = 0;
#ifdef DEBUG_CONSOLE
sprintf (error, "winampGetExtendedFileInfoW (%s)\n", metadata);
debug_write (error);
#endif
if (!_stricmp(metadata, "type"))
{
ret[0] = '0';
ret[1] = 0;
return 1;
}
else if (!_stricmp(metadata, "family"))
{
int len;
const wchar_t *p;
if (!filename || !filename[0]) return 0;
len = lstrlenW(filename);
if (len < 3 || L'.' != filename[len - 3]) return 0;
p = &filename[len - 2];
if (!_wcsicmp(p, L"wv")) { WASABI_API_LNGSTRINGW_BUF(IDS_FAMILY_STRING, ret, retlen); return 1; }
return 0;
}
if (!filename || !*filename)
return retval;
if (!_stricmp(metadata, "length")) /* even if no file, return a 1 and write "0" */
{
StringCchPrintfW(ret, retlen, L"%d", 0);
retval = 1;
}
if (!info.wpc || wcscmp(filename, info.w_lastfn) || !_stricmp(metadata, "formatinformation"))
{
close_context(&info);
if (!(info.wv_id = _wfopen(filename, L"rb")))
return retval;
if (config_bits & ALLOW_WVC) {
int length = wcslen(filename) + 10;
wchar_t *wvc_name = (wchar_t *)malloc(length * sizeof(wchar_t));
if (wvc_name) {
lstrcpynW(wvc_name, filename, length);
StringCchCatW(wvc_name, length, L"c");
info.wvc_id = _wfopen(wvc_name, L"rb");
free(wvc_name);
}
}
info.wpc = WavpackOpenFileInputEx(&freader, &info.wv_id, info.wvc_id ? &info.wvc_id : NULL, error, open_flags, 0);
if (!info.wpc)
{
close_context(&info);
return retval;
}
lstrcpynW(info.w_lastfn, filename, MAX_PATH);
info.lastfn[0] = 0;
}
if (!_stricmp(metadata, "formatinformation"))
{
generate_format_string(info.wpc, ret, retlen, 0);
retval = 1;
}
else if (!_stricmp (metadata, "length"))
{
StringCchPrintfW(ret, retlen, L"%d", (int)(WavpackGetNumSamples(info.wpc) * 1000.0 / WavpackGetSampleRate(info.wpc)));
retval = 1;
}
else if (!_stricmp(metadata, "lossless"))
{
StringCchPrintfW(ret, retlen, L"%d", (WavpackGetMode(info.wpc) & MODE_LOSSLESS) ? 1 : 0);
retval = 1;
}
else if (!_stricmp(metadata, "gain"))
{
StringCchPrintfW(ret, retlen, L"%-+.2f dB", calculate_gain(info.wpc, false));
retval = 1;
}
else if (!_stricmp(metadata, "numsamples"))
{
StringCchPrintfW(ret, retlen, L"%d", WavpackGetNumSamples(info.wpc));
retval = 1;
}
else if (!_stricmp(metadata, "mime"))
{
lstrcpynW(ret, L"audio/x-wavpack", retlen);
retval = 1;
}
else if (WavpackGetTagItem(info.wpc, metadata, res, sizeof (res)))
{
if (!_stricmp(metadata, "rating"))
{
int rating = atoi(res);
// appears to be generally 0-5 or 0-100
if (rating > 10) {
rating /= 20;
}
// or maybe we're dealing with a 1-10 range
else if (rating > 5) {
rating /= 2;
}
// otherwise it is hopefully in the 0-5 range
StringCchPrintfW(ret, retlen, L"%u", rating);
}
else
{
if (!(WavpackGetMode(info.wpc) & MODE_APETAG))
lstrcpynW(ret, AutoWide(res), retlen);
else
lstrcpynW(ret, AutoWide(res, CP_UTF8), retlen);
}
retval = 1;
}
else if (metadata_we_can_write (metadata))
{
if (retlen)
*ret = 0;
retval = 1;
}
// This is a little ugly, but since the WavPack library has read the tags off the
// files, we can close the files (but not the WavPack context) now so that we don't
// leave handles open. We may access the file again for the "formatinformation"
// field, so we reopen the file if we get that one.
if (info.wv_id)
{
fclose (info.wv_id);
info.wv_id = NULL;
}
if (info.wvc_id)
{
fclose (info.wvc_id);
info.wvc_id = NULL;
}
return retval;
}
#endif
#ifdef ANSI_METADATA
extern "C" int __declspec (dllexport) winampSetExtendedFileInfo(const char *filename, const char *metadata, char *val)
{
char error[128];
#ifdef DEBUG_CONSOLE
sprintf (error, "winampSetExtendedFileInfo (%s=%s)\n", metadata, val);
debug_write (error);
#endif
if (!filename || !*filename || !metadata_we_can_write(metadata))
return 0;
if (!edit.wpc || strcmp(filename, edit.lastfn))
{
if (edit.wpc)
WavpackCloseFile(edit.wpc);
edit.wpc = WavpackOpenFileInput(filename, error, OPEN_TAGS | OPEN_EDIT_TAGS, 0);
if (!edit.wpc)
return 0;
lstrcpyn(edit.lastfn, filename, MAX_PATH);
edit.w_lastfn [0] = 0;
}
if (strlen(val))
return WavpackAppendTagItem(edit.wpc, metadata, val, strlen (val));
else
return WavpackDeleteTagItem(edit.wpc, metadata);
}
#endif
#ifdef UNICODE_METADATA
extern "C" int __declspec (dllexport) winampSetExtendedFileInfoW(const wchar_t *filename, const char *metadata, wchar_t *val)
{
char error[128], utf8_val[256];
lstrcpyn(utf8_val,AutoChar(val, CP_UTF8),sizeof(utf8_val) - 1);
#ifdef DEBUG_CONSOLE
sprintf (error, "winampSetExtendedFileInfoW (%s=%s)\n", metadata, utf8_val);
debug_write (error);
#endif
if (!filename || !*filename || !metadata_we_can_write(metadata))
return 0;
if (!edit.wpc || wcscmp(filename, edit.w_lastfn))
{
if (edit.wpc)
{
WavpackCloseFile(edit.wpc);
edit.wpc = NULL;
}
if (edit.wv_id)
fclose(edit.wv_id);
if (!(edit.wv_id = _wfopen(filename, L"r+b")))
return 0;
edit.wpc = WavpackOpenFileInputEx(&freader, &edit.wv_id, NULL, error, OPEN_TAGS | OPEN_EDIT_TAGS, 0);
if (!edit.wpc)
{
fclose(edit.wv_id);
return 0;
}
lstrcpynW(edit.w_lastfn, filename, MAX_PATH);
edit.lastfn [0] = 0;
}
if (strlen(utf8_val))
return WavpackAppendTagItem(edit.wpc, metadata, utf8_val, strlen (utf8_val));
else
return WavpackDeleteTagItem(edit.wpc, metadata);
}
#endif
extern "C" int __declspec (dllexport) winampWriteExtendedFileInfo(void)
{
#ifdef DEBUG_CONSOLE
debug_write ("winampWriteExtendedFileInfo ()\n");
#endif
if (edit.wpc)
{
WavpackWriteTag(edit.wpc);
WavpackCloseFile(edit.wpc);
edit.wpc = NULL;
}
if (edit.wv_id)
{
fclose(edit.wv_id);
edit.wv_id = NULL;
}
close_context(&info); // make sure we re-read info on any open files
return 1;
}
// return 1 if you want winamp to show it's own file info dialogue, 0 if you want to show your own (via In_Module.InfoBox)
// if returning 1, remember to implement winampGetExtendedFileInfo("formatinformation")!
extern "C" __declspec(dllexport) int winampUseUnifiedFileInfoDlg(const wchar_t * fn)
{
return 1;
}
static const char *writable_metadata [] = {
"track", "genre", "year", "comment", "artist",
"album", "title", "albumartist", "composer",
"publisher", "disc", "tool", "encoder", "bpm",
"category", "rating",
"replaygain_track_gain", "replaygain_track_peak",
"replaygain_album_gain", "replaygain_album_peak"
};
#define NUM_KNOWN_METADATA (sizeof (writable_metadata) / sizeof (writable_metadata [0]))
static int metadata_we_can_write(const char *metadata)
{
if (!metadata || !*metadata)
return 0;
for (int i = 0; i < NUM_KNOWN_METADATA; ++i)
if (!_stricmp(metadata, writable_metadata[i]))
return 1;
return 0;
}
static void generate_format_string(WavpackContext *wpc, wchar_t *string, int maxlen, int wide)
{
int mode = WavpackGetMode(wpc);
unsigned char md5_sum[16];
wchar_t modes[256];
wchar_t fmt[256];
WASABI_API_LNGSTRINGW_BUF(IDS_ENCODER_VERSION, fmt, sizeof(fmt));
StringCchPrintfW(string, maxlen, fmt, WavpackGetVersion(wpc));
while (*string && string++ && maxlen--);
WASABI_API_LNGSTRINGW_BUF(IDS_SOURCE, fmt, sizeof (fmt));
StringCchPrintfW(string, maxlen, fmt, WavpackGetBitsPerSample(wpc),
WASABI_API_LNGSTRINGW((WavpackGetMode(wpc) & MODE_FLOAT) ? IDS_FLOATS : IDS_INTS),
WavpackGetSampleRate(wpc));
while (*string && string++ && maxlen--);
if (WavpackGetNumChannels(wpc) > 2)
{
WASABI_API_LNGSTRINGW_BUF(IDS_MULTICHANNEL, fmt, sizeof (fmt));
StringCchPrintfW(string, maxlen, fmt, WavpackGetNumChannels(wpc));
while (*string && string++ && maxlen--);
}
else if (WavpackGetNumChannels(wpc) == 2)
{
WASABI_API_LNGSTRINGW_BUF(IDS_STEREO, fmt, sizeof (fmt));
StringCchPrintfW(string, maxlen, fmt);
while (*string && string++ && maxlen--);
}
else
{
WASABI_API_LNGSTRINGW_BUF(IDS_MONO, fmt, sizeof (fmt));
StringCchPrintfW(string, maxlen, fmt);
while (*string && string++ && maxlen--);
}
modes [0] = 0;
if (WavpackGetMode(wpc) & MODE_HYBRID)
{
StringCchCatW(modes, 256, WASABI_API_LNGSTRINGW(IDS_HYBRID));
StringCchCatW(modes, 256, L" ");
}
StringCchCatW(modes, 256, WASABI_API_LNGSTRINGW((WavpackGetMode(wpc) & MODE_LOSSLESS) ? IDS_LOSSLESS : IDS_LOSSY));
if (WavpackGetMode(wpc) & MODE_FAST)
StringCchCatW(modes, 256, WASABI_API_LNGSTRINGW(IDS_FAST));
else if (WavpackGetMode(wpc) & MODE_VERY_HIGH)
StringCchCatW(modes, 256, WASABI_API_LNGSTRINGW(IDS_VHIGH));
else if (WavpackGetMode(wpc) & MODE_HIGH)
StringCchCatW(modes, 256, WASABI_API_LNGSTRINGW(IDS_HIGH));
if (WavpackGetMode(wpc) & MODE_EXTRA)
StringCchCatW(modes, 256, WASABI_API_LNGSTRINGW(IDS_EXTRA));
StringCchPrintfW(string, maxlen, L"%s:%s %s\n",
WASABI_API_LNGSTRINGW(IDS_MODES),
(wide || lstrlenW(modes) < 24) ? L"" : L"\n", modes);
while (*string && string++ && maxlen--);
if (WavpackGetRatio(wpc) != 0.0)
{
wchar_t str_kbps[32];
StringCchPrintfW(string, maxlen, L"%s: %d %s \n",
WASABI_API_LNGSTRINGW(IDS_BITRATE),
(int)((WavpackGetAverageBitrate(wpc, TRUE) + 500.0) / 1000.0),
WASABI_API_LNGSTRINGW_BUF(IDS_KBPS, str_kbps, sizeof(str_kbps)));
while (*string && string++ && maxlen--);
StringCchPrintfW(string, maxlen, L"%s: %.2f : 1 \n",
WASABI_API_LNGSTRINGW(IDS_RATIO), 1.0 / WavpackGetRatio(wpc));
while (*string && string++ && maxlen--);
}
if (WavpackGetMD5Sum(wpc, md5_sum))
{
wchar_t md5s1 [17], md5s2 [17];
int i;
for (i = 0; i < 8; ++i)
{
StringCchPrintfW(md5s1 + i * 2, sizeof(md5s1), L"%02x", md5_sum [i]);
StringCchPrintfW(md5s2 + i * 2, sizeof(md5s2), L"%02x", md5_sum [i+8]);
}
StringCchPrintfW(string, maxlen, (wide ? L"%s: %s%s\n" : L"%s:\n %s\n %s\n"),
WASABI_API_LNGSTRINGW(IDS_MD5), md5s1, md5s2);
}
}
///////////////////// native "C" functions required for AlbumArt support ///////////////////////////
#ifdef DEBUG_CONSOLE
static char temp_buff [256];
static char *wide2char (const wchar_t *src)
{
char *dst = temp_buff;
while (*src)
*dst++ = (char) *src++;
*dst = 0;
return temp_buff;
}
#endif
int WavPack_HandlesExtension(const wchar_t *extension)
{
return !_wcsicmp(extension, L"wv");
}
int WavPack_GetAlbumArt(const wchar_t *filename, const wchar_t *type, void **bits, size_t *len, wchar_t **mime_type)
{
char *buffer;
char error[128];
int tag_size, i;
int retval = 1;
#ifdef DEBUG_CONSOLE
sprintf (error, "WavPack_GetAlbumArt (%s)\n", wide2char (type));
debug_write (error);
#endif
if (!filename || !*filename || _wcsicmp(type, L"cover"))
return retval;
if (!info.wpc || wcscmp(filename, info.w_lastfn))
{
close_context(&info);
if (!(info.wv_id = _wfopen(filename, L"rb")))
return retval;
if (config_bits & ALLOW_WVC)
{
int length = wcslen(filename) + 10;
wchar_t *wvc_name = (wchar_t *)malloc(length * sizeof(wchar_t));
if (wvc_name)
{
lstrcpynW(wvc_name, filename, length);
StringCchCatW(wvc_name, length, L"c");
info.wvc_id = _wfopen(wvc_name, L"rb");
free(wvc_name);
}
}
info.wpc = WavpackOpenFileInputEx(&freader, &info.wv_id, info.wvc_id ? &info.wvc_id : NULL, error, OPEN_TAGS, 0);
if (!info.wpc)
{
close_context(&info);
return retval;
}
lstrcpynW(info.w_lastfn, filename, MAX_PATH);
info.lastfn[0] = 0;
}
tag_size = WavpackGetBinaryTagItem(info.wpc, "Cover Art (Front)", NULL, 0);
if (!tag_size)
return retval;
buffer = (char*)WASABI_API_MEMMGR->sysMalloc(tag_size);
WavpackGetBinaryTagItem(info.wpc, "Cover Art (Front)", buffer, tag_size);
for (i = 0; i < tag_size - 1; ++i)
if (!buffer[i] && strrchr(buffer, '.')) {
char *ext = strrchr(buffer, '.') + 1;
wchar_t *wcptr;
wcptr = *mime_type = (wchar_t*)WASABI_API_MEMMGR->sysMalloc(strlen(ext) * 2 + 2);
while (*ext)
*wcptr++ = *ext++;
*wcptr = 0;
*bits = buffer;
*len = tag_size - i - 1;
memmove(buffer, buffer + i + 1, *len);
retval = 0;
#ifdef DEBUG_CONSOLE
sprintf (error, "WavPack_GetAlbumArt (\"%s\", %d) success!\n", wide2char (*mime_type), *len);
debug_write (error);
#endif
}
if (retval)
WASABI_API_MEMMGR->sysFree(buffer);
// This is a little ugly, but since the WavPack library has read the tags off the
// files, we can close the files (but not the WavPack context) now so that we don't
// leave handles open. We may access the file again for the "formatinformation"
// field, so we reopen the file if we get that one.
if (info.wv_id)
{
fclose(info.wv_id);
info.wv_id = NULL;
}
if (info.wvc_id)
{
fclose(info.wvc_id);
info.wvc_id = NULL;
}
return retval;
}
int WavPack_SetAlbumArt(const wchar_t *filename, const wchar_t *type, void *bits, size_t len, const wchar_t *mime_type)
{
#if 1
return 2; // return 2 to indicate "read-only" cover art for now
#else
char error [128], name [50], *cp;
int tag_size, retval = 0;
unsigned char *buffer;
#ifdef DEBUG_CONSOLE
sprintf (error, "WavPack_SetAlbumArt (%s)\n", wide2char (mime_type));
debug_write (error);
#endif
if (!filename || !*filename || _wcsicmp (type, L"cover") || wcslen (mime_type) > 16)
return 1;
strcpy (name, "Cover Art (Front)");
cp = name + strlen (name);
*cp++ = '.';
while (*mime_type)
*cp++ = (char) *mime_type++;
*cp = 0;
tag_size = strlen (name) + 1 + len;
buffer = malloc (tag_size);
strcpy (buffer, name);
memcpy (buffer + strlen (buffer) + 1, bits, len);
if (!edit.wpc || wcscmp (filename, edit.w_lastfn)) {
if (edit.wpc) {
WavpackCloseFile (edit.wpc);
edit.wpc = NULL;
}
if (edit.wv_id)
fclose (edit.wv_id);
if (!(edit.wv_id = _wfopen (filename, L"r+b"))) {
free (buffer);
return 1;
}
edit.wpc = WavpackOpenFileInputEx (&freader, &edit.wv_id, NULL, error, OPEN_TAGS | OPEN_EDIT_TAGS, 0);
if (!edit.wpc) {
fclose (edit.wv_id);
free (buffer);
return 1;
}
wcscpy (edit.w_lastfn, filename);
edit.lastfn [0] = 0;
}
retval = WavpackAppendTagItem (edit.wpc, "Cover Art (Front)", buffer, tag_size);
free (buffer);
if (retval) {
winampWriteExtendedFileInfo ();
return 0;
}
else {
close_context (&edit);
return 1;
}
#endif
}
int WavPack_DeleteAlbumArt(const wchar_t *filename, const wchar_t *type)
{
#if 1
return 2; // return 2 to indicate "read-only" cover art for now
#else
char error [128];
#ifdef DEBUG_CONSOLE
sprintf (error, "WavPack_DeleteAlbumArt ()\n");
debug_write (error);
#endif
if (!filename || !*filename || _wcsicmp (type, L"cover"))
return 0;
if (!edit.wpc || wcscmp (filename, edit.w_lastfn)) {
if (edit.wpc) {
WavpackCloseFile (edit.wpc);
edit.wpc = NULL;
}
if (edit.wv_id)
fclose (edit.wv_id);
if (!(edit.wv_id = _wfopen (filename, L"r+b")))
return 1;
edit.wpc = WavpackOpenFileInputEx (&freader, &edit.wv_id, NULL, error, OPEN_TAGS | OPEN_EDIT_TAGS, 0);
if (!edit.wpc) {
fclose (edit.wv_id);
return 1;
}
wcscpy (edit.w_lastfn, filename);
edit.lastfn [0] = 0;
}
if (WavpackDeleteTagItem (edit.wpc, "Cover Art (Front)")) {
winampWriteExtendedFileInfo ();
return 0;
}
else {
close_context (&edit);
return 1;
}
#endif
}
//////////////////////////////////////////////////////////////////////////////
// This function uses the ReplayGain mode selected by the user and the info //
// stored in the specified tag to determine the gain value used to play the //
// file and whether "soft clipping" is required. Note that the gain is in //
// voltage scaling (not dB), so a value of 1.0 (not 0.0) is unity gain. //
//////////////////////////////////////////////////////////////////////////////
static float calculate_gain(WavpackContext *wpc, bool allowDefault)
{
if (AGAVE_API_CONFIG->GetBool(playbackConfigGroupGUID, L"replaygain", false))
{
float dB = 0, peak = 1.0f;
char gain[128] = "", peakVal[128] = "";
_locale_t C_locale = WASABI_API_LNG->Get_C_NumericLocale();
switch (AGAVE_API_CONFIG->GetUnsigned(playbackConfigGroupGUID, L"replaygain_source", 0))
{
case 0: // track
if ((!WavpackGetTagItem(wpc, "replaygain_track_gain", gain, sizeof(gain)) || !gain[0])
&& !AGAVE_API_CONFIG->GetBool(playbackConfigGroupGUID, L"replaygain_preferred_only", false))
WavpackGetTagItem(wpc, "replaygain_album_gain", gain, sizeof(gain));
if ((!WavpackGetTagItem(wpc, "replaygain_track_peak", peakVal, sizeof(peakVal)) || !peakVal[0])
&& !AGAVE_API_CONFIG->GetBool(playbackConfigGroupGUID, L"replaygain_preferred_only", false))
WavpackGetTagItem(wpc, "replaygain_album_peak", peakVal, sizeof(peakVal));
break;
case 1:
if ((!WavpackGetTagItem(wpc, "replaygain_album_gain", gain, sizeof(gain)) || !gain[0])
&& !AGAVE_API_CONFIG->GetBool(playbackConfigGroupGUID, L"replaygain_preferred_only", false))
WavpackGetTagItem(wpc, "replaygain_track_gain", gain, sizeof(gain));
if ((!WavpackGetTagItem(wpc, "replaygain_album_peak", peakVal, sizeof(peakVal)) || !peakVal[0])
&& !AGAVE_API_CONFIG->GetBool(playbackConfigGroupGUID, L"replaygain_preferred_only", false))
WavpackGetTagItem(wpc, "replaygain_track_peak", peakVal, sizeof(peakVal));
break;
}
if (gain[0])
{
if (gain[0] == L'+')
dB = (float)_atof_l(&gain[1],C_locale);
else
dB = (float)_atof_l(gain,C_locale);
}
else if (allowDefault)
{
dB = AGAVE_API_CONFIG->GetFloat(playbackConfigGroupGUID, L"non_replaygain", -6.0);
return powf(10.0f, dB / 20.0f);
}
if (peakVal[0])
{
peak = (float)_atof_l(peakVal,C_locale);
}
switch (AGAVE_API_CONFIG->GetUnsigned(playbackConfigGroupGUID, L"replaygain_mode", 1))
{
case 0: // apply gain
return powf(10.0f, dB / 20.0f);
case 1: // apply gain, but don't clip
return min(powf(10.0f, dB / 20.0f), 1.0f / peak);
case 2: // normalize
return 1.0f / peak;
case 3: // prevent clipping
if (peak > 1.0f)
return 1.0f / peak;
else
return 1.0f;
}
}
return 1.0f; // no gain
}
// Convert a Ansi string into its Unicode UTF-8 format equivalent. The
// conversion is done in-place so the maximum length of the string buffer must
// be specified because the string may become longer or shorter. If the
// resulting string will not fit in the specified buffer size then it is
// truncated.
#ifdef OLD_INFO_DIALOG
static void AnsiToUTF8(char *string, int len)
{
int max_chars = (int) strlen(string);
wchar_t *temp = (wchar_t *) malloc((max_chars + 1) * 2);
MultiByteToWideChar(CP_ACP, 0, string, -1, temp, max_chars + 1);
lstrcpyn(string, AutoChar(temp, CP_UTF8), len);
free(temp);
}
#endif
// Convert Unicode UTF-8 string to wide format. UTF-8 string must be NULL
// terminated. Resulting wide string must be able to fit in provided space
// and will also be NULL terminated. The number of characters converted will
// be returned (not counting terminator).
static int UTF8ToWideChar(const char *pUTF8, wchar_t *pWide)
{
int trail_bytes = 0;
int chrcnt = 0;
while (*pUTF8)
{
if (*pUTF8 & 0x80)
{
if (*pUTF8 & 0x40)
{
if (trail_bytes)
{
trail_bytes = 0;
chrcnt++;
}
else
{
char temp = *pUTF8;
while (temp & 0x80)
{
trail_bytes++;
temp <<= 1;
}
pWide [chrcnt] = temp >> trail_bytes--;
}
}
else if (trail_bytes)
{
pWide [chrcnt] = (pWide [chrcnt] << 6) | (*pUTF8 & 0x3f);
if (!--trail_bytes)
chrcnt++;
}
}
else
pWide [chrcnt++] = *pUTF8;
pUTF8++;
}
pWide [chrcnt] = 0;
return chrcnt;
}
// Convert a Unicode UTF-8 format string into its Ansi equivalent. The
// conversion is done in-place so the maximum length of the string buffer must
// be specified because the string may become longer or shorter. If the
// resulting string will not fit in the specified buffer size then it is
// truncated.
static void UTF8ToAnsi(char *string, int len)
{
int max_chars = (int)strlen(string);
wchar_t *temp = (wchar_t *)malloc((max_chars + 1) * 2);
int act_chars = UTF8ToWideChar(string, temp);
while (act_chars)
{
memset (string, 0, len);
if (WideCharToMultiByte(CP_ACP, 0, temp, act_chars, string, len - 1, NULL, NULL))
break;
else
act_chars--;
}
if (!act_chars)
*string = 0;
free (temp);
}
extern "C" __declspec(dllexport) int winampUninstallPlugin(HINSTANCE hDllInst, HWND hwndDlg, int param)
{
// as we're not hooking anything and have no settings we can support an on-the-fly uninstall action
return IN_PLUGIN_UNINSTALL_NOW;
}
|