Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1132)

Unified Diff: media/filters/ffmpeg_demuxer.cc

Issue 9015015: Take advantage of the new Pass() machinery on scoped_ptr{,_malloc}. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased & removed unnecessary include of ffmpeg_common.h from ffmpeg_demuxer.h Created 8 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: media/filters/ffmpeg_demuxer.cc
diff --git a/media/filters/ffmpeg_demuxer.cc b/media/filters/ffmpeg_demuxer.cc
index f85d3f337cf83bb214d2705827153b4e4f3d3cb9..cf32d0851313514b32d5b0ae5cbb9eb927f4c96a 100644
--- a/media/filters/ffmpeg_demuxer.cc
+++ b/media/filters/ffmpeg_demuxer.cc
@@ -26,9 +26,10 @@ namespace media {
//
class AVPacketBuffer : public Buffer {
public:
- AVPacketBuffer(AVPacket* packet, const base::TimeDelta& timestamp,
+ AVPacketBuffer(scoped_ptr_malloc<AVPacket, ScopedPtrAVFreePacket> packet,
acolwell GONE FROM CHROMIUM 2012/01/03 19:27:06 Wow. This says way more about this pointer than th
Ami GONE FROM CHROMIUM 2012/01/03 20:58:34 ...and yet, it says no more than the comment that
+ const base::TimeDelta& timestamp,
const base::TimeDelta& duration)
- : packet_(packet) {
+ : packet_(packet.Pass()) {
SetTimestamp(timestamp);
SetDuration(duration);
}
@@ -98,7 +99,8 @@ bool FFmpegDemuxerStream::HasPendingReads() {
return !read_queue_.empty();
}
-void FFmpegDemuxerStream::EnqueuePacket(AVPacket* packet) {
+void FFmpegDemuxerStream::EnqueuePacket(
+ scoped_ptr_malloc<AVPacket, ScopedPtrAVFreePacket> packet) {
DCHECK_EQ(MessageLoop::current(), demuxer_->message_loop());
base::TimeDelta timestamp =
ConvertStreamTimestamp(stream_->time_base, packet->pts);
@@ -113,13 +115,13 @@ void FFmpegDemuxerStream::EnqueuePacket(AVPacket* packet) {
// Convert if the packet if there is bitstream filter.
if (packet->data && bitstream_converter_.get() &&
- !bitstream_converter_->ConvertPacket(packet)) {
+ !bitstream_converter_->ConvertPacket(packet.get())) {
LOG(ERROR) << "Format converstion failed.";
}
// Enqueue the callback and attempt to satisfy a read immediately.
scoped_refptr<Buffer> buffer(
- new AVPacketBuffer(packet, timestamp, duration));
+ new AVPacketBuffer(packet.Pass(), timestamp, duration));
if (!buffer) {
NOTREACHED() << "Unable to allocate AVPacketBuffer";
return;
@@ -671,8 +673,7 @@ void FFmpegDemuxer::DemuxTask() {
// not refer to inner memory from FFmpeg.
av_dup_packet(packet.get());
- // The stream takes ownership of the AVPacket.
- demuxer_stream->EnqueuePacket(packet.release());
+ demuxer_stream->EnqueuePacket(packet.Pass());
}
// Create a loop by posting another task. This allows seek and message loop
@@ -723,9 +724,9 @@ void FFmpegDemuxer::StreamHasEnded() {
for (iter = streams_.begin(); iter != streams_.end(); ++iter) {
if (!*iter)
continue;
- AVPacket* packet = new AVPacket();
- memset(packet, 0, sizeof(*packet));
- (*iter)->EnqueuePacket(packet);
+ scoped_ptr_malloc<AVPacket, ScopedPtrAVFreePacket> packet(new AVPacket());
+ memset(packet.get(), 0, sizeof(*packet.get()));
+ (*iter)->EnqueuePacket(packet.Pass());
}
}

Powered by Google App Engine
This is Rietveld 408576698