Fix AAC mono output

The entire mono situation is my fault.  I did test it and it seemed
like it was working at first when I got the pull request so I said "hey
okay looks good."  Unfortunately I was mistaken, so I'm fixing the code
myself.

AAC was taking in stereo audio and was not calculating the timestamps
correctly.  Internally OBS still gets data in the form of stereo, so
because this is OBS1 I'm just going to put in this workaround code that
downmixes stereo to mono in to the AAC encoder buffer.
This commit is contained in:
jp9000 2014-03-14 13:00:02 -07:00
parent 6ccf140b8b
commit 6ba6f8b584
3 changed files with 17 additions and 5 deletions

View File

@ -67,7 +67,7 @@ struct BlankAudioPlayback
err = mmClient->Initialize(AUDCLNT_SHAREMODE_SHARED, 0, ConvertMSTo100NanoSec(1000), 0, pwfx, NULL);
if(FAILED(err))
CrashError(TEXT("Could not initialize audio client"));
CrashError(TEXT("Could not initialize audio client, error = %08lX"), err);
err = mmClient->GetService(IID_IAudioRenderClient, (void**)&mmRender);
if(FAILED(err))

View File

@ -102,8 +102,20 @@ public:
QWORD curTimestamp = timestamp;
UINT lastSampleSize = inputBuffer.Num();
UINT numInputSamples = numInputFrames*2;
inputBuffer.AppendArray(input, numInputSamples);
UINT numInputSamples = numInputFrames*App->NumAudioChannels();
if (App->NumAudioChannels() == 2)
inputBuffer.AppendArray(input, numInputSamples);
else
{
UINT inputBufferPos = inputBuffer.Num();
inputBuffer.SetSize(inputBufferPos + numInputSamples);
for (UINT i = 0; i < numInputSamples; i++)
{
UINT pos = i * 2;
inputBuffer[inputBufferPos + i] = (input[pos] + input[pos + 1]) / 2.0f;
}
}
int ret = 0;
@ -155,7 +167,7 @@ public:
inputBuffer.RemoveRange(0, numReadSamples);
bufferedTimestamps << curEncodeTimestamp;
curEncodeTimestamp = curTimestamp + (((numReadSamples-lastSampleSize)/2)*1000/App->GetSampleRateHz());
curEncodeTimestamp = curTimestamp + (((numReadSamples-lastSampleSize)/App->NumAudioChannels())*1000/App->GetSampleRateHz());
}
return ret > 0;

View File

@ -83,7 +83,7 @@ extern TCHAR lpAppDataPath[MAX_PATH];
#define OBS_VERSION 0x006103 //version number is 0xMMmmtt (super-major.major.minor - hex)
#define OBS_VERSION_STRING_RAW "Open Broadcaster Software v0.613b"
//#define OBS_TEST_BUILD 1 //define this if releasing a test build to disable the auto updater
#define OBS_TEST_BUILD 1 //define this if releasing a test build to disable the auto updater
#define OBS_VERSION_STRING_ANSI OBS_VERSION_STRING_RAW OBS_VERSION_SUFFIX
#define OBS_VERSION_STRING TEXT(OBS_VERSION_STRING_RAW) TEXT(OBS_VERSION_SUFFIX)