| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/renderer/media/android/audio_decoder_android.h" | 5 #include "content/renderer/media/android/audio_decoder_android.h" |
| 6 | 6 |
| 7 #include <errno.h> | 7 #include <errno.h> |
| 8 #include <fcntl.h> | 8 #include <fcntl.h> |
| 9 #include <limits.h> | 9 #include <limits.h> |
| 10 #include <stdint.h> |
| 10 #include <sys/mman.h> | 11 #include <sys/mman.h> |
| 11 #include <unistd.h> | 12 #include <unistd.h> |
| 12 #include <vector> | 13 #include <vector> |
| 13 | 14 |
| 14 #include "base/file_descriptor_posix.h" | 15 #include "base/file_descriptor_posix.h" |
| 15 #include "base/logging.h" | 16 #include "base/logging.h" |
| 17 #include "base/macros.h" |
| 16 #include "base/memory/shared_memory.h" | 18 #include "base/memory/shared_memory.h" |
| 17 #include "base/posix/eintr_wrapper.h" | 19 #include "base/posix/eintr_wrapper.h" |
| 18 #include "base/process/process_handle.h" | 20 #include "base/process/process_handle.h" |
| 19 #include "content/common/view_messages.h" | 21 #include "content/common/view_messages.h" |
| 20 #include "media/base/android/webaudio_media_codec_info.h" | 22 #include "media/base/android/webaudio_media_codec_info.h" |
| 21 #include "media/base/audio_bus.h" | 23 #include "media/base/audio_bus.h" |
| 22 #include "media/base/limits.h" | 24 #include "media/base/limits.h" |
| 23 #include "third_party/WebKit/public/platform/WebAudioBus.h" | 25 #include "third_party/WebKit/public/platform/WebAudioBus.h" |
| 24 | 26 |
| 25 namespace content { | 27 namespace content { |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 const float kMinScale = -1.0f / std::numeric_limits<int16_t>::min(); | 101 const float kMinScale = -1.0f / std::numeric_limits<int16_t>::min(); |
| 100 | 102 |
| 101 return sample * (sample < 0 ? kMinScale : kMaxScale); | 103 return sample * (sample < 0 ? kMinScale : kMaxScale); |
| 102 } | 104 } |
| 103 | 105 |
| 104 // A basic WAVE file decoder. See | 106 // A basic WAVE file decoder. See |
| 105 // https://ccrma.stanford.edu/courses/422/projects/WaveFormat/ for a | 107 // https://ccrma.stanford.edu/courses/422/projects/WaveFormat/ for a |
| 106 // basic guide to the WAVE file format. | 108 // basic guide to the WAVE file format. |
| 107 class WAVEDecoder { | 109 class WAVEDecoder { |
| 108 public: | 110 public: |
| 109 WAVEDecoder(const uint8* data, size_t data_size); | 111 WAVEDecoder(const uint8_t* data, size_t data_size); |
| 110 ~WAVEDecoder(); | 112 ~WAVEDecoder(); |
| 111 | 113 |
| 112 // Try to decode the data as a WAVE file. If the data is a supported | 114 // Try to decode the data as a WAVE file. If the data is a supported |
| 113 // WAVE file, |destination_bus| is filled with the decoded data and | 115 // WAVE file, |destination_bus| is filled with the decoded data and |
| 114 // DecodeWAVEFile returns true. Otherwise, DecodeWAVEFile returns | 116 // DecodeWAVEFile returns true. Otherwise, DecodeWAVEFile returns |
| 115 // false. | 117 // false. |
| 116 bool DecodeWAVEFile(blink::WebAudioBus* destination_bus); | 118 bool DecodeWAVEFile(blink::WebAudioBus* destination_bus); |
| 117 | 119 |
| 118 private: | 120 private: |
| 119 // Minimum number of bytes in a WAVE file to hold all of the data we | 121 // Minimum number of bytes in a WAVE file to hold all of the data we |
| (...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 585 BufferAndCopyPcmDataToBus(input_fd, | 587 BufferAndCopyPcmDataToBus(input_fd, |
| 586 destination_bus, | 588 destination_bus, |
| 587 number_of_channels, | 589 number_of_channels, |
| 588 file_sample_rate); | 590 file_sample_rate); |
| 589 } | 591 } |
| 590 | 592 |
| 591 return true; | 593 return true; |
| 592 } | 594 } |
| 593 | 595 |
| 594 } // namespace content | 596 } // namespace content |
| OLD | NEW |