Bug 1570337 - p5: repeat calling Drain() until no more output. r=jya

Existing tests will fail when there are more than 1 pending frames when Drain()
is called. Repeatly calling it to ensure all frames will be collected.

Differential Revision: https://phabricator.services.mozilla.com/D43689

--HG--
extra : moz-landing-system : lando
This commit is contained in:
John Lin 2019-08-31 00:20:47 +00:00
Родитель 6550375203
Коммит 28b4c73d92
1 изменённых файлов: 8 добавлений и 17 удалений

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

@ -260,29 +260,20 @@ static MediaDataEncoder::EncodedData Encode(
}
size_t pending = 0;
media::Await(
GetMediaThreadPool(MediaThreadType::PLAYBACK), aEncoder->Drain(),
[&pending, &output, &succeeded](MediaDataEncoder::EncodedData encoded) {
pending = encoded.Length();
output.AppendElements(std::move(encoded));
succeeded = true;
},
[&succeeded](MediaResult r) { succeeded = false; });
EXPECT_TRUE(succeeded);
if (!succeeded) {
return output;
}
if (pending > 0) {
do {
media::Await(
GetMediaThreadPool(MediaThreadType::PLAYBACK), aEncoder->Drain(),
[&succeeded](MediaDataEncoder::EncodedData encoded) {
EXPECT_EQ(encoded.Length(), 0UL);
[&pending, &output, &succeeded](MediaDataEncoder::EncodedData encoded) {
pending = encoded.Length();
output.AppendElements(std::move(encoded));
succeeded = true;
},
[&succeeded](MediaResult r) { succeeded = false; });
EXPECT_TRUE(succeeded);
}
if (!succeeded) {
return output;
}
} while (pending > 0);
return output;
}