Trivial data() and mutable_data() implementations
This will allow migrating existing references to data_ over to data() and mutable_data(), so that https://codereview.webrtc.org/2750783004/ can be imported cleanly. BUG=webrtc:7343 TBR=henrika@webrtc.org Review-Url: https://codereview.webrtc.org/2795103002 Cr-Commit-Position: refs/heads/master@{#17532}
This commit is contained in:
@ -279,9 +279,16 @@ class CallStatsObserver {
|
||||
*/
|
||||
class AudioFrame {
|
||||
public:
|
||||
// Stereo, 32 kHz, 60 ms (2 * 32 * 60)
|
||||
// Using constexpr here causes linker errors unless the variable also has an
|
||||
// out-of-class definition, which is impractical in this header-only class.
|
||||
// (This makes no sense because it compiles as an enum value, which we most
|
||||
// certainly cannot take the address of, just fine.) C++17 introduces inline
|
||||
// variables which should allow us to switch to constexpr and keep this a
|
||||
// header-only class.
|
||||
enum : size_t {
|
||||
kMaxDataSizeSamples = 3840
|
||||
// Stereo, 32 kHz, 60 ms (2 * 32 * 60)
|
||||
kMaxDataSizeSamples = 3840,
|
||||
kMaxDataSizeBytes = kMaxDataSizeSamples * sizeof(int16_t),
|
||||
};
|
||||
|
||||
enum VADActivity {
|
||||
@ -310,6 +317,11 @@ class AudioFrame {
|
||||
|
||||
void CopyFrom(const AudioFrame& src);
|
||||
|
||||
// TODO(yujo): upcoming API update. Currently, both of these just return
|
||||
// data_.
|
||||
const int16_t* data() const;
|
||||
int16_t* mutable_data();
|
||||
|
||||
// These methods are deprecated. Use the functions in
|
||||
// webrtc/audio/utility instead. These methods will exists for a
|
||||
// short period of time until webrtc clients have updated. See
|
||||
@ -401,6 +413,14 @@ inline void AudioFrame::CopyFrom(const AudioFrame& src) {
|
||||
memcpy(data_, src.data_, sizeof(int16_t) * length);
|
||||
}
|
||||
|
||||
inline const int16_t* AudioFrame::data() const {
|
||||
return data_;
|
||||
}
|
||||
|
||||
inline int16_t* AudioFrame::mutable_data() {
|
||||
return data_;
|
||||
}
|
||||
|
||||
inline void AudioFrame::Mute() {
|
||||
memset(data_, 0, samples_per_channel_ * num_channels_ * sizeof(int16_t));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user