• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //
2 // Copyright (C) 2020 The Android Open Source Project
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 //      http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 
16 #include "host/libs/audio_connector/buffers.h"
17 
18 #include <android-base/logging.h>
19 
20 namespace cuttlefish {
21 
ShmBuffer(ShmBuffer && other)22 ShmBuffer::ShmBuffer(ShmBuffer&& other)
23     : header_(std::move(other.header_)),
24       len_(std::move(other.len_)),
25       on_consumed_(std::move(other.on_consumed_)),
26       status_sent_(other.status_sent_) {
27   // It's now this buffer's responsibility to send the status.
28   other.status_sent_ = true;
29 }
30 
~ShmBuffer()31 ShmBuffer::~ShmBuffer() {
32   CHECK(status_sent_) << "Disposing of ShmBuffer before setting status";
33 }
34 
stream_id() const35 uint32_t ShmBuffer::stream_id() const { return header_.stream_id.as_uint32_t(); }
36 
SendStatus(AudioStatus status,uint32_t latency_bytes,uint32_t consumed_len)37 void ShmBuffer::SendStatus(AudioStatus status, uint32_t latency_bytes,
38                           uint32_t consumed_len) {
39   on_consumed_(status, latency_bytes, consumed_len);
40   status_sent_ = true;
41 }
42 
43 }  // namespace cuttlefish
44