summaryrefslogtreecommitdiffstats
path: root/media/base
diff options
context:
space:
mode:
authorfischman@chromium.org <fischman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-18 03:29:37 +0000
committerfischman@chromium.org <fischman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-18 03:29:37 +0000
commiteb5d608b4b2a345da0ae80097ecfc7e522301590 (patch)
tree4471d19b8dbc00ca48944381910955d4cd22eed3 /media/base
parent47c7ec8be8c6829d7973568fe453f46046c2e818 (diff)
downloadchromium_src-eb5d608b4b2a345da0ae80097ecfc7e522301590.zip
chromium_src-eb5d608b4b2a345da0ae80097ecfc7e522301590.tar.gz
chromium_src-eb5d608b4b2a345da0ae80097ecfc7e522301590.tar.bz2
buffers.cc: replaced global TimeDelta constants with fully-inlined functions.
media_log.cc: replaced global AtomicSequenceNumber with LazyInstance. BUG=94925 TEST=none Review URL: http://codereview.chromium.org/9225001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@118026 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media/base')
-rw-r--r--media/base/buffers.cc8
-rw-r--r--media/base/buffers.h10
-rw-r--r--media/base/clock.cc2
-rw-r--r--media/base/media_log.cc6
-rw-r--r--media/base/pts_stream.cc12
-rw-r--r--media/base/pts_stream_unittest.cc10
-rw-r--r--media/base/seekable_buffer.cc6
-rw-r--r--media/base/seekable_buffer.h4
-rw-r--r--media/base/seekable_buffer_unittest.cc24
9 files changed, 41 insertions, 41 deletions
diff --git a/media/base/buffers.cc b/media/base/buffers.cc
index 67a936e..9f59c18 100644
--- a/media/base/buffers.cc
+++ b/media/base/buffers.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -6,12 +6,6 @@
namespace media {
-const base::TimeDelta kNoTimestamp =
- base::TimeDelta::FromMicroseconds(kint64min);
-
-const base::TimeDelta kInfiniteDuration =
- base::TimeDelta::FromMicroseconds(kint64max);
-
StreamSample::StreamSample() {}
StreamSample::~StreamSample() {}
diff --git a/media/base/buffers.h b/media/base/buffers.h
index 400eaf7..cbe89e1 100644
--- a/media/base/buffers.h
+++ b/media/base/buffers.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -35,10 +35,14 @@
namespace media {
// Indicates an invalid or missing timestamp.
-MEDIA_EXPORT extern const base::TimeDelta kNoTimestamp;
+MEDIA_EXPORT extern inline base::TimeDelta kNoTimestamp() {
+ return base::TimeDelta::FromMicroseconds(kint64min);
+}
// Represents an infinite stream duration.
-MEDIA_EXPORT extern const base::TimeDelta kInfiniteDuration;
+MEDIA_EXPORT extern inline base::TimeDelta kInfiniteDuration() {
+ return base::TimeDelta::FromMicroseconds(kint64max);
+}
class MEDIA_EXPORT StreamSample
: public base::RefCountedThreadSafe<StreamSample> {
diff --git a/media/base/clock.cc b/media/base/clock.cc
index aaa0c13..4cdc021 100644
--- a/media/base/clock.cc
+++ b/media/base/clock.cc
@@ -46,7 +46,7 @@ void Clock::SetPlaybackRate(float playback_rate) {
}
void Clock::SetTime(const base::TimeDelta& time) {
- if (time == kNoTimestamp) {
+ if (time == kNoTimestamp()) {
NOTREACHED();
return;
}
diff --git a/media/base/media_log.cc b/media/base/media_log.cc
index 2312942..a9fabe2 100644
--- a/media/base/media_log.cc
+++ b/media/base/media_log.cc
@@ -8,6 +8,7 @@
#include "base/atomic_sequence_num.h"
#include "base/bind.h"
+#include "base/lazy_instance.h"
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
#include "base/values.h"
@@ -16,7 +17,8 @@ namespace media {
// A count of all MediaLogs created on this render process.
// Used to generate unique ids.
-static base::AtomicSequenceNumber media_log_count(base::LINKER_INITIALIZED);
+static base::LazyInstance<base::AtomicSequenceNumber> media_log_count =
+ LAZY_INSTANCE_INITIALIZER;
const char* MediaLog::EventTypeToString(MediaLogEvent::Type type) {
switch (type) {
@@ -144,7 +146,7 @@ const char* MediaLog::PipelineStatusToString(PipelineStatus status) {
}
MediaLog::MediaLog() {
- id_ = media_log_count.GetNext();
+ id_ = media_log_count.Get().GetNext();
stats_update_pending_ = false;
}
diff --git a/media/base/pts_stream.cc b/media/base/pts_stream.cc
index 0223cdb..48cec61 100644
--- a/media/base/pts_stream.cc
+++ b/media/base/pts_stream.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -31,7 +31,7 @@ void PtsStream::Flush() {
void PtsStream::EnqueuePts(StreamSample* sample) {
DCHECK(sample);
- if (!sample->IsEndOfStream() && sample->GetTimestamp() != kNoTimestamp) {
+ if (!sample->IsEndOfStream() && sample->GetTimestamp() != kNoTimestamp()) {
pts_heap_.Push(sample->GetTimestamp());
}
}
@@ -46,7 +46,7 @@ void PtsStream::UpdatePtsAndDuration(StreamSample* sample) {
// situation and set the timestamp to kInvalidTimestamp.
DCHECK(sample);
base::TimeDelta timestamp = sample->GetTimestamp();
- if (timestamp != kNoTimestamp &&
+ if (timestamp != kNoTimestamp() &&
timestamp.ToInternalValue() != 0) {
current_pts_ = timestamp;
// We need to clean up the timestamp we pushed onto the |pts_heap_|.
@@ -56,18 +56,18 @@ void PtsStream::UpdatePtsAndDuration(StreamSample* sample) {
// If the frame did not have pts, try to get the pts from the |pts_heap|.
current_pts_ = pts_heap_.Top();
pts_heap_.Pop();
- } else if (current_pts_ != kNoTimestamp) {
+ } else if (current_pts_ != kNoTimestamp()) {
// Guess assuming this frame was the same as the last frame.
current_pts_ = current_pts_ + current_duration_;
} else {
// Now we really have no clue!!! Mark an invalid timestamp and let the
// video renderer handle it (i.e., drop frame).
- current_pts_ = kNoTimestamp;
+ current_pts_ = kNoTimestamp();
}
// Fill in the duration, using the frame itself as the authoratative source.
base::TimeDelta duration = sample->GetDuration();
- if (duration != kNoTimestamp &&
+ if (duration != kNoTimestamp() &&
duration.ToInternalValue() != 0) {
current_duration_ = duration;
} else {
diff --git a/media/base/pts_stream_unittest.cc b/media/base/pts_stream_unittest.cc
index 22f3807..5b200b7 100644
--- a/media/base/pts_stream_unittest.cc
+++ b/media/base/pts_stream_unittest.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -31,8 +31,8 @@ class PtsStreamTest : public testing::Test {
TEST_F(PtsStreamTest, NoTimestamp) {
// Simulate an uninitialized |video_frame| where we cannot determine a
// timestamp at all.
- video_frame_->SetTimestamp(kNoTimestamp);
- video_frame_->SetDuration(kNoTimestamp);
+ video_frame_->SetTimestamp(kNoTimestamp());
+ video_frame_->SetDuration(kNoTimestamp());
pts_stream_.UpdatePtsAndDuration(video_frame_);
EXPECT_EQ(0, pts_stream_.current_pts().InMicroseconds());
EXPECT_EQ(40000, pts_stream_.current_duration().InMicroseconds());
@@ -48,8 +48,8 @@ TEST_F(PtsStreamTest, LastKnownTimestamp) {
// Simulate an uninitialized |video_frame| where last known pts will be used
// to generate a timestamp and |frame_duration| will be used to generate a
// duration.
- video_frame_->SetTimestamp(kNoTimestamp);
- video_frame_->SetDuration(kNoTimestamp);
+ video_frame_->SetTimestamp(kNoTimestamp());
+ video_frame_->SetDuration(kNoTimestamp());
pts_stream_.UpdatePtsAndDuration(video_frame_);
EXPECT_EQ(116, pts_stream_.current_pts().InMicroseconds());
EXPECT_EQ(40000, pts_stream_.current_duration().InMicroseconds());
diff --git a/media/base/seekable_buffer.cc b/media/base/seekable_buffer.cc
index 2e3180a..b9ad7a4 100644
--- a/media/base/seekable_buffer.cc
+++ b/media/base/seekable_buffer.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -18,7 +18,7 @@ SeekableBuffer::SeekableBuffer(size_t backward_capacity,
backward_bytes_(0),
forward_capacity_(forward_capacity),
forward_bytes_(0),
- current_time_(kNoTimestamp) {
+ current_time_(kNoTimestamp()) {
current_buffer_ = buffers_.begin();
}
@@ -31,7 +31,7 @@ void SeekableBuffer::Clear() {
current_buffer_offset_ = 0;
backward_bytes_ = 0;
forward_bytes_ = 0;
- current_time_ = kNoTimestamp;
+ current_time_ = kNoTimestamp();
}
size_t SeekableBuffer::Read(uint8* data, size_t size) {
diff --git a/media/base/seekable_buffer.h b/media/base/seekable_buffer.h
index 18dee8d..56a7ceb 100644
--- a/media/base/seekable_buffer.h
+++ b/media/base/seekable_buffer.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -121,7 +121,7 @@ class MEDIA_EXPORT SeekableBuffer {
// timestamp for the current buffer is set to 0 or the data was added with
// Append(const uint*, size_t), then returns value that corresponds to the
// last position in a buffer that had timestamp set.
- // kNoTimestamp is returned if no buffers we read from had timestamp set.
+ // kNoTimestamp() is returned if no buffers we read from had timestamp set.
base::TimeDelta current_time() const { return current_time_; }
private:
diff --git a/media/base/seekable_buffer_unittest.cc b/media/base/seekable_buffer_unittest.cc
index cf87b5d..2cb547f 100644
--- a/media/base/seekable_buffer_unittest.cc
+++ b/media/base/seekable_buffer_unittest.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -298,15 +298,15 @@ TEST_F(SeekableBufferTest, GetTime) {
int64 expected_time;
} tests[] = {
// Timestamps of 0 are treated as garbage.
- { 0, 1000000, 0, kNoTimestamp.ToInternalValue() },
- { 0, 4000000, 0, kNoTimestamp.ToInternalValue() },
- { 0, 8000000, 0, kNoTimestamp.ToInternalValue() },
- { 0, 1000000, 4, kNoTimestamp.ToInternalValue() },
- { 0, 4000000, 4, kNoTimestamp.ToInternalValue() },
- { 0, 8000000, 4, kNoTimestamp.ToInternalValue() },
- { 0, 1000000, kWriteSize, kNoTimestamp.ToInternalValue() },
- { 0, 4000000, kWriteSize, kNoTimestamp.ToInternalValue() },
- { 0, 8000000, kWriteSize, kNoTimestamp.ToInternalValue() },
+ { 0, 1000000, 0, kNoTimestamp().ToInternalValue() },
+ { 0, 4000000, 0, kNoTimestamp().ToInternalValue() },
+ { 0, 8000000, 0, kNoTimestamp().ToInternalValue() },
+ { 0, 1000000, 4, kNoTimestamp().ToInternalValue() },
+ { 0, 4000000, 4, kNoTimestamp().ToInternalValue() },
+ { 0, 8000000, 4, kNoTimestamp().ToInternalValue() },
+ { 0, 1000000, kWriteSize, kNoTimestamp().ToInternalValue() },
+ { 0, 4000000, kWriteSize, kNoTimestamp().ToInternalValue() },
+ { 0, 8000000, kWriteSize, kNoTimestamp().ToInternalValue() },
{ 5, 1000000, 0, 5 },
{ 5, 4000000, 0, 5 },
{ 5, 8000000, 0, 5 },
@@ -318,8 +318,8 @@ TEST_F(SeekableBufferTest, GetTime) {
{ 5, 8000000, kWriteSize, 8000005 },
};
- // current_time() must initially return kNoTimestamp.
- EXPECT_EQ(kNoTimestamp.ToInternalValue(),
+ // current_time() must initially return kNoTimestamp().
+ EXPECT_EQ(kNoTimestamp().ToInternalValue(),
buffer_.current_time().ToInternalValue());
scoped_refptr<media::DataBuffer> buffer(new media::DataBuffer(kWriteSize));