use different stream formats for input and output
This commit is contained in:
parent
7d5c8165d4
commit
d0ffc5ceed
1 changed files with 20 additions and 11 deletions
|
@ -29,15 +29,24 @@
|
||||||
CSound::CSound ( void (*fpNewProcessCallback) ( CVector<short>& psData, void* arg ), void* arg ) :
|
CSound::CSound ( void (*fpNewProcessCallback) ( CVector<short>& psData, void* arg ), void* arg ) :
|
||||||
CSoundBase ( "OpenSL", true, fpNewProcessCallback, arg )
|
CSoundBase ( "OpenSL", true, fpNewProcessCallback, arg )
|
||||||
{
|
{
|
||||||
// set up stream format
|
// set up stream formats for input and output
|
||||||
SLDataFormat_PCM streamFormat;
|
SLDataFormat_PCM inStreamFormat;
|
||||||
streamFormat.formatType = SL_DATAFORMAT_PCM;
|
inStreamFormat.formatType = SL_DATAFORMAT_PCM;
|
||||||
streamFormat.numChannels = 1;// TEST 2;
|
inStreamFormat.numChannels = 1;
|
||||||
streamFormat.samplesPerSec = SL_SAMPLINGRATE_16;//TEST SYSTEM_SAMPLE_RATE_HZ * 1000; // unit is mHz
|
inStreamFormat.samplesPerSec = SL_SAMPLINGRATE_16;
|
||||||
streamFormat.bitsPerSample = SL_PCMSAMPLEFORMAT_FIXED_16;
|
inStreamFormat.bitsPerSample = SL_PCMSAMPLEFORMAT_FIXED_16;
|
||||||
streamFormat.containerSize = 16;
|
inStreamFormat.containerSize = 16;
|
||||||
streamFormat.channelMask = SL_SPEAKER_FRONT_CENTER;// TEST SL_SPEAKER_FRONT_LEFT | SL_SPEAKER_FRONT_RIGHT;
|
inStreamFormat.channelMask = SL_SPEAKER_FRONT_CENTER;
|
||||||
streamFormat.endianness = SL_BYTEORDER_LITTLEENDIAN;
|
inStreamFormat.endianness = SL_BYTEORDER_LITTLEENDIAN;
|
||||||
|
|
||||||
|
SLDataFormat_PCM outStreamFormat;
|
||||||
|
outStreamFormat.formatType = SL_DATAFORMAT_PCM;
|
||||||
|
outStreamFormat.numChannels = 2;
|
||||||
|
outStreamFormat.samplesPerSec = SYSTEM_SAMPLE_RATE_HZ * 1000; // unit is mHz
|
||||||
|
outStreamFormat.bitsPerSample = SL_PCMSAMPLEFORMAT_FIXED_16;
|
||||||
|
outStreamFormat.containerSize = 16;
|
||||||
|
outStreamFormat.channelMask = SL_SPEAKER_FRONT_LEFT | SL_SPEAKER_FRONT_RIGHT;
|
||||||
|
outStreamFormat.endianness = SL_BYTEORDER_LITTLEENDIAN;
|
||||||
|
|
||||||
// create the OpenSL root engine object
|
// create the OpenSL root engine object
|
||||||
slCreateEngine ( &engineObject,
|
slCreateEngine ( &engineObject,
|
||||||
|
@ -86,7 +95,7 @@ CSound::CSound ( void (*fpNewProcessCallback) ( CVector<short>& psData, void* ar
|
||||||
// configure the audio (data) sink for input
|
// configure the audio (data) sink for input
|
||||||
SLDataSink inDataSink;
|
SLDataSink inDataSink;
|
||||||
inDataSink.pLocator = &inBufferQueue;
|
inDataSink.pLocator = &inBufferQueue;
|
||||||
inDataSink.pFormat = &streamFormat;
|
inDataSink.pFormat = &inStreamFormat;
|
||||||
|
|
||||||
// create the audio recorder
|
// create the audio recorder
|
||||||
const SLInterfaceID recorderIds[] = { SL_IID_ANDROIDSIMPLEBUFFERQUEUE };
|
const SLInterfaceID recorderIds[] = { SL_IID_ANDROIDSIMPLEBUFFERQUEUE };
|
||||||
|
@ -127,7 +136,7 @@ CSound::CSound ( void (*fpNewProcessCallback) ( CVector<short>& psData, void* ar
|
||||||
// configure the audio (data) source for output
|
// configure the audio (data) source for output
|
||||||
SLDataSource outDataSource;
|
SLDataSource outDataSource;
|
||||||
outDataSource.pLocator = &outBufferQueue;
|
outDataSource.pLocator = &outBufferQueue;
|
||||||
outDataSource.pFormat = &streamFormat;
|
outDataSource.pFormat = &outStreamFormat;
|
||||||
|
|
||||||
// configure the output mix
|
// configure the output mix
|
||||||
SLDataLocator_OutputMix outputMix;
|
SLDataLocator_OutputMix outputMix;
|
||||||
|
|
Loading…
Reference in a new issue