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

Side by Side Diff: webrtc/common_audio/wav_file.h

Issue 1710083006: Changes in the wav_file implementation in order to avoid clang warnings (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 10 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
« no previous file with comments | « no previous file | webrtc/common_audio/wav_file.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2014 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 24 matching lines...) Expand all
35 }; 35 };
36 36
37 // Simple C++ class for writing 16-bit PCM WAV files. All error handling is 37 // Simple C++ class for writing 16-bit PCM WAV files. All error handling is
38 // by calls to RTC_CHECK(), making it unsuitable for anything but debug code. 38 // by calls to RTC_CHECK(), making it unsuitable for anything but debug code.
39 class WavWriter final : public WavFile { 39 class WavWriter final : public WavFile {
40 public: 40 public:
41 // Open a new WAV file for writing. 41 // Open a new WAV file for writing.
42 WavWriter(const std::string& filename, int sample_rate, size_t num_channels); 42 WavWriter(const std::string& filename, int sample_rate, size_t num_channels);
43 43
44 // Close the WAV file, after writing its header. 44 // Close the WAV file, after writing its header.
45 ~WavWriter(); 45 ~WavWriter() override;
46 46
47 // Write additional samples to the file. Each sample is in the range 47 // Write additional samples to the file. Each sample is in the range
48 // [-32768,32767], and there must be the previously specified number of 48 // [-32768,32767], and there must be the previously specified number of
49 // interleaved channels. 49 // interleaved channels.
50 void WriteSamples(const float* samples, size_t num_samples); 50 void WriteSamples(const float* samples, size_t num_samples);
51 void WriteSamples(const int16_t* samples, size_t num_samples); 51 void WriteSamples(const int16_t* samples, size_t num_samples);
52 52
53 int sample_rate() const override { return sample_rate_; } 53 int sample_rate() const override;
54 size_t num_channels() const override { return num_channels_; } 54 size_t num_channels() const override;
55 size_t num_samples() const override { return num_samples_; } 55 size_t num_samples() const override;
56 56
57 private: 57 private:
58 void Close(); 58 void Close();
59 const int sample_rate_; 59 const int sample_rate_;
60 const size_t num_channels_; 60 const size_t num_channels_;
61 size_t num_samples_; // Total number of samples written to file. 61 size_t num_samples_; // Total number of samples written to file.
62 FILE* file_handle_; // Output file, owned by this class 62 FILE* file_handle_; // Output file, owned by this class
63 63
64 RTC_DISALLOW_COPY_AND_ASSIGN(WavWriter); 64 RTC_DISALLOW_COPY_AND_ASSIGN(WavWriter);
65 }; 65 };
66 66
67 // Follows the conventions of WavWriter. 67 // Follows the conventions of WavWriter.
68 class WavReader final : public WavFile { 68 class WavReader final : public WavFile {
69 public: 69 public:
70 // Opens an existing WAV file for reading. 70 // Opens an existing WAV file for reading.
71 explicit WavReader(const std::string& filename); 71 explicit WavReader(const std::string& filename);
72 72
73 // Close the WAV file. 73 // Close the WAV file.
74 ~WavReader(); 74 ~WavReader() override;
75 75
76 // Returns the number of samples read. If this is less than requested, 76 // Returns the number of samples read. If this is less than requested,
77 // verifies that the end of the file was reached. 77 // verifies that the end of the file was reached.
78 size_t ReadSamples(size_t num_samples, float* samples); 78 size_t ReadSamples(size_t num_samples, float* samples);
79 size_t ReadSamples(size_t num_samples, int16_t* samples); 79 size_t ReadSamples(size_t num_samples, int16_t* samples);
80 80
81 int sample_rate() const override { return sample_rate_; } 81 int sample_rate() const override;
82 size_t num_channels() const override { return num_channels_; } 82 size_t num_channels() const override;
83 size_t num_samples() const override { return num_samples_; } 83 size_t num_samples() const override;
84 84
85 private: 85 private:
86 void Close(); 86 void Close();
87 int sample_rate_; 87 int sample_rate_;
88 size_t num_channels_; 88 size_t num_channels_;
89 size_t num_samples_; // Total number of samples in the file. 89 size_t num_samples_; // Total number of samples in the file.
90 size_t num_samples_remaining_; 90 size_t num_samples_remaining_;
91 FILE* file_handle_; // Input file, owned by this class. 91 FILE* file_handle_; // Input file, owned by this class.
92 92
93 RTC_DISALLOW_COPY_AND_ASSIGN(WavReader); 93 RTC_DISALLOW_COPY_AND_ASSIGN(WavReader);
(...skipping 15 matching lines...) Expand all
109 size_t num_samples); 109 size_t num_samples);
110 int rtc_WavSampleRate(const rtc_WavWriter* wf); 110 int rtc_WavSampleRate(const rtc_WavWriter* wf);
111 size_t rtc_WavNumChannels(const rtc_WavWriter* wf); 111 size_t rtc_WavNumChannels(const rtc_WavWriter* wf);
112 size_t rtc_WavNumSamples(const rtc_WavWriter* wf); 112 size_t rtc_WavNumSamples(const rtc_WavWriter* wf);
113 113
114 #ifdef __cplusplus 114 #ifdef __cplusplus
115 } // extern "C" 115 } // extern "C"
116 #endif 116 #endif
117 117
118 #endif // WEBRTC_COMMON_AUDIO_WAV_FILE_H_ 118 #endif // WEBRTC_COMMON_AUDIO_WAV_FILE_H_
OLDNEW
« no previous file with comments | « no previous file | webrtc/common_audio/wav_file.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698