|
|
@ -261,6 +261,8 @@ bool mirror(IMMDevice *monitor, IMMDevice *output)
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (;;)
|
|
|
|
|
|
|
|
{
|
|
|
|
UINT32 padding = 0;
|
|
|
|
UINT32 padding = 0;
|
|
|
|
|
|
|
|
|
|
|
|
if ((res = out_client->lpVtbl->GetCurrentPadding(out_client, &padding)) != S_OK)
|
|
|
|
if ((res = out_client->lpVtbl->GetCurrentPadding(out_client, &padding)) != S_OK)
|
|
|
@ -284,23 +286,31 @@ bool mirror(IMMDevice *monitor, IMMDevice *output)
|
|
|
|
UINT32 frames = 0;
|
|
|
|
UINT32 frames = 0;
|
|
|
|
DWORD flags = 0;
|
|
|
|
DWORD flags = 0;
|
|
|
|
|
|
|
|
|
|
|
|
if (packet_size > buffer_size - padding)
|
|
|
|
if (packet_size == 0)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if ((res = capture->lpVtbl->GetBuffer(capture, &mon_data, &frames, &flags,
|
|
|
|
// no input data, play silence
|
|
|
|
NULL, NULL)) != S_OK)
|
|
|
|
|
|
|
|
|
|
|
|
if ((res = render->lpVtbl->GetBuffer(render, buffer_size - padding, &out_data)) != S_OK)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
fprintf(stderr, "Failed to get capture buffer of monitor client! [0x%08lx]\n", res);
|
|
|
|
fprintf(stderr, "Failed to get render buffer of output client! [0x%08lx]\n", res);
|
|
|
|
goto out;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if ((res = capture->lpVtbl->ReleaseBuffer(capture, 0)) != S_OK)
|
|
|
|
if ((res = render->lpVtbl->ReleaseBuffer(render, buffer_size - padding,
|
|
|
|
|
|
|
|
AUDCLNT_BUFFERFLAGS_SILENT)) != S_OK)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
fprintf(stderr, "Failed to release capture buffer of monitor client! [0x%08lx]\n", res);
|
|
|
|
fprintf(stderr, "Failed to release render buffer of output client! [0x%08lx]\n", res);
|
|
|
|
goto out;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (packet_size > 0)
|
|
|
|
else if (packet_size > buffer_size - padding)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
// output buffer is full, we have to wait
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if ((res = capture->lpVtbl->GetBuffer(capture, &mon_data, &frames, &flags,
|
|
|
|
if ((res = capture->lpVtbl->GetBuffer(capture, &mon_data, &frames, &flags,
|
|
|
|
NULL, NULL)) != S_OK)
|
|
|
|
NULL, NULL)) != S_OK)
|
|
|
@ -329,20 +339,6 @@ bool mirror(IMMDevice *monitor, IMMDevice *output)
|
|
|
|
goto out;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if ((res = render->lpVtbl->GetBuffer(render, buffer_size - padding, &out_data)) != S_OK)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
fprintf(stderr, "Failed to get render buffer of output client! [0x%08lx]\n", res);
|
|
|
|
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ((res = render->lpVtbl->ReleaseBuffer(render, buffer_size - padding,
|
|
|
|
|
|
|
|
AUDCLNT_BUFFERFLAGS_SILENT)) != S_OK)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
fprintf(stderr, "Failed to release render buffer of output client! [0x%08lx]\n", res);
|
|
|
|
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|