Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(306)

Unified Diff: webrtc/modules/audio_device/audio_device_buffer.h

Issue 2324113002: Avoids crash at device switch on iOS (Closed)
Patch Set: Feedback from grunell@ Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webrtc/modules/audio_device/audio_device_buffer.h
diff --git a/webrtc/modules/audio_device/audio_device_buffer.h b/webrtc/modules/audio_device/audio_device_buffer.h
index 9754187c9bb668acf6c5ec22cb6704bbb755f1ec..e384a31239002723ffe17369ef2064850cea94e5 100644
--- a/webrtc/modules/audio_device/audio_device_buffer.h
+++ b/webrtc/modules/audio_device/audio_device_buffer.h
@@ -73,8 +73,11 @@ class AudioDeviceBuffer {
int32_t SetTypingStatus(bool typing_status);
private:
- void AllocatePlayoutBufferIfNeeded();
- void AllocateRecordingBufferIfNeeded();
+ // Playout and recording parameters can change on the fly. e.g. at device
+ // switch. These methods ensures that the callback methods always use the
+ // latest parameters.
+ void UpdatePlayoutParameters();
+ void UpdateRecordingParameters();
// Posts the first delayed task in the task queue and starts the periodic
// timer.
@@ -131,14 +134,14 @@ class AudioDeviceBuffer {
size_t play_samples_per_10ms_;
size_t play_bytes_per_10ms_;
- // Buffer used for recorded audio samples. Size is given by
- // |rec_bytes_per_10ms_| and the buffer is allocated in InitRecording() on the
- // main/creating thread.
+ // Buffer used for recorded audio samples. Size is currently fixed
+ // but it should be changed to be dynamic and correspond to
+ // |play_bytes_per_10ms_|. TODO(henrika): avoid using fixed (max) size.
std::unique_ptr<int8_t[]> rec_buffer_;
- // Buffer used for audio samples to be played out. Size is given by
- // |play_bytes_per_10ms_| and the buffer is allocated in InitPlayout() on the
- // main/creating thread.
+ // Buffer used for audio samples to be played out. Size is currently fixed
+ // but it should be changed to be dynamic and correspond to
+ // |play_bytes_per_10ms_|. TODO(henrika): avoid using fixed (max) size.
std::unique_ptr<int8_t[]> play_buffer_;
// AGC parameters.
« no previous file with comments | « no previous file | webrtc/modules/audio_device/audio_device_buffer.cc » ('j') | webrtc/modules/audio_device/audio_device_buffer.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698