OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_track_output_android.h" | 5 #include "media/audio/android/audio_track_output_android.h" |
6 | 6 |
7 #include "base/android/jni_android.h" | 7 #include "base/android/jni_android.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/time.h" | 10 #include "base/time.h" |
11 | 11 |
12 using base::android::AttachCurrentThread; | 12 using base::android::AttachCurrentThread; |
13 using base::android::CheckException; | 13 using base::android::CheckException; |
14 | 14 |
| 15 namespace media { |
| 16 |
15 static const int kTimerIntervalInMilliseconds = 50; | 17 static const int kTimerIntervalInMilliseconds = 50; |
16 | 18 |
17 class AudioTrackOutputStream::StreamBuffer { | 19 class AudioTrackOutputStream::StreamBuffer { |
18 public: | 20 public: |
19 explicit StreamBuffer(uint32 buffer_size); | 21 explicit StreamBuffer(uint32 buffer_size); |
20 | 22 |
21 uint32 ReadStream(uint8* dest, uint32 max_size); | 23 uint32 ReadStream(uint8* dest, uint32 max_size); |
22 void ResetBuffer(uint32 data_size); | 24 void ResetBuffer(uint32 data_size); |
23 uint8* GetWritableBuffer(); | 25 uint8* GetWritableBuffer(); |
24 const uint8* ReadBuffer(); | 26 const uint8* ReadBuffer(); |
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
302 reinterpret_cast<const jbyte*>(data_buffer_->ReadBuffer())); | 304 reinterpret_cast<const jbyte*>(data_buffer_->ReadBuffer())); |
303 data_buffer_->AdvancePosition(need_buffer); | 305 data_buffer_->AdvancePosition(need_buffer); |
304 | 306 |
305 // Invoke method to submit samples. | 307 // Invoke method to submit samples. |
306 method = env->GetMethodID(j_class_, "write", "([BII)I"); | 308 method = env->GetMethodID(j_class_, "write", "([BII)I"); |
307 env->CallIntMethod(j_audio_track_, method, buf, static_cast<jint>(0), | 309 env->CallIntMethod(j_audio_track_, method, buf, static_cast<jint>(0), |
308 static_cast<jint>(need_buffer)); | 310 static_cast<jint>(need_buffer)); |
309 CheckException(env); | 311 CheckException(env); |
310 env->DeleteLocalRef(buf); | 312 env->DeleteLocalRef(buf); |
311 } | 313 } |
| 314 |
| 315 } // namespace media |
OLD | NEW |