Merge pull request #3418 from llyzs/rdpsnd_server_latency

rdpsnd/server: decrease audio latency and make it configurable.
This commit is contained in:
Martin Fleisz 2016-06-22 15:32:11 +02:00 committed by GitHub
commit 0d7a6b5596
2 changed files with 14 additions and 10 deletions

View File

@ -337,25 +337,26 @@ static UINT rdpsnd_server_select_format(RdpsndServerContext* context, int client
goto out;
}
if (context->latency <= 0)
context->latency = 50;
context->priv->out_frames = context->src_format.nSamplesPerSec * context->latency / 1000;
if (context->priv->out_frames < 1)
context->priv->out_frames = 1;
switch(format->wFormatTag)
{
case WAVE_FORMAT_DVI_ADPCM:
bs = (format->nBlockAlign - 4 * format->nChannels) * 4;
context->priv->out_frames = (format->nBlockAlign * 4 * format->nChannels * 2 / bs + 1) * bs / (format->nChannels * 2);
context->priv->out_frames -= context->priv->out_frames % bs;
if (context->priv->out_frames < bs)
context->priv->out_frames = bs;
break;
case WAVE_FORMAT_ADPCM:
bs = (format->nBlockAlign - 7 * format->nChannels) * 2 / format->nChannels + 2;
context->priv->out_frames = bs * 4;
context->priv->out_frames -= context->priv->out_frames % bs;
if (context->priv->out_frames < bs)
context->priv->out_frames = bs;
break;
default:
context->priv->out_frames = 0x4000 / context->priv->src_bytes_per_frame;
break;
}
if (format->nSamplesPerSec != context->src_format.nSamplesPerSec)
{
context->priv->out_frames = (context->priv->out_frames * context->src_format.nSamplesPerSec + format->nSamplesPerSec - 100) / format->nSamplesPerSec;
}
context->priv->out_pending_frames = 0;

View File

@ -61,6 +61,9 @@ struct _rdpsnd_server_context
/* Server source PCM audio format. Set by server. */
AUDIO_FORMAT src_format;
/* Server audio latency, or buffer size, in milli-seconds. Set by server. */
int latency;
/* Client supported formats. */
AUDIO_FORMAT* client_formats;
int num_client_formats;