Ejemplo n.º 1
0
static void BufInsert (
    const char* s, int index, char**& buf, int& bufsize, int& count
) {
    char** spot;
    index = (index < 0) ? count : index;

    if (index < count) {
        BufCheck(buf, bufsize, count, count+1);
        spot = &buf[index];
        Memory::copy(spot, spot+1, (count - index)*sizeof(char*));

    } else {
        BufCheck(buf, bufsize, count, index);
        spot = &buf[index];
    }
    *spot = (char*)s;
    ++count;
}
Ejemplo n.º 2
0
static DWORD WINAPI WaveOutThread(void* Arg)
{
#ifdef NDEBUG
    UINT32 RetVal;
#endif
    UINT16 CurBuf;
    WAVE_16BS* TempBuf;
    UINT32 WrtSmpls;
    //char TestStr[0x80];
    bool DidBuffer;	// a buffer was processed

    hWaveOutThread = GetCurrentThread();
#ifdef NDEBUG
    RetVal = SetThreadPriority(hWaveOutThread, THREAD_PRIORITY_TIME_CRITICAL);
    if (! RetVal)
    {
        // Error by setting priority
        // try a lower priority, because too low priorities cause sound stuttering
        RetVal = SetThreadPriority(hWaveOutThread, THREAD_PRIORITY_HIGHEST);
    }
#endif

    BlocksSent = 0x00;
    BlocksPlayed = 0x00;
    while(! CloseThread)
    {
        while(PauseThread && ! CloseThread && ! (StreamPause && DidBuffer))
        {
            ThreadPauseConfrm = true;
            Sleep(1);
        }
        if (CloseThread)
            break;

        BufCheck();
        DidBuffer = false;
        for (CurBuf = 0x00; CurBuf < AUDIOBUFFERU; CurBuf ++)
        {
            if (WaveHdrOut[CurBuf].dwFlags & WHDR_DONE)
            {
                TempBuf = (WAVE_16BS*)WaveHdrOut[CurBuf].lpData;

                if (WaveHdrOut[CurBuf].dwUser & 0x01)
                    BlocksPlayed ++;
                else
                    WaveHdrOut[CurBuf].dwUser |= 0x01;

                WrtSmpls = FillBuffer(TempBuf, SMPL_P_BUFFER);

                WaveHdrOut[CurBuf].dwBufferLength = WrtSmpls * SAMPLESIZE;
                waveOutWrite(hWaveOut, &WaveHdrOut[CurBuf], sizeof(WAVEHDR));
                if (SoundLog && hFile != NULL)
                    SaveFile(WrtSmpls, TempBuf);

                DidBuffer = true;
                BlocksSent ++;
                BufCheck();
                //CurBuf = 0x00;
                //break;
            }
            if (CloseThread)
                break;
        }
        Sleep(1);
    }

    hWaveOutThread = NULL;
    return 0x00000000;
}