2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved.
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
11 #ifndef WEBRTC_EXAMPLES_ANDROID_OPENSL_LOOPBACK_FAKE_AUDIO_DEVICE_BUFFER_H_
12 #define WEBRTC_EXAMPLES_ANDROID_OPENSL_LOOPBACK_FAKE_AUDIO_DEVICE_BUFFER_H_
14 #include "webrtc/modules/audio_device/android/audio_manager_jni.h"
15 #include "webrtc/modules/audio_device/android/single_rw_fifo.h"
16 #include "webrtc/modules/audio_device/audio_device_buffer.h"
17 #include "webrtc/system_wrappers/interface/scoped_ptr.h"
21 // Fake AudioDeviceBuffer implementation that returns audio data that is pushed
22 // to it. It implements all APIs used by the OpenSL implementation.
23 class FakeAudioDeviceBuffer : public AudioDeviceBuffer {
25 FakeAudioDeviceBuffer();
26 virtual ~FakeAudioDeviceBuffer() {}
28 virtual int32_t SetRecordingSampleRate(uint32_t fsHz);
29 virtual int32_t SetPlayoutSampleRate(uint32_t fsHz);
30 virtual int32_t SetRecordingChannels(uint8_t channels);
31 virtual int32_t SetPlayoutChannels(uint8_t channels);
32 virtual int32_t SetRecordedBuffer(const void* audioBuffer,
34 virtual void SetVQEData(int playDelayMS,
37 virtual int32_t DeliverRecordedData() { return 0; }
38 virtual int32_t RequestPlayoutData(uint32_t nSamples);
39 virtual int32_t GetPlayoutData(void* audioBuffer);
45 // Each buffer contains 10 ms of data since that is what OpenSlesInput
46 // delivers. Keep 7 buffers which would cover 70 ms of data. These buffers
47 // are needed because of jitter between OpenSl recording and playing.
50 int sample_rate() const;
51 int buffer_size_samples() const;
52 int buffer_size_bytes() const;
55 AudioManagerJni audio_manager_;
58 scoped_ptr<scoped_ptr<int8_t[]>[]> buf_;
59 int next_available_buffer_;
61 uint8_t record_channels_;
62 uint8_t play_channels_;
67 #endif // WEBRTC_EXAMPLES_ANDROID_OPENSL_LOOPBACK_FAKE_AUDIO_DEVICE_BUFFER_H_