Index: media/audio/sounds/wav_audio_handler.h |
diff --git a/media/audio/sounds/wav_audio_handler.h b/media/audio/sounds/wav_audio_handler.h |
index 6e404faba18715c6752c5263f1923c915ed03183..1a95783753a7edb464d4170766da52f2633459bf 100644 |
--- a/media/audio/sounds/wav_audio_handler.h |
+++ b/media/audio/sounds/wav_audio_handler.h |
@@ -17,25 +17,32 @@ class AudioBus; |
// https://ccrma.stanford.edu/courses/422/projects/WaveFormat/ |
class MEDIA_EXPORT WavAudioHandler { |
public: |
+ // Parses |wav_data| for use by this class. If wav_data parses successfully, |
+ // is_valid() will return true. Otherwise, is_valid() will return false. |
explicit WavAudioHandler(const base::StringPiece& wav_data); |
virtual ~WavAudioHandler(); |
- // Returns true when cursor points to the end of the track. |
+ // If the data is not valid, returns true for any value of cursor. |
+ // Otherwise, returns true when cursor points to the end of the track. |
bool AtEnd(size_t cursor) const; |
// Copies the audio data to |bus| starting from the |cursor| and in |
// the case of success stores the number of written bytes in |
- // |bytes_written|. |bytes_written| should not be NULL. |
+ // |bytes_written|. |bytes_written| should not be NULL. Returns false if |
+ // data is not valid, or if the operation was unssuccessful. Returns true |
+ // otherwise. |
bool CopyTo(AudioBus* bus, size_t cursor, size_t* bytes_written) const; |
// Accessors. |
+ bool is_valid() const { return is_valid_; } |
const base::StringPiece& data() const { return data_; } |
uint16_t num_channels() const { return num_channels_; } |
uint32_t sample_rate() const { return sample_rate_; } |
uint16_t bits_per_sample() const { return bits_per_sample_; } |
uint32_t total_frames() const { return total_frames_; } |
- // Returns the duration of the entire audio chunk. |
+ // If the data is not valid(), returns zero duration. Otherwise, returns the |
+ // duration of the entire audio chunk. |
base::TimeDelta GetDuration() const; |
private: |
@@ -48,9 +55,12 @@ class MEDIA_EXPORT WavAudioHandler { |
// Parses the 'data' section chunk and stores |data_|. |
bool ParseDataChunk(const base::StringPiece& data); |
+ // Reset all data members to intial values. |
+ void ResetAll(); |
+ |
// Data part of the |wav_data_|. |
base::StringPiece data_; |
- |
+ bool is_valid_; |
uint16_t num_channels_; |
uint32_t sample_rate_; |
uint16_t bits_per_sample_; |