blob: 0f0d16ed96bdc2f32623bda93ccf673cd7a48cb6 [file] [log] [blame]
xjb04a4022021-11-25 15:01:52 +08001#include "AudioParamParserPriv.h"
2
3#ifdef WIN32
4#include <windows.h>
5#include <io.h>
6#include <iostream>
7#include <fstream>
8#include <fcntl.h>
9#include <stdio.h>
10
11#ifndef _USE_OLD_IOSTREAMS
12using namespace std;
13#endif
14
15#else
16#endif
17
18
19#ifndef WIN32
20
21EXPORT int isCustXmlEnable(void)
22{
23 return true;
24}
25
26#else /* WIN32 */
27
28// maximum mumber of lines the output console should have
29static const WORD MAX_CONSOLE_LINES = 500;
30
31/* For Tuning Tool show the debug message */
32EXPORT void redirectIOToConsole()
33{
34 int hConHandle;
35 long lStdHandle;
36
37 CONSOLE_SCREEN_BUFFER_INFO coninfo;
38 FILE *fp;
39
40 // allocate a console for this app
41 AllocConsole();
42
43 // set the screen buffer to be big enough to let us scroll text
44 GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE),
45 &coninfo);
46 coninfo.dwSize.Y = MAX_CONSOLE_LINES;
47 SetConsoleScreenBufferSize(GetStdHandle(STD_OUTPUT_HANDLE), coninfo.dwSize);
48
49 // redirect unbuffered STDOUT to the console
50 lStdHandle = (long)GetStdHandle(STD_OUTPUT_HANDLE);
51 hConHandle = _open_osfhandle(lStdHandle, _O_TEXT);
52 fp = _fdopen(hConHandle, "w");
53 *stdout = *fp;
54 setvbuf(stdout, NULL, _IONBF, 0);
55
56 // redirect unbuffered STDIN to the console
57 lStdHandle = (long)GetStdHandle(STD_INPUT_HANDLE);
58 hConHandle = _open_osfhandle(lStdHandle, _O_TEXT);
59 fp = _fdopen(hConHandle, "r");
60 *stdin = *fp;
61 setvbuf(stdin, NULL, _IONBF, 0);
62
63 // redirect unbuffered STDERR to the console
64 lStdHandle = (long)GetStdHandle(STD_ERROR_HANDLE);
65 hConHandle = _open_osfhandle(lStdHandle, _O_TEXT);
66 fp = _fdopen(hConHandle, "w");
67 *stderr = *fp;
68 setvbuf(stderr, NULL, _IONBF, 0);
69 ios::sync_with_stdio();
70}
71#endif