// Winamp playthreadvoid PlayThread(void) { // this is needed to get vis working long bufsize=576*4; int decode_pos,decode_pos_ms; unsigned long ticks=0, written=0; unsigned char * buf = new unsigned char[bufsize+200]; threadRunning=1; // this should hopefully stop that popping noise at the start of a track memset(buf,0,bufsize+200); // TODO: different form of visualization that doesn't crash winamp decode_pos=0; decode_pos_ms=0; while (!postthreadclose) { if (!paused) { decode_pos+=bufsize; if(InMod.outMod->IsPlaying()) { Sleep(10); continue; } if (InMod.outMod->CanWrite() >= (bufsize<<(InMod.dsp_isactive()?1:0))) { written = _system.Run(bufsize,buf); if (written != 0) { // Although this dsp code uses a common known algorithm, I sourced this one from in_cube. if (InMod.dsp_isactive()) written = InMod.dsp_dosamples((short*)buf,written/channels/(16/8),16,channels,mySampleRate) * (channels*(16/8)); InMod.outMod->Write((char*)buf,written); InMod.VSAAddPCMData((char*)buf,channels,16,InMod.outMod->GetWrittenTime()); InMod.SAAddPCMData((char*)buf,channels,16,InMod.outMod->GetWrittenTime()); //while (InMod.outMod->IsPlaying()) Sleep(10); } } else Sleep(10); } } threadRunning=0; if (buf) delete[] buf;}// Decode algorithm for foo_in_notmerge (returns 0 samples no matter what happens)bool decode_run(audio_chunk & p_chunk,abort_callback & p_abort) { int written=0,bufsize,samples; if (!written) samples=512*raw_channels*2; //..nsf. m_buffer.grow_size(samples/2); written = _system.Run(m_buffer.get_size(),m_buffer.get_ptr()); p_chunk.set_data_fixedpoint(m_buffer.get_ptr(),written * raw_total_sample_width,raw_sample_rate,raw_channels,raw_bits_per_sample,audio_chunk::g_guess_channel_config(raw_channels)); //processed successfully, no EOF return true; }