chxavtimevalue.cpp
上传用户:zhongxx05
上传日期:2007-06-06
资源大小:33641k
文件大小:1k
- /*============================================================================*
- *
- * (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;
- }
- }