| 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 <sys/mman.h> | 10 #include <sys/mman.h> |
| 11 #include <unistd.h> | 11 #include <unistd.h> |
| 12 #include <vector> | 12 #include <vector> |
| 13 | 13 |
| 14 #include "base/file_descriptor_posix.h" | 14 #include "base/file_descriptor_posix.h" |
| 15 #include "base/logging.h" | 15 #include "base/logging.h" |
| 16 #include "base/memory/shared_memory.h" | 16 #include "base/memory/shared_memory.h" |
| 17 #include "base/posix/eintr_wrapper.h" | 17 #include "base/posix/eintr_wrapper.h" |
| 18 #include "base/process/process_handle.h" |
| 18 #include "content/common/view_messages.h" | 19 #include "content/common/view_messages.h" |
| 19 #include "media/base/android/webaudio_media_codec_info.h" | 20 #include "media/base/android/webaudio_media_codec_info.h" |
| 20 #include "media/base/audio_bus.h" | 21 #include "media/base/audio_bus.h" |
| 21 #include "media/base/limits.h" | 22 #include "media/base/limits.h" |
| 22 #include "third_party/WebKit/public/platform/WebAudioBus.h" | 23 #include "third_party/WebKit/public/platform/WebAudioBus.h" |
| 23 | 24 |
| 24 namespace content { | 25 namespace content { |
| 25 | 26 |
| 26 class AudioDecoderIO { | 27 class AudioDecoderIO { |
| 27 public: | 28 public: |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 << ": " << strerror(errno); | 83 << ": " << strerror(errno); |
| 83 } | 84 } |
| 84 } | 85 } |
| 85 | 86 |
| 86 bool AudioDecoderIO::IsValid() const { | 87 bool AudioDecoderIO::IsValid() const { |
| 87 return read_fd_ >= 0 && write_fd_ >= 0 && | 88 return read_fd_ >= 0 && write_fd_ >= 0 && |
| 88 encoded_shared_memory_.memory(); | 89 encoded_shared_memory_.memory(); |
| 89 } | 90 } |
| 90 | 91 |
| 91 bool AudioDecoderIO::ShareEncodedToProcess(base::SharedMemoryHandle* handle) { | 92 bool AudioDecoderIO::ShareEncodedToProcess(base::SharedMemoryHandle* handle) { |
| 92 return encoded_shared_memory_.ShareToProcess( | 93 return encoded_shared_memory_.ShareToProcess(base::GetCurrentProcessHandle(), |
| 93 base::Process::Current().handle(), | 94 handle); |
| 94 handle); | |
| 95 } | 95 } |
| 96 | 96 |
| 97 static float ConvertSampleToFloat(int16_t sample) { | 97 static float ConvertSampleToFloat(int16_t sample) { |
| 98 const float kMaxScale = 1.0f / std::numeric_limits<int16_t>::max(); | 98 const float kMaxScale = 1.0f / std::numeric_limits<int16_t>::max(); |
| 99 const float kMinScale = -1.0f / std::numeric_limits<int16_t>::min(); | 99 const float kMinScale = -1.0f / std::numeric_limits<int16_t>::min(); |
| 100 | 100 |
| 101 return sample * (sample < 0 ? kMinScale : kMaxScale); | 101 return sample * (sample < 0 ? kMinScale : kMaxScale); |
| 102 } | 102 } |
| 103 | 103 |
| 104 // A basic WAVE file decoder. See | 104 // A basic WAVE file decoder. See |
| (...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 582 BufferAndCopyPcmDataToBus(input_fd, | 582 BufferAndCopyPcmDataToBus(input_fd, |
| 583 destination_bus, | 583 destination_bus, |
| 584 number_of_channels, | 584 number_of_channels, |
| 585 file_sample_rate); | 585 file_sample_rate); |
| 586 } | 586 } |
| 587 | 587 |
| 588 return true; | 588 return true; |
| 589 } | 589 } |
| 590 | 590 |
| 591 } // namespace content | 591 } // namespace content |
| OLD | NEW |