~ubuntu-branches/ubuntu/wily/tucnak/wily

« back to all changes in this revision

Viewing changes to src/sles.c

  • Committer: Package Import Robot
  • Author(s): Colin Tuckley
  • Date: 2015-05-25 17:38:00 UTC
  • Revision ID: package-import@ubuntu.com-20150525173800-81ok9cfis17n3ohu
Tags: upstream-4.03
ImportĀ upstreamĀ versionĀ 4.03

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
    Tucnak - VHF contest log
 
3
    Copyright (C) 2002-2013  Ladislav Vaiz <ok1zia@nagano.cz>
 
4
 
 
5
    This program is free software; you can redistribute it and/or
 
6
    modify it under the terms of the GNU General Public License
 
7
    version 2 as published by the Free Software Foundation.
 
8
 
 
9
*/
 
10
 
 
11
#include "header.h"
 
12
 
 
13
#include "dsp.h"
 
14
 
 
15
#ifdef HAVE_SLES_OPENSLES_H
 
16
#include <SLES/OpenSLES_Android.h>
 
17
#endif
 
18
 
 
19
 
 
20
int sles_open(struct dsp *dsp, int rec){
 
21
    int result;
 
22
 
 
23
    result = slCreateEngine(&(dsp->engineObject), 0, NULL, 0, NULL, NULL);
 
24
 
 
25
    if (!rec){
 
26
        // play
 
27
        const SLInterfaceID ids[] = {SL_IID_VOLUME};
 
28
        const SLboolean req[] = {SL_BOOLEAN_FALSE} ;
 
29
        result = (*dsp->engineEngine)->CreateOutputMix(dsp->engineEngine, &(dsp->outputMixObject), 1, ids, req);
 
30
        result = (*dsp->outputMixObject)->Realize(dsp->outputMixObject, SL_BOOLEAN_FALSE);
 
31
 
 
32
        SLDataLocator_AndroidSimpleBufferQueue loc_bufq = {SL_DATALOCATOR_ANDROIDSIMPLEBUFFERQUEUE, 2};
 
33
        SLDataFormat_PCM format_pcm = {SL_DATAFORMAT_PCM, dsp->channels, dsp->speed, SL_PCMSAMPLEFORMAT_FIXED_16, SL_PCMSAMPLEFORMAT_FIXED_16,
 
34
               speakers, SL_BYTEORDER_LITTLEENDIAN};
 
35
        SLDataSource audioSrc = {&loc_bufq, &format_pcm};
 
36
 
 
37
        SLDataLocator_OutputMix loc_outmix = {SL_DATALOCATOR_OUTPUTMIX, dsp->outputMixObject};
 
38
        SLDataSink audioSnk = {&loc_outmix, NULL};
 
39
 
 
40
        const SLInterfaceID ids1[] = {SL_IID_ANDROIDSIMPLEBUFFERQUEUE};
 
41
        const SLboolean req1[] = {SL_BOOLEAN_TRUE};
 
42
        result = (*dsp->engineEngine)->CreateAudioPlayer(dsp->engineEngine, &(dsp->bqPlayerObject), &audioSrc, &audioSnk, 1, ids1, req1);
 
43
        result = (*dsp->bqPlayerObject)->Realize(dsp->bqPlayerObject, SL_BOOLEAN_FALSE);
 
44
 
 
45
        result = (*dsp->bqPlayerObject)->GetInterface(dsp->bqPlayerObject, SL_IID_PLAY,&(dsp->bqPlayerPlay));
 
46
        result = (*dsp->bqPlayerObject)->GetInterface(dsp->bqPlayerObject, SL_IID_ANDROIDSIMPLEBUFFERQUEUE, &(dsp->bqPlayerBufferQueue));
 
47
 
 
48
        result = (*dsp->bqPlayerBufferQueue)->RegisterCallback(dsp->bqPlayerBufferQueue, bqPlayerCallback, dsp);
 
49
        result = (*p->bqPlayerPlay)->SetPlayState(p->bqPlayerPlay, SL_PLAYSTATE_PLAYING);
 
50
 
 
51
    }else{
 
52
        // record
 
53
 
 
54
        SLDataLocator_IODevice loc_dev = {SL_DATALOCATOR_IODEVICE, SL_IODEVICE_AUDIOINPUT, SL_DEFAULTDEVICEID_AUDIOINPUT, NULL};
 
55
        SLDataSource audioSrc = {&loc_dev, NULL};
 
56
 
 
57
        SLDataLocator_AndroidSimpleBufferQueue loc_bq = {SL_DATALOCATOR_ANDROIDSIMPLEBUFFERQUEUE, 2};
 
58
        SLDataFormat_PCM format_pcm = {SL_DATAFORMAT_PCM, channels, sr, SL_PCMSAMPLEFORMAT_FIXED_16, SL_PCMSAMPLEFORMAT_FIXED_16,
 
59
              speakers, SL_BYTEORDER_LITTLEENDIAN};
 
60
        SLDataSink audioSnk = {&loc_bq, &format_pcm};
 
61
 
 
62
        const SLInterfaceID id[1] = {SL_IID_ANDROIDSIMPLEBUFFERQUEUE};
 
63
        const SLboolean req[1] = {SL_BOOLEAN_TRUE};
 
64
        result = (*p->engineEngine)->CreateAudioRecorder(p->engineEngine, &(p->recorderObject), &audioSrc, &audioSnk, 1, id, req);
 
65
 
 
66
        result = (*p->recorderObject)->Realize(p->recorderObject, SL_BOOLEAN_FALSE);
 
67
 
 
68
        result = (*p->recorderObject)->GetInterface(p->recorderObject, SL_IID_RECORD, &(p->recorderRecord));
 
69
 
 
70
        result = (*p->recorderObject)->GetInterface(p->recorderObject, SL_IID_ANDROIDSIMPLEBUFFERQUEUE, &(p->recorderBufferQueue));
 
71
 
 
72
        result = (*p->recorderBufferQueue)->RegisterCallback(p->recorderBufferQueue, bqRecorderCallback,p);
 
73
 
 
74
        result = (*p->recorderRecord)->SetRecordState(
 
75
                      p->recorderRecord,SL_RECORDSTATE_RECORDING);
 
76
    }
 
77
 
 
78
}
 
79
 
 
80
int sles_close(struct dsp *dsp){
 
81
}
 
82
 
 
83
 
 
84
 
 
85
int sles_write(struct dsp *dsp, void *data, int len){
 
86
}
 
87
 
 
88
int sles_read(struct dsp *dsp, void *data, int len){
 
89
}
 
90
 
 
91
int sles_reset(struct dsp *dsp){
 
92
}
 
93
 
 
94
int sles_sync(struct dsp *dsp){
 
95
}
 
96
 
 
97
int sles_set_format(struct dsp *dsp, SF_INFO *sfinfo, int ret){
 
98
}