• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2012 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5  * use this file except in compliance with the License. You may obtain a copy of
6  * the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13  * License for the specific language governing permissions and limitations under
14  * the License.
15  */
16 
17 #ifndef CTSAUDIO_SIGNALPROCESSINGIMPL_H
18 #define CTSAUDIO_SIGNALPROCESSINGIMPL_H
19 
20 #include <memory>
21 #include <utils/String8.h>
22 
23 #include "SignalProcessingInterface.h"
24 #include "ClientSocket.h"
25 #include "RWBuffer.h"
26 
27 /**
28  * Implements SignalProcessingInterface
29  */
30 class SignalProcessingImpl: public SignalProcessingInterface {
31 public:
32     static const android::String8 MAIN_PROCESSING_SCRIPT;
33     SignalProcessingImpl();
34     virtual ~SignalProcessingImpl();
35     /**
36      * @param script main script to call function script
37      */
38     virtual bool init(const android::String8& script);
39 
40     virtual TaskGeneric::ExecutionResult run(const android::String8& functionScript,
41             int nInputs, bool* inputTypes, void** inputs,
42             int nOutputs, bool* outputTypes, void** outputs);
43 private:
44     bool send(const char* data, int len);
45     bool read(char* data, int len);
46 
47 private:
48     static const int SCRIPT_PORT = 15010;
49     std::unique_ptr<ClientSocket> mSocket;
50     pid_t mChildPid;
51     bool mChildRunning;
52     RWBuffer mBuffer;
53 };
54 
55 
56 #endif //CTSAUDIO_SIGNALPROCESSINGIMPL_H
57