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

Unified Diff: media/filters/ffmpeg_audio_decoder.cc

Issue 2723083004: Remove a scoped_refptr<>::swap overload (Closed)
Patch Set: avoid to use std::swap Created 3 years, 9 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
« no previous file with comments | « base/memory/ref_counted.h ('k') | media/filters/ffmpeg_video_decoder.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/filters/ffmpeg_audio_decoder.cc
diff --git a/media/filters/ffmpeg_audio_decoder.cc b/media/filters/ffmpeg_audio_decoder.cc
index e3560ff1b8bcf9d359f2a7c0ab06147b8e6b4e3f..06233eaa7d141c033ac0c80a7574defee61d04ba 100644
--- a/media/filters/ffmpeg_audio_decoder.cc
+++ b/media/filters/ffmpeg_audio_decoder.cc
@@ -45,8 +45,8 @@ static inline int DetermineChannels(AVFrame* frame) {
// Called by FFmpeg's allocation routine to free a buffer. |opaque| is the
// AudioBuffer allocated, so unref it.
static void ReleaseAudioBufferImpl(void* opaque, uint8_t* data) {
- scoped_refptr<AudioBuffer> buffer;
- buffer.swap(reinterpret_cast<AudioBuffer**>(&opaque));
+ if (opaque)
+ static_cast<AudioBuffer*>(opaque)->Release();
}
// Called by FFmpeg's allocation routine to allocate a buffer. Uses
@@ -124,8 +124,8 @@ static int GetAudioBuffer(struct AVCodecContext* s, AVFrame* frame, int flags) {
// Now create an AVBufferRef for the data just allocated. It will own the
// reference to the AudioBuffer object.
- void* opaque = NULL;
- buffer.swap(reinterpret_cast<AudioBuffer**>(&opaque));
+ AudioBuffer* opaque = buffer.get();
+ opaque->AddRef();
frame->buf[0] = av_buffer_create(
frame->data[0], buffer_size_in_bytes, ReleaseAudioBufferImpl, opaque, 0);
return 0;
« no previous file with comments | « base/memory/ref_counted.h ('k') | media/filters/ffmpeg_video_decoder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698