Updated MediaInfo binaries to v19.07 (2019-07-16), compiled with ICL 19.0 and MSVC...
[LameXP.git] / etc / Patches / WavPack-5.1.0-FlushPipe.diff
blobf3283e2350d63d4f4ac61e535664c03555730374
1 cli/utils.c | 34 +++++++++++++++++++++++++---------
2 cli/wavpack.c | 58 +++++++++++++++++++++++++++++++++++++---------------------
3 cli/wvgain.c | 34 +++++++++++++++++++++++++---------
4 cli/wvtag.c | 30 +++++++++++++++++++++++-------
5 cli/wvunpack.c | 46 +++++++++++++++++++++++++++++++---------------
6 5 files changed, 141 insertions(+), 61 deletions(-)
8 diff --git a/cli/utils.c b/cli/utils.c
9 index d59bad0..8840032 100644
10 --- a/cli/utils.c
11 +++ b/cli/utils.c
12 @@ -38,6 +38,22 @@
13 #define remove(f) unlink_utf8(f)
14 #endif
16 +#ifdef _MSC_VER
17 +static __inline void flush_pipe(FILE *const stream)
19 + struct _stat stat;
20 + if (!_fstat(_fileno(stream), &stat))
21 + {
22 + if ((stat.st_mode & _S_IFMT) == _S_IFIFO)
23 + {
24 + fflush(stream); /*flush iff it is a pipe*/
25 + }
26 + }
28 +#else
29 +#define flush_pipe(X) ((void)0)
30 +#endif
32 #ifdef _WIN32
34 int copy_timestamp (const char *src_filename, const char *dst_filename)
35 @@ -325,38 +341,38 @@ char yna (void)
36 else if (key == '\r' || key == '\n') {
37 if (choice) {
38 fprintf (stderr, "\r\n");
39 - fflush (stderr);
40 + flush_pipe (stderr);
41 break;
43 else {
44 fprintf (stderr, "%c", 7);
45 - fflush (stderr);
46 + flush_pipe (stderr);
49 else if (key == 'Y' || key == 'y') {
50 #ifdef _WIN32
51 fprintf (stderr, "%c\b", key);
52 - fflush (stderr);
53 + flush_pipe (stderr);
54 #endif
55 choice = 'y';
57 else if (key == 'N' || key == 'n') {
58 #ifdef _WIN32
59 fprintf (stderr, "%c\b", key);
60 - fflush (stderr);
61 + flush_pipe (stderr);
62 #endif
63 choice = 'n';
65 else if (key == 'A' || key == 'a') {
66 #ifdef _WIN32
67 fprintf (stderr, "%c\b", key);
68 - fflush (stderr);
69 + flush_pipe (stderr);
70 #endif
71 choice = 'a';
73 else {
74 fprintf (stderr, "%c", 7);
75 - fflush (stderr);
76 + flush_pipe (stderr);
80 @@ -557,7 +573,7 @@ void finish_line (void)
81 else
82 fprintf (stderr, " \n");
84 - fflush (stderr);
85 + flush_pipe (stderr);
87 #else
88 //////////////////////////////////////////////////////////////////////////////
89 @@ -568,7 +584,7 @@ void finish_line (void)
90 void finish_line (void)
92 fprintf (stderr, " \n");
93 - fflush (stderr);
94 + flush_pipe (stderr);
97 //////////////////////////////////////////////////////////////////////////////
98 @@ -763,7 +779,7 @@ void DoSetConsoleTitle (char *text)
99 void DoSetConsoleTitle (char *text)
101 fprintf (stderr, "\033]0;%s\007", text);
102 - fflush (stderr);
103 + flush_pipe (stderr);
106 #endif
107 diff --git a/cli/wavpack.c b/cli/wavpack.c
108 index 4d46aba..f33086f 100644
109 --- a/cli/wavpack.c
110 +++ b/cli/wavpack.c
111 @@ -61,6 +61,22 @@
112 #define stricmp strcasecmp
113 #endif
115 +#ifdef _MSC_VER
116 +static __inline void flush_pipe(FILE *const stream)
118 + struct _stat stat;
119 + if (!_fstat(_fileno(stream), &stat))
121 + if ((stat.st_mode & _S_IFMT) == _S_IFIFO)
123 + fflush(stream); /*flush iff it is a pipe*/
127 +#else
128 +#define flush_pipe(X) ((void)0)
129 +#endif
131 ///////////////////////////// local variable storage //////////////////////////
133 static const char *sign_on = "\n"
134 @@ -882,11 +898,11 @@ int main (int argc, char **argv)
136 if (strcmp (WavpackGetLibraryVersionString (), PACKAGE_VERSION)) {
137 fprintf (stderr, version_warning, WavpackGetLibraryVersionString (), PACKAGE_VERSION);
138 - fflush (stderr);
139 + flush_pipe (stderr);
141 else if (!quiet_mode && !error_count) {
142 fprintf (stderr, sign_on, VERSION_OS, WavpackGetLibraryVersionString ());
143 - fflush (stderr);
144 + flush_pipe (stderr);
147 // Loop through any tag specification strings and check for file access, convert text
148 @@ -1004,7 +1020,7 @@ int main (int argc, char **argv)
150 if (error_count) {
151 fprintf (stderr, "\ntype 'wavpack' for short help or 'wavpack --help' for full help\n");
152 - fflush (stderr);
153 + flush_pipe (stderr);
154 return 1;
157 @@ -1261,7 +1277,7 @@ int main (int argc, char **argv)
159 if (num_files > 1 && !quiet_mode) {
160 fprintf (stderr, "\n%s:\n", matches [file_index]);
161 - fflush (stderr);
162 + flush_pipe (stderr);
165 if (filespec_ext (matches [file_index]) && !stricmp (filespec_ext (matches [file_index]), ".wv"))
166 @@ -1295,11 +1311,11 @@ int main (int argc, char **argv)
167 if (num_files > 1) {
168 if (error_count) {
169 fprintf (stderr, "\n **** warning: errors occurred in %d of %d files! ****\n", error_count, num_files);
170 - fflush (stderr);
171 + flush_pipe (stderr);
173 else if (!quiet_mode) {
174 fprintf (stderr, "\n **** %d files successfully processed ****\n", num_files);
175 - fflush (stderr);
176 + flush_pipe (stderr);
180 @@ -1350,7 +1366,7 @@ int main(int argc, char **argv)
182 if (pause_mode) {
183 fprintf (stderr, "\nPress any key to continue . . . ");
184 - fflush (stderr);
185 + flush_pipe (stderr);
186 while (!_kbhit ());
187 _getch ();
188 fprintf (stderr, "\n");
189 @@ -1604,7 +1620,7 @@ static int pack_file (char *infilename, char *outfilename, char *out2filename, c
191 if (!overwrite_all) {
192 fprintf (stderr, "overwrite %s (yes/no/all)? ", FN_FIT (outfilename));
193 - fflush (stderr);
194 + flush_pipe (stderr);
196 if (set_console_title)
197 DoSetConsoleTitle ("overwrite?");
198 @@ -1629,7 +1645,7 @@ static int pack_file (char *infilename, char *outfilename, char *out2filename, c
200 if (res == 1) {
201 fprintf (stderr, "overwrite %s (yes/no/all)? ", FN_FIT (out2filename));
202 - fflush (stderr);
203 + flush_pipe (stderr);
205 if (set_console_title)
206 DoSetConsoleTitle ("overwrite?");
207 @@ -1740,7 +1756,7 @@ static int pack_file (char *infilename, char *outfilename, char *out2filename, c
208 else
209 fprintf (stderr, "creating %s,", FN_FIT (outfilename));
211 - fflush (stderr);
212 + flush_pipe (stderr);
215 // for now, raw 1-bit PCM is only DSDIFF format
216 @@ -2364,7 +2380,7 @@ static int pack_audio (WavpackContext *wpc, FILE *infile, int qmode, unsigned ch
217 #else
218 fprintf (stderr, "\n");
219 #endif
220 - fflush (stderr);
221 + flush_pipe (stderr);
222 free (sample_buffer);
223 free (input_buffer);
224 return WAVPACK_SOFT_ERROR;
225 @@ -2380,7 +2396,7 @@ static int pack_audio (WavpackContext *wpc, FILE *infile, int qmode, unsigned ch
226 if (!quiet_mode) {
227 fprintf (stderr, "%s%3d%% done...",
228 nobs ? " " : "\b\b\b\b\b\b\b\b\b\b\b\b", (int) progress);
229 - fflush (stderr);
230 + flush_pipe (stderr);
234 @@ -2522,7 +2538,7 @@ static int pack_dsd_audio (WavpackContext *wpc, FILE *infile, int qmode, unsigne
235 #else
236 fprintf (stderr, "\n");
237 #endif
238 - fflush (stderr);
239 + flush_pipe (stderr);
240 free (sample_buffer);
241 free (input_buffer);
242 return WAVPACK_SOFT_ERROR;
243 @@ -2538,7 +2554,7 @@ static int pack_dsd_audio (WavpackContext *wpc, FILE *infile, int qmode, unsigne
244 if (!quiet_mode) {
245 fprintf (stderr, "%s%3d%% done...",
246 nobs ? " " : "\b\b\b\b\b\b\b\b\b\b\b\b", (int) progress);
247 - fflush (stderr);
248 + flush_pipe (stderr);
252 @@ -2637,7 +2653,7 @@ static int repack_file (char *infilename, char *outfilename, char *out2filename,
253 else
254 fprintf (stderr, "overwrite %s with lossy transcode (yes/no/all)? ", FN_FIT (outfilename));
256 - fflush (stderr);
257 + flush_pipe (stderr);
259 if (set_console_title)
260 DoSetConsoleTitle ("overwrite?");
261 @@ -2657,7 +2673,7 @@ static int repack_file (char *infilename, char *outfilename, char *out2filename,
262 if (out2filename && !overwrite_all && (wvc_file.file = fopen (out2filename, "rb")) != NULL) {
263 DoCloseHandle (wvc_file.file);
264 fprintf (stderr, "overwrite %s (yes/no/all)? ", FN_FIT (out2filename));
265 - fflush (stderr);
266 + flush_pipe (stderr);
268 if (set_console_title)
269 DoSetConsoleTitle ("overwrite?");
270 @@ -2759,7 +2775,7 @@ static int repack_file (char *infilename, char *outfilename, char *out2filename,
271 else
272 fprintf (stderr, "creating %s,", FN_FIT (outfilename));
274 - fflush (stderr);
275 + flush_pipe (stderr);
278 WavpackSetFileInformation (outfile, WavpackGetFileExtension (infile), WavpackGetFileFormat (infile));
279 @@ -3324,7 +3340,7 @@ static int repack_audio (WavpackContext *outfile, WavpackContext *infile, unsign
280 #else
281 fprintf (stderr, "\n");
282 #endif
283 - fflush (stderr);
284 + flush_pipe (stderr);
285 free (sample_buffer);
286 return WAVPACK_SOFT_ERROR;
288 @@ -3339,7 +3355,7 @@ static int repack_audio (WavpackContext *outfile, WavpackContext *infile, unsign
289 if (!quiet_mode) {
290 fprintf (stderr, "%s%3d%% done...",
291 nobs ? " " : "\b\b\b\b\b\b\b\b\b\b\b\b", (int) progress);
292 - fflush (stderr);
293 + flush_pipe (stderr);
297 @@ -3525,7 +3541,7 @@ static int verify_audio (char *infilename, unsigned char *md5_digest_source)
298 #else
299 fprintf (stderr, "\n");
300 #endif
301 - fflush (stderr);
302 + flush_pipe (stderr);
303 result = WAVPACK_SOFT_ERROR;
304 break;
306 @@ -3539,7 +3555,7 @@ static int verify_audio (char *infilename, unsigned char *md5_digest_source)
307 if (!quiet_mode) {
308 fprintf (stderr, "%s%3d%% done...",
309 "\b\b\b\b\b\b\b\b\b\b\b\b", (int) progress);
310 - fflush (stderr);
311 + flush_pipe (stderr);
315 diff --git a/cli/wvgain.c b/cli/wvgain.c
316 index 4e789ea..2603824 100644
317 --- a/cli/wvgain.c
318 +++ b/cli/wvgain.c
319 @@ -57,6 +57,22 @@
320 #define fopen(f,m) fopen_utf8(f,m)
321 #endif
323 +#ifdef _MSC_VER
324 +static __inline void flush_pipe(FILE *const stream)
326 + struct _stat stat;
327 + if (!_fstat(_fileno(stream), &stat))
329 + if ((stat.st_mode & _S_IFMT) == _S_IFIFO)
331 + fflush(stream); /*flush iff it is a pipe*/
335 +#else
336 +#define flush_pipe(X) ((void)0)
337 +#endif
339 ///////////////////////////// local variable storage //////////////////////////
341 static const char *sign_on = "\n"
342 @@ -258,11 +274,11 @@ int main(int argc, char **argv)
344 if (strcmp (WavpackGetLibraryVersionString (), PACKAGE_VERSION)) {
345 fprintf (stderr, version_warning, WavpackGetLibraryVersionString (), PACKAGE_VERSION);
346 - fflush (stderr);
347 + flush_pipe (stderr);
349 else if (!quiet_mode && !error_count) {
350 fprintf (stderr, sign_on, VERSION_OS, WavpackGetLibraryVersionString ());
351 - fflush (stderr);
352 + flush_pipe (stderr);
355 if (!num_files) {
356 @@ -407,7 +423,7 @@ int main(int argc, char **argv)
358 if (num_files > 1 && !quiet_mode) {
359 fprintf (stderr, "\n%s:\n", matches [file_index]);
360 - fflush (stderr);
361 + flush_pipe (stderr);
364 if (new_mode) {
365 @@ -496,7 +512,7 @@ int main(int argc, char **argv)
367 if (num_files > 1 && !quiet_mode) {
368 fprintf (stderr, "\n%s:\n", matches [file_index]);
369 - fflush (stderr);
370 + flush_pipe (stderr);
373 if (show_mode)
374 @@ -517,11 +533,11 @@ int main(int argc, char **argv)
375 if (num_files > 1) {
376 if (error_count) {
377 fprintf (stderr, "\n **** warning: errors occurred in %d of %d files! ****\n", error_count, num_files);
378 - fflush (stderr);
379 + flush_pipe (stderr);
381 else if (!quiet_mode) {
382 fprintf (stderr, "\n **** %d files successfully processed ****\n", num_files);
383 - fflush (stderr);
384 + flush_pipe (stderr);
388 @@ -624,7 +640,7 @@ static int analyze_file (char *infilename, uint32_t *histogram, float *peak)
389 if (!quiet_mode) {
390 fprintf (stderr, "analyzing %s%s,", *infilename == '-' ? "stdin" :
391 FN_FIT (infilename), wvc_mode ? " (+.wvc)" : "");
392 - fflush (stderr);
393 + flush_pipe (stderr);
396 sample_rate = WavpackGetSampleRate (wpc);
397 @@ -711,7 +727,7 @@ static int analyze_file (char *infilename, uint32_t *histogram, float *peak)
398 #else
399 fprintf (stderr, "\n");
400 #endif
401 - fflush (stderr);
402 + flush_pipe (stderr);
403 result = WAVPACK_HARD_ERROR;
404 break;
406 @@ -727,7 +743,7 @@ static int analyze_file (char *infilename, uint32_t *histogram, float *peak)
407 if (!quiet_mode) {
408 fprintf (stderr, "%s%3d%% done...",
409 nobs ? " " : "\b\b\b\b\b\b\b\b\b\b\b\b", (int) progress);
410 - fflush (stderr);
411 + flush_pipe (stderr);
415 diff --git a/cli/wvtag.c b/cli/wvtag.c
416 index 6e6512a..33f3526 100644
417 --- a/cli/wvtag.c
418 +++ b/cli/wvtag.c
419 @@ -60,6 +60,22 @@
420 #define stricmp strcasecmp
421 #endif
423 +#ifdef _MSC_VER
424 +static __inline void flush_pipe(FILE *const stream)
426 + struct _stat stat;
427 + if (!_fstat(_fileno(stream), &stat))
429 + if ((stat.st_mode & _S_IFMT) == _S_IFIFO)
431 + fflush(stream); /*flush iff it is a pipe*/
435 +#else
436 +#define flush_pipe(X) ((void)0)
437 +#endif
439 ///////////////////////////// local variable storage //////////////////////////
441 static const char *sign_on = "\n"
442 @@ -408,11 +424,11 @@ int main (int argc, char **argv)
444 if (strcmp (WavpackGetLibraryVersionString (), PACKAGE_VERSION)) {
445 fprintf (stderr, version_warning, WavpackGetLibraryVersionString (), PACKAGE_VERSION);
446 - fflush (stderr);
447 + flush_pipe (stderr);
449 else if (!quiet_mode && !error_count) {
450 fprintf (stderr, sign_on, VERSION_OS, WavpackGetLibraryVersionString ());
451 - fflush (stderr);
452 + flush_pipe (stderr);
455 // Loop through any tag specification strings and check for file access, convert text
456 @@ -653,7 +669,7 @@ int main (int argc, char **argv)
458 if (num_files > 1 && !quiet_mode) {
459 fprintf (stderr, "\n%s:\n", matches [file_index]);
460 - fflush (stderr);
461 + flush_pipe (stderr);
464 result = process_file (matches [file_index]);
465 @@ -672,11 +688,11 @@ int main (int argc, char **argv)
466 if (num_files > 1) {
467 if (error_count) {
468 fprintf (stderr, "\n **** warning: errors occurred in %d of %d files! ****\n", error_count, num_files);
469 - fflush (stderr);
470 + flush_pipe (stderr);
472 else if (!quiet_mode) {
473 fprintf (stderr, "\n **** %d files successfully processed ****\n", num_files);
474 - fflush (stderr);
475 + flush_pipe (stderr);
479 @@ -721,7 +737,7 @@ int main(int argc, char **argv)
481 if (pause_mode) {
482 fprintf (stderr, "\nPress any key to continue . . . ");
483 - fflush (stderr);
484 + flush_pipe (stderr);
485 while (!_kbhit ());
486 _getch ();
487 fprintf (stderr, "\n");
488 @@ -995,7 +1011,7 @@ static int do_tag_extractions (WavpackContext *wpc, char *outfilename)
489 if (!overwrite_all && (outfile = fopen (full_filename, "r")) != NULL) {
490 DoCloseHandle (outfile);
491 fprintf (stderr, "overwrite %s (yes/no/all)? ", FN_FIT (full_filename));
492 - fflush (stderr);
493 + flush_pipe (stderr);
495 switch (yna ()) {
497 diff --git a/cli/wvunpack.c b/cli/wvunpack.c
498 index 2db1cb3..c0a3c87 100644
499 --- a/cli/wvunpack.c
500 +++ b/cli/wvunpack.c
501 @@ -58,6 +58,22 @@
502 #define strdup(x) _strdup(x)
503 #endif
505 +#ifdef _MSC_VER
506 +static __inline void flush_pipe(FILE *const stream)
508 + struct _stat stat;
509 + if (!_fstat(_fileno(stream), &stat))
511 + if ((stat.st_mode & _S_IFMT) == _S_IFIFO)
513 + fflush(stream); /*flush iff it is a pipe*/
517 +#else
518 +#define flush_pipe(X) ((void)0)
519 +#endif
521 ///////////////////////////// local variable storage //////////////////////////
523 static const char *sign_on = "\n"
524 @@ -549,11 +565,11 @@ int main(int argc, char **argv)
526 if (strcmp (WavpackGetLibraryVersionString (), PACKAGE_VERSION)) {
527 fprintf (stderr, version_warning, WavpackGetLibraryVersionString (), PACKAGE_VERSION);
528 - fflush (stderr);
529 + flush_pipe (stderr);
531 else if (!quiet_mode && !error_count) {
532 fprintf (stderr, sign_on, VERSION_OS, WavpackGetLibraryVersionString ());
533 - fflush (stderr);
534 + flush_pipe (stderr);
537 if (!num_files) {
538 @@ -763,7 +779,7 @@ int main(int argc, char **argv)
540 if (num_files > 1 && !quiet_mode) {
541 fprintf (stderr, "\n%s:\n", matches [file_index]);
542 - fflush (stderr);
543 + flush_pipe (stderr);
546 result = unpack_file (matches [file_index], verify_only ? NULL : outfilename, add_extension);
547 @@ -789,11 +805,11 @@ int main(int argc, char **argv)
548 if (num_files > 1) {
549 if (error_count) {
550 fprintf (stderr, "\n **** warning: errors occurred in %d of %d files! ****\n", error_count, num_files);
551 - fflush (stderr);
552 + flush_pipe (stderr);
554 else if (!quiet_mode) {
555 fprintf (stderr, "\n **** %d files successfully processed ****\n", num_files);
556 - fflush (stderr);
557 + flush_pipe (stderr);
561 @@ -844,7 +860,7 @@ int main(int argc, char **argv)
563 if (pause_mode) {
564 fprintf (stderr, "\nPress any key to continue . . . ");
565 - fflush (stderr);
566 + flush_pipe (stderr);
567 while (!_kbhit ());
568 _getch ();
569 fprintf (stderr, "\n");
570 @@ -931,7 +947,7 @@ static FILE *open_output_file (char *filename, char **tempfilename)
572 if (!overwrite_all) {
573 fprintf (stderr, "overwrite %s (yes/no/all)? ", FN_FIT (filename));
574 - fflush (stderr);
575 + flush_pipe (stderr);
577 if (set_console_title)
578 DoSetConsoleTitle ("overwrite?");
579 @@ -1235,12 +1251,12 @@ static int unpack_file (char *infilename, char *outfilename, int add_extension)
580 if (!quiet_mode) {
581 fprintf (stderr, "unpacking %s%s to stdout,", *infilename == '-' ?
582 "stdin" : FN_FIT (infilename), wvc_mode ? " (+.wvc)" : "");
583 - fflush (stderr);
584 + flush_pipe (stderr);
587 else if (!quiet_mode) {
588 fprintf (stderr, "restoring %s,", FN_FIT (outfilename));
589 - fflush (stderr);
590 + flush_pipe (stderr);
593 else { // in verify only mode we don't worry about headers
594 @@ -1249,7 +1265,7 @@ static int unpack_file (char *infilename, char *outfilename, int add_extension)
595 if (!quiet_mode) {
596 fprintf (stderr, "verifying %s%s,", *infilename == '-' ? "stdin" :
597 FN_FIT (infilename), wvc_mode ? " (+.wvc)" : "");
598 - fflush (stderr);
599 + flush_pipe (stderr);
603 @@ -1607,7 +1623,7 @@ static int unpack_audio (WavpackContext *wpc, FILE *outfile, int qmode, unsigned
604 #else
605 fprintf (stderr, "\n");
606 #endif
607 - fflush (stderr);
608 + flush_pipe (stderr);
609 DoTruncateFile (outfile);
610 result = WAVPACK_SOFT_ERROR;
611 break;
612 @@ -1624,7 +1640,7 @@ static int unpack_audio (WavpackContext *wpc, FILE *outfile, int qmode, unsigned
613 if (!quiet_mode) {
614 fprintf (stderr, "%s%3d%% done...",
615 nobs ? " " : "\b\b\b\b\b\b\b\b\b\b\b\b", (int) progress);
616 - fflush (stderr);
617 + flush_pipe (stderr);
621 @@ -1762,7 +1778,7 @@ static int unpack_dsd_audio (WavpackContext *wpc, FILE *outfile, int qmode, unsi
622 #else
623 fprintf (stderr, "\n");
624 #endif
625 - fflush (stderr);
626 + flush_pipe (stderr);
627 DoTruncateFile (outfile);
628 result = WAVPACK_SOFT_ERROR;
629 break;
630 @@ -1779,7 +1795,7 @@ static int unpack_dsd_audio (WavpackContext *wpc, FILE *outfile, int qmode, unsi
631 if (!quiet_mode) {
632 fprintf (stderr, "%s%3d%% done...",
633 nobs ? " " : "\b\b\b\b\b\b\b\b\b\b\b\b", (int) progress);
634 - fflush (stderr);
635 + flush_pipe (stderr);
639 @@ -1883,7 +1899,7 @@ static int do_tag_extractions (WavpackContext *wpc, char *outfilename)
640 if (!overwrite_all && (outfile = fopen (full_filename, "r")) != NULL) {
641 DoCloseHandle (outfile);
642 fprintf (stderr, "overwrite %s (yes/no/all)? ", FN_FIT (full_filename));
643 - fflush (stderr);
644 + flush_pipe (stderr);
646 if (set_console_title)
647 DoSetConsoleTitle ("overwrite?");