Bug 1426171 - Only use the graph's rate if supported by the AudioConduit. r=pehrsons

Otherwise we will use 48kHz as default, the MSG will resample as needed.
It would be possible to allow all frequencies in the AudioConduit as the webrtc backend supports them all, however it would require more changes and likely heap allocation that we're trying to limit in this part of the code.

MozReview-Commit-ID: B3x5t1FSaQ8

--HG--
extra : rebase_source : 77f83a876ed9b5ded45419245655709aee2573df
This commit is contained in:
Jean-Yves Avenard 2017-12-20 14:16:04 +01:00
Родитель 1ea5b80a67
Коммит c3f319f1c7
3 изменённых файлов: 18 добавлений и 4 удалений

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

@ -268,6 +268,9 @@ public:
int64_t aTimestamp,
bool aHasLevel,
uint8_t aLevel);
bool IsSamplingFreqSupported(int freq) const override;
private:
WebrtcAudioConduit(const WebrtcAudioConduit& other) = delete;
void operator=(const WebrtcAudioConduit& other) = delete;
@ -279,9 +282,6 @@ private:
bool CodecConfigToWebRTCCodec(const AudioCodecConfig* codecInfo,
webrtc::CodecInst& cinst);
//Checks if given sampling frequency is supported
bool IsSamplingFreqSupported(int freq) const;
//Generate block size in sample lenght for a given sampling frequency
unsigned int GetNum10msSamplesForFrequency(int samplingFreqHz) const;

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

@ -519,6 +519,12 @@ public:
int32_t capture_delay,
int& lengthSamples) = 0;
/**
* Checks if given sampling frequency is supported
* @param freq: Sampling rate (in Hz) to check
*/
virtual bool IsSamplingFreqSupported(int freq) const = 0;
/**
* Function to configure send codec for the audio session
* @param sendSessionConfig: CodecConfiguration

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

@ -2172,7 +2172,15 @@ public:
, mConduit(aConduit)
, mSource(mTrack->GetInputStream()->AsSourceStream())
, mTrackId(mTrack->GetInputTrackId())
, mRate(mSource ? mSource->GraphRate() : 0)
// AudioSession conduit only supports 16, 32, 44.1 and 48kHz
// This is an artificial limitation, it would however require more changes
// to support any rates.
// If the sampling rate is not-supported, we will use 48kHz instead.
, mRate(mSource ? (static_cast<AudioSessionConduit*>(mConduit.get())
->IsSamplingFreqSupported(mSource->GraphRate())
? mSource->GraphRate()
: WEBRTC_MAX_SAMPLE_RATE)
: WEBRTC_MAX_SAMPLE_RATE)
, mTaskQueue(
new AutoTaskQueue(GetMediaThreadPool(MediaThreadType::WEBRTC_DECODER),
"AudioPipelineListener"))