OLD | NEW |
1 // Copyright (c) 2012 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 | |
17 static const int kTimerIntervalInMilliseconds = 50; | 15 static const int kTimerIntervalInMilliseconds = 50; |
18 | 16 |
19 class AudioTrackOutputStream::StreamBuffer { | 17 class AudioTrackOutputStream::StreamBuffer { |
20 public: | 18 public: |
21 explicit StreamBuffer(uint32 buffer_size); | 19 explicit StreamBuffer(uint32 buffer_size); |
22 | 20 |
23 uint32 ReadStream(uint8* dest, uint32 max_size); | 21 uint32 ReadStream(uint8* dest, uint32 max_size); |
24 void ResetBuffer(uint32 data_size); | 22 void ResetBuffer(uint32 data_size); |
25 uint8* GetWritableBuffer(); | 23 uint8* GetWritableBuffer(); |
26 const uint8* ReadBuffer(); | 24 const uint8* ReadBuffer(); |
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
304 reinterpret_cast<const jbyte*>(data_buffer_->ReadBuffer())); | 302 reinterpret_cast<const jbyte*>(data_buffer_->ReadBuffer())); |
305 data_buffer_->AdvancePosition(need_buffer); | 303 data_buffer_->AdvancePosition(need_buffer); |
306 | 304 |
307 // Invoke method to submit samples. | 305 // Invoke method to submit samples. |
308 method = env->GetMethodID(j_class_, "write", "([BII)I"); | 306 method = env->GetMethodID(j_class_, "write", "([BII)I"); |
309 env->CallIntMethod(j_audio_track_, method, buf, static_cast<jint>(0), | 307 env->CallIntMethod(j_audio_track_, method, buf, static_cast<jint>(0), |
310 static_cast<jint>(need_buffer)); | 308 static_cast<jint>(need_buffer)); |
311 CheckException(env); | 309 CheckException(env); |
312 env->DeleteLocalRef(buf); | 310 env->DeleteLocalRef(buf); |
313 } | 311 } |
314 | |
315 } // namespace media | |
OLD | NEW |