MCPcopy Create free account
hub / github.com/SFML/SFML / AudioResource

Method AudioResource

src/SFML/Audio/AudioResource.cpp:38–60  ·  view source on GitHub ↗

///////////////////////////////////////////////////////

Source from the content-addressed store, hash-verified

36{
37////////////////////////////////////////////////////////////
38AudioResource::AudioResource() :
39 m_device(
40 []
41 {
42 // Ensure we only ever create a single instance of an
43 // AudioDevice that is shared between all AudioResources
44 static std::mutex mutex;
45 static std::weak_ptr<priv::AudioDevice> weakAudioDevice;
46
47 const std::lock_guard lock(mutex);
48
49 auto audioDevice = weakAudioDevice.lock();
50
51 if (audioDevice == nullptr)
52 {
53 audioDevice = std::make_shared<priv::AudioDevice>();
54 weakAudioDevice = audioDevice;
55 }
56
57 return audioDevice;
58 }())
59{
60}
61
62} // namespace sf

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected