Bug 971528 - Allow stereo capture in AudioCallbackDriver. r=padenot

* * *
[mq]: graph-driver-comments

MozReview-Commit-ID: JnU3opk8X5K
* * *
[mq]: tmp

MozReview-Commit-ID: 73CtZw4CRG

--HG--
extra : rebase_source : cf6942aeaf4c2831fce4d92de0c5eeaaba7c0cd6
This commit is contained in:
Alex Chronopoulos 2017-05-29 13:26:27 +03:00
Родитель 6d024a14d7
Коммит fa245fd24c
2 изменённых файлов: 27 добавлений и 3 удалений

Просмотреть файл

@ -662,10 +662,19 @@ AudioCallbackDriver::Init()
latency_frames = std::max((uint32_t) 512, latency_frames);
}
input = output;
input.channels = mInputChannels; // change to support optional stereo capture
input.layout = CUBEB_LAYOUT_MONO;
input.channels = mInputChannels;
input.layout = CUBEB_LAYOUT_UNDEFINED;
#ifdef MOZ_WEBRTC
if (mGraphImpl->mInputWanted) {
StaticMutexAutoLock lock(AudioInputCubeb::Mutex());
uint32_t maxInputChannels = 0;
if (AudioInputCubeb::GetDeviceMaxChannels(mGraphImpl->mInputDeviceID, maxInputChannels) == 0) {
input.channels = mInputChannels = maxInputChannels;
}
}
#endif
cubeb_stream* stream = nullptr;
CubebUtils::AudioDeviceID input_id = nullptr, output_id = nullptr;

Просмотреть файл

@ -208,6 +208,7 @@ public:
aIndex = mDefaultDevice;
}
}
MOZ_ASSERT(mDeviceIndexes);
if (aIndex < 0 || aIndex >= (int) mDeviceIndexes->Length()) {
return -1;
}
@ -263,6 +264,20 @@ public:
return 0;
}
static int GetDeviceMaxChannels(int aDeviceIndex, uint32_t& aChannels)
{
#ifdef MOZ_WIDGET_ANDROID
aChannels = 1;
#else
int32_t devindex = DeviceIndex(aDeviceIndex);
if (!mDevices || devindex < 0) {
return 1;
}
aChannels = mDevices->device[devindex]->max_channels;
#endif
return 0;
}
void StartRecording(SourceMediaStream *aStream, AudioDataListener *aListener)
{
#ifdef MOZ_WIDGET_ANDROID