Manage external process and IPC when UI is requested to be visible. */
| 148 | Manage external process and IPC when UI is requested to be visible. |
| 149 | */ |
| 150 | void visibilityChanged(const bool visible) override |
| 151 | { |
| 152 | #ifdef KDE_FIFO_TEST |
| 153 | if (visible) |
| 154 | { |
| 155 | DISTRHO_SAFE_ASSERT_RETURN(fileExists(fExternalScript),); |
| 156 | |
| 157 | mkfifo(kFifoFilename, 0666); |
| 158 | sync(); |
| 159 | |
| 160 | char winIdStr[24]; |
| 161 | std::memset(winIdStr, 0, sizeof(winIdStr)); |
| 162 | std::snprintf(winIdStr, 23, "%lu", getTransientWindowId()); |
| 163 | |
| 164 | const char* args[] = { |
| 165 | fExternalScript.buffer(), |
| 166 | kFifoFilename, |
| 167 | "--progressbar", "External UI example", |
| 168 | "--title", getTitle(), |
| 169 | nullptr, |
| 170 | }; |
| 171 | DISTRHO_SAFE_ASSERT_RETURN(startExternalProcess(args),); |
| 172 | |
| 173 | // NOTE: this can lockup the current thread if the other side does not read the file! |
| 174 | fFifo = open(kFifoFilename, O_WRONLY); |
| 175 | DISTRHO_SAFE_ASSERT_RETURN(fFifo != -1,); |
| 176 | |
| 177 | parameterChanged(0, fValue); |
| 178 | } |
| 179 | else |
| 180 | { |
| 181 | if (fFifo != -1) |
| 182 | { |
| 183 | if (isRunning()) |
| 184 | { |
| 185 | DISTRHO_SAFE_ASSERT(writeRetry(fFifo, "quit\n", 5) == 5); |
| 186 | fsync(fFifo); |
| 187 | } |
| 188 | ::close(fFifo); |
| 189 | fFifo = -1; |
| 190 | } |
| 191 | |
| 192 | unlink(kFifoFilename); |
| 193 | terminateAndWaitForExternalProcess(); |
| 194 | } |
| 195 | #endif |
| 196 | #ifdef MPV_TEST |
| 197 | if (visible) |
| 198 | { |
| 199 | const char* const file = "/home/falktx/Videos/HD/"; // TODO make this a state file? |
| 200 | |
| 201 | if (isEmbed()) |
| 202 | { |
| 203 | char winIdStr[64]; |
| 204 | snprintf(winIdStr, sizeof(winIdStr), "--wid=%lu", getParentWindowHandle()); |
| 205 | const char* args[] = { |
| 206 | "mpv", |
| 207 | "--ao=jack", |
no test coverage detected