Fix last commit
[carla.git] / source / tests.old / CarlaPipeUtils.cpp
blob7a5468fce6627ca7f46884699bb6a99545e8a5e1
1 /*
2 * Carla Utility Tests
3 * Copyright (C) 2013-2018 Filipe Coelho <falktx@falktx.com>
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation; either version 2 of
8 * the License, or any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * For a full copy of the GNU General Public License see the doc/GPL.txt file.
18 #include "CarlaPipeUtils.hpp"
19 #include "../modules/water/files/File.h"
21 // -----------------------------------------------------------------------
23 class CarlaPipeClient2 : public CarlaPipeClient
25 public:
26 CarlaPipeClient2()
27 : CarlaPipeClient() {}
29 bool msgReceived(const char* const msg) noexcept override
31 carla_stdout("CLIENT RECEIVED: \"%s\"", msg);
32 return true;
36 class CarlaPipeServer2 : public CarlaPipeServer
38 public:
39 CarlaPipeServer2()
40 : CarlaPipeServer() {}
42 bool msgReceived(const char* const msg) noexcept override
44 carla_stdout("SERVER RECEIVED: \"%s\"", msg);
45 return true;
49 // -----------------------------------------------------------------------
51 int main(int argc, const char* argv[])
53 if (argc != 1)
55 carla_stdout("CLIENT STARTED %i", argc);
56 std::fflush(stdout);
58 CarlaPipeClient2 p;
59 const bool ok = p.initPipeClient(argv);
60 CARLA_SAFE_ASSERT_RETURN(ok,1);
62 p.lockPipe();
63 p.writeMessage("CLIENT=>SERVER\n");
64 p.writeAndFixMessage("heheheheheh");
65 p.unlockPipe();
67 carla_msleep(500);
69 carla_stderr2("CLIENT idle start");
70 std::fflush(stdout);
72 p.idlePipe();
74 carla_stderr2("CLIENT idle end");
75 std::fflush(stdout);
77 carla_msleep(500);
79 else
81 carla_stdout("SERVER STARTED %i", argc);
82 std::fflush(stdout);
84 using water::File;
85 using water::String;
86 String path = File(File::getSpecialLocation(File::currentExecutableFile)).getFullPathName();
88 #ifdef CARLA_OS_WINDOWS
89 path = "wine " + path;
90 #endif
92 CarlaPipeServer2 p;
93 const bool ok = p.startPipeServer(path.toRawUTF8(), "/home/falktx/Videos", "/home/falktx");
94 CARLA_SAFE_ASSERT_RETURN(ok,1);
96 p.lockPipe();
97 p.writeMessage("SERVER=>CLIENT\n");
98 p.unlockPipe();
100 carla_msleep(500);
102 carla_stderr2("SERVER idle start");
103 std::fflush(stdout);
105 p.idlePipe();
106 carla_stderr2("SERVER idle end");
107 std::fflush(stdout);
109 carla_msleep(500);
112 return 0;
115 // -----------------------------------------------------------------------
117 #include "../utils/CarlaPipeUtils.cpp"
119 // -----------------------------------------------------------------------