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

Unified Diff: services/media/common/media_pipe_base.cc

Issue 1823833003: Take advantage of MojoGetBufferInformation (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: rebase and fix a type mismatch which the android build caught Created 4 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 | « services/media/common/media_pipe_base.h ('k') | services/media/framework_mojo/mojo_consumer.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: services/media/common/media_pipe_base.cc
diff --git a/services/media/common/media_pipe_base.cc b/services/media/common/media_pipe_base.cc
index 069283c6c21227304e01e1c3096380f02b8cd7e5..6c8e2c5d979b11c48f65dd3b5ab92e394ff5bf4e 100644
--- a/services/media/common/media_pipe_base.cc
+++ b/services/media/common/media_pipe_base.cc
@@ -40,27 +40,38 @@ void MediaPipeBase::Reset() {
}
void MediaPipeBase::SetBuffer(ScopedSharedBufferHandle handle,
- uint64_t size,
const SetBufferCallback& cbk) {
+ DCHECK(handle.is_valid());
+
// Double init? Close the connection.
if (buffer_) {
- LOG(ERROR) << "Attempting to set a new buffer (size = "
- << size
- << ") on a MediaConsumer which already has a buffer (size = "
+ LOG(ERROR) << "Attempting to set a new buffer on a MediaConsumer which "
+ "already has a buffer assigned. (size = "
<< buffer_->size()
<< ")";
Reset();
return;
}
+ // Query the buffer for its size. If we fail to query the info, close the
+ // connection.
+ MojoResult res;
+ MojoBufferInformation info;
+ res = MojoGetBufferInformation(handle.get().value(), &info, sizeof(info));
+ if (res != MOJO_RESULT_OK) {
+ LOG(ERROR) << "Failed to query shared buffer info (res = " << res << ")";
+ Reset();
+ return;
+ }
+
// Invalid size? Close the connection.
+ uint64_t size = info.num_bytes;
if (!size || (size > MediaConsumer::kMaxBufferLen)) {
LOG(ERROR) << "Invalid shared buffer size (size = " << size << ")";
Reset();
return;
}
-
// Failed to map the buffer? Close the connection.
buffer_ = MappedSharedBuffer::Create(handle.Pass(), size);
if (!buffer_) {
@@ -183,7 +194,7 @@ MediaPipeBase::MappedSharedBuffer::~MappedSharedBuffer() {
MediaPipeBase::MappedSharedBuffer::MappedSharedBuffer(
ScopedSharedBufferHandle handle,
- size_t size)
+ uint64_t size)
: handle_(handle.Pass()),
size_(size) {
MojoResult res = MapBuffer(handle_.get(),
« no previous file with comments | « services/media/common/media_pipe_base.h ('k') | services/media/framework_mojo/mojo_consumer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698