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

Side by Side Diff: webrtc/api/audio/audio_mixer.h

Issue 2420913002: Move audio frame memory handling inside AudioMixer. (Closed)
Patch Set: . 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 14 matching lines...) Expand all
25 public: 25 public:
26 enum class AudioFrameInfo { 26 enum class AudioFrameInfo {
27 kNormal, // The samples in audio_frame are valid and should be used. 27 kNormal, // The samples in audio_frame are valid and should be used.
28 kMuted, // The samples in audio_frame should not be used, but 28 kMuted, // The samples in audio_frame should not be used, but
29 // should be implicitly interpreted as zero. Other 29 // should be implicitly interpreted as zero. Other
30 // fields in audio_frame may be read and should 30 // fields in audio_frame may be read and should
31 // contain meaningful values. 31 // contain meaningful values.
32 kError, // The audio_frame will not be used. 32 kError, // The audio_frame will not be used.
33 }; 33 };
34 34
35 struct AudioFrameWithInfo { 35 // The AudioFrame pointer should be treated as only valid for the
36 AudioFrame* audio_frame; 36 // duration of this call. The passed AudioFrame is strictly an
37 AudioFrameInfo audio_frame_info; 37 // output parameter and its fields can have any values when being
38 }; 38 // passed to GetAudioFrameWithInfo. Implementing classes may
39 39 // return sound with either one or two interleaved
40 // The implementation of GetAudioFrameWithInfo should update 40 // channels. Implementing classes are responsible for filling all
41 // audio_frame with new audio every time it's called. Implementing 41 // fields of the provided AudioFrame with meaningful values.
42 // classes are allowed to return the same AudioFrame pointer on 42 virtual AudioFrameInfo GetAudioFrameWithInfo(int sample_rate_hz,
43 // different calls. The pointer must stay valid until the next 43 AudioFrame* audio_frame) = 0;
44 // mixing call or until this audio source is disconnected from the
45 // mixer. The mixer may modify the contents of the passed
46 // AudioFrame pointer at any time until the next call to
47 // GetAudioFrameWithInfo, or until the source is removed from the
48 // mixer.
49 virtual AudioFrameWithInfo GetAudioFrameWithInfo(int sample_rate_hz) = 0;
50 44
51 // A way for a mixer implementation to distinguish participants. 45 // A way for a mixer implementation to distinguish participants.
52 virtual int Ssrc() = 0; 46 virtual int Ssrc() = 0;
53 47
54 protected: 48 protected:
55 virtual ~Source() {} 49 virtual ~Source() {}
aleloi 2016/10/14 15:34:44 [Unrelated to this CL]: I think the reasoning behi
kwiberg-webrtc 2016/10/14 19:59:32 Implementations can't make that choice. If you hav
aleloi 2016/10/17 11:06:39 Thanks for the explanation! Previously I ran in th
kwiberg-webrtc 2016/10/17 12:08:32 Oh, right. It's the AudioMixer destructor that sho
56 }; 50 };
57 51
58 // Since the mixer is reference counted, the destructor may be 52 // Since the mixer is reference counted, the destructor may be
59 // called from any thread. 53 // called from any thread.
60 ~AudioMixer() override {} 54 ~AudioMixer() override {}
61 55
62 // Returns true if adding/removing was successful. A source is never 56 // Returns true if adding/removing was successful. A source is never
63 // added twice and removal is never attempted if a source has not 57 // added twice and removal is never attempted if a source has not
64 // been successfully added to the mixer. Addition and removal can 58 // been successfully added to the mixer. Addition and removal can
65 // happen on different threads. 59 // happen on different threads.
66 virtual bool AddSource(Source* audio_source) = 0; 60 virtual bool AddSource(Source* audio_source) = 0;
67 virtual bool RemoveSource(Source* audio_source) = 0; 61 virtual bool RemoveSource(Source* audio_source) = 0;
68 62
69 // Performs mixing by asking registered audio sources for audio. The 63 // Performs mixing by asking registered audio sources for audio. The
70 // mixed result is placed in the provided AudioFrame. Will only be 64 // mixed result is placed in the provided AudioFrame. Will only be
71 // called from a single thread. The rate and channels arguments 65 // called from a single thread. The rate and channels arguments
72 // specify the rate and number of channels of the mix result. 66 // specify the rate and number of channels of the mix result.
73 virtual void Mix(int sample_rate_hz, 67 virtual void Mix(int sample_rate_hz,
74 size_t number_of_channels, 68 size_t number_of_channels,
75 AudioFrame* audio_frame_for_mixing) = 0; 69 AudioFrame* audio_frame_for_mixing) = 0;
76 }; 70 };
77 } // namespace webrtc 71 } // namespace webrtc
78 72
79 #endif // WEBRTC_API_AUDIO_AUDIO_MIXER_H_ 73 #endif // WEBRTC_API_AUDIO_AUDIO_MIXER_H_
OLDNEW
« no previous file with comments | « no previous file | webrtc/modules/audio_mixer/audio_mixer_impl.h » ('j') | webrtc/modules/audio_mixer/audio_mixer_impl.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698