neoGFX
Cross-platform C++ app/game engine
Loading...
Searching...
No Matches
audio_device.hpp
Go to the documentation of this file.
1// audio_device.hpp
2/*
3 neogfx C++ App/Game Engine
4 Copyright (c) 2021 Leigh Johnston. All Rights Reserved.
5
6 This program is free software: you can redistribute it and / or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
18*/
19
20#include <neogfx/neogfx.hpp>
24
25#pragma once
26
27namespace neogfx
28{
30 {
31 public:
32 audio_device_info(audio_device_id aId, audio_device_type aType, i_string const& aName, bool aIsDefault, vector<audio_data_format> const& aDataFormats);
35 public:
36 audio_device_id id() const override;
37 audio_device_type type() const override;
38 i_string const& name() const override;
39 bool is_default() const override;
40 public:
42 private:
45 string iName;
46 bool iIsDefault;
47 vector<audio_data_format> iDataFormats;
48 };
49
50 class audio_device : public reference_counted<i_audio_device>
51 {
52 public:
53 audio_device(audio_context aContext, i_audio_device_info const& aDeviceInfo, audio_data_format const& aDataFormat);
55 public:
56 i_audio_device_info const& info() const final;
57 audio_data_format const& data_format() const final;
58 public:
59 void start() final;
60 void stop() final;
61 public:
62 void play(i_audio_bitstream& aBitstream, std::chrono::duration<double> const& aDuration) final;
63 private:
64 mutable std::recursive_mutex iMutex;
66 audio_data_format iDataFormat;
67 audio_device_config iConfig;
68 audio_device_handle iHandle;
69 struct source
70 {
71 ref_ptr<i_audio_bitstream> bitstream; // todo: should be i_audio_bitstream
72 std::optional<std::chrono::steady_clock::time_point> expiryTime;
73 };
74 std::vector<source> iSources;
75 };
76}
audio_device_id id() const override
i_vector< audio_data_format > const & data_formats() const override
audio_device_info(i_audio_device_info const &aOther)
i_string const & name() const override
audio_device_info(audio_device_id aId, audio_device_type aType, i_string const &aName, bool aIsDefault, vector< audio_data_format > const &aDataFormats)
bool is_default() const override
audio_device_type type() const override
audio_data_format const & data_format() const final
void play(i_audio_bitstream &aBitstream, std::chrono::duration< double > const &aDuration) final
void start() final
audio_device(audio_context aContext, i_audio_device_info const &aDeviceInfo, audio_data_format const &aDataFormat)
i_audio_device_info const & info() const final
std::any audio_device_config
std::any audio_context
Definition i_audio.hpp:27
std::any audio_device_handle
std::any audio_device_id
Definition plf_hive.h:79