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

Unified Diff: webrtc/modules/audio_mixer/audio_mixer_impl.h

Issue 2420913002: Move audio frame memory handling inside AudioMixer. (Closed)
Patch Set: Rebase. Created 4 years, 2 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_mixer/audio_mixer_impl.h
diff --git a/webrtc/modules/audio_mixer/audio_mixer_impl.h b/webrtc/modules/audio_mixer/audio_mixer_impl.h
index 500bb7862e5defe2b9fd906c057c6cf60fec3087..df14b3b469e31b4049806cd540b72cc87662bb9f 100644
--- a/webrtc/modules/audio_mixer/audio_mixer_impl.h
+++ b/webrtc/modules/audio_mixer/audio_mixer_impl.h
@@ -29,15 +29,22 @@ typedef std::vector<AudioFrame*> AudioFrameList;
class AudioMixerImpl : public AudioMixer {
public:
- struct SourceStatus {
- SourceStatus(Source* audio_source, bool is_mixed, float gain)
- : audio_source(audio_source), is_mixed(is_mixed), gain(gain) {}
+ struct SourceStatusWithFrame {
+ SourceStatusWithFrame(Source* audio_source, bool is_mixed, float gain)
kwiberg-webrtc 2016/10/14 19:59:33 I don't think you need to change the name. That we
aleloi 2016/10/17 11:06:39 OK, I've changed it back.
+ : audio_source(audio_source),
+ is_mixed(is_mixed),
+ gain(gain),
+ audio_frame() {}
kwiberg-webrtc 2016/10/14 19:59:33 You don't need to mention audio_frame here; since
aleloi 2016/10/17 11:06:39 Thanks! I mis-applied a guideline from Scott Meyer
Source* audio_source = nullptr;
bool is_mixed = false;
float gain = 0.0f;
+
+ // A frame that will be passed to audio_source->GetAudioFrameWithInfo.
+ AudioFrame audio_frame{};
};
- typedef std::vector<SourceStatus> SourceStatusList;
+ typedef std::vector<std::unique_ptr<SourceStatusWithFrame>>
+ SourceStatusWithFrameList;
kwiberg-webrtc 2016/10/14 19:59:33 Did you start using unique_ptr here because you ca
kwiberg-webrtc 2016/10/14 19:59:33 Prefer to use "using" instead of "typedef". It has
aleloi 2016/10/17 11:06:39 Done.
aleloi 2016/10/17 11:06:39 Yes, exactly. We could probably add move construct
kwiberg-webrtc 2016/10/17 12:08:32 I don't think anything bad would happen. But since
// AudioProcessing only accepts 10 ms frames.
static const int kFrameDurationInMs = 10;
@@ -77,9 +84,10 @@ class AudioMixerImpl : public AudioMixer {
// Add/remove the MixerAudioSource to the specified
// MixerAudioSource list.
bool AddAudioSourceToList(Source* audio_source,
- SourceStatusList* audio_source_list) const;
- bool RemoveAudioSourceFromList(Source* remove_audio_source,
- SourceStatusList* audio_source_list) const;
+ SourceStatusWithFrameList* audio_source_list) const;
+ bool RemoveAudioSourceFromList(
+ Source* remove_audio_source,
+ SourceStatusWithFrameList* audio_source_list) const;
bool LimitMixedAudio(AudioFrame* mixed_audio) const;
@@ -91,7 +99,8 @@ class AudioMixerImpl : public AudioMixer {
size_t sample_size_ ACCESS_ON(&thread_checker_);
// List of all audio sources. Note all lists are disjunct
- SourceStatusList audio_source_list_ GUARDED_BY(crit_); // May be mixed.
+ SourceStatusWithFrameList audio_source_list_
+ GUARDED_BY(crit_); // May be mixed.
// Determines if we will use a limiter for clipping protection during
// mixing.

Powered by Google App Engine
This is Rietveld 408576698