VOID wavestreamProcess(WAVESTREAM *wsPtr) {

 STREAM_BUFFER *sbPtr;
 STREAM *streamPtr = wsPtr->streamPtr;
 USHORT streamMode = wsPtr->streamPtr->streamType & STREAM_RW_MODE;

 wsPtr->bytesProcessed = abUpdate(1, &wsPtr->waPtr->ab);  // get 'final' stream byte consumed/produced count

 if (streamMode == STREAM_WRITE) {           // playback

// even undoing this only brought it down to 58%!
// so pretty-much rem'ed out all of the irq (just resets int and bye!)...it runs at 58%
// don't know what the hell's going on

    if (sbNotEmpty(&streamPtr->sbaProc)) {   // if buffer in proc queue...
       FillAudioBuffer(wsPtr);               // keep audio buffer full
    }

    // if there are buffers that have been completely written to the audio buffer
    // check the first one on the done queue to see if the hardware has consumed it
    // and if so return it

// rem'ing out the return-buffer stuff below only went from 66% down to 60% or so...hm
// now checking the FillAudioBuffer section above (rem'ing it out--will get back tomorrow
// in any case) ... if that's not it, have to check ssm_idc stuff next


// should see about doing this out of interrupt context, via arm context hook (18-Feb-99)
// since it calls back to SHDD and ints are enabled there

    if (sbNotEmpty(&streamPtr->sbaDone)) {   
       sbPtr = sbHead(&streamPtr->sbaDone);
       if ((wsPtr->bytesProcessed + wsPtr->waveConfig.bytesPerIRQ) >= sbPtr->bufferDonePos) {
          streamReturnBuffer(streamPtr);
       }
    }

 }
 else { // STREAM_READ capture
    ReadAudioBuffer(wsPtr);
    while(sbNotEmpty(&streamPtr->sbaDone)) {
       streamReturnBuffer(streamPtr);
    }
 }

// streamProcessEvents(streamPtr); // stub routine for now

 return;
}
static VOID ResetAudioBuffer(WAVESTREAM *wsPtr) {

 AUDIOBUFFER *abPtr = &wsPtr->waPtr->ab;
 USHORT streamMode = wsPtr->streamPtr->streamType & STREAM_RW_MODE;

 abReset(streamMode, abPtr);            // reset audiobuffer
 if (streamMode == STREAM_WRITE) {
    FillAudioBuffer(wsPtr);
 }
 else {
    abFill(wsPtr->waveConfig.silence, abPtr);
 }

 return;
}
Beispiel #3
0
void wxSoundBackendSDL::FillAudioBuffer(Uint8 *stream, int len)
{
    if (m_playing)
    {
        // finished playing the sample
        if (m_pos == m_data->m_dataBytes)
        {
            m_playing = false;
            wxSoundBackendSDLNotification event;
            m_evtHandler->AddPendingEvent(event);
        }
        // still something to play
        else
        {
            unsigned size = ((len + m_pos) < m_data->m_dataBytes) ?
                            len :
                            (m_data->m_dataBytes - m_pos);
            memcpy(stream, m_data->m_data + m_pos, size);
            m_pos += size;
            len -= size;
            stream += size;
        }
    }
    // the sample doesn't play, fill the buffer with silence and wait for
    // the main thread to shut the playback down:
    if (len > 0)
    {
        if (m_loop)
        {
            m_pos = 0;
            FillAudioBuffer(stream, len);
            return;
        }
        else
        {
            memset(stream, m_spec.silence, len);
        }
    }
}