Updated German translation. Includes suggestions by "tablerocker" <tablerocker@web...
[LameXP.git] / etc / Patches / AC3Filter-tools-FlushProgress+STDOUT.V4.diff
blob34925dc46fb509c077764d36f4d0509600f55758
1 valdec.cpp | 102 +++++++++++++++++++++++++++++++++----------------------------
2 1 file changed, 56 insertions(+), 46 deletions(-)
4 diff --git a/valdec.cpp b/valdec.cpp
5 index 2530a56..589068c 100644
6 --- a/valdec.cpp
7 +++ b/valdec.cpp
8 @@ -3,6 +3,10 @@
9 #include <math.h>
10 #include <string>
12 +// CRT
13 +#include <fcntl.h>
14 +#include <io.h>
16 // parsers
17 #include "source/file_parser.h"
19 @@ -131,7 +135,7 @@ int valdec(const arg_list_t &args)
20 using std::string;
21 if (args.size() < 2)
23 - printf(usage);
24 + fprintf(stderr, usage);
25 return 1;
28 @@ -218,7 +222,7 @@ int valdec(const arg_list_t &args)
30 if (parser)
32 - printf("-ac3 : ambiguous parser\n");
33 + fprintf(stderr, "-ac3 : ambiguous parser\n");
34 return 1;
37 @@ -231,7 +235,7 @@ int valdec(const arg_list_t &args)
39 if (parser)
41 - printf("-dts : ambiguous parser\n");
42 + fprintf(stderr, "-dts : ambiguous parser\n");
43 return 1;
46 @@ -244,7 +248,7 @@ int valdec(const arg_list_t &args)
48 if (parser)
50 - printf("-mpa : ambiguous parser\n");
51 + fprintf(stderr, "-mpa : ambiguous parser\n");
52 return 1;
55 @@ -288,7 +292,7 @@ int valdec(const arg_list_t &args)
57 if (sink)
59 - printf("-decode : ambiguous output mode\n");
60 + fprintf(stderr, "-decode : ambiguous output mode\n");
61 return 1;
64 @@ -304,7 +308,7 @@ int valdec(const arg_list_t &args)
66 if (sink)
68 - printf("-play : ambiguous output mode\n");
69 + fprintf(stderr, "-play : ambiguous output mode\n");
70 return 1;
73 @@ -320,12 +324,12 @@ int valdec(const arg_list_t &args)
75 if (sink)
77 - printf("-raw : ambiguous output mode\n");
78 + fprintf(stderr, "-raw : ambiguous output mode\n");
79 return 1;
81 if (args.size() - iarg < 1)
83 - printf("-raw : specify a file name\n");
84 + fprintf(stderr, "-raw : specify a file name\n");
85 return 1;
88 @@ -342,12 +346,12 @@ int valdec(const arg_list_t &args)
90 if (sink)
92 - printf("-wav : ambiguous output mode\n");
93 + fprintf(stderr, "-wav : ambiguous output mode\n");
94 return 1;
96 if (args.size() - iarg < 1)
98 - printf("-wav : specify a file name\n");
99 + fprintf(stderr, "-wav : specify a file name\n");
100 return 1;
103 @@ -364,7 +368,7 @@ int valdec(const arg_list_t &args)
105 if (sink)
107 - printf("-nothing : ambiguous output mode\n");
108 + fprintf(stderr, "-nothing : ambiguous output mode\n");
109 return 1;
112 @@ -404,7 +408,7 @@ int valdec(const arg_list_t &args)
114 if (args.size() - iarg < 1)
116 - printf("-log : specify a file name\n");
117 + fprintf(stderr, "-log : specify a file name\n");
118 return 1;
121 @@ -587,7 +591,7 @@ int valdec(const arg_list_t &args)
123 if (have_delay) continue;
125 - printf("Error: unknown option: %s\n", arg.raw.c_str());
126 + fprintf(stderr, "Error: unknown option: %s\n", arg.raw.c_str());
127 return 1;
130 @@ -600,13 +604,13 @@ int valdec(const arg_list_t &args)
132 if (!file.open(input_filename, parser, 1000000))
134 - printf("Error: Cannot open file '%s'\n", input_filename);
135 + fprintf(stderr, "Error: Cannot open file '%s'\n", input_filename);
136 return 1;
139 if (!file.stats() || !file.probe())
141 - printf("Error: Cannot detect input file format\n", input_filename);
142 + fprintf(stderr, "Error: Cannot detect input file format\n", input_filename);
143 return 1;
146 @@ -616,8 +620,8 @@ int valdec(const arg_list_t &args)
148 if (print_info)
150 - printf("%s\n", file.file_info().c_str());
151 - printf("%s", file.stream_info().c_str());
152 + fprintf(stderr, "%s\n", file.file_info().c_str());
153 + fprintf(stderr, "%s", file.stream_info().c_str());
156 if (mode == mode_nothing)
157 @@ -638,14 +642,14 @@ int valdec(const arg_list_t &args)
158 Speakers user_spk(format, mask, sample_rate);
159 if (!dvd_graph.set_user(user_spk))
161 - printf("Error: unsupported user format %s\n", user_spk.print());
162 + fprintf(stderr, "Error: unsupported user format %s\n", user_spk.print());
163 return 1;
166 Speakers in_spk = file.get_output();
167 if (!dvd_graph.open(in_spk))
169 - printf("Error: unsupported file format %s\n", in_spk.print());
170 + fprintf(stderr, "Error: unsupported file format %s\n", in_spk.print());
171 return 1;
174 @@ -679,7 +683,7 @@ int valdec(const arg_list_t &args)
175 case mode_raw:
176 if (!out_filename || !raw.open_file(out_filename))
178 - printf("Error: failed to open output file '%s'\n", out_filename);
179 + fprintf(stderr, "Error: failed to open output file '%s'\n", out_filename);
180 return 1;
182 break;
183 @@ -687,7 +691,7 @@ int valdec(const arg_list_t &args)
184 case mode_wav:
185 if (!out_filename || !wav.open_file(out_filename))
187 - printf("Error: failed to open output file '%s'\n", out_filename);
188 + fprintf(stderr, "Error: failed to open output file '%s'\n", out_filename);
189 return 1;
191 break;
192 @@ -695,7 +699,7 @@ int valdec(const arg_list_t &args)
193 case mode_play:
194 if (!dsound.open_dsound(0))
196 - printf("Error: failed to init DirectSound\n");
197 + fprintf(stderr, "Error: failed to init DirectSound\n");
198 return 1;
200 break;
201 @@ -744,10 +748,14 @@ int valdec(const arg_list_t &args)
202 int(value2db(level)), \
203 int(file.get_frames() / time), \
204 cpu_current.usage() * 100); \
205 + fflush(stderr); \
208 #define DROP_STAT \
209 - fprintf(stderr, " \r");
210 + { \
211 + fprintf(stderr, " \r"); \
212 + fflush(stderr); \
215 while (file.get_chunk(chunk))
217 @@ -760,7 +768,7 @@ int valdec(const arg_list_t &args)
218 PRINT_STAT;
220 if (streams > 0 && print_info)
221 - printf("\n\n%s", file.stream_info().c_str());
222 + fprintf(stderr, "\n\n%s", file.stream_info().c_str());
224 streams++;
225 if (mode == mode_nothing)
226 @@ -775,11 +783,11 @@ int valdec(const arg_list_t &args)
227 if (sink->open(new_spk))
229 DROP_STAT;
230 - printf("Opening audio output %s...\n", new_spk.print().c_str());
231 + fprintf(stderr, "Opening audio output %s...\n", new_spk.print().c_str());
233 else
235 - printf("\nOutput format %s is unsupported\n", new_spk.print().c_str());
236 + fprintf(stderr, "\nOutput format %s is unsupported\n", new_spk.print().c_str());
237 return 1;
240 @@ -806,11 +814,11 @@ int valdec(const arg_list_t &args)
241 if (sink->open(new_spk))
243 DROP_STAT;
244 - printf("Opening audio output %s...\n", new_spk.print().c_str());
245 + fprintf(stderr, "Opening audio output %s...\n", new_spk.print().c_str());
247 else
249 - printf("\nOutput format %s is unsupported\n", new_spk.print().c_str());
250 + fprintf(stderr, "\nOutput format %s is unsupported\n", new_spk.print().c_str());
251 return 1;
254 @@ -829,13 +837,13 @@ int valdec(const arg_list_t &args)
255 // Final statistics
257 PRINT_STAT;
258 - printf("\n---------------------------------------\n");
259 + fprintf(stderr, "\n---------------------------------------\n");
260 if (streams > 1)
261 - printf("Streams found: %i\n", streams);
262 - printf("Frames: %i\n", file.get_frames());
263 - printf("System time: %ims\n", int(cpu_total.get_system_time() * 1000));
264 - printf("Process time: %ims\n", int(cpu_total.get_thread_time() * 1000 ));
265 - printf("Approx. %.2f%% realtime CPU usage\n", double(cpu_total.get_thread_time() * 100) / file.get_size(file.time));
266 + fprintf(stderr, "Streams found: %i\n", streams);
267 + fprintf(stderr, "Frames: %i\n", file.get_frames());
268 + fprintf(stderr, "System time: %ims\n", int(cpu_total.get_system_time() * 1000));
269 + fprintf(stderr, "Process time: %ims\n", int(cpu_total.get_thread_time() * 1000 ));
270 + fprintf(stderr, "Approx. %.2f%% realtime CPU usage\n", double(cpu_total.get_thread_time() * 100) / file.get_size(file.time));
272 /////////////////////////////////////////////////////////
273 // Print levels histogram
274 @@ -852,21 +860,21 @@ int valdec(const arg_list_t &args)
275 max_level = dvd_graph.proc.get_max_level();
276 dbpb = dvd_graph.proc.get_dbpb();
278 - printf("\nHistogram:\n");
279 - printf("------------------------------------------------------------------------------\n");
280 + fprintf(stderr, "\nHistogram:\n");
281 + fprintf(stderr, "------------------------------------------------------------------------------\n");
282 for (i = 0; i*dbpb < 100 && i < MAX_HISTOGRAM; i++)
284 - printf("%2idB: %4.1f ", i * dbpb, hist[i] * 100);
285 + fprintf(stderr, "%2idB: %4.1f ", i * dbpb, hist[i] * 100);
286 for (j = 0; j < 67 && j < hist[i] * 67; j++)
287 - printf("*");
288 - printf("\n");
289 + fprintf(stderr, "*");
290 + fprintf(stderr, "\n");
292 - printf("------------------------------------------------------------------------------\n");
293 - printf("max_level;%f\ndbpb;%i\nhistogram;", max_level, dbpb);
294 + fprintf(stderr, "------------------------------------------------------------------------------\n");
295 + fprintf(stderr, "max_level;%f\ndbpb;%i\nhistogram;", max_level, dbpb);
296 for (i = 0; i < MAX_HISTOGRAM; i++)
297 - printf("%.4f;", hist[i]);
298 - printf("\n");
299 - printf("------------------------------------------------------------------------------\n");
300 + fprintf(stderr, "%.4f;", hist[i]);
301 + fprintf(stderr, "\n");
302 + fprintf(stderr, "------------------------------------------------------------------------------\n");
305 return 0;
306 @@ -876,16 +884,18 @@ int main(int argc, const char *argv[])
310 + _setmode(_fileno(stdout), _O_BINARY);
311 + _setmode(_fileno(stdin), _O_BINARY);
312 return valdec(args_utf8(argc, argv));
314 catch (ValibException &e)
316 - printf("Processing error: %s\n", boost::diagnostic_information(e).c_str());
317 + fprintf(stderr, "Processing error: %s\n", boost::diagnostic_information(e).c_str());
318 return -1;
320 catch (arg_t::bad_value_e &e)
322 - printf("Bad argument value: %s", e.arg.c_str());
323 + fprintf(stderr, "Bad argument value: %s", e.arg.c_str());
324 return -1;
326 return 0;