diff options
author | hclam@chromium.org <hclam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-17 20:04:29 +0000 |
---|---|---|
committer | hclam@chromium.org <hclam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-17 20:04:29 +0000 |
commit | 40e5ac1f115a7905372d3414debaac63a5244886 (patch) | |
tree | 1613d237a6e69e0d1f95b1953b8b2572a9f5b52a /media/base/data_buffer.cc | |
parent | b0c2bda2081e3627baac5814d6c66ef121b88515 (diff) | |
download | chromium_src-40e5ac1f115a7905372d3414debaac63a5244886.zip chromium_src-40e5ac1f115a7905372d3414debaac63a5244886.tar.gz chromium_src-40e5ac1f115a7905372d3414debaac63a5244886.tar.bz2 |
andrew's patch
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@11904 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media/base/data_buffer.cc')
-rw-r--r--[-rwxr-xr-x] | media/base/data_buffer.cc | 41 |
1 files changed, 23 insertions, 18 deletions
diff --git a/media/base/data_buffer.cc b/media/base/data_buffer.cc index b88790f..8c800ea 100755..100644 --- a/media/base/data_buffer.cc +++ b/media/base/data_buffer.cc @@ -7,17 +7,30 @@ namespace media { -DataBuffer::DataBuffer() - : data_(NULL), - buffer_size_(0), - data_size_(0) { +DataBuffer::DataBuffer(char* data, size_t buffer_size, size_t data_size, + const base::TimeDelta& timestamp, + const base::TimeDelta& duration, + DeleteBuffer delete_buffer) + : data_(data), + buffer_size_(buffer_size), + data_size_(data_size), + delete_buffer_(delete_buffer) { + DCHECK(data); + DCHECK(buffer_size >= 0); + DCHECK(data_size <= buffer_size); + SetTimestamp(timestamp); + SetDuration(duration); } DataBuffer::~DataBuffer() { - delete [] data_; + if (delete_buffer_) { + delete_buffer_(data_); + } else { + delete [] data_; + } } -const uint8* DataBuffer::GetData() const { +const char* DataBuffer::GetData() const { return data_; } @@ -25,23 +38,15 @@ size_t DataBuffer::GetDataSize() const { return data_size_; } -uint8* DataBuffer::GetWritableData(size_t buffer_size) { - if (buffer_size > buffer_size_) { - delete [] data_; - data_ = new uint8[buffer_size]; - if (!data_) { - NOTREACHED(); - buffer_size = 0; - } - buffer_size_ = buffer_size; - } - data_size_ = buffer_size; +char* DataBuffer::GetWritableData() { return data_; } +size_t DataBuffer::GetBufferSize() const { + return buffer_size_; +} void DataBuffer::SetDataSize(size_t data_size) { - DCHECK(data_size <= buffer_size_); data_size_ = data_size; } |