| 8 | #include <unistd.h> |
| 9 | |
| 10 | void WriteImage(void *start, int length, int index) { |
| 11 | printf("Dequeued buffer index: %d\n" |
| 12 | " bytesused: %d\n", |
| 13 | index, length); |
| 14 | |
| 15 | std::string filename = "img" + std::to_string(index) + ".yuv"; |
| 16 | int outfd = open(filename.c_str(), O_WRONLY | O_CREAT | O_EXCL, 0600); |
| 17 | if ((outfd == -1) && (EEXIST == errno)) { |
| 18 | /* open the existing file with write flag */ |
| 19 | outfd = open(filename.c_str(), O_WRONLY); |
| 20 | } |
| 21 | |
| 22 | write(outfd, start, length); |
| 23 | } |
| 24 | |
| 25 | int main(int argc, char *argv[]) { |
| 26 | std::mutex mtx; |