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

Unified Diff: media/filters/ffmpeg_audio_decoder.cc

Issue 2723083004: Remove a scoped_refptr<>::swap overload (Closed)
Patch Set: fix Created 3 years, 10 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_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();
xhwang 2017/03/03 18:36:08 This is hard to read (not saying it's worse than b
dcheng 2017/03/03 18:45:19 Eh... this seems Good Enough (tm) for the use case
frame->buf[0] = av_buffer_create(
frame->data[0], buffer_size_in_bytes, ReleaseAudioBufferImpl, opaque, 0);
return 0;

Powered by Google App Engine
This is Rietveld 408576698