47 lines
1.1 KiB
C++
Raw Normal View History

#include "config.h"
2019-07-29 19:59:48 -07:00
#include "base.h"
2019-07-29 19:59:48 -07:00
#include <atomic>
2018-11-26 23:06:49 -08:00
#include <thread>
2019-07-29 19:59:48 -07:00
#include "AL/al.h"
2019-07-29 19:59:48 -07:00
#include "alcmain.h"
#include "alexcpt.h"
2019-07-29 19:59:48 -07:00
#include "alnumeric.h"
#include "atomic.h"
bool BackendBase::reset()
2019-10-07 22:42:54 -07:00
{ throw al::backend_exception{ALC_INVALID_DEVICE, "Invalid BackendBase call"}; }
ALCenum BackendBase::captureSamples(al::byte*, ALCuint)
{ return ALC_INVALID_DEVICE; }
ALCuint BackendBase::availableSamples()
{ return 0; }
ClockLatency BackendBase::getClockLatency()
{
ClockLatency ret;
ALuint refcount;
do {
refcount = mDevice->waitForMix();
ret.ClockTime = GetDeviceClockTime(mDevice);
2018-11-19 05:04:17 -08:00
std::atomic_thread_fence(std::memory_order_acquire);
} while(refcount != ReadRef(mDevice->MixCount));
/* NOTE: The device will generally have about all but one periods filled at
* any given time during playback. Without a more accurate measurement from
* the output, this is an okay approximation.
*/
2019-09-13 12:51:16 -07:00
ret.Latency = std::max(std::chrono::seconds{mDevice->BufferSize-mDevice->UpdateSize},
std::chrono::seconds::zero());
ret.Latency /= mDevice->Frequency;
return ret;
}