OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "media/filters/ffmpeg_audio_decoder.h" | 5 #include "media/filters/ffmpeg_audio_decoder.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include "base/callback_helpers.h" | 9 #include "base/callback_helpers.h" |
10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 | 54 |
55 // Called by FFmpeg's allocation routine to free a buffer. |opaque| is the | 55 // Called by FFmpeg's allocation routine to free a buffer. |opaque| is the |
56 // AudioBuffer allocated, so unref it. | 56 // AudioBuffer allocated, so unref it. |
57 static void ReleaseAudioBufferImpl(void* opaque, uint8_t* data) { | 57 static void ReleaseAudioBufferImpl(void* opaque, uint8_t* data) { |
58 if (opaque) | 58 if (opaque) |
59 static_cast<AudioBuffer*>(opaque)->Release(); | 59 static_cast<AudioBuffer*>(opaque)->Release(); |
60 } | 60 } |
61 | 61 |
62 FFmpegAudioDecoder::FFmpegAudioDecoder( | 62 FFmpegAudioDecoder::FFmpegAudioDecoder( |
63 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, | 63 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, |
64 const scoped_refptr<MediaLog>& media_log) | 64 MediaLog* media_log) |
65 : task_runner_(task_runner), | 65 : task_runner_(task_runner), |
66 state_(kUninitialized), | 66 state_(kUninitialized), |
67 av_sample_format_(0), | 67 av_sample_format_(0), |
68 media_log_(media_log), | 68 media_log_(media_log), |
69 pool_(new AudioBufferMemoryPool()) {} | 69 pool_(new AudioBufferMemoryPool()) {} |
70 | 70 |
71 FFmpegAudioDecoder::~FFmpegAudioDecoder() { | 71 FFmpegAudioDecoder::~FFmpegAudioDecoder() { |
72 DCHECK(task_runner_->BelongsToCurrentThread()); | 72 DCHECK(task_runner_->BelongsToCurrentThread()); |
73 | 73 |
74 if (state_ != kUninitialized) | 74 if (state_ != kUninitialized) |
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
450 // Now create an AVBufferRef for the data just allocated. It will own the | 450 // Now create an AVBufferRef for the data just allocated. It will own the |
451 // reference to the AudioBuffer object. | 451 // reference to the AudioBuffer object. |
452 AudioBuffer* opaque = buffer.get(); | 452 AudioBuffer* opaque = buffer.get(); |
453 opaque->AddRef(); | 453 opaque->AddRef(); |
454 frame->buf[0] = av_buffer_create(frame->data[0], buffer_size_in_bytes, | 454 frame->buf[0] = av_buffer_create(frame->data[0], buffer_size_in_bytes, |
455 ReleaseAudioBufferImpl, opaque, 0); | 455 ReleaseAudioBufferImpl, opaque, 0); |
456 return 0; | 456 return 0; |
457 } | 457 } |
458 | 458 |
459 } // namespace media | 459 } // namespace media |
OLD | NEW |