Audaspace 1.5.0
A high level audio library.
Loading...
Searching...
No Matches
OpenCloseDevice.h
Go to the documentation of this file.
1/*******************************************************************************
2 * Copyright 2009-2024 Jörg Müller
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 ******************************************************************************/
16
17#pragma once
18
24
25#include <thread>
26#include <chrono>
27
29
31
35class AUD_PLUGIN_API OpenCloseDevice : public SoftwareDevice
36{
37private:
41 bool m_device_opened{false};
42
46 bool m_playing{false};
47
51 bool m_delayed_close_finished{false};
52
56 std::thread m_delayed_close_thread;
57
61 std::chrono::milliseconds m_device_close_delay{std::chrono::milliseconds(10000)};
62
66 std::chrono::time_point<std::chrono::steady_clock> m_playback_stopped_time;
67
71 void closeAfterDelay();
72
76 AUD_LOCAL virtual void start() = 0;
77
81 AUD_LOCAL virtual void stop() = 0;
82
86 AUD_LOCAL virtual void open() = 0;
87
91 AUD_LOCAL virtual void close() = 0;
92
93 // delete copy constructor and operator=
94 OpenCloseDevice(const OpenCloseDevice&) = delete;
95 OpenCloseDevice& operator=(const OpenCloseDevice&) = delete;
96
97protected:
98 OpenCloseDevice() = default;
99
100 virtual void playing(bool playing);
101};
102
#define AUD_NAMESPACE_END
Closes the audaspace namespace aud.
Definition Audaspace.h:119
#define AUD_LOCAL
Used for hiding symbols from export in the shared library.
Definition Audaspace.h:80
#define AUD_NAMESPACE_BEGIN
Opens the audaspace namespace aud.
Definition Audaspace.h:116
#define AUD_PLUGIN_API
Used for exporting symbols in the shared library.
Definition Audaspace.h:94
The SoftwareDevice class.
virtual void playing(bool playing)
This function tells the device, to start or pause playback.
SoftwareDevice()
Empty default constructor.