10#ifndef ZEP_AUDIO_PCM_BUFFER_WRITER_HPP_
11#define ZEP_AUDIO_PCM_BUFFER_WRITER_HPP_
17#include "../TimestampInterface.hpp"
22class PcmBufferPoolInterface;
29class PcmBufferWriter final {
45 std::int16_t* pointer, std::size_t writable_samples) noexcept
46 : pool_weak_(pool_weak),
48 writable_samples_(writable_samples) {}
56 *
this = std::move(other);
66 std::swap(pool_weak_, other.pool_weak_);
67 std::swap(pointer_, other.pointer_);
68 std::swap(writable_samples_, other.writable_samples_);
89 bool IsValid() const noexcept {
return !!pointer_; }
98 explicit operator bool() const noexcept {
return IsValid(); }
105 std::int16_t*
GetPointer() const noexcept {
return pointer_; }
141 std::weak_ptr<PcmBufferPoolInterface> pool_weak_;
142 std::int16_t* pointer_ =
nullptr;
143 std::size_t writable_samples_ = 0;
149#include "PcmBufferPoolInterface.hpp"
152 std::size_t written_samples,
157 if (
auto pool = pool_weak_.lock()) {
158 pool->FinalizeWriter(*
this, written_samples, head_timestamp);
162 writable_samples_ = 0;
std::uint64_t Rep
Integer type used to represent timestamps.
Definition TimestampInterface.hpp:25
Writer implementation of PCM buffer.
Definition PcmBufferWriter.hpp:29
bool IsValid() const noexcept
有効なバッファを保持しているか否かを取得する。
Definition PcmBufferWriter.hpp:89
void Finalize(std::size_t written_samples, TimestampInterface::Rep head_timestamp) noexcept
バッファへのデータ書き込み完了を通知する。
void Cancel() noexcept
Notify the cancellation of writing data into the buffer.
Definition PcmBufferWriter.hpp:137
PcmBufferWriter & operator=(PcmBufferWriter &&other) noexcept
PcmBufferWriterオブジェクトをムーブ代入する。
Definition PcmBufferWriter.hpp:64
~PcmBufferWriter() noexcept
PcmBufferWriterオブジェクトを破棄する。
Definition PcmBufferWriter.hpp:81
std::size_t GetWritableSamples() const noexcept
書き込める最大サンプル数を取得する。
Definition PcmBufferWriter.hpp:113
std::int16_t * GetPointer() const noexcept
管理対象バッファの先頭ポインタを取得する
Definition PcmBufferWriter.hpp:105
PcmBufferWriter() noexcept
PcmBufferWriterオブジェクトを管理対象無しでデフォルト構築する。
Definition PcmBufferWriter.hpp:35
PcmBufferWriter(PcmBufferWriter &&other) noexcept
PcmBufferWriterオブジェクトをムーブ構築する。
Definition PcmBufferWriter.hpp:55
PcmBufferWriter(const std::weak_ptr< PcmBufferPoolInterface > &pool_weak, std::int16_t *pointer, std::size_t writable_samples) noexcept
PcmBufferWriterオブジェクトを構築する。
Definition PcmBufferWriter.hpp:44
void Finalize() noexcept
Notify the completion of reading data from the buffer.
Namespace for ZEP SDK.
Definition FactoryInterface.hpp:19