Winamp 2 Kernel Streaming Output Plugin
Reply #239 – 2007-01-04 15:56:05
Hi, I've a feeling it differs with the sound card and drivers. On my Prodigy 192 the visualisation were lagging FAR behind, so I modified the code to help bring them back. When Winamp wanted to know the current output time, the plug-in was reporting written time to the KS interface ignoring the output lag, and when Winamp wanted to know the written time from the input plug-in, it wasn't taking into account the data in the input buffer. This mean that when Winamp wanted written time it was reporting a time in the past, and for output time it was giving a time in the future. These changes bring the time delay down a lot but still not quite perfect.int KSCore::GetKSTime(void) { unsigned int bytes_per_sec, t; bytes_per_sec = wfx_cur.Format.nAvgBytesPerSec; t = written_data / bytes_per_sec * 1000; // time to nearest second in mS t += (written_data % bytes_per_sec) * 1000 / bytes_per_sec; // add in fractional component return t; } int KSCore::GetOutputTime(void) { float packet_lat, out_lat = 0.0; unsigned int bytes_per_sec; int t; bytes_per_sec = wfx_cur.Format.nAvgBytesPerSec; packet_lat = (float)packet_size * 1000.0 / (float)bytes_per_sec; for (int n = 0; n < num_packets; n++) { if (WaitForSingleObject(events[n+EV_KSPACKET], 0) != WAIT_OBJECT_0) { out_lat += packet_lat; } } t = GetKSTime(); // get time written to KS interface t -= (int)(out_lat); // apply output latency return t; } int KSCore::GetWrittenTime(void) { float in_lat; unsigned int bytes_per_sec; int t; bytes_per_sec = wfx_cur.Format.nAvgBytesPerSec; in_lat = (float)input_buffer_len * 1000.0 / (float)bytes_per_sec; t = GetKSTime(); // get time written to KS interface t += (int)(in_lat); // apply input latency return t; } The above helps the Prodigy 192, but makes things worse for the Nvidia onboard sound. Also, with the prodigy I had to properly pad the data to 32bit when using 24bit. Thanks for making this excellent plug-in! Craig