|
@@ -20,6 +20,7 @@
|
|
|
|
|
|
#include "Pool.h"
|
|
#include "Pool.h"
|
|
|
|
|
|
|
|
+#include "event/Event.h"
|
|
#include "Source.h"
|
|
#include "Source.h"
|
|
|
|
|
|
namespace love
|
|
namespace love
|
|
@@ -29,8 +30,10 @@ namespace audio
|
|
namespace openal
|
|
namespace openal
|
|
{
|
|
{
|
|
|
|
|
|
-Pool::Pool()
|
|
|
|
- : sources()
|
|
|
|
|
|
+Pool::Pool(ALCdevice *device)
|
|
|
|
+ : device(device)
|
|
|
|
+ , sources()
|
|
|
|
+ , disconnectNotified(false)
|
|
, totalSources(0)
|
|
, totalSources(0)
|
|
{
|
|
{
|
|
// Clear errors.
|
|
// Clear errors.
|
|
@@ -101,8 +104,34 @@ bool Pool::isPlaying(Source *s)
|
|
|
|
|
|
void Pool::update()
|
|
void Pool::update()
|
|
{
|
|
{
|
|
|
|
+#ifndef ALC_CONNECTED
|
|
|
|
+ constexpr ALCenum ALC_CONNECTED = 0x313;
|
|
|
|
+#endif
|
|
|
|
+
|
|
thread::Lock lock(mutex);
|
|
thread::Lock lock(mutex);
|
|
|
|
|
|
|
|
+ static bool disconnectExtSupported = alcIsExtensionPresent(device, "ALC_EXT_Disconnect") == ALC_TRUE;
|
|
|
|
+
|
|
|
|
+ // Device disconnection event
|
|
|
|
+ if (disconnectExtSupported)
|
|
|
|
+ {
|
|
|
|
+ auto eventModule = Module::getInstance<event::Event>(Module::M_EVENT);
|
|
|
|
+ if (eventModule)
|
|
|
|
+ {
|
|
|
|
+ ALCint connected;
|
|
|
|
+ alcGetIntegerv(device, ALC_CONNECTED, 1, &connected);
|
|
|
|
+
|
|
|
|
+ if (connected)
|
|
|
|
+ disconnectNotified = false;
|
|
|
|
+ else if (!disconnectNotified)
|
|
|
|
+ {
|
|
|
|
+ StrongRef<event::Message> msg(new event::Message("audiodisconnected"), Acquire::NORETAIN);
|
|
|
|
+ eventModule->push(msg);
|
|
|
|
+ disconnectNotified = true;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
std::vector<Source *> torelease;
|
|
std::vector<Source *> torelease;
|
|
|
|
|
|
for (const auto &i : playing)
|
|
for (const auto &i : playing)
|