Set safe values to prevent possible sigsegv while using AudioTransport, add doc
Bug: webrtc:8946 Change-Id: Ica066a05905894fba6ba24e45af46b0d5951b5d5 Reviewed-on: https://webrtc-review.googlesource.com/65040 Commit-Queue: Artem Titov <titovartem@webrtc.org> Reviewed-by: Fredrik Solenberg <solenberg@webrtc.org> Reviewed-by: Henrik Andreassson <henrika@webrtc.org> Cr-Commit-Position: refs/heads/master@{#22652}
This commit is contained in:
@ -71,6 +71,11 @@ class ADMWrapper : public AudioDeviceModule, public AudioTransport {
|
||||
int64_t* elapsed_time_ms,
|
||||
int64_t* ntp_time_ms) override {
|
||||
int32_t res = 0;
|
||||
// Set out parameters to safe values to be sure not to return corrupted
|
||||
// data.
|
||||
nSamplesOut = 0;
|
||||
*elapsed_time_ms = -1;
|
||||
*ntp_time_ms = -1;
|
||||
// Request data from audio transport.
|
||||
if (audio_transport_) {
|
||||
res = audio_transport_->NeedMorePlayData(
|
||||
|
||||
@ -45,6 +45,7 @@ class AudioTransport {
|
||||
const bool keyPressed,
|
||||
uint32_t& newMicLevel) = 0; // NOLINT
|
||||
|
||||
// Implementation has to setup safe values for all specified out parameters.
|
||||
virtual int32_t NeedMorePlayData(const size_t nSamples,
|
||||
const size_t nBytesPerSample,
|
||||
const size_t nChannels,
|
||||
|
||||
@ -174,8 +174,8 @@ class TestAudioDeviceModuleImpl
|
||||
}
|
||||
if (rendering_) {
|
||||
size_t samples_out = 0;
|
||||
int64_t elapsed_time_ms = 0;
|
||||
int64_t ntp_time_ms = 0;
|
||||
int64_t elapsed_time_ms = -1;
|
||||
int64_t ntp_time_ms = -1;
|
||||
const int sampling_frequency = renderer_->SamplingFrequency();
|
||||
audio_callback_->NeedMorePlayData(
|
||||
SamplesPerFrame(sampling_frequency), 2, renderer_->NumChannels(),
|
||||
|
||||
Reference in New Issue
Block a user