| 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 "media/audio/android/audio_record_input.h" | 5 #include "media/audio/android/audio_record_input.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "jni/AudioRecordInput_jni.h" | 8 #include "jni/AudioRecordInput_jni.h" |
| 9 #include "media/audio/android/audio_manager_android.h" | 9 #include "media/audio/android/audio_manager_android.h" |
| 10 #include "media/base/audio_bus.h" | 10 #include "media/base/audio_bus.h" |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 // Passing zero as the volume parameter indicates there is no access to a | 63 // Passing zero as the volume parameter indicates there is no access to a |
| 64 // hardware volume slider. | 64 // hardware volume slider. |
| 65 audio_bus_->FromInterleaved( | 65 audio_bus_->FromInterleaved( |
| 66 direct_buffer_address_, audio_bus_->frames(), bytes_per_sample_); | 66 direct_buffer_address_, audio_bus_->frames(), bytes_per_sample_); |
| 67 callback_->OnData(this, audio_bus_.get(), hardware_delay_bytes, 0.0); | 67 callback_->OnData(this, audio_bus_.get(), hardware_delay_bytes, 0.0); |
| 68 } | 68 } |
| 69 | 69 |
| 70 bool AudioRecordInputStream::Open() { | 70 bool AudioRecordInputStream::Open() { |
| 71 DVLOG(2) << __PRETTY_FUNCTION__; | 71 DVLOG(2) << __PRETTY_FUNCTION__; |
| 72 DCHECK(thread_checker_.CalledOnValidThread()); | 72 DCHECK(thread_checker_.CalledOnValidThread()); |
| 73 return Java_AudioRecordInput_open( | 73 return Java_AudioRecordInput_open(base::android::AttachCurrentThread(), |
| 74 base::android::AttachCurrentThread(), j_audio_record_.obj()); | 74 j_audio_record_); |
| 75 } | 75 } |
| 76 | 76 |
| 77 void AudioRecordInputStream::Start(AudioInputCallback* callback) { | 77 void AudioRecordInputStream::Start(AudioInputCallback* callback) { |
| 78 DVLOG(2) << __PRETTY_FUNCTION__; | 78 DVLOG(2) << __PRETTY_FUNCTION__; |
| 79 DCHECK(thread_checker_.CalledOnValidThread()); | 79 DCHECK(thread_checker_.CalledOnValidThread()); |
| 80 DCHECK(callback); | 80 DCHECK(callback); |
| 81 | 81 |
| 82 if (callback_) { | 82 if (callback_) { |
| 83 // Start() was already called. | 83 // Start() was already called. |
| 84 DCHECK_EQ(callback_, callback); | 84 DCHECK_EQ(callback_, callback); |
| 85 return; | 85 return; |
| 86 } | 86 } |
| 87 // The Java thread has not yet started, so we are free to set |callback_|. | 87 // The Java thread has not yet started, so we are free to set |callback_|. |
| 88 callback_ = callback; | 88 callback_ = callback; |
| 89 | 89 |
| 90 Java_AudioRecordInput_start( | 90 Java_AudioRecordInput_start(base::android::AttachCurrentThread(), |
| 91 base::android::AttachCurrentThread(), j_audio_record_.obj()); | 91 j_audio_record_); |
| 92 } | 92 } |
| 93 | 93 |
| 94 void AudioRecordInputStream::Stop() { | 94 void AudioRecordInputStream::Stop() { |
| 95 DVLOG(2) << __PRETTY_FUNCTION__; | 95 DVLOG(2) << __PRETTY_FUNCTION__; |
| 96 DCHECK(thread_checker_.CalledOnValidThread()); | 96 DCHECK(thread_checker_.CalledOnValidThread()); |
| 97 if (!callback_) { | 97 if (!callback_) { |
| 98 // Start() was never called, or Stop() was already called. | 98 // Start() was never called, or Stop() was already called. |
| 99 return; | 99 return; |
| 100 } | 100 } |
| 101 | 101 |
| 102 Java_AudioRecordInput_stop( | 102 Java_AudioRecordInput_stop(base::android::AttachCurrentThread(), |
| 103 base::android::AttachCurrentThread(), j_audio_record_.obj()); | 103 j_audio_record_); |
| 104 | 104 |
| 105 // The Java thread must have been stopped at this point, so we are free to | 105 // The Java thread must have been stopped at this point, so we are free to |
| 106 // clear |callback_|. | 106 // clear |callback_|. |
| 107 callback_ = NULL; | 107 callback_ = NULL; |
| 108 } | 108 } |
| 109 | 109 |
| 110 void AudioRecordInputStream::Close() { | 110 void AudioRecordInputStream::Close() { |
| 111 DVLOG(2) << __PRETTY_FUNCTION__; | 111 DVLOG(2) << __PRETTY_FUNCTION__; |
| 112 DCHECK(thread_checker_.CalledOnValidThread()); | 112 DCHECK(thread_checker_.CalledOnValidThread()); |
| 113 Stop(); | 113 Stop(); |
| 114 DCHECK(!callback_); | 114 DCHECK(!callback_); |
| 115 Java_AudioRecordInput_close( | 115 Java_AudioRecordInput_close(base::android::AttachCurrentThread(), |
| 116 base::android::AttachCurrentThread(), j_audio_record_.obj()); | 116 j_audio_record_); |
| 117 audio_manager_->ReleaseInputStream(this); | 117 audio_manager_->ReleaseInputStream(this); |
| 118 } | 118 } |
| 119 | 119 |
| 120 double AudioRecordInputStream::GetMaxVolume() { | 120 double AudioRecordInputStream::GetMaxVolume() { |
| 121 NOTIMPLEMENTED(); | 121 NOTIMPLEMENTED(); |
| 122 return 0.0; | 122 return 0.0; |
| 123 } | 123 } |
| 124 | 124 |
| 125 void AudioRecordInputStream::SetVolume(double volume) { | 125 void AudioRecordInputStream::SetVolume(double volume) { |
| 126 NOTIMPLEMENTED(); | 126 NOTIMPLEMENTED(); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 140 NOTIMPLEMENTED(); | 140 NOTIMPLEMENTED(); |
| 141 return false; | 141 return false; |
| 142 } | 142 } |
| 143 | 143 |
| 144 bool AudioRecordInputStream::IsMuted() { | 144 bool AudioRecordInputStream::IsMuted() { |
| 145 NOTIMPLEMENTED(); | 145 NOTIMPLEMENTED(); |
| 146 return false; | 146 return false; |
| 147 } | 147 } |
| 148 | 148 |
| 149 } // namespace media | 149 } // namespace media |
| OLD | NEW |