From 158dbd1a71a890d29490198c8e5019081ac94ac3 Mon Sep 17 00:00:00 2001 From: Glenn Kasten Date: Wed, 14 Jul 2010 09:09:26 -0700 Subject: [PATCH] Logging and comments to make testing easier. Add utility function to print an IID. checkDataFormat now prints a detailed log on invalid format. Use SL_LOGE and SL_LOGV for logging instead of fprintf, we can easily redirect to standard Android logging eventually. Add Doxygen-style comments. Log more specific error message on invalid data format. Use the full copyright header in one file. Change-Id: I2342e29f57e97c3b5d94cb219d00e767a75e93fa --- opensles/libopensles/CAudioPlayer.c | 6 + opensles/libopensles/CEngine.c | 6 + opensles/libopensles/IAndroidStreamType.c | 2 +- opensles/libopensles/IBufferQueue.c | 6 +- opensles/libopensles/MPH_to.c | 16 +- opensles/libopensles/OpenSLUT.h | 1 + opensles/libopensles/locks.c | 27 ++- opensles/libopensles/sles.c | 321 ++++++++++++++++++++---------- opensles/libopensles/sles_allinclusive.h | 7 + opensles/libopensles/sync.c | 9 +- 10 files changed, 278 insertions(+), 123 deletions(-) diff --git a/opensles/libopensles/CAudioPlayer.c b/opensles/libopensles/CAudioPlayer.c index 428ed2a1..761d2291 100644 --- a/opensles/libopensles/CAudioPlayer.c +++ b/opensles/libopensles/CAudioPlayer.c @@ -20,6 +20,9 @@ // IObject hooks + +/** Hook called by Object::Realize when an audio player is realized */ + SLresult CAudioPlayer_Realize(void *self, SLboolean async) { CAudioPlayer *this = (CAudioPlayer *) self; @@ -62,6 +65,9 @@ SLresult CAudioPlayer_Realize(void *self, SLboolean async) return result; } + +/** Hook called by Object::Destroy when an audio player is destroyed */ + void CAudioPlayer_Destroy(void *self) { CAudioPlayer *this = (CAudioPlayer *) self; diff --git a/opensles/libopensles/CEngine.c b/opensles/libopensles/CEngine.c index 2e9524c3..cb48a701 100644 --- a/opensles/libopensles/CEngine.c +++ b/opensles/libopensles/CEngine.c @@ -20,6 +20,9 @@ // IObject hooks + +/** Hook called by Object::Realize when an engine is realized */ + SLresult CEngine_Realize(void *self, SLboolean async) { CEngine *this = (CEngine *) self; @@ -39,6 +42,9 @@ SLresult CEngine_Realize(void *self, SLboolean async) return SL_RESULT_SUCCESS; } + +/** Hook called by Object::Destroy when an engine is destroyed */ + void CEngine_Destroy(void *self) { CEngine *this = (CEngine *) self; diff --git a/opensles/libopensles/IAndroidStreamType.c b/opensles/libopensles/IAndroidStreamType.c index 9cf181b4..e374018b 100644 --- a/opensles/libopensles/IAndroidStreamType.c +++ b/opensles/libopensles/IAndroidStreamType.c @@ -25,7 +25,7 @@ static SLresult IAndroidStreamType_SetStreamType(SLAndroidStreamTypeItf self, SL { SL_ENTER_INTERFACE - fprintf(stdout, "IAndroidStreamType_SetStreamType for type %lu\n", type); + SL_LOGV("IAndroidStreamType_SetStreamType for type %lu", type); if (type >= android::AudioSystem::NUM_STREAM_TYPES) { result = SL_RESULT_PARAMETER_INVALID; diff --git a/opensles/libopensles/IBufferQueue.c b/opensles/libopensles/IBufferQueue.c index 8e0b63c8..5e6c5574 100644 --- a/opensles/libopensles/IBufferQueue.c +++ b/opensles/libopensles/IBufferQueue.c @@ -59,7 +59,7 @@ static SLresult IBufferQueue_Clear(SLBufferQueueItf self) this->mState.count = 0; #ifdef ANDROID // FIXME must flush associated player - fprintf(stderr, "FIXME: IBufferQueue_Clear must flush associated player, not implemented\n"); + SL_LOGE("FIXME: IBufferQueue_Clear must flush associated player, not implemented"); #endif interface_unlock_exclusive(this); result = SL_RESULT_SUCCESS; @@ -99,8 +99,8 @@ static SLresult IBufferQueue_RegisterCallback(SLBufferQueueItf self, SL_ENTER_INTERFACE // FIXME verify conditions media object is in the SL_PLAYSTATE_STOPPED state - fprintf(stderr, "FIXME: verify RegisterCallback is called on a player in SL_PLAYSTATE_STOPPED \ -state, not implemented\n"); + SL_LOGE("FIXME: verify RegisterCallback is called on a player in SL_PLAYSTATE_STOPPED \ +state, not implemented"); IBufferQueue *this = (IBufferQueue *) self; interface_lock_exclusive(this); this->mCallback = callback; diff --git a/opensles/libopensles/MPH_to.c b/opensles/libopensles/MPH_to.c index 34569f8b..efae6857 100644 --- a/opensles/libopensles/MPH_to.c +++ b/opensles/libopensles/MPH_to.c @@ -1,4 +1,18 @@ -/* Copyright 2010 The Android Open Source Project */ +/* + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ // Map minimal perfect hash of an interface ID to its class index. diff --git a/opensles/libopensles/OpenSLUT.h b/opensles/libopensles/OpenSLUT.h index a32d23ad..35a1715e 100644 --- a/opensles/libopensles/OpenSLUT.h +++ b/opensles/libopensles/OpenSLUT.h @@ -23,6 +23,7 @@ extern "C" { #endif extern const char * const slutResultStrings[SLUT_RESULT_MAX]; +extern void slutPrintIID(SLInterfaceID iid); #ifdef __cplusplus } diff --git a/opensles/libopensles/locks.c b/opensles/libopensles/locks.c index 2ac8d522..184f7ec1 100644 --- a/opensles/libopensles/locks.c +++ b/opensles/libopensles/locks.c @@ -16,6 +16,9 @@ #include "sles_allinclusive.h" + +/* Exclusively lock an object */ + void object_lock_exclusive(IObject *this) { int ok; @@ -23,6 +26,9 @@ void object_lock_exclusive(IObject *this) assert(0 == ok); } + +/* Exclusively unlock an object and do not report any updates */ + void object_unlock_exclusive(IObject *this) { int ok; @@ -30,6 +36,9 @@ void object_unlock_exclusive(IObject *this) assert(0 == ok); } + +/* Exclusively unlock an object and report updates to the specified bit-mask of attributes */ + void object_unlock_exclusive_attributes(IObject *this, unsigned attributes) { int ok; @@ -50,13 +59,11 @@ void object_unlock_exclusive_attributes(IObject *this, unsigned attributes) break; case SL_OBJECTID_OUTPUTMIX: // FIXME update gains on all players attached to this outputmix - fprintf(stderr, - "[ FIXME: gain update on an SL_OBJECTID_OUTPUTMIX to be implemented ]\n"); + SL_LOGE("[ FIXME: gain update on an SL_OBJECTID_OUTPUTMIX to be implemented ]"); break; case SL_OBJECTID_MIDIPLAYER: // MIDI - fprintf(stderr, - "[ FIXME: gain update on an SL_OBJECTID_MIDIPLAYER to be implemented ]\n"); + SL_LOGE("[ FIXME: gain update on an SL_OBJECTID_MIDIPLAYER to be implemented ]"); break; default: break; @@ -76,8 +83,7 @@ void object_unlock_exclusive_attributes(IObject *this, unsigned attributes) break; case SL_OBJECTID_MIDIPLAYER: // MIDI - fprintf(stderr, - "[ FIXME: position update on an SL_OBJECTID_MIDIPLAYER to be implemented ]\n"); + SL_LOGE("[ FIXME: position update on an SL_OBJECTID_MIDIPLAYER to be implemented ]"); break; default: break; @@ -114,6 +120,9 @@ void object_unlock_exclusive_attributes(IObject *this, unsigned attributes) } } + +/* Wait on the condition variable associated with the object; see pthread_cond_wait */ + void object_cond_wait(IObject *this) { int ok; @@ -121,6 +130,9 @@ void object_cond_wait(IObject *this) assert(0 == ok); } + +/* Signal the condition variable associated with the object; see pthread_cond_signal */ + void object_cond_signal(IObject *this) { int ok; @@ -128,6 +140,9 @@ void object_cond_signal(IObject *this) assert(0 == ok); } + +/* Broadcast the condition variable associated with the object; see pthread_cond_broadcast */ + void object_cond_broadcast(IObject *this) { int ok; diff --git a/opensles/libopensles/sles.c b/opensles/libopensles/sles.c index f7c716ee..c795a5d0 100644 --- a/opensles/libopensles/sles.c +++ b/opensles/libopensles/sles.c @@ -20,7 +20,8 @@ /* Private functions */ -// Map an IObject to it's "object ID" (which is really a class ID) + +/** Map an IObject to it's "object ID" (which is really a class ID) */ SLuint32 IObjectToObjectID(IObject *this) { @@ -28,7 +29,8 @@ SLuint32 IObjectToObjectID(IObject *this) return this->mClass->mObjectID; } -// Convert POSIX pthread error code to OpenSL ES result code + +/** Convert POSIX pthread error code to OpenSL ES result code */ SLresult err_to_result(int err) { @@ -39,7 +41,8 @@ SLresult err_to_result(int err) return SL_RESULT_SUCCESS; } -// Check the interface IDs passed into a Create operation + +/** Check the interface IDs passed into a Create operation */ SLresult checkInterfaces(const ClassTable *class__, SLuint32 numInterfaces, const SLInterfaceID *pInterfaceIds, const SLboolean *pInterfaceRequired, unsigned *pExposedMask) @@ -79,7 +82,9 @@ SLresult checkInterfaces(const ClassTable *class__, SLuint32 numInterfaces, return SL_RESULT_SUCCESS; } -// private helper shared by decoder and encoder + +/** Private helper shared by decoder and encoder */ + SLresult GetCodecCapabilities(SLuint32 codecId, SLuint32 *pIndex, SLAudioCodecDescriptor *pDescriptor, const struct CodecDescriptor *codecDescriptors) { @@ -120,6 +125,8 @@ SLresult GetCodecCapabilities(SLuint32 codecId, SLuint32 *pIndex, return SL_RESULT_PARAMETER_INVALID; } +/** Check a data locator and make local deep copy */ + static SLresult checkDataLocator(void *pLocator, DataLocator *pDataLocator) { if (NULL == pLocator) { @@ -214,7 +221,7 @@ static SLresult checkDataLocator(void *pLocator, DataLocator *pDataLocator) case SL_DATALOCATOR_ANDROIDFD: { pDataLocator->mFD = *(SLDataLocator_AndroidFD *)pLocator; - fprintf(stdout, "Data locator FD: fd=%ld offset=%lld length=%lld\n", pDataLocator->mFD.fd, + SL_LOGV("Data locator FD: fd=%ld offset=%lld length=%lld", pDataLocator->mFD.fd, pDataLocator->mFD.offset, pDataLocator->mFD.length); if (-1 == pDataLocator->mFD.fd) { return SL_RESULT_PARAMETER_INVALID; @@ -233,6 +240,9 @@ static SLresult checkDataLocator(void *pLocator, DataLocator *pDataLocator) return SL_RESULT_SUCCESS; } + +/** Free the local deep copy of a data locator */ + static void freeDataLocator(DataLocator *pDataLocator) { switch (pDataLocator->mLocatorType) { @@ -245,119 +255,188 @@ static void freeDataLocator(DataLocator *pDataLocator) } } + +/** Check a data format and make local deep copy */ + static SLresult checkDataFormat(void *pFormat, DataFormat *pDataFormat) { + SLresult result = SL_RESULT_SUCCESS; + if (NULL == pFormat) { pDataFormat->mFormatType = SL_DATAFORMAT_NULL; - return SL_RESULT_SUCCESS; - } - SLuint32 formatType = *(SLuint32 *)pFormat; - switch (formatType) { - case SL_DATAFORMAT_PCM: - pDataFormat->mPCM = *(SLDataFormat_PCM *)pFormat; - switch (pDataFormat->mPCM.numChannels) { - case 1: - case 2: - break; - case 0: - return SL_RESULT_PARAMETER_INVALID; - default: - return SL_RESULT_CONTENT_UNSUPPORTED; - } - switch (pDataFormat->mPCM.samplesPerSec) { - case SL_SAMPLINGRATE_8: - case SL_SAMPLINGRATE_11_025: - case SL_SAMPLINGRATE_12: - case SL_SAMPLINGRATE_16: - case SL_SAMPLINGRATE_22_05: - case SL_SAMPLINGRATE_24: - case SL_SAMPLINGRATE_32: - case SL_SAMPLINGRATE_44_1: - case SL_SAMPLINGRATE_48: - case SL_SAMPLINGRATE_64: - case SL_SAMPLINGRATE_88_2: - case SL_SAMPLINGRATE_96: - case SL_SAMPLINGRATE_192: - break; - case 0: - return SL_RESULT_PARAMETER_INVALID; - default: - return SL_RESULT_CONTENT_UNSUPPORTED; - } - switch (pDataFormat->mPCM.bitsPerSample) { - case SL_PCMSAMPLEFORMAT_FIXED_8: - case SL_PCMSAMPLEFORMAT_FIXED_16: - break; - case SL_PCMSAMPLEFORMAT_FIXED_20: - case SL_PCMSAMPLEFORMAT_FIXED_24: - case SL_PCMSAMPLEFORMAT_FIXED_28: - case SL_PCMSAMPLEFORMAT_FIXED_32: - return SL_RESULT_CONTENT_UNSUPPORTED; - default: - return SL_RESULT_PARAMETER_INVALID; - } - switch (pDataFormat->mPCM.containerSize) { - case SL_PCMSAMPLEFORMAT_FIXED_8: - case SL_PCMSAMPLEFORMAT_FIXED_16: - if (pDataFormat->mPCM.containerSize != pDataFormat->mPCM.bitsPerSample) - return SL_RESULT_CONTENT_UNSUPPORTED; - break; - default: - return SL_RESULT_CONTENT_UNSUPPORTED; - } - switch (pDataFormat->mPCM.channelMask) { - case SL_SPEAKER_FRONT_LEFT | SL_SPEAKER_FRONT_RIGHT: - if (2 != pDataFormat->mPCM.numChannels) - return SL_RESULT_PARAMETER_INVALID; - break; - case SL_SPEAKER_FRONT_LEFT: - case SL_SPEAKER_FRONT_RIGHT: - case SL_SPEAKER_FRONT_CENTER: - if (1 != pDataFormat->mPCM.numChannels) - return SL_RESULT_PARAMETER_INVALID; + } else { + SLuint32 formatType = *(SLuint32 *)pFormat; + switch (formatType) { + + case SL_DATAFORMAT_PCM: + pDataFormat->mPCM = *(SLDataFormat_PCM *)pFormat; + do { + + // check the channel count + switch (pDataFormat->mPCM.numChannels) { + case 1: // mono + case 2: // stereo + break; + case 0: // unknown + result = SL_RESULT_PARAMETER_INVALID; + break; + default: // multi-channel + result = SL_RESULT_CONTENT_UNSUPPORTED; + break; + } + if (SL_RESULT_SUCCESS != result) { + SL_LOGE("numChannels=%u", (unsigned) pDataFormat->mPCM.numChannels); + break; + } + + // check the sampling rate + switch (pDataFormat->mPCM.samplesPerSec) { + case SL_SAMPLINGRATE_8: + case SL_SAMPLINGRATE_11_025: + case SL_SAMPLINGRATE_12: + case SL_SAMPLINGRATE_16: + case SL_SAMPLINGRATE_22_05: + case SL_SAMPLINGRATE_24: + case SL_SAMPLINGRATE_32: + case SL_SAMPLINGRATE_44_1: + case SL_SAMPLINGRATE_48: + case SL_SAMPLINGRATE_64: + case SL_SAMPLINGRATE_88_2: + case SL_SAMPLINGRATE_96: + case SL_SAMPLINGRATE_192: + break; + case 0: + result = SL_RESULT_PARAMETER_INVALID; + break; + default: + result = SL_RESULT_CONTENT_UNSUPPORTED; + break; + } + if (SL_RESULT_SUCCESS != result) { + SL_LOGE("samplesPerSec=%u", (unsigned) pDataFormat->mPCM.samplesPerSec); + break; + } + + // check the sample bit depth + switch (pDataFormat->mPCM.bitsPerSample) { + case SL_PCMSAMPLEFORMAT_FIXED_8: + case SL_PCMSAMPLEFORMAT_FIXED_16: + break; + case SL_PCMSAMPLEFORMAT_FIXED_20: + case SL_PCMSAMPLEFORMAT_FIXED_24: + case SL_PCMSAMPLEFORMAT_FIXED_28: + case SL_PCMSAMPLEFORMAT_FIXED_32: + result = SL_RESULT_CONTENT_UNSUPPORTED; + break; + default: + result = SL_RESULT_PARAMETER_INVALID; + break; + } + if (SL_RESULT_SUCCESS != result) { + SL_LOGE("bitsPerSample=%u", (unsigned) pDataFormat->mPCM.bitsPerSample); + break; + } + + // check the container bit depth + switch (pDataFormat->mPCM.containerSize) { + case SL_PCMSAMPLEFORMAT_FIXED_8: + case SL_PCMSAMPLEFORMAT_FIXED_16: + if (pDataFormat->mPCM.containerSize != pDataFormat->mPCM.bitsPerSample) + result = SL_RESULT_CONTENT_UNSUPPORTED; + break; + default: + result = SL_RESULT_CONTENT_UNSUPPORTED; + break; + } + if (SL_RESULT_SUCCESS != result) { + SL_LOGE("containerSize=%u", (unsigned) pDataFormat->mPCM.containerSize); + break; + } + + // check the channel mask + switch (pDataFormat->mPCM.channelMask) { + case SL_SPEAKER_FRONT_LEFT | SL_SPEAKER_FRONT_RIGHT: + if (2 != pDataFormat->mPCM.numChannels) + result = SL_RESULT_PARAMETER_INVALID; + break; + case SL_SPEAKER_FRONT_LEFT: + case SL_SPEAKER_FRONT_RIGHT: + case SL_SPEAKER_FRONT_CENTER: + if (1 != pDataFormat->mPCM.numChannels) + result = SL_RESULT_PARAMETER_INVALID; + break; + case 0: + pDataFormat->mPCM.channelMask = pDataFormat->mPCM.numChannels == 2 ? + SL_SPEAKER_FRONT_LEFT | SL_SPEAKER_FRONT_RIGHT : SL_SPEAKER_FRONT_CENTER; + break; + default: + result = SL_RESULT_PARAMETER_INVALID; + break; + } + if (SL_RESULT_SUCCESS != result) { + SL_LOGE("channelMask=%u", (unsigned) pDataFormat->mPCM.channelMask); + break; + } + + // check the endianness / byte order + switch (pDataFormat->mPCM.endianness) { + case SL_BYTEORDER_LITTLEENDIAN: + break; + case SL_BYTEORDER_BIGENDIAN: + result = SL_RESULT_CONTENT_UNSUPPORTED; + break; + default: + result = SL_RESULT_PARAMETER_INVALID; + break; + } + if (SL_RESULT_SUCCESS != result) { + SL_LOGE("endianness=%u", (unsigned) pDataFormat->mPCM.endianness); + break; + } + + // here if all checks passed successfully + + } while(0); break; - case 0: - pDataFormat->mPCM.channelMask = pDataFormat->mPCM.numChannels == 2 ? - SL_SPEAKER_FRONT_LEFT | SL_SPEAKER_FRONT_RIGHT : SL_SPEAKER_FRONT_CENTER; + + case SL_DATAFORMAT_MIME: + pDataFormat->mMIME = *(SLDataFormat_MIME *)pFormat; + if (NULL != pDataFormat->mMIME.mimeType) { + size_t len = strlen((const char *) pDataFormat->mMIME.mimeType); + SLchar *myMIME = (SLchar *) malloc(len + 1); + if (NULL == myMIME) { + result = SL_RESULT_MEMORY_FAILURE; + } else { + memcpy(myMIME, pDataFormat->mMIME.mimeType, len + 1); + // make sure MIME string was not modified asynchronously + if ('\0' != myMIME[len]) { + free(myMIME); + result = SL_RESULT_PRECONDITIONS_VIOLATED; + } + pDataFormat->mMIME.mimeType = myMIME; + } + } break; + default: - return SL_RESULT_PARAMETER_INVALID; - } - switch (pDataFormat->mPCM.endianness) { - case SL_BYTEORDER_LITTLEENDIAN: + result = SL_RESULT_PARAMETER_INVALID; + SL_LOGE("formatType=%u", (unsigned) formatType); break; - case SL_BYTEORDER_BIGENDIAN: - return SL_RESULT_CONTENT_UNSUPPORTED; - default: - return SL_RESULT_PARAMETER_INVALID; - } - break; - case SL_DATAFORMAT_MIME: - { - pDataFormat->mMIME = *(SLDataFormat_MIME *)pFormat; - if (NULL == pDataFormat->mMIME.mimeType) - return SL_RESULT_SUCCESS; - size_t len = strlen((const char *) pDataFormat->mMIME.mimeType); - SLchar *myMIME = (SLchar *) malloc(len + 1); - if (NULL == myMIME) - return SL_RESULT_MEMORY_FAILURE; - memcpy(myMIME, pDataFormat->mMIME.mimeType, len + 1); - // ditto - if ('\0' != myMIME[len]) { - free(myMIME); - return SL_RESULT_PARAMETER_INVALID; - } - pDataFormat->mMIME.mimeType = myMIME; + } - break; - default: - return SL_RESULT_PARAMETER_INVALID; + + // make sure format type was not modified asynchronously + if (SL_RESULT_SUCCESS == result && formatType != pDataFormat->mFormatType) + result = SL_RESULT_PRECONDITIONS_VIOLATED; + } - if (formatType != pDataFormat->mFormatType) - return SL_RESULT_PARAMETER_INVALID; - return SL_RESULT_SUCCESS; + + return result; } + +/** Check interface ID compatibility with respect to a particular data locator format */ + SLresult checkSourceFormatVsInterfacesCompatibility(const DataLocatorFormat *pDataLocatorFormat, SLuint32 numInterfaces, const SLInterfaceID *pInterfaceIds, const SLboolean *pInterfaceRequired) { @@ -366,8 +445,7 @@ SLresult checkSourceFormatVsInterfacesCompatibility(const DataLocatorFormat *pDa SLuint32 i; for (i = 0; i < numInterfaces; i++) { if (pInterfaceRequired[i] && (SL_IID_SEEK == pInterfaceIds[i])) { - fprintf(stderr, - "Error: can't request SL_IID_SEEK with a buffer queue data source\n"); + SL_LOGE("can't request SL_IID_SEEK with a buffer queue data source"); return SL_RESULT_FEATURE_UNSUPPORTED; } } @@ -375,6 +453,9 @@ SLresult checkSourceFormatVsInterfacesCompatibility(const DataLocatorFormat *pDa return SL_RESULT_SUCCESS; } + +/** Free the local deep copy of a data format */ + static void freeDataFormat(DataFormat *pDataFormat) { switch (pDataFormat->mFormatType) { @@ -387,6 +468,9 @@ static void freeDataFormat(DataFormat *pDataFormat) } } + +/** Check a data source and make local deep copy */ + SLresult checkDataSource(const SLDataSource *pDataSrc, DataLocatorFormat *pDataLocatorFormat) { if (NULL == pDataSrc) @@ -411,6 +495,8 @@ SLresult checkDataSource(const SLDataSource *pDataSrc, DataLocatorFormat *pDataL case SL_DATALOCATOR_OUTPUTMIX: default: // invalid but fall through; the invalid locator will be caught later + SL_LOGE("mLocatorType=%u", (unsigned) pDataLocatorFormat->mLocator.mLocatorType); + // keep going case SL_DATALOCATOR_IODEVICE: // for these data locator types, ignore the pFormat as it might be uninitialized pDataLocatorFormat->mFormat.mFormatType = SL_DATAFORMAT_NULL; @@ -421,6 +507,9 @@ SLresult checkDataSource(const SLDataSource *pDataSrc, DataLocatorFormat *pDataL return SL_RESULT_SUCCESS; } + +/** Check a data sink and make local deep copy */ + SLresult checkDataSink(const SLDataSink *pDataSink, DataLocatorFormat *pDataLocatorFormat) { if (NULL == pDataSink) @@ -444,6 +533,8 @@ SLresult checkDataSink(const SLDataSink *pDataSink, DataLocatorFormat *pDataLoca case SL_DATALOCATOR_MIDIBUFFERQUEUE: default: // invalid but fall through; the invalid locator will be caught later + SL_LOGE("mLocatorType=%u", (unsigned) pDataLocatorFormat->mLocator.mLocatorType); + // keep going case SL_DATALOCATOR_IODEVICE: case SL_DATALOCATOR_OUTPUTMIX: // for these data locator types, ignore the pFormat as it might be uninitialized @@ -455,12 +546,16 @@ SLresult checkDataSink(const SLDataSink *pDataSink, DataLocatorFormat *pDataLoca return SL_RESULT_SUCCESS; } + +/** Free the local deep copy of a data locator format */ + void freeDataLocatorFormat(DataLocatorFormat *dlf) { freeDataLocator(&dlf->mLocator); freeDataFormat(&dlf->mFormat); } + /* Interface initialization hooks */ extern void @@ -574,7 +669,8 @@ extern void #endif }; -// Construct a new instance of the specified class, exposing selected interfaces + +/** Construct a new instance of the specified class, exposing selected interfaces */ IObject *construct(const ClassTable *class__, unsigned exposedMask, SLEngineItf engine) { @@ -653,6 +749,9 @@ IObject *construct(const ClassTable *class__, unsigned exposedMask, SLEngineItf /* Initial global entry points */ + +/** slCreateEngine Function */ + SLresult SLAPIENTRY slCreateEngine(SLObjectItf *pEngine, SLuint32 numOptions, const SLEngineOption *pEngineOptions, SLuint32 numInterfaces, const SLInterfaceID *pInterfaceIds, const SLboolean *pInterfaceRequired) @@ -725,6 +824,8 @@ SLresult SLAPIENTRY slCreateEngine(SLObjectItf *pEngine, SLuint32 numOptions, } +/** slQueryNumSupportedEngineInterfaces Function */ + SLresult SLAPIENTRY slQueryNumSupportedEngineInterfaces(SLuint32 *pNumSupportedInterfaces) { SL_ENTER_GLOBAL @@ -747,6 +848,8 @@ SLresult SLAPIENTRY slQueryNumSupportedEngineInterfaces(SLuint32 *pNumSupportedI } +/** slQuerySupportedEngineInterfaces Function */ + SLresult SLAPIENTRY slQuerySupportedEngineInterfaces(SLuint32 index, SLInterfaceID *pInterfaceId) { SL_ENTER_GLOBAL diff --git a/opensles/libopensles/sles_allinclusive.h b/opensles/libopensles/sles_allinclusive.h index 1eded900..79aaa144 100644 --- a/opensles/libopensles/sles_allinclusive.h +++ b/opensles/libopensles/sles_allinclusive.h @@ -1103,3 +1103,10 @@ extern void slLeaveInterfaceVoid(const char *function); #define SL_LEAVE_INTERFACE_VOID slLeaveInterfaceVoid(__FUNCTION__); return; #endif + +#define SL_LOGE(...) do { fputs("ERROR: ", stderr); fprintf(stderr, __VA_ARGS__); fputc('\n', stderr); } while(0) +#if 1 +#define SL_LOGV +#else +#define SL_LOGV(...) do { fputs("VERBOSE: ", stderr); fprintf(stderr, __VA_ARGS__); fputc('\n', stderr); } while(0) +#endif diff --git a/opensles/libopensles/sync.c b/opensles/libopensles/sync.c index 1322b723..7f72394f 100644 --- a/opensles/libopensles/sync.c +++ b/opensles/libopensles/sync.c @@ -18,9 +18,12 @@ #include "sles_allinclusive.h" -// The sync thread runs periodically to synchronize audio state between -// the application and platform-specific device driver; for best results -// it should run about every graphics frame (e.g. 20 Hz to 50 Hz). + +/** Sync thread. + * The sync thread runs periodically to synchronize audio state between + * the application and platform-specific device driver; for best results + * it should run about every graphics frame (e.g. 20 Hz to 50 Hz). + */ void *sync_start(void *arg) { -- 2.11.0