49void ruf::StreamWriterChannel::setup_python() {
51 bp::class_<ruf::StreamWriterChannel, ruf::StreamWriterChannelPtr, bp::bases<ris::Slave>, boost::noncopyable>(
52 "StreamWriterChannel",
54 .def(
"getFrameCount", &ruf::StreamWriterChannel::getFrameCount)
55 .def(
"waitFrameCount", &ruf::StreamWriterChannel::waitFrameCount)
56 .def(
"setFrameCount", &ruf::StreamWriterChannel::setFrameCount);
57 bp::implicitly_convertible<ruf::StreamWriterChannelPtr, ris::SlavePtr>();
101bool ruf::StreamWriterChannel::waitFrameCount(uint32_t count, uint64_t timeout) {
102 struct timeval endTime;
103 struct timeval sumTime;
104 struct timeval curTime;
107 std::unique_lock<std::mutex> lock(mtx_);
110 gettimeofday(&curTime, NULL);
112 div_t divResult = div(timeout, 1000000);
113 sumTime.tv_sec = divResult.quot;
114 sumTime.tv_usec = divResult.rem;
116 timeradd(&curTime, &sumTime, &endTime);
119 while (frameCount_ < count) {
120 cond_.wait_for(lock, std::chrono::microseconds(1000));
123 gettimeofday(&curTime, NULL);
124 if (timercmp(&curTime, &endTime, >))
break;
128 return (frameCount_ >= count);