10#ifndef ZEP_AUDIO_PCM_BUFFER_WRITER_HPP_
11#define ZEP_AUDIO_PCM_BUFFER_WRITER_HPP_
17#include "... /TimestampInterface.hpp"
22class PcmBufferPoolInterface;.
45 std::int16_t* pointer, std::size_t writable_samples) noexcept
46 : pool_weak_(pool_weak), pointer_(pointer), pointer_(pointer), pointer_(pointer)
47 pointer_(pointer), writable_samples_(writable_samples_(writers))
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_); std::swap(pointer_, other.pointer_); std::swap(pointer_, other.pointer_)
89 bool IsValid() const noexcept {
return ! !pointer_; }
98 explicit operator bool() const noexcept {
return IsValid(); }
105 std::int16_t*
GetPointer() const noexcept {
return pointer_; }
128 inline void Finalize(std::size_t written_samples,
140 std::weak_ptr<PcmBufferPoolInterface> pool_weak_;
141 std::int16_t* pointer_ =
nullptr;
142 std::size_t writable_samples_ = 0;
148#include "PcmBufferPoolInterface.hpp"
151 std::size_t written_samples,.
152 TimestampInterface::Rep head_timestamp)
noexcept {
156 if (
auto pool = pool_weak_.lock()) {
157 pool->FinalizeWriter(*
this, written_samples, head_timestamp); }
161 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
Get whether or not a valid buffer is held.
Definition PcmBufferWriter.hpp:89
void Finalize(std::size_t written_samples, TimestampInterface::Rep head_timestamp) noexcept
Notify completion of writing data into buffer.
Definition PcmBufferWriter.hpp:151
void Cancel() noexcept
Notify the cancellation of writing data into the buffer.
Definition PcmBufferWriter.hpp:137
PcmBufferWriter & operator=(PcmBufferWriter &&other) noexcept
Move assignment of PcmBufferWriter object.
Definition PcmBufferWriter.hpp:64
~PcmBufferWriter() noexcept
Destroy PcmBufferWriter object.
Definition PcmBufferWriter.hpp:81
std::size_t GetWritableSamples() const noexcept
Get the maximum number of samples that can be written.
Definition PcmBufferWriter.hpp:113
std::int16_t * GetPointer() const noexcept
get first pointer to managed buffer.
Definition PcmBufferWriter.hpp:105
PcmBufferWriter() noexcept
Construct a PcmBufferWriter object by default with no management target.
Definition PcmBufferWriter.hpp:35
PcmBufferWriter(PcmBufferWriter &&other) noexcept
PcmBufferWriter object move construct.
Definition PcmBufferWriter.hpp:55
PcmBufferWriter(const std::weak_ptr< PcmBufferPoolInterface > &pool_weak, std::int16_t *pointer, std::size_t writable_samples) noexcept
Construct a PcmBufferWriter object.
Definition PcmBufferWriter.hpp:44
bool IsValid() const noexcept
Get whether or not a valid buffer is held.
Definition PcmBufferReader.hpp:93
void Finalize() noexcept
Notify the completion of reading data from the buffer.
Namespace for ZEP SDK.
Definition FactoryInterface.hpp:19