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

Side by Side Diff: mojo/services/media/common/cpp/circular_buffer_media_pipe_adapter.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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "mojo/public/cpp/environment/logging.h" 5 #include "mojo/public/cpp/environment/logging.h"
6 #include "mojo/public/cpp/utility/run_loop.h" 6 #include "mojo/public/cpp/utility/run_loop.h"
7 #include "mojo/services/media/common/cpp/circular_buffer_media_pipe_adapter.h" 7 #include "mojo/services/media/common/cpp/circular_buffer_media_pipe_adapter.h"
8 #include "mojo/services/media/common/interfaces/media_common.mojom.h" 8 #include "mojo/services/media/common/interfaces/media_common.mojom.h"
9 #include "mojo/services/media/common/interfaces/media_transport.mojom.h" 9 #include "mojo/services/media/common/interfaces/media_transport.mojom.h"
10 10
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 // read-only. 108 // read-only.
109 ScopedSharedBufferHandle duplicated_handle; 109 ScopedSharedBufferHandle duplicated_handle;
110 res = DuplicateBuffer(buffer_handle_.get(), nullptr, &duplicated_handle); 110 res = DuplicateBuffer(buffer_handle_.get(), nullptr, &duplicated_handle);
111 if (res != MOJO_RESULT_OK) { 111 if (res != MOJO_RESULT_OK) {
112 MOJO_LOG(ERROR) << "Failed to duplicate handle in " << __PRETTY_FUNCTION__ 112 MOJO_LOG(ERROR) << "Failed to duplicate handle in " << __PRETTY_FUNCTION__
113 << " (error " << res << ")"; 113 << " (error " << res << ")";
114 Fault(MediaResult::UNKNOWN_ERROR); 114 Fault(MediaResult::UNKNOWN_ERROR);
115 return; 115 return;
116 } 116 }
117 117
118 // TODO(johngro) : We should not have to send the buffer size, it should be an 118 pipe_->SetBuffer(duplicated_handle.Pass(), []() {});
119 // intrinsic property of the buffer itself and be query-able via the handle.
120 pipe_->SetBuffer(duplicated_handle.Pass(), buffer_size_, []() {});
121 } 119 }
122 120
123 void CircularBufferMediaPipeAdapter::SetSignalCallback(SignalCbk cbk) { 121 void CircularBufferMediaPipeAdapter::SetSignalCallback(SignalCbk cbk) {
124 bool schedule; 122 bool schedule;
125 signal_cbk_ = cbk; 123 signal_cbk_ = cbk;
126 schedule = (signal_cbk_ != nullptr); 124 schedule = (signal_cbk_ != nullptr);
127 125
128 // If the user supplied a non-null callback, make sure we schedule a 126 // If the user supplied a non-null callback, make sure we schedule a
129 // callback if we are currently signalled. 127 // callback if we are currently signalled.
130 if (schedule) { 128 if (schedule) {
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after
517 uint64_t CircularBufferMediaPipeAdapter::GetBufferSize() const { 515 uint64_t CircularBufferMediaPipeAdapter::GetBufferSize() const {
518 if (nullptr == buffer_) 516 if (nullptr == buffer_)
519 return 0; 517 return 0;
520 518
521 MOJO_DCHECK(buffer_size_); 519 MOJO_DCHECK(buffer_size_);
522 return buffer_size_ - 1; 520 return buffer_size_ - 1;
523 } 521 }
524 522
525 } // namespace media 523 } // namespace media
526 } // namespace mojo 524 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698