10#ifndef ZEP_AUDIO_PCM_BUFFER_READER_HPP_
11#define ZEP_AUDIO_PCM_BUFFER_READER_HPP_
17#include "../TimestampInterface.hpp"
22class PcmBufferPoolInterface;
29class PcmBufferReader final {
46 std::int16_t* pointer, std::size_t readable_samples,
48 : pool_weak_(pool_weak),
50 readable_samples_(readable_samples),
51 head_timestamp_(head_timestamp) {}
59 *
this = std::move(other);
69 std::swap(pool_weak_, other.pool_weak_);
70 std::swap(pointer_, other.pointer_);
71 std::swap(readable_samples_, other.readable_samples_);
72 std::swap(head_timestamp_, other.head_timestamp_);
93 bool IsValid() const noexcept {
return !!pointer_; }
102 explicit operator bool() const noexcept {
return IsValid(); }
109 const std::int16_t*
GetPointer() const noexcept {
return pointer_; }
123 return head_timestamp_;
136 const std::int16_t* pointer_ =
nullptr;
137 std::
size_t readable_samples_ = 0;
144#include "PcmBufferPoolInterface.hpp"
150 if (
auto pool = pool_weak_.lock()) {
151 pool->FinalizeReader(*
this);
155 readable_samples_ = 0;
Interface to timestamp management functions.
Definition TimestampInterface.hpp:20
std::uint64_t Rep
Integer type used to represent timestamps.
Definition TimestampInterface.hpp:25
PCM buffer pool interface.
Definition PcmBufferPoolInterface.hpp:26
Reader implementation of PCM buffer.
Definition PcmBufferReader.hpp:29
~PcmBufferReader() noexcept
PcmBufferReaderオブジェクトを破棄する。
Definition PcmBufferReader.hpp:85
TimestampInterface::Rep GetHeadTimestamp() const noexcept
先頭のタイムスタンプを取得する。
Definition PcmBufferReader.hpp:122
bool IsValid() const noexcept
有効なバッファを保持しているか否かを取得する。
Definition PcmBufferReader.hpp:93
std::size_t GetReadableSamples() const noexcept
有効なサンプル数を取得する。
Definition PcmBufferReader.hpp:117
void Finalize() noexcept
バッファからのデータ読み込み完了を通知する。
Definition PcmBufferReader.hpp:146
const std::int16_t * GetPointer() const noexcept
管理対象バッファの先頭ポインタを取得する。
Definition PcmBufferReader.hpp:109
PcmBufferReader(const std::weak_ptr< PcmBufferPoolInterface > &pool_weak, std::int16_t *pointer, std::size_t readable_samples, TimestampInterface::Rep head_timestamp) noexcept
PcmBufferReaderオブジェクトを構築する。
Definition PcmBufferReader.hpp:45
PcmBufferReader & operator=(PcmBufferReader &&other) noexcept
PcmBufferReaderオブジェクトをムーブ代入する。
Definition PcmBufferReader.hpp:67
PcmBufferReader() noexcept
PcmBufferReaderオブジェクトを管理対象無しでデフォルト構築する。
Definition PcmBufferReader.hpp:35
PcmBufferReader(PcmBufferReader &&other) noexcept
PcmBufferReaderオブジェクトをムーブ構築する。
Definition PcmBufferReader.hpp:58
Namespace for ZEP SDK.
Definition FactoryInterface.hpp:19