static pascal void
MyTimerProc(QElemPtr time)
{
    lowResMSecs = ioMicroMSecs();
    PrimeTime((QElemPtr)time, LOW_RES_TICK_MSECS);
    return;
}
int snd_Start(int frameCount, int samplesPerSec, int stereo, int semaIndex)
{
    Synchronized<es::Monitor*> method(monitorPlayState);

    if (!gSoundOutput)
    {
        return false;
    }

    int bytesPerFrame;
    int bufferBytes;

    bytesPerFrame = stereo ? 2 * BYTES_PER_SAMPLE : BYTES_PER_SAMPLE;
    bufferBytes   = ((frameCount * bytesPerFrame) / 8) * 8;

    if (playState.open)
    {
        // still open from last time; clean up before continuing
        snd_Stop();
    }

    int chan = (stereo ? 2 : 1);

    Handle<es::AudioFormat> audio(gSoundOutput);
    audio->setBitsPerSample(16);
    audio->setChannels(chan);
    audio->setSamplingRate(samplesPerSec);

    playState.bufSizeInBytes = bufferBytes * 2;
    playState.buffer = new u8[playState.bufSizeInBytes];
    if (!playState.buffer)
    {
        return false;
    }
    memset(playState.buffer, 0, playState.bufSizeInBytes);

    playState.open           = false;  // set to true if successful
    playState.stereo         = stereo;
    playState.frameCount     = bufferBytes / bytesPerFrame;
    playState.sampleRate     = samplesPerSec;
    playState.lastFlipTime   = ioMicroMSecs();
    playState.playSemaIndex  = semaIndex;
    playState.playing        = true;
    playState.head = playState.tail = playState.buffer;
    playState.done           = false;
    playState.open = true;
    monitorPlayState->notifyAll();

    return true;
}
Beispiel #3
0
sqInt ioMSecs(void) {
    //API Documented
    return ioMicroMSecs();
}
int
ioLowResMSecs(void) { return ioMicroMSecs(); }
int ioMSecs() {
    return ioMicroMSecs();
}
long ioMSecs() { return ioMicroMSecs(); }