本文整理汇总了C++中AudioPlayer::tick_p方法的典型用法代码示例。如果您正苦于以下问题:C++ AudioPlayer::tick_p方法的具体用法?C++ AudioPlayer::tick_p怎么用?C++ AudioPlayer::tick_p使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AudioPlayer
的用法示例。
在下文中一共展示了AudioPlayer::tick_p方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: tick_s
void* AudioPlayer::tick_s(void *ptr)
{
struct timespec ts;
AudioPlayer* that = static_cast<AudioPlayer*>(ptr);
while (true)
{
if (that->playing_ == false)
break;
that->tick_p();
if (that->playing_ == false)
break;
/*
struct _timeb timebuffer;
_ftime_s(&timebuffer);
ts.tv_sec = timebuffer.time;
ts.tv_nsec = timebuffer.millitm * 1000;
ts.tv_nsec += 900000000;
*/
#if defined(_WIN32)
FILETIME ft;
GetSystemTimeAsFileTime(&ft);
ptw32_filetime_to_timespec(&ft, &ts);
ts.tv_nsec += 1000000000/30; // 1/30 of sec
#elif defined(__APPLE__)
struct timeval tv;
gettimeofday(&tv, NULL);
ts.tv_sec = tv.tv_sec;
ts.tv_nsec = tv.tv_usec * 1000;
ts.tv_nsec += 1000000000/30; // 1/30 of sec
#else
clock_gettime(CLOCK_REALTIME, &ts);
ts.tv_nsec += 1000000000/30; // 1/30 of sec
#endif
// sem_timedwait(&that->sem_, &ts);
pthread_mutex_lock(&that->mutex2_);
pthread_cond_timedwait(&that->cond_, &that->mutex2_, &ts);
pthread_mutex_unlock(&that->mutex2_);
}
// pthread_exit(NULL);
return NULL;
}