Add audio::mixer::stream_count()
This commit is contained in:
parent
44672ac1fd
commit
8b5c35f89a
2 changed files with 10 additions and 0 deletions
|
|
@ -13,6 +13,8 @@ namespace psemek::audio
|
|||
: stream
|
||||
{
|
||||
virtual channel_ptr add(stream_ptr stream) = 0;
|
||||
|
||||
virtual std::size_t stream_count() const = 0;
|
||||
};
|
||||
|
||||
using mixer_ptr = std::shared_ptr<mixer>;
|
||||
|
|
|
|||
|
|
@ -17,6 +17,11 @@ namespace psemek::audio
|
|||
{
|
||||
channel_ptr add(stream_ptr stream) override;
|
||||
|
||||
std::size_t stream_count() const override
|
||||
{
|
||||
return stream_count_.load();
|
||||
}
|
||||
|
||||
std::size_t read(util::span<float> samples) override;
|
||||
|
||||
std::optional<std::size_t> length() const override
|
||||
|
|
@ -39,6 +44,7 @@ namespace psemek::audio
|
|||
std::vector<channel_ptr> new_channels_;
|
||||
|
||||
std::atomic<std::size_t> played_{0};
|
||||
std::atomic<std::size_t> stream_count_{0};
|
||||
};
|
||||
|
||||
channel_ptr mixer_impl::add(stream_ptr stream)
|
||||
|
|
@ -89,6 +95,8 @@ namespace psemek::audio
|
|||
alive_channels_.push_back(std::move(ch));
|
||||
}
|
||||
|
||||
stream_count_ = alive_channels_.size();
|
||||
|
||||
std::swap(channels_, alive_channels_);
|
||||
alive_channels_.clear();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue