On 6/22/21 5:34 PM, Giovanni Mascellani wrote:
@@ -1359,7 +1369,10 @@ static HRESULT WINAPI audio_renderer_stream_ProcessSample(IMFStreamSink *iface, EnterCriticalSection(&renderer->cs); if (renderer->state == STREAM_STATE_RUNNING) hr = stream_queue_sample(renderer, sample); - renderer->flags &= ~SAR_SAMPLE_REQUESTED; + if (renderer->queued_frames < renderer->target_queued_frames) + IMFMediaEventQueue_QueueEventParamVar(renderer->stream_event_queue, MEStreamSinkRequestSample, &GUID_NULL, S_OK, NULL); + else + renderer->flags &= ~SAR_SAMPLE_REQUESTED; LeaveCriticalSection(&renderer->cs); Let's request only when running.
+ if (FAILED(hr = IAudioClient_GetDevicePeriod(renderer->audio_client, &period, NULL))) + { + WARN("Failed to retrieve device period, hr %#x.\n", hr); + return hr; + } + renderer->target_queued_frames = 2 * period * samples_per_second / 10000000; + Could this be replaced with GetBufferSize() that returns size in frames?
@@ -1789,6 +1812,7 @@ static void audio_renderer_render(struct audio_renderer *renderer, IMFAsyncResul IAudioRenderClient_ReleaseBuffer(renderer->audio_render_client, dst_frames, 0);
obj->u.sample.frame_offset += dst_frames; + renderer->queued_frames -= dst_frames; queued_frames should be reset when every time we empty this list.
Have you tested patch v4 with the game?