blob: 0452f577f1e8bb870f9e865ce6c884c9e6bba091 [file] [log] [blame]
Subhash Chandra Bose Naripeddye40a7cd2014-06-03 19:42:41 -07001/*
Dhananjay Kumar16ac9e52015-07-20 16:56:45 +05302 * Copyright (c) 2014-15, The Linux Foundation. All rights reserved.
Subhash Chandra Bose Naripeddye40a7cd2014-06-03 19:42:41 -07003 *
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);
Dhananjay Kumar16ac9e52015-07-20 16:56:45 +053046 virtual status_t prepareEffects(AudioBufferProvider **trackInputBufferProvider,
47 AudioBufferProvider **trackBufferProvider,
Subhash Chandra Bose Naripeddye40a7cd2014-06-03 19:42:41 -070048 int sessionId, audio_channel_mask_t channelMask,
49 int frameCount);
Dhananjay Kumar16ac9e52015-07-20 16:56:45 +053050 virtual void setBufferProvider(AudioBufferProvider **trackInputbufferProvider,
Subhash Chandra Bose Naripeddye40a7cd2014-06-03 19:42:41 -070051 AudioBufferProvider **trackBufferProvider);
Alexy Josephd464f3b2014-11-18 16:14:41 -080052#ifdef HW_ACC_HPX
53 virtual void updateHPXState(uint32_t state);
54#endif
55
Subhash Chandra Bose Naripeddye40a7cd2014-06-03 19:42:41 -070056 /* AudioBufferProvider that wraps a track AudioBufferProvider by a call to
57 h/w accelerated effect */
58 class EffectsBufferProvider : public AudioBufferProvider {
59 public:
60 EffectsBufferProvider();
61 virtual ~EffectsBufferProvider();
62
63 virtual status_t getNextBuffer(Buffer* buffer, int64_t pts);
64 virtual void releaseBuffer(Buffer* buffer);
65
Dhananjay Kumar16ac9e52015-07-20 16:56:45 +053066 AudioBufferProvider* mTrackInputBufferProvider;
Subhash Chandra Bose Naripeddye40a7cd2014-06-03 19:42:41 -070067 AudioBufferProvider* mTrackBufferProvider;
68 effect_handle_t mEffectsHandle;
69 effect_config_t mEffectsConfig;
70
71 void *mInputBuffer;
72 void *mOutputBuffer;
73 uint32_t mInputBufferFrameCountOffset;
74 };
75
76 bool mEnabled;
77 int32_t mFd;
78
79 EffectsBufferProvider* mBufferProvider;
80
81private:
82 uint32_t mInputSampleRate;
83 uint32_t mOutputSampleRate;
84};
85
86
87// ----------------------------------------------------------------------------
88}; // namespace android
89
90#endif // ANDROID_EFFECTS_HW_ACC_H