Blender V5.3
sound_reader_cache.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2026 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#pragma once
10
11#if defined(WITH_AUDASPACE)
12
13# include <memory>
14
15# include "BLI_utility_mixins.hh"
16
17namespace aud {
18class IReader;
19class ISound;
20} // namespace aud
21
22namespace blender::bke {
23
24struct SoundReaderCacheState;
25
26class SoundReaderCache;
27
29class SoundReaderLease : NonCopyable {
30 private:
35 std::shared_ptr<SoundReaderCacheState> state_;
36 std::shared_ptr<aud::IReader> reader_;
37
38 SoundReaderLease(std::shared_ptr<SoundReaderCacheState> state,
39 std::shared_ptr<aud::IReader> reader);
40 void release() noexcept;
41
42 friend SoundReaderCache;
43
44 public:
45 SoundReaderLease() = default;
46 ~SoundReaderLease();
47
48 SoundReaderLease(SoundReaderLease &&other) noexcept;
49 SoundReaderLease &operator=(SoundReaderLease &&other) noexcept;
50
51 explicit operator bool() const;
52 aud::IReader *operator->() const;
53
59 void discard() noexcept;
60};
61
67class SoundReaderCache : NonCopyable {
68 private:
69 std::shared_ptr<SoundReaderCacheState> state_;
70
71 public:
72 explicit SoundReaderCache(std::shared_ptr<aud::ISound> sound);
73
75 SoundReaderLease acquire();
76};
77
78} // namespace blender::bke
79
80#endif
const int state