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

Side by Side Diff: content/renderer/pepper/content_decryptor_delegate.cc

Issue 2788483003: Introduce AudioBufferMemoryPool to avoid thrashing on audio buffers. (Closed)
Patch Set: Add class comments. Created 3 years, 8 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 unified diff | Download patch
« no previous file with comments | « content/renderer/pepper/content_decryptor_delegate.h ('k') | media/base/audio_buffer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "content/renderer/pepper/content_decryptor_delegate.h" 5 #include "content/renderer/pepper/content_decryptor_delegate.h"
6 6
7 #include <string.h> 7 #include <string.h>
8 #include <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/callback_helpers.h" 11 #include "base/callback_helpers.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/metrics/histogram_macros.h" 13 #include "base/metrics/histogram_macros.h"
14 #include "base/numerics/safe_conversions.h" 14 #include "base/numerics/safe_conversions.h"
15 #include "base/trace_event/trace_event.h" 15 #include "base/trace_event/trace_event.h"
16 #include "content/renderer/pepper/ppb_buffer_impl.h" 16 #include "content/renderer/pepper/ppb_buffer_impl.h"
17 #include "media/base/audio_buffer.h"
18 #include "media/base/audio_decoder_config.h" 17 #include "media/base/audio_decoder_config.h"
19 #include "media/base/bind_to_current_loop.h" 18 #include "media/base/bind_to_current_loop.h"
20 #include "media/base/cdm_key_information.h" 19 #include "media/base/cdm_key_information.h"
21 #include "media/base/channel_layout.h" 20 #include "media/base/channel_layout.h"
22 #include "media/base/data_buffer.h" 21 #include "media/base/data_buffer.h"
23 #include "media/base/decoder_buffer.h" 22 #include "media/base/decoder_buffer.h"
24 #include "media/base/decrypt_config.h" 23 #include "media/base/decrypt_config.h"
25 #include "media/base/key_systems.h" 24 #include "media/base/key_systems.h"
26 #include "media/base/limits.h" 25 #include "media/base/limits.h"
27 #include "media/base/video_decoder_config.h" 26 #include "media/base/video_decoder_config.h"
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 376
378 ContentDecryptorDelegate::ContentDecryptorDelegate( 377 ContentDecryptorDelegate::ContentDecryptorDelegate(
379 PP_Instance pp_instance, 378 PP_Instance pp_instance,
380 const PPP_ContentDecryptor_Private* plugin_decryption_interface) 379 const PPP_ContentDecryptor_Private* plugin_decryption_interface)
381 : pp_instance_(pp_instance), 380 : pp_instance_(pp_instance),
382 plugin_decryption_interface_(plugin_decryption_interface), 381 plugin_decryption_interface_(plugin_decryption_interface),
383 next_decryption_request_id_(1), 382 next_decryption_request_id_(1),
384 audio_samples_per_second_(0), 383 audio_samples_per_second_(0),
385 audio_channel_count_(0), 384 audio_channel_count_(0),
386 audio_channel_layout_(media::CHANNEL_LAYOUT_NONE), 385 audio_channel_layout_(media::CHANNEL_LAYOUT_NONE),
386 pool_(new media::AudioBufferMemoryPool()),
387 weak_ptr_factory_(this) { 387 weak_ptr_factory_(this) {
388 weak_this_ = weak_ptr_factory_.GetWeakPtr(); 388 weak_this_ = weak_ptr_factory_.GetWeakPtr();
389 } 389 }
390 390
391 ContentDecryptorDelegate::~ContentDecryptorDelegate() { 391 ContentDecryptorDelegate::~ContentDecryptorDelegate() {
392 SatisfyAllPendingCallbacksOnError(); 392 SatisfyAllPendingCallbacksOnError();
393 } 393 }
394 394
395 void ContentDecryptorDelegate::Initialize( 395 void ContentDecryptorDelegate::Initialize(
396 const std::string& key_system, 396 const std::string& key_system,
(...skipping 834 matching lines...) Expand 10 before | Expand all | Expand 10 after
1231 } 1231 }
1232 1232
1233 // Setup channel pointers. AudioBuffer::CopyFrom() will only use the first 1233 // Setup channel pointers. AudioBuffer::CopyFrom() will only use the first
1234 // one in the case of interleaved data. 1234 // one in the case of interleaved data.
1235 const int size_per_channel = frame_size / audio_channel_count_; 1235 const int size_per_channel = frame_size / audio_channel_count_;
1236 for (int i = 0; i < audio_channel_count_; ++i) 1236 for (int i = 0; i < audio_channel_count_; ++i)
1237 channel_ptrs[i] = cur + i * size_per_channel; 1237 channel_ptrs[i] = cur + i * size_per_channel;
1238 1238
1239 const int frame_count = frame_size / audio_bytes_per_frame; 1239 const int frame_count = frame_size / audio_bytes_per_frame;
1240 scoped_refptr<media::AudioBuffer> frame = media::AudioBuffer::CopyFrom( 1240 scoped_refptr<media::AudioBuffer> frame = media::AudioBuffer::CopyFrom(
1241 sample_format, 1241 sample_format, audio_channel_layout_, audio_channel_count_,
1242 audio_channel_layout_, 1242 audio_samples_per_second_, frame_count, &channel_ptrs[0],
1243 audio_channel_count_, 1243 base::TimeDelta::FromMicroseconds(timestamp), pool_);
1244 audio_samples_per_second_,
1245 frame_count,
1246 &channel_ptrs[0],
1247 base::TimeDelta::FromMicroseconds(timestamp));
1248 frames->push_back(frame); 1244 frames->push_back(frame);
1249 1245
1250 cur += frame_size; 1246 cur += frame_size;
1251 bytes_left -= frame_size; 1247 bytes_left -= frame_size;
1252 } while (bytes_left > 0); 1248 } while (bytes_left > 0);
1253 1249
1254 return true; 1250 return true;
1255 } 1251 }
1256 1252
1257 void ContentDecryptorDelegate::SatisfyAllPendingCallbacksOnError() { 1253 void ContentDecryptorDelegate::SatisfyAllPendingCallbacksOnError() {
(...skipping 20 matching lines...) Expand all
1278 1274
1279 if (!video_decode_cb_.is_null()) 1275 if (!video_decode_cb_.is_null())
1280 video_decode_cb_.ResetAndReturn().Run(media::Decryptor::kError, NULL); 1276 video_decode_cb_.ResetAndReturn().Run(media::Decryptor::kError, NULL);
1281 1277
1282 cdm_promise_adapter_.Clear(); 1278 cdm_promise_adapter_.Clear();
1283 1279
1284 cdm_session_tracker_.CloseRemainingSessions(session_closed_cb_); 1280 cdm_session_tracker_.CloseRemainingSessions(session_closed_cb_);
1285 } 1281 }
1286 1282
1287 } // namespace content 1283 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/pepper/content_decryptor_delegate.h ('k') | media/base/audio_buffer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698