Skip to content

Commit

Permalink
Merge pull request #71 from google/openslerr
Browse files Browse the repository at this point in the history
oboe: cleanup OpenSL ES input
  • Loading branch information
philburk authored Mar 27, 2018
2 parents dac7687 + 0cb67a6 commit 2925aa7
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 11 deletions.
5 changes: 2 additions & 3 deletions include/oboe/AudioStream.h
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,6 @@ class AudioStream : public AudioStreamBase {
return static_cast<int32_t>(Result::ErrorUnimplemented);
}


/**
*
* @return the API that this stream uses
Expand Down Expand Up @@ -228,8 +227,8 @@ class AudioStream : public AudioStreamBase {
* or ErrorTimeout.
*/
virtual Result waitForStateTransition(StreamState startingState,
StreamState endingState,
int64_t timeoutNanoseconds);
StreamState endingState,
int64_t timeoutNanoseconds);

/**
* Override this to provide a default for when the application did not specify a callback.
Expand Down
4 changes: 2 additions & 2 deletions src/common/AudioStream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ DataCallbackResult AudioStream::fireCallback(void *audioData, int32_t numFrames)
}

Result AudioStream::waitForStateTransition(StreamState startingState,
StreamState endingState,
int64_t timeoutNanoseconds)
StreamState endingState,
int64_t timeoutNanoseconds)
{
StreamState state = getState();
StreamState nextState = state;
Expand Down
9 changes: 4 additions & 5 deletions src/opensles/AudioInputStreamOpenSLES.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,12 +156,13 @@ Result AudioInputStreamOpenSLES::close() {
Result AudioInputStreamOpenSLES::setRecordState(SLuint32 newState) {
Result result = Result::OK;
LOGD("AudioInputStreamOpenSLES::setRecordState(%d)", newState);
if (mRecordInterface == NULL) {
if (mRecordInterface == nullptr) {
LOGE("AudioInputStreamOpenSLES::SetRecordState() mRecordInterface is null");
return Result::ErrorInvalidState;
}
SLresult slResult = (*mRecordInterface)->SetRecordState(mRecordInterface, newState);
if(SL_RESULT_SUCCESS != slResult) {
LOGD("AudioInputStreamOpenSLES::setPlayState() returned %s", getSLErrStr(slResult));
LOGE("AudioInputStreamOpenSLES::SetRecordState() returned %s", getSLErrStr(slResult));
result = Result::ErrorInvalidState; // TODO review
} else {
setState(StreamState::Pausing);
Expand All @@ -173,9 +174,7 @@ Result AudioInputStreamOpenSLES::requestStart()
{
LOGD("AudioInputStreamOpenSLES::requestStart()");
Result result = setRecordState(SL_RECORDSTATE_RECORDING);
if(result != Result::OK) {
result = Result::ErrorInvalidState; // TODO review
} else {
if(result == Result::OK) {
// Enqueue the first buffer so that we have data ready in the callback.
enqueueCallbackBuffer(mSimpleBufferQueueInterface);
setState(StreamState::Starting);
Expand Down
2 changes: 1 addition & 1 deletion src/opensles/AudioInputStreamOpenSLES.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class AudioInputStreamOpenSLES : public AudioStreamOpenSLES {

Result setRecordState(SLuint32 newState);

SLRecordItf mRecordInterface;
SLRecordItf mRecordInterface = nullptr;
};

} // namespace oboe
Expand Down

0 comments on commit 2925aa7

Please sign in to comment.