Support auto-starting streams

This commit is contained in:
Nikita Lisitsa 2020-09-21 12:10:22 +03:00
parent 313f8bbf80
commit ec4db5c6cb
2 changed files with 5 additions and 3 deletions

View file

@ -21,7 +21,7 @@ namespace psemek::audio
std::shared_ptr<sample> load_raw(std::int16_t const * data, std::size_t sample_count, bool copy = true);
std::shared_ptr<sample> load_wav(char const * data, std::size_t size);
std::shared_ptr<stream> play(std::shared_ptr<sample> s, bool loop = false);
std::shared_ptr<stream> play(std::shared_ptr<sample> s, bool start = true, bool loop = false);
private:
struct impl;

View file

@ -274,9 +274,11 @@ namespace psemek::audio
return std::make_shared<sample_impl>(chunk);
}
std::shared_ptr<stream> engine::play(std::shared_ptr<sample> s, bool loop)
std::shared_ptr<stream> engine::play(std::shared_ptr<sample> s, bool start, bool loop)
{
return impl().play(std::move(s), loop);
auto str = impl().play(std::move(s), loop);
if (start) str->start();
return str;
}
}