blob: 6420a9bf45c28a48dd83111bc1c7250416366ca7 [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);
Alexy Josephd464f3b2014-11-18 16:14:41 -080051#ifdef HW_ACC_HPX
52 virtual void updateHPXState(uint32_t state);
53#endif
54
Subhash Chandra Bose Naripeddye40a7cd2014-06-03 19:42:41 -070055 /* AudioBufferProvider that wraps a track AudioBufferProvider by a call to
56 h/w accelerated effect */
57 class EffectsBufferProvider : public AudioBufferProvider {
58 public:
59 EffectsBufferProvider();
60 virtual ~EffectsBufferProvider();
61
62 virtual status_t getNextBuffer(Buffer* buffer, int64_t pts);
63 virtual void releaseBuffer(Buffer* buffer);
64
65 AudioBufferProvider* mTrackBufferProvider;
66 effect_handle_t mEffectsHandle;
67 effect_config_t mEffectsConfig;
68
69 void *mInputBuffer;
70 void *mOutputBuffer;
71 uint32_t mInputBufferFrameCountOffset;
72 };
73
74 bool mEnabled;
75 int32_t mFd;
76
77 EffectsBufferProvider* mBufferProvider;
78
79private:
80 uint32_t mInputSampleRate;
81 uint32_t mOutputSampleRate;
82};
83
84
85// ----------------------------------------------------------------------------
86}; // namespace android
87
88#endif // ANDROID_EFFECTS_HW_ACC_H