static void
TestPrintSignedLeast32()
{
  PoisonOutput();
  sprintf(output, "%" PRIdLEAST32, int_least32_t(-342178));
  MOZ_RELEASE_ASSERT(!strcmp(output, "-342178"));

  PoisonOutput();
  sprintf(output, "%" PRIiLEAST32, int_least32_t(5719283));
  MOZ_RELEASE_ASSERT(!strcmp(output, "5719283"));
}
Exemple #2
0
void Mixer::renderSamples()
{
    /* extract buffer info now that the SID is updated.
     * clock() may update bufferpos.
     * NB: if chip2 exists, its bufferpos is identical to chip1's. */
    const int sampleCount = m_chips.front()->bufferpos();
    const unsigned int channels = m_stereo ? 2 : 1;

    short *buf = m_sampleBuffer + m_sampleIndex;

    int i = 0;
    while (i < sampleCount && m_sampleIndex < m_sampleCount)
    {
        const int dither = triangularDithering();

        for (size_t k = 0; k < m_buffers.size(); k++)
        {
            m_iSamples[k] = (int_least32_t(m_buffers[k][i]) * m_volume[k] + dither) / VOLUME_MAX;
        }

        for (unsigned int k = 0; k < channels; k++)
        {
            *buf++ = (m_mix[k])(&m_iSamples.front());
            m_sampleIndex++;
        }
        ++i;
    }

    /* move the unhandled data to start of buffer, if any. */
    const int samplesLeft = sampleCount - i;
    std::for_each(m_buffers.begin(), m_buffers.end(), bufferMove(i, samplesLeft));
    std::for_each(m_chips.begin(), m_chips.end(), bufferPos(samplesLeft));
}