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

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

Issue 414643003: Support configuring the audio buffer duration in the Pepper MediaStream API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add clarifying comment about buffer size. Created 6 years, 4 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/pepper_media_stream_track_host_base.h" 5 #include "content/renderer/pepper/pepper_media_stream_track_host_base.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/numerics/safe_math.h" 8 #include "base/numerics/safe_math.h"
9 #include "content/public/renderer/render_thread.h" 9 #include "content/public/renderer/render_thread.h"
10 #include "content/public/renderer/renderer_ppapi_host.h" 10 #include "content/public/renderer/renderer_ppapi_host.h"
(...skipping 20 matching lines...) Expand all
31 PepperMediaStreamTrackHostBase::~PepperMediaStreamTrackHostBase() {} 31 PepperMediaStreamTrackHostBase::~PepperMediaStreamTrackHostBase() {}
32 32
33 bool PepperMediaStreamTrackHostBase::InitBuffers(int32_t number_of_buffers, 33 bool PepperMediaStreamTrackHostBase::InitBuffers(int32_t number_of_buffers,
34 int32_t buffer_size, 34 int32_t buffer_size,
35 TrackType track_type) { 35 TrackType track_type) {
36 DCHECK_GT(number_of_buffers, 0); 36 DCHECK_GT(number_of_buffers, 0);
37 DCHECK_GT(buffer_size, 37 DCHECK_GT(buffer_size,
38 static_cast<int32_t>(sizeof(ppapi::MediaStreamBuffer::Header))); 38 static_cast<int32_t>(sizeof(ppapi::MediaStreamBuffer::Header)));
39 // Make each buffer 4 byte aligned. 39 // Make each buffer 4 byte aligned.
40 base::CheckedNumeric<int32_t> buffer_size_aligned = buffer_size; 40 base::CheckedNumeric<int32_t> buffer_size_aligned = buffer_size;
41 // TODO(amistry): "buffer size" might not == "buffer stride", in the same way
42 // that width != stride in an image buffer.
41 buffer_size_aligned += (4 - buffer_size % 4); 43 buffer_size_aligned += (4 - buffer_size % 4);
42 44
43 // TODO(penghuang): |HostAllocateSharedMemoryBuffer| uses sync IPC. We should 45 // TODO(penghuang): |HostAllocateSharedMemoryBuffer| uses sync IPC. We should
44 // avoid it. 46 // avoid it.
45 base::CheckedNumeric<int32_t> size = number_of_buffers * buffer_size_aligned; 47 base::CheckedNumeric<int32_t> size = number_of_buffers * buffer_size_aligned;
46 if (!size.IsValid()) 48 if (!size.IsValid())
47 return false; 49 return false;
48 50
49 content::RenderThread* render_thread = content::RenderThread::Get(); 51 content::RenderThread* render_thread = content::RenderThread::Get();
50 scoped_ptr<base::SharedMemory> shm( 52 scoped_ptr<base::SharedMemory> shm(
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 return PP_OK; 117 return PP_OK;
116 } 118 }
117 119
118 int32_t PepperMediaStreamTrackHostBase::OnHostMsgClose( 120 int32_t PepperMediaStreamTrackHostBase::OnHostMsgClose(
119 HostMessageContext* context) { 121 HostMessageContext* context) {
120 OnClose(); 122 OnClose();
121 return PP_OK; 123 return PP_OK;
122 } 124 }
123 125
124 } // namespace content 126 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698