Ejemplo n.º 1
0
static void winsnd_set_level(MSSndCard *card, MSSndCardMixerElem e, int percent)
{
	WinSndData *d=(WinSndData*)card->data;
    MMRESULT mr = NOERROR;
    DWORD dwVolume = 0xFFFF;
    dwVolume = ((0xFFFF) * percent) / 100;

	if (d->mixdev==NULL) return;
	switch(e){
		case MS_SND_CARD_MASTER:
            mr = waveOutSetVolume(d->waveoutdev, dwVolume);
	        if (mr != MMSYSERR_NOERROR)
	        {
                ms_warning("Failed to set master volume. (waveOutSetVolume:0x%i)", mr);
                return;
	        }
            return;
        break;
#if 0
        case MS_SND_CARD_CAPTURE:
			wincmd=SOUND_MIXER_IGAIN;
		break;
		case MS_SND_CARD_PLAYBACK:
			wincmd=SOUND_MIXER_PCM;
		break;
#endif
        default:
			ms_warning("winsnd_card_set_level: unsupported command.");
			return;
	}
}
Ejemplo n.º 2
0
static BOOL rdpsnd_winmm_open(rdpsndDevicePlugin* device, AUDIO_FORMAT* format, int latency)
{
	MMRESULT mmResult;
	rdpsndWinmmPlugin* winmm = (rdpsndWinmmPlugin*) device;

	if (winmm->hWaveOut)
		return TRUE;

	rdpsnd_winmm_set_format(device, format, latency);
	freerdp_dsp_context_reset_adpcm(winmm->dsp_context);

	mmResult = waveOutOpen(&winmm->hWaveOut, WAVE_MAPPER, &winmm->format,
			(DWORD_PTR) rdpsnd_winmm_callback_function, (DWORD_PTR) winmm, CALLBACK_FUNCTION);

	if (mmResult != MMSYSERR_NOERROR)
	{
		WLog_ERR(TAG,  "waveOutOpen failed: %"PRIu32"", mmResult);
		return FALSE;
	}

	mmResult = waveOutSetVolume(winmm->hWaveOut, winmm->volume);

	if (mmResult != MMSYSERR_NOERROR)
	{
		WLog_ERR(TAG,  "waveOutSetVolume failed: %"PRIu32"", mmResult);
		return FALSE;
	}

	return TRUE;
}
Ejemplo n.º 3
0
void W95_PlayStart(MADDriverRec *WinMADDriver)
{
	waveOutSetVolume(0,0xffffffff);
	
	WinMADDriver->WaveOutHdr.lpData= (char*) WinMADDriver->mydata;
	WinMADDriver->WaveOutHdr.dwBufferLength = WinMADDriver->WIN95BUFFERSIZE;
	WinMADDriver->WaveOutHdr.dwFlags = WHDR_BEGINLOOP | WHDR_ENDLOOP;
	WinMADDriver->WaveOutHdr.dwLoops = 0xffffffff;
	WinMADDriver->WaveOutHdr.dwUser = 0;
	waveOutPrepareHeader(WinMADDriver->hWaveOut, &WinMADDriver->WaveOutHdr, sizeof(WAVEHDR));
	waveOutWrite(WinMADDriver->hWaveOut, &WinMADDriver->WaveOutHdr, sizeof(WAVEHDR));
	WinMADDriver->mydma = (char*) WinMADDriver->mydata;
	
	WinMADDriver->MICROBUFState = 0;
	
	timeBeginPeriod(20);	/* set the minimum resolution */
	
	WinMADDriver->gwID = timeSetEvent(40,								/* how often                 */
									  40,								/* timer resolution          */
									  TimeProc,							/* callback function         */
									  (unsigned long)  WinMADDriver,	/* info to pass to callback  */
									  TIME_PERIODIC);					/* oneshot or periodic?      */
							  
							  
	//////
}
void __fastcall TMainForm::tbRightVolumeChange(TObject *Sender)
{
    unsigned long      v ,t;
    t = tbRightVolume->Max-tbRightVolume->Position;
    waveOutGetVolume(0 ,&v);
    v = v & 0x0000ffff | (t<<24);
    waveOutSetVolume(0 ,v);
}
Ejemplo n.º 5
0
static	DWORD	wodSetVolume(UINT wDevID, WAVEMAPDATA* wom, DWORD vol)
{
    TRACE("(%04x %p %08x)\n",wDevID, wom, vol);

    if (WAVEMAP_IsData(wom))
	return waveOutSetVolume(wom->u.out.hInnerWave, vol);
    return MMSYSERR_NOERROR;
}
Ejemplo n.º 6
0
static void set_vol_pan(WAVContext *ctx)
{
	WORD rV, lV;
	/*in wave, volume & pan are specified as a DWORD. LOW word is LEFT channel, HIGH is right - iPaq doesn't support that*/
	lV = (WORD) (ctx->vol * ctx->pan / 100);
	rV = (WORD) (ctx->vol * (100 - ctx->pan) / 100);

	waveOutSetVolume(ctx->hwo, MAKELONG(lV, rV) );
}
Ejemplo n.º 7
0
void CPlayer::SetVolume(DWORD dwVolume, BOOL bSysVolume)
{
	if (bSysVolume) {
		waveOutSetVolume(NULL, dwVolume);
	}
	else {
		m_Output.SetVolume(dwVolume);
	}
}
Ejemplo n.º 8
0
static void rdpsnd_winmm_set_volume(rdpsndDevicePlugin* device, UINT32 value)
{
	rdpsndWinmmPlugin* winmm = (rdpsndWinmmPlugin*) device;

	if (!winmm->hWaveOut)
		return;

	waveOutSetVolume(winmm->hWaveOut, value);
}
Ejemplo n.º 9
0
BOOL CAudioCtrl::SetPlayVolume(DWORD dwVolume)
{
    if (m_eStatus == ENUM_STATUS_PLAYING)
    {
        if(waveOutSetVolume( m_hPlay, dwVolume ) == MMSYSERR_NOERROR)
            return TRUE;
	}
    return FALSE;
}
Ejemplo n.º 10
0
void WaveOut::SetVolume(double volume){
    if(this->waveHandle){
        DWORD newVolume = (DWORD)(volume*65535.0);
        newVolume   += newVolume*65536;

        waveOutSetVolume(this->waveHandle,newVolume); 
    }
    this->currentVolume = volume;
}
//---------------------------------------------------------------------------
void __fastcall TMainForm::tbMainVolumeChange(TObject *Sender)
{
    unsigned long      v ,t;
    t = tbMainVolume->Position;
    tbLeftVolume->Position = tbMainVolume->Max-t;
    tbRightVolume->Position = tbMainVolume->Max-t;
    v = (t<<8) | (t<<24);
    waveOutSetVolume(0 ,v);
}
Ejemplo n.º 12
0
static void winsnd_stop_w(MSSndCard *card){
	WinSndData *d=(WinSndData*)card->data;
	d->write_started=FALSE;
	if (d->read_started==FALSE){
		ms_thread_join(d->thread,NULL);
	}
#ifdef CONTROLVOLUME
	waveOutSetVolume(d->waveoutdev, d->dwOldVolume);
#endif
}
Ejemplo n.º 13
0
void Px_SetPCMOutputVolume( PxMixer *mixer, PxVolume volume )
{
  MMRESULT result;
  PxInfo *info = (PxInfo *)mixer;

  result = waveOutSetVolume(info->muxID, MAKELONG(volume*0xFFFF, volume*0xFFFF));

  if (result != MMSYSERR_NOERROR)
      return;
}
Ejemplo n.º 14
0
	MMRESULT TinyWaveOut::SetVolume(DWORD dwVolume)
	{
		MMRESULT hRes = waveOutSetVolume(hWaveOut, dwVolume);
		if (hRes != MMSYSERR_NOERROR)
		{
			waveOutClose(hWaveOut);
			hWaveOut = NULL;
		}
		return hRes;
	}
