sles.h revision 73391c7b0650f8b96d9976c0fe36a967900958c5
1fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot/*
2fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot * Copyright (C) 2015 The Android Open Source Project
3fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot *
4fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot * Licensed under the Apache License, Version 2.0 (the "License");
5fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot * you may not use this file except in compliance with the License.
6fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot * You may obtain a copy of the License at
7fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot *
8fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot *      http://www.apache.org/licenses/LICENSE-2.0
9fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot *
10fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot * Unless required by applicable law or agreed to in writing, software
11fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot * distributed under the License is distributed on an "AS IS" BASIS,
12fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot * See the License for the specific language governing permissions and
14fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot * limitations under the License.
15fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot */
16fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot
17fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot#include <SLES/OpenSLES.h>
18fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot#include <SLES/OpenSLES_Android.h>
19fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot#include <pthread.h>
20fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot
21fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot#ifndef _Included_org_drrickorang_loopback_sles
22fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot#define _Included_org_drrickorang_loopback_sles
23fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot
24fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot//struct audio_utils_fifo;
25fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot
26fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot#ifdef __cplusplus
27extern "C" {
28#endif
29#include <audio_utils/fifo.h>
30
31typedef struct {
32    SLuint32 rxBufCount;     // -r#
33    SLuint32 txBufCount;     // -t#
34    SLuint32 bufSizeInFrames;  // -f#
35    SLuint32 channels;       // -c#
36    SLuint32 sampleRate; // -s#
37    SLuint32 exitAfterSeconds; // -e#
38    SLuint32 freeBufCount;   // calculated
39    SLuint32 bufSizeInBytes; // calculated
40    int injectImpulse; // -i#i
41
42    // Storage area for the buffer queues
43    char **rxBuffers;
44    char **txBuffers;
45    char **freeBuffers;
46
47    // Buffer indices
48    SLuint32 rxFront;    // oldest recording
49    SLuint32 rxRear;     // next to be recorded
50    SLuint32 txFront;    // oldest playing
51    SLuint32 txRear;     // next to be played
52    SLuint32 freeFront;  // oldest free
53    SLuint32 freeRear;   // next to be freed
54
55    struct audio_utils_fifo fifo; //(*)
56    struct audio_utils_fifo fifo2;
57    short *fifo2Buffer;
58    short *fifoBuffer;
59    SLAndroidSimpleBufferQueueItf recorderBufferQueue;
60    SLBufferQueueItf playerBufferQueue;
61
62    pthread_mutex_t mutex;// = PTHREAD_MUTEX_INITIALIZER;
63
64    //other things that belong here
65    SLObjectItf playerObject;
66    SLObjectItf recorderObject;
67    SLObjectItf outputmixObject;
68    SLObjectItf engineObject;
69} sles_data;
70
71enum {
72    SLES_SUCCESS = 0,
73    SLES_FAIL = 1,
74} SLES_STATUS_ENUM;
75
76int slesInit( sles_data ** ppSles, int samplingRate, int frameCount);
77//note the double pointer to properly free the memory of the structure
78int slesDestroy( sles_data ** ppSles);
79
80
81///full
82int slesFull(sles_data *pSles);
83
84int slesCreateServer(sles_data *pSles, int samplingRate, int frameCount);
85int slesProcessNext(sles_data *pSles, double *pSamples, long maxSamples);
86int slesDestroyServer(sles_data *pSles);
87
88#ifdef __cplusplus
89}
90#endif
91#endif //_Included_org_drrickorang_loopback_sles
92