blob: 919332b2014b9b06615e90a170d319bdb79bad95 [file] [log] [blame]
Subhash Chandra Bose Naripeddye40a7cd2014-06-03 19:42:41 -07001/*
2 * Copyright (c) 2014, The Linux Foundation. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above
10 * copyright notice, this list of conditions and the following
11 * disclaimer in the documentation and/or other materials provided
12 * with the distribution.
13 * * Neither the name of The Linux Foundation nor the names of its
14 * contributors may be used to endorse or promote products derived
15 * from this software without specific prior written permission.
16 *
17 *
18 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
19 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
21 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
22 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
25 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
27 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
28 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31#ifndef ANDROID_EFFECTS_HW_ACC_H
32#define ANDROID_EFFECTS_HW_ACC_H
33
34#include <media/AudioBufferProvider.h>
35
36namespace android {
37
38// ----------------------------------------------------------------------------
39class EffectsHwAcc {
40public:
41 EffectsHwAcc(uint32_t sampleRate);
42 virtual ~EffectsHwAcc();
43
44 virtual void setSampleRate(uint32_t inpSR, uint32_t outSR);
45 virtual void unprepareEffects(AudioBufferProvider **trackBufferProvider);
46 virtual status_t prepareEffects(AudioBufferProvider **trackBufferProvider,
47 int sessionId, audio_channel_mask_t channelMask,
48 int frameCount);
49 virtual void setBufferProvider(AudioBufferProvider **bufferProvider,
50 AudioBufferProvider **trackBufferProvider);
51 /* AudioBufferProvider that wraps a track AudioBufferProvider by a call to
52 h/w accelerated effect */
53 class EffectsBufferProvider : public AudioBufferProvider {
54 public:
55 EffectsBufferProvider();
56 virtual ~EffectsBufferProvider();
57
58 virtual status_t getNextBuffer(Buffer* buffer, int64_t pts);
59 virtual void releaseBuffer(Buffer* buffer);
60
61 AudioBufferProvider* mTrackBufferProvider;
62 effect_handle_t mEffectsHandle;
63 effect_config_t mEffectsConfig;
64
65 void *mInputBuffer;
66 void *mOutputBuffer;
67 uint32_t mInputBufferFrameCountOffset;
68 };
69
70 bool mEnabled;
71 int32_t mFd;
72
73 EffectsBufferProvider* mBufferProvider;
74
75private:
76 uint32_t mInputSampleRate;
77 uint32_t mOutputSampleRate;
78};
79
80
81// ----------------------------------------------------------------------------
82}; // namespace android
83
84#endif // ANDROID_EFFECTS_HW_ACC_H