uint8_t  win32AudioDevice::setVolume(int volume)
{
    DWORD value;
    value=0xffff;
    value*=volume;
    value/=10;
    value=value+(value<<16);
    waveOutSetVolume(myDevice,value);
    return 1;
}
Ejemplo n.º 16
0
static void killsystem2(void)
{
	MSG msg;

	stopsample();

	pcmwf.wf.wFormatTag=WAVE_FORMAT_PCM;
	pcmwf.wf.nChannels=1;
	pcmwf.wf.nSamplesPerSec=11025L;
	pcmwf.wf.nAvgBytesPerSec=11025L;
	pcmwf.wf.nBlockAlign=1;
	pcmwf.wBitsPerSample=8;
	nosound=waveOutOpen(&hwo,WAVE_MAPPER,(WAVEFORMAT *)&pcmwf,NULL,NULL,NULL);
	if (!nosound)
	{
		waveOutGetID(hwo,&nosound);
		waveOutSetVolume(nosound,0);
		waveOutReset(hwo);
		waveOutClose(hwo);
	    	nosound=1;
	}

	playsample(&silence,1L,11025L);
	stopsample();

	SelectObject(hdcm,holdbrush);
	SelectObject(hdcm,holdpen);
	DeleteObject(hbrush);
	DeleteObject(hpen);

	SelectObject(hdcm,holdbitmap);
	SelectObject(hdcm2,holdbitmap2);
	DeleteObject(hcharbm);
	DeleteObject(hecran[0]);
	DeleteObject(hecran[1]);
	DeleteDC(hdcm);
	DeleteDC(hdcm2);


	PostQuitMessage(0);

	killcursor();

	while(GetMessage(&msg, NULL, 0, 0))
	{
		TranslateMessage(&msg);
		DispatchMessage(&msg);
	}

	freebloc(&cursorbak);
	freebloc(&cursorbob);

/*	exit(0);*/
	longjmp(jmpb,1);
}
uint8_t  win32AudioDevice::setVolume(int volume) 
{
	uint32_t value;

	value = (0xffff * volume) / 100;
	value = value + (value << 16);

	waveOutSetVolume(myDevice, value);

	return 1;
}
Ejemplo n.º 18
0
static BOOL rdpsnd_winmm_set_volume(rdpsndDevicePlugin* device, UINT32 value)
{
	rdpsndWinmmPlugin* winmm = (rdpsndWinmmPlugin*) device;

	winmm->volume = value;

	if (!winmm->hWaveOut)
		return TRUE;

	return (waveOutSetVolume(winmm->hWaveOut, value) == MMSYSERR_NOERROR);
}
Ejemplo n.º 19
0
void native_midi_setvolume(int volume)
{
	int calcVolume = volume << 1;
	if(calcVolume > 255)
	{
		calcVolume = 255;
	}
	else if (calcVolume < 0)
	{
		calcVolume = 0;
	}
	waveOutSetVolume((HWAVEOUT)hMidiStream, MAKEWORD(calcVolume , calcVolume));
}
Ejemplo n.º 20
0
static void initwindow(void)
{
	hdc=GetDC(window);
	hdcm=CreateCompatibleDC(hdc);
	hdcm2=CreateCompatibleDC(hdc);
	hcharbm=CreateBitmap(8,8,1,1,&sysfonte[0]);
	hecran[0]=CreateCompatibleBitmap(hdc,WIDTH*RATIO,HEIGHT*RATIO);
	hecran[1]=CreateCompatibleBitmap(hdc,WIDTH*RATIO,HEIGHT*RATIO);
	ReleaseDC(window,hdc);
	holdbitmap=SelectObject(hdcm,hecran[ecran_actif]);
	holdbitmap2=SelectObject(hdcm2,hcharbm);

	hpen=CreatePen(PS_NULL,1,NULL);
	hbrush=CreateSolidBrush(RGB(0,0,0));
	holdbrush=SelectObject(hdcm,hbrush);
	holdpen=SelectObject(hdcm,hpen);
	Rectangle(hdcm,0,0,WIDTH*RATIO+1,HEIGHT*RATIO+1);
	SelectObject(hdcm,hecran[ecran_travail]);
	Rectangle(hdcm,0,0,WIDTH*RATIO+1,HEIGHT*RATIO+1);
	SelectObject(hdcm,holdbrush);
	SelectObject(hdcm,holdbrush);
	SelectObject(hdcm,holdpen);
	DeleteObject(hbrush);
	DeleteObject(hpen);

	hpen=CreatePen(PS_NULL,1,NULL);
	holdpen=SelectObject(hdcm,hpen);
	hbrush=CreateSolidBrush(color);
	holdbrush=SelectObject(hdcm,hbrush);

	SetTextColor(hdcm,RGB(0,0,0));



	pcmwf.wf.wFormatTag=WAVE_FORMAT_PCM;
	pcmwf.wf.nChannels=1;
	pcmwf.wf.nSamplesPerSec=11025L;
	pcmwf.wf.nAvgBytesPerSec=11025L;
	pcmwf.wf.nBlockAlign=1;
	pcmwf.wBitsPerSample=8;    
	nosound=waveOutOpen(&hwo,WAVE_MAPPER,(WAVEFORMAT *)&pcmwf,NULL,NULL,NULL);
	if (!nosound)
	{
		waveOutGetID(hwo,&nosound);
		waveOutSetVolume(nosound,0xffff);
		waveOutReset(hwo);
		waveOutClose(hwo);
    		nosound=1;
	}

}
Ejemplo n.º 21
0
void SoundGen_Initialize(WORD volume)
{
    if (m_SoundGenInitialized)
        return;

    DWORD totalBufferSize = (BLOCK_SIZE + sizeof(WAVEHDR)) * BLOCK_COUNT;

    unsigned char* mbuffer = (unsigned char*)HeapAlloc(
            GetProcessHeap(),
            HEAP_ZERO_MEMORY,
            totalBufferSize);
    if (mbuffer == nullptr)
        return;

    waveBlocks = (WAVEHDR*)mbuffer;
    mbuffer += sizeof(WAVEHDR) * BLOCK_COUNT;
    for (int i = 0; i < BLOCK_COUNT; i++)
    {
        waveBlocks[i].dwBufferLength = BLOCK_SIZE;
        waveBlocks[i].lpData = (LPSTR)mbuffer;
        mbuffer += BLOCK_SIZE;
    }

    waveFreeBlockCount = BLOCK_COUNT;
    waveCurrentBlock   = 0;

    wfx.nSamplesPerSec  = SOUNDSAMPLERATE;
    wfx.wBitsPerSample  = 16;
    wfx.nChannels       = 2;
    wfx.cbSize          = 0;
    wfx.wFormatTag      = WAVE_FORMAT_PCM;
    wfx.nBlockAlign     = (wfx.wBitsPerSample * wfx.nChannels) >> 3;
    wfx.nAvgBytesPerSec = wfx.nBlockAlign * wfx.nSamplesPerSec;

    MMRESULT result = waveOutOpen(
            &hWaveOut, WAVE_MAPPER, &wfx, (DWORD_PTR)WaveCallback, (DWORD_PTR)&waveFreeBlockCount, CALLBACK_FUNCTION);
    if (result != MMSYSERR_NOERROR)
    {
        return;
    }

    waveOutSetVolume(hWaveOut, ((DWORD)volume << 16) | ((DWORD)volume));

    InitializeCriticalSection(&waveCriticalSection);
    bufcurpos = 0;

    m_SoundGenInitialized = true;
}
Ejemplo n.º 22
0
static HRESULT WINAPI PrimaryBufferImpl_SetVolume(
	LPDIRECTSOUNDBUFFER iface,LONG vol
) {
	DirectSoundDevice *device = ((PrimaryBufferImpl *)iface)->device;
	DWORD ampfactors;
        HRESULT hres = DS_OK;
	TRACE("(%p,%d)\n", iface, vol);

	if (!(device->dsbd.dwFlags & DSBCAPS_CTRLVOLUME)) {
		WARN("control unavailable\n");
		return DSERR_CONTROLUNAVAIL;
	}

	if ((vol > DSBVOLUME_MAX) || (vol < DSBVOLUME_MIN)) {
		WARN("invalid parameter: vol = %d\n", vol);
		return DSERR_INVALIDPARAM;
	}

	/* **** */
	EnterCriticalSection(&(device->mixlock));

        waveOutGetVolume(device->hwo, &ampfactors);
        device->volpan.dwTotalLeftAmpFactor=ampfactors & 0xffff;
        device->volpan.dwTotalRightAmpFactor=ampfactors >> 16;
        DSOUND_AmpFactorToVolPan(&device->volpan);
        if (vol != device->volpan.lVolume) {
            device->volpan.lVolume=vol;
            DSOUND_RecalcVolPan(&device->volpan);
            if (device->hwbuf) {
                hres = IDsDriverBuffer_SetVolumePan(device->hwbuf, &device->volpan);
                if (hres != DS_OK)
                    WARN("IDsDriverBuffer_SetVolumePan failed\n");
            } else {
                ampfactors = (device->volpan.dwTotalLeftAmpFactor & 0xffff) | (device->volpan.dwTotalRightAmpFactor << 16);
                waveOutSetVolume(device->hwo, ampfactors);
            }
        }

	LeaveCriticalSection(&(device->mixlock));
	/* **** */

	return hres;
}
Ejemplo n.º 23
0
/** changes volume as an int in a scale from 0x0000 to 0xFFFF*/
int sa_stream_change_write_volume(sa_stream_t *s, const int32_t vol[], unsigned int n) {
  int status;
	DWORD volume;
	WORD left;
	WORD right;
	
	ERROR_IF_NO_INIT(s);
	
  volume = (DWORD)vol[0];
	left = volume & LEFT_CHANNEL_MASK;	  
	right = left;	  
	volume =  (left << 16) | right;	
	
	status = waveOutSetVolume(s->hWaveOut, volume);
	HANDLE_WAVE_ERROR(status, "setting new audio volume level");	

	return SA_SUCCESS;


}
Ejemplo n.º 24
0
void Px_SetPCMOutputVolume( PxMixer *mixer, PxVolume volume )
{
	MMRESULT result;
	PxInfo *info = (PxInfo *)mixer;

	/* invalid waveID */
	if ( info->waveID == -1 )
		return ;

	/* set the wave output volume */
	result = waveOutSetVolume( (HWAVEOUT)( info->waveID ), MAKELONG(volume*0xFFFF, volume*0xFFFF));

	/* on failure, mark waveID as invalid  */
	if ( result != MMSYSERR_NOERROR )
	{
		info->waveID = -1 ;
	}

	return ;
}
Ejemplo n.º 25
0
STDMETHODIMP CPlayer::put_Volume(long newVal)
{
	volume = newVal;

	char buf[1024];
	_snprintf(buf, sizeof(buf), "setaudio \"%s\" volume %d", (char*)path, volume); 
	MCIERROR err = ::mciSendString(buf, NULL, 0, 0);
	if (err != 0) {
		waveOutSetVolume((HWAVEOUT)0, MAKELONG(volume*0xffff/1000,volume*0xffff/1000));
/*		WAVEFORMATEX wf;
		wf.wFormatTag = WAVE_FORMAT_PCM;
		wf.nChannels = 1;
		wf.nSamplesPerSec = 8000 * 1000;
		wf.wBitsPerSample = 8;
		wf.nBlockAlign = wf.nChannels * wf.wBitsPerSample / 8;
		wf.nAvgBytesPerSec = wf.nSamplesPerSec * wf.nBlockAlign;
		wf.cbSize = 0;
		HWAVEOUT hwo;
		for (UINT id = 0; id < waveOutGetNumDevs(); id++)
		{
			if (waveOutOpen(&hwo, id, &wf, 0, 0, CALLBACK_NULL) == MMSYSERR_NOERROR)
			{
				waveOutSetVolume(hwo, volume*0xffff/1000);
				waveOutClose(hwo);
				break;
			}
		}
*/
	}

#ifdef _DEBUG
	if (err != 0) {
		char errBuf[129];
		::mciGetErrorString(err, errBuf, 128);
		AtlTrace("MCI error: %s\n", errBuf);
	}
#endif

	return S_OK;
}
Ejemplo n.º 26
0
static HRESULT WINAPI PrimaryBufferImpl_SetPan(
    LPDIRECTSOUNDBUFFER iface,LONG pan
) {
    IDirectSoundBufferImpl *This = impl_from_IDirectSoundBuffer(iface);
    DirectSoundDevice *device = This->device;
    DWORD ampfactors;
    HRESULT hres = DS_OK;
    TRACE("(%p,%d)\n", iface, pan);

    if (!(This->dsbd.dwFlags & DSBCAPS_CTRLPAN)) {
        WARN("control unavailable\n");
        return DSERR_CONTROLUNAVAIL;
    }

    if ((pan > DSBPAN_RIGHT) || (pan < DSBPAN_LEFT)) {
        WARN("invalid parameter: pan = %d\n", pan);
        return DSERR_INVALIDPARAM;
    }

    /* **** */
    EnterCriticalSection(&(device->mixlock));

    waveOutGetVolume(device->hwo, &ampfactors);
    device->volpan.dwTotalLeftAmpFactor=ampfactors & 0xffff;
    device->volpan.dwTotalRightAmpFactor=ampfactors >> 16;
    DSOUND_AmpFactorToVolPan(&device->volpan);
    if (pan != device->volpan.lPan) {
        device->volpan.lPan=pan;
        DSOUND_RecalcVolPan(&device->volpan);
        ampfactors = (device->volpan.dwTotalLeftAmpFactor & 0xffff) | (device->volpan.dwTotalRightAmpFactor << 16);
        waveOutSetVolume(device->hwo, ampfactors);
    }

    LeaveCriticalSection(&(device->mixlock));
    /* **** */

    return hres;
}
Ejemplo n.º 27
0
// to set/get/query special features/parameters
static int control(int cmd,void *arg)
{
	DWORD volume;
	switch (cmd)
	{
		case AOCONTROL_GET_VOLUME:
		{
			ao_control_vol_t* vol = (ao_control_vol_t*)arg;
			waveOutGetVolume(hWaveOut,&volume);
			vol->left = LOWORD(volume)/655.35;
			vol->right = HIWORD(volume)/655.35;
			mp_msg(MSGT_AO, MSGL_DBG2,"ao_win32: volume left:%f volume right:%f\n",vol->left,vol->right);
			return CONTROL_OK;
		}
		case AOCONTROL_SET_VOLUME:
		{
			ao_control_vol_t* vol = (ao_control_vol_t*)arg;
			volume = MAKELONG(vol->left*655.35,vol->right*655.35);
			waveOutSetVolume(hWaveOut,volume);
			return CONTROL_OK;
		}
	}
    return -1;
}
Ejemplo n.º 28
0
static int sound_init(LPHWAVEOUT wave_out, HANDLE event)
{
    static const WAVEFORMATEX format =
    {
        WAVE_FORMAT_PCM,    /* Format */
        2,                  /* Number of channels */
        44100,              /* Samples per second */
        44100 * 4,          /* Bytes per second */
        4,                  /* Block align */
        16,                 /* Bits per sample */
        0                   /* Extra size */
    };

    if (MMSYSERR_NOERROR != waveOutOpen(wave_out, WAVE_MAPPER, &format, 
        (DWORD_PTR) event, 0, CALLBACK_EVENT))
    {
        return -1;
    }

    /* Full volume on left and right */
    waveOutSetVolume(*wave_out, 0xffffffff);

    return 0;
}
Ejemplo n.º 29
0
bool_t gaudio_play_lld_set_volume(uint8_t vol) {
	if (!ah)
		return FALSE;
	return waveOutSetVolume(ah, (((uint16_t)vol)<<8)|vol) != 0;
}
Ejemplo n.º 30
0
VOID CALLBACK WaveOutProc(HWAVEOUT hwo, UINT uMsg, DWORD_PTR dwInstance, DWORD_PTR dwParam1, DWORD_PTR dwParam2)
{
    USHORT i;

    switch (uMsg)
    {
    case WOM_DONE:
        {
            LPWAVEHDR header = (LPWAVEHDR)dwParam1;
            PSOUNDINSTANCE instance = (PSOUNDINSTANCE)dwInstance;

            assert(instance->Header == header);
            if (instance->Sound->IsMusic)
            {
                /* need to continue the stream */
                DWORD remaining;
                PSTREAMINFO streamInfo = instance->Sound->Stream;

                /* cleanup current chunk */
                waveOutUnprepareHeader(instance->WaveOut, instance->Header, sizeof(WAVEHDR));

                /* is there more to play? */
                remaining = streamInfo->TotalSize - streamInfo->UsedSize;

                if (remaining > 0)
                {
                    MMRESULT mr = 0;
                    DWORD current, size;

                    size = min(g_streamChunkSize, remaining);
                    streamInfo->UsedSize += size;
                    instance->Header->dwBufferLength = size;

                    for (current = 0; current < size && mr == MMSYSERR_NOERROR; ++current)
                    {
                        if (streamInfo->StreamInfo.pchNext == streamInfo->StreamInfo.pchEndRead)
                        {
                            mr = mmioAdvance(streamInfo->Stream, &streamInfo->StreamInfo, MMIO_READ);
                            if (mr == MMSYSERR_NOERROR)
                            {
                                mr = (streamInfo->StreamInfo.pchNext != streamInfo->StreamInfo.pchEndRead ? MMSYSERR_NOERROR : MMSYSERR_ERROR);
                            }
                        }

                        if (mr == MMSYSERR_NOERROR)
                        {
                            instance->Header->lpData[current] = *streamInfo->StreamInfo.pchNext;
                            ++streamInfo->StreamInfo.pchNext;
                        }
                    }

                    /* ensure header is ready, and start playing next chunk */
                    waveOutPrepareHeader(instance->WaveOut, instance->Header, sizeof(WAVEHDR));
                    waveOutSetVolume(instance->WaveOut, instance->Volume);
                    waveOutWrite(instance->WaveOut, instance->Header, sizeof(WAVEHDR));
                }
                else
                {
                    /* TODO: Should music always loop? or should we add a flag for it? */
                    streamInfo->Playing = FALSE;
                    streamInfo->UsedSize = 0;

                    AddInstanceToDestroyQueue(instance);
                }
            }
            else
            {
                /* sound fx instances should get cleaned up */
                AddInstanceToDestroyQueue(instance);
            }
        }
        break;
    }
}