chxavtimevalue.cpp

来自「symbian 下的helix player源代码」· C++ 代码 · 共 54 行

CPP
54
字号
/*============================================================================*
 *
 * (c) 1995-2002 RealNetworks, Inc. Patents pending. All rights reserved.
 *
 *============================================================================*/
 

//
// normalize:
//
//  normalize sec and usec in a TimeValue
//  This code was lifted from Doug Schmidt's ACE network communication package.
//
//

#include "chxavtimevalue.h"

static const long ONE_SECOND = 1000000L;

void
CHXAvTimeValue::normalize ()
{
    // New code from Hans Rohnert...
    if (this->usec_ >= ONE_SECOND)
    {
	do
	{ 
	    this->sec_++;
	    this->usec_ -= ONE_SECOND;
	}
	while (usec_ >= ONE_SECOND);
    }
    else if (this->usec_ <= -ONE_SECOND)
    {
	do
	{ 
	    this->sec_--;
	    this->usec_ += ONE_SECOND;
	}
	while (this->usec_ <= -ONE_SECOND);
    }
  
    if (this->sec_ >= 1 && this->usec_ < 0)
    {
	this->sec_--;
	this->usec_ += ONE_SECOND;
    }
    else if (this->sec_ < 0 && this->usec_ > 0)
    {
	this->sec_++;
	this->usec_ -= ONE_SECOND;
    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?