本文整理汇总了C++中FixedSizeQueue::push方法的典型用法代码示例。如果您正苦于以下问题:C++ FixedSizeQueue::push方法的具体用法?C++ FixedSizeQueue::push怎么用?C++ FixedSizeQueue::push使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FixedSizeQueue
的用法示例。
在下文中一共展示了FixedSizeQueue::push方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: __AudioUpdate
// Mix samples from the various audio channels into a single sample queue.
// This single sample queue is where __AudioMix should read from. If the sample queue is full, we should
// just sleep the main emulator thread a little.
void __AudioUpdate()
{
// Audio throttle doesn't really work on the PSP since the mixing intervals are so closely tied
// to the CPU. Much better to throttle the frame rate on frame display and just throw away audio
// if the buffer somehow gets full.
s32 mixBuffer[hwBlockSize * 2];
memset(mixBuffer, 0, sizeof(mixBuffer));
for (int i = 0; i < PSP_AUDIO_CHANNEL_MAX; i++)
{
if (!chans[i].reserved)
continue;
if (!chans[i].sampleQueue.size()) {
// ERROR_LOG(HLE, "No queued samples, skipping channel %i", i);
continue;
}
for (int s = 0; s < hwBlockSize; s++)
{
if (chans[i].sampleQueue.size() >= 2)
{
s16 sampleL = chans[i].sampleQueue.pop_front();
s16 sampleR = chans[i].sampleQueue.pop_front();
mixBuffer[s * 2 + 0] += sampleL;
mixBuffer[s * 2 + 1] += sampleR;
}
else
{
ERROR_LOG(HLE, "Channel %i buffer underrun at %i of %i", i, s, hwBlockSize);
break;
}
}
if (chans[i].sampleQueue.size() < chans[i].sampleCount * 2 * chanQueueMinSizeFactor)
{
// Ask the thread to send more samples until next time, queue is being drained.
if (chans[i].waitingThread) {
SceUID waitingThread = chans[i].waitingThread;
chans[i].waitingThread = 0;
// DEBUG_LOG(HLE, "Woke thread %i for some buffer filling", waitingThread);
__KernelResumeThreadFromWait(waitingThread, chans[i].sampleCount);
}
}
}
if (g_Config.bEnableSound) {
section.lock();
if (outAudioQueue.room() >= hwBlockSize * 2) {
// Push the mixed samples onto the output audio queue.
for (int i = 0; i < hwBlockSize; i++) {
s32 sampleL = mixBuffer[i * 2 + 0] >> 2; // TODO - what factor?
s32 sampleR = mixBuffer[i * 2 + 1] >> 2;
outAudioQueue.push((s16)sampleL);
outAudioQueue.push((s16)sampleR);
}
} else {
示例2: __AudioUpdate
// Mix samples from the various audio channels into a single sample queue.
// This single sample queue is where __AudioMix should read from. If the sample queue is full, we should
// just sleep the main emulator thread a little.
void __AudioUpdate()
{
// Audio throttle doesn't really work on the PSP since the mixing intervals are so closely tied
// to the CPU. Much better to throttle the frame rate on frame display and just throw away audio
// if the buffer somehow gets full.
s32 mixBuffer[hwBlockSize * 2];
memset(mixBuffer, 0, sizeof(mixBuffer));
for (u32 i = 0; i < PSP_AUDIO_CHANNEL_MAX + 1; i++)
{
if (!chans[i].reserved)
continue;
__AudioWakeThreads(chans[i], hwBlockSize);
if (!chans[i].sampleQueue.size()) {
// ERROR_LOG(HLE, "No queued samples, skipping channel %i", i);
continue;
}
for (int s = 0; s < hwBlockSize; s++)
{
if (chans[i].sampleQueue.size() >= 2)
{
s16 sampleL = chans[i].sampleQueue.pop_front();
s16 sampleR = chans[i].sampleQueue.pop_front();
mixBuffer[s * 2 + 0] += sampleL;
mixBuffer[s * 2 + 1] += sampleR;
}
else
{
ERROR_LOG(HLE, "Channel %i buffer underrun at %i of %i", i, s, hwBlockSize);
break;
}
}
}
if (g_Config.bEnableSound) {
section.lock();
if (outAudioQueue.room() >= hwBlockSize * 2) {
// Push the mixed samples onto the output audio queue.
for (int i = 0; i < hwBlockSize; i++) {
s16 sampleL = clamp_s16(mixBuffer[i * 2 + 0]);
s16 sampleR = clamp_s16(mixBuffer[i * 2 + 1]);
outAudioQueue.push((s16)sampleL);
outAudioQueue.push((s16)sampleR);
}
} else {
// This happens quite a lot. There's still something slightly off
// about the amount of audio we produce.
DEBUG_LOG(HLE, "Audio outbuffer overrun! room = %i / %i", outAudioQueue.room(), (u32)outAudioQueue.capacity());
}
section.unlock();
}
}