本文整理汇总了C++中nsCircularByteBuffer::Available方法的典型用法代码示例。如果您正苦于以下问题:C++ nsCircularByteBuffer::Available方法的具体用法?C++ nsCircularByteBuffer::Available怎么用?C++ nsCircularByteBuffer::Available使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nsCircularByteBuffer
的用法示例。
在下文中一共展示了nsCircularByteBuffer::Available方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: mon
uint32_t
BufferedAudioStream::Available()
{
MonitorAutoLock mon(mMonitor);
NS_ABORT_IF_FALSE(mBuffer.Length() % mBytesPerFrame == 0, "Buffer invariant violated.");
return BytesToFrames(mBuffer.Available());
}
示例2: mon
nsresult
nsBufferedAudioStream::Write(const AudioDataValue* aBuf, uint32_t aFrames)
{
MonitorAutoLock mon(mMonitor);
if (!mCubebStream || mState == ERRORED) {
return NS_ERROR_FAILURE;
}
NS_ASSERTION(mState == INITIALIZED || mState == STARTED, "Stream write in unexpected state.");
const uint8_t* src = reinterpret_cast<const uint8_t*>(aBuf);
uint32_t bytesToCopy = aFrames * mBytesPerFrame;
while (bytesToCopy > 0) {
uint32_t available = NS_MIN(bytesToCopy, mBuffer.Available());
NS_ABORT_IF_FALSE(available % mBytesPerFrame == 0, "Must copy complete frames.");
mBuffer.AppendElements(src, available);
src += available;
bytesToCopy -= available;
if (mState != STARTED) {
int r;
{
MonitorAutoUnlock mon(mMonitor);
r = cubeb_stream_start(mCubebStream);
}
mState = r == CUBEB_OK ? STARTED : ERRORED;
}
if (mState != STARTED) {
return NS_ERROR_FAILURE;
}
if (bytesToCopy > 0) {
mon.Wait();
}
}
return NS_OK;
}