2013-10-28 12:30:57 -07:00
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2019-07-29 19:59:48 -07:00
|
|
|
#include "base.h"
|
2013-10-28 12:30:57 -07:00
|
|
|
|
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"
|
2013-10-28 12:30:57 -07:00
|
|
|
|
2019-07-29 19:59:48 -07:00
|
|
|
#include "alcmain.h"
|
2019-10-07 21:37:56 -07:00
|
|
|
#include "alexcpt.h"
|
2019-07-29 19:59:48 -07:00
|
|
|
#include "alnumeric.h"
|
|
|
|
#include "atomic.h"
|
2013-10-28 12:30:57 -07:00
|
|
|
|
|
|
|
|
2019-09-15 09:50:28 -07:00
|
|
|
bool BackendBase::reset()
|
2019-10-07 22:42:54 -07:00
|
|
|
{ throw al::backend_exception{ALC_INVALID_DEVICE, "Invalid BackendBase call"}; }
|
2013-10-29 15:07:13 -07:00
|
|
|
|
2019-09-15 09:50:28 -07:00
|
|
|
ALCenum BackendBase::captureSamples(al::byte*, ALCuint)
|
2018-12-28 22:56:20 -08:00
|
|
|
{ return ALC_INVALID_DEVICE; }
|
2013-10-29 15:07:13 -07:00
|
|
|
|
2018-12-28 22:56:20 -08:00
|
|
|
ALCuint BackendBase::availableSamples()
|
|
|
|
{ return 0; }
|
2013-10-29 15:07:13 -07:00
|
|
|
|
2018-12-28 22:56:20 -08:00
|
|
|
ClockLatency BackendBase::getClockLatency()
|
2013-10-28 12:30:57 -07:00
|
|
|
{
|
2016-05-28 00:43:14 -07:00
|
|
|
ClockLatency ret;
|
|
|
|
|
2018-12-28 22:56:20 -08:00
|
|
|
ALuint refcount;
|
2017-02-28 03:50:42 -08:00
|
|
|
do {
|
2020-03-03 20:32:44 -08:00
|
|
|
refcount = mDevice->waitForMix();
|
2018-12-28 22:56:20 -08:00
|
|
|
ret.ClockTime = GetDeviceClockTime(mDevice);
|
2018-11-19 05:04:17 -08:00
|
|
|
std::atomic_thread_fence(std::memory_order_acquire);
|
2019-08-01 13:28:53 -07:00
|
|
|
} while(refcount != ReadRef(mDevice->MixCount));
|
2017-02-28 03:50:42 -08:00
|
|
|
|
2017-02-18 16:55:48 -08:00
|
|
|
/* 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());
|
2018-12-28 22:56:20 -08:00
|
|
|
ret.Latency /= mDevice->Frequency;
|
2016-05-28 00:43:14 -07:00
|
|
|
|
|
|
|
return ret;
|
2013-10-28 12:30:57 -07:00
|
|
|
}
|