Fix a stupid bug with ffmpeg audio playback that was resulting in (practically) no sound.

git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5526 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
Spoike 2019-08-28 02:47:00 +00:00
parent 9202c3f015
commit 560235c57b
2 changed files with 27 additions and 2 deletions

View File

@ -127,6 +127,7 @@ static void S_AV_ReadFrame(struct avaudioctx *ctx)
auddatasize/=2;
width = 2;
}
break;
case AV_SAMPLE_FMT_DBLP:
auddatasize /= channels;

View File

@ -374,8 +374,31 @@ static qboolean VARGS AVDec_DisplayFrame(void *vctx, qboolean nosound, qboolean
break;
case AV_SAMPLE_FMT_FLTP:
auddatasize /= channels;
channels = 1;
//FIXME: support float audio internally.
{
float *in[2] = {(float*)ctx->pAFrame->data[0],(float*)ctx->pAFrame->data[1]};
signed short *out = (void*)auddata;
int v;
unsigned int i, c;
unsigned int frames = ctx->pAFrame->nb_samples;
if (channels > 2)
channels = 2;
for (i = 0; i < frames; i++)
{
for (c = 0; c < channels; c++)
{
v = (short)(in[c][i]*32767);
if (v < -32767)
v = -32767;
else if (v > 32767)
v = 32767;
*out++ = v;
}
}
width = sizeof(*out);
auddatasize = frames*width*channels;
}
break;
case AV_SAMPLE_FMT_FLT:
//FIXME: support float audio internally.
{
@ -395,6 +418,7 @@ static qboolean VARGS AVDec_DisplayFrame(void *vctx, qboolean nosound, qboolean
auddatasize/=2;
width = 2;
}
break;
case AV_SAMPLE_FMT_DBLP:
auddatasize /= channels;