Support auto-starting streams
This commit is contained in:
parent
313f8bbf80
commit
ec4db5c6cb
2 changed files with 5 additions and 3 deletions
|
|
@ -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_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<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:
|
private:
|
||||||
struct impl;
|
struct impl;
|
||||||
|
|
|
||||||
|
|
@ -274,9 +274,11 @@ namespace psemek::audio
|
||||||
return std::make_shared<sample_impl>(chunk);
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue