OSDN Git Service

Test cleanup
authorGlenn Kasten <gkasten@google.com>
Sun, 10 Oct 2010 22:04:20 +0000 (15:04 -0700)
committerGlenn Kasten <gkasten@google.com>
Sun, 10 Oct 2010 23:40:32 +0000 (16:40 -0700)
Fix bug in QueryEffect test - was not re-initializing the name length.
Add QueryEffect test for over-writing the name buffer.
Don't create output with VOLUME or NULL interfaces.
Use <stdlib.h> symbolic names for exit codes instead of 0 and 1.
Remove Android-style logging from examples; use only printf.
Remove extra blank lines in test output.
Remove the MAX_NUMBER_OUTPUT_DEVICES macro.
Use <unistd.h> to declare usleep.
Remove obsolete #include statements.
Fix build warnings.

Change-Id: I8d198a317246b3894f104edf7c9f317a51593d07

22 files changed:
opensles/tests/examples/slesTestBassBoostPath.cpp
opensles/tests/examples/slesTestEffectCapabilities.cpp
opensles/tests/examples/slesTestEqFdPath.cpp
opensles/tests/examples/slesTestEqOutputPath.cpp
opensles/tests/examples/slesTestPlayFdPath.cpp
opensles/tests/examples/slesTestRecBuffQueue.cpp
opensles/tests/examples/slesTestSawtoothBufferQueue.cpp
opensles/tests/examples/slesTestSendToPresetReverb.cpp
opensles/tests/examples/slesTestVirtualizerPath.cpp
opensles/tests/listening/slesTest_playMuteSolo.cpp
opensles/tests/mimeUri/Android.mk
opensles/tests/mimeUri/slesTestLoopUri.cpp
opensles/tests/mimeUri/slesTestPlayStreamType.cpp
opensles/tests/mimeUri/slesTestPlayUri.cpp
opensles/tests/mimeUri/slesTestPlayUri2.cpp
opensles/tests/mimeUri/slesTestSlowDownUri.cpp
opensles/tests/mimeUri/slesTest_playStates.cpp
opensles/tests/mimeUri_test.cpp
opensles/tests/sandbox/configbq.c
opensles/tests/sandbox/multiplay.c
opensles/tests/sandbox/reverb.c
opensles/tests/sandbox/urimime.c

index 00a7668..e480633 100644 (file)
  * limitations under the License.
  */
 
-#ifdef ANDROID
-#define LOG_NDEBUG 0
-#define LOG_TAG "slesTest_bassboost"
-
-#include <utils/Log.h>
-#else
-#define LOGV printf
-#endif
-
-#include <getopt.h>
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
@@ -49,7 +39,7 @@ void ExitOnErrorFunc( SLresult result , int line)
 {
     if (SL_RESULT_SUCCESS != result) {
         fprintf(stderr, "%lu error code encountered at line %d, exiting\n", result, line);
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 }
 
@@ -255,8 +245,6 @@ void TestBassBoostPathFromFD( SLObjectItf sl, const char* path, int16_t boostStr
 //-----------------------------------------------------------------
 int main(int argc, char* const argv[])
 {
-    LOGV("Starting %s\n", argv[0]);
-
     SLresult    result;
     SLObjectItf sl;
 
@@ -271,7 +259,7 @@ int main(int argc, char* const argv[])
     if (argc < 3) {
         fprintf(stdout, "Usage: \t%s path bass_boost_strength\n", argv[0]);
         fprintf(stdout, "Example: \"%s /sdcard/my.mp3 1000\" \n", argv[0]);
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     SLEngineOption EngineOption[] = {
@@ -290,7 +278,6 @@ int main(int argc, char* const argv[])
 
     /* Shutdown OpenSL ES */
     (*sl)->Destroy(sl);
-    exit(0);
 
-    return 0;
+    return EXIT_SUCCESS;
 }
index ef71b78..9239f08 100644 (file)
  * limitations under the License.
  */
 
-#define LOG_NDEBUG 0
-#define LOG_TAG "slesTest_virtualizer"
-
-#include <utils/Log.h>
-#include <getopt.h>
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
@@ -30,7 +25,7 @@
 #include "SLES/OpenSLES_Android.h"
 
 
-#define MAX_NUMBER_INTERFACES 3
+#define MAX_NUMBER_INTERFACES 1
 
 #define GUID_DISPLAY_LENGTH 35
 #define FX_NAME_LENGTH 64
@@ -44,7 +39,7 @@ void ExitOnErrorFunc( SLresult result , int line)
 {
     if (SL_RESULT_SUCCESS != result) {
         fprintf(stderr, "%lu error code encountered at line %d, exiting\n", result, line);
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 }
 
@@ -122,7 +117,7 @@ void TestGenericFxCapabilities(  )
     ExitOnError(result);
     fprintf(stdout, "Effect library contains %ld effects:\n", nbEffects);
 
-    SLchar effectName[FX_NAME_LENGTH];
+    SLchar effectName[FX_NAME_LENGTH+1];
     SLuint16 effectNameLength = FX_NAME_LENGTH;
     char typeString[GUID_DISPLAY_LENGTH];
     char implString[GUID_DISPLAY_LENGTH];
@@ -130,12 +125,24 @@ void TestGenericFxCapabilities(  )
     SLInterfaceID effectType, effectImplementation;
     for (SLuint32 i = 0 ; i < nbEffects ; i++ ) {
         fprintf(stdout,"- effect %ld: ", i);
+        memset(effectName, 'Z', FX_NAME_LENGTH+1);
+        effectNameLength = FX_NAME_LENGTH;
         result = (*EffectLibItf)->QueryEffect(EffectLibItf, i,
                 &effectType, &effectImplementation, effectName, &effectNameLength);
+        if ('Z' != effectName[FX_NAME_LENGTH]) {
+            fprintf(stderr, "QueryEffect wrote beyond end of buffer\n");
+            continue;
+        }
         ExitOnError(result);
+        printf("length=%u ", effectNameLength);
+        if (FX_NAME_LENGTH < effectNameLength) {
+            printf(" (>max) ");
+            effectNameLength = FX_NAME_LENGTH;
+        }
         guidToString(effectType, typeString);
         guidToString(effectImplementation, implString);
-        fprintf(stdout, "type = %s impl = %s name = %s \n", typeString, implString, effectName);
+        effectName[FX_NAME_LENGTH - 1] = '\0';
+        fprintf(stdout, " type=%s, impl=%s name=%.*s \n", typeString, implString, effectNameLength, effectName);
     }
 
     /* Shutdown OpenSL ES */
@@ -145,8 +152,6 @@ void TestGenericFxCapabilities(  )
 //-----------------------------------------------------------------
 int main(int argc, char* const argv[])
 {
-    LOGV("Starting %s\n", argv[0]);
-
     SLresult    result;
     SLObjectItf sl;
 
@@ -154,5 +159,5 @@ int main(int argc, char* const argv[])
 
     TestGenericFxCapabilities();
 
-    return 0;
+    return EXIT_SUCCESS;
 }
index c6c2836..9960501 100644 (file)
  * limitations under the License.
  */
 
-#ifdef ANDROID
-#define LOG_NDEBUG 0
-#define LOG_TAG "slesTest_seekFdPath"
-
-#include <utils/Log.h>
-#else
-#define LOGV printf
-#endif
-
-#include <getopt.h>
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
@@ -49,7 +39,7 @@ void ExitOnErrorFunc( SLresult result , int line)
 {
     if (SL_RESULT_SUCCESS != result) {
         fprintf(stderr, "%lu error code encountered at line %d, exiting\n", result, line);
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 }
 
@@ -283,8 +273,6 @@ void TestEQPathFromFD( SLObjectItf sl, const char* path
 //-----------------------------------------------------------------
 int main(int argc, char* const argv[])
 {
-    LOGV("Starting %s\n", argv[0]);
-
     SLresult    result;
     SLObjectItf sl;
 
@@ -304,7 +292,7 @@ int main(int argc, char* const argv[])
     {
         fprintf(stdout, "Usage: \t%s path offsetInBytes [sizeInBytes]\n", argv[0]);
         fprintf(stdout, "Example: \"%s /sdcard/my.mp3 0 344460\" \n", argv[0]);
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     SLEngineOption EngineOption[] = {
@@ -332,7 +320,6 @@ int main(int argc, char* const argv[])
 
     /* Shutdown OpenSL ES */
     (*sl)->Destroy(sl);
-    exit(0);
 
-    return 0;
+    return EXIT_SUCCESS;
 }
index 7b12a64..8658668 100644 (file)
  * limitations under the License.
  */
 
-#ifdef ANDROID
-#define LOG_NDEBUG 0
-#define LOG_TAG "slesTest_seekFdPath"
-
-#include <utils/Log.h>
-#else
-#define LOGV printf
-#endif
-#include <getopt.h>
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
@@ -48,7 +39,7 @@ void ExitOnErrorFunc( SLresult result , int line)
 {
     if (SL_RESULT_SUCCESS != result) {
         fprintf(stderr, "%lu error code encountered at line %d, exiting\n", result, line);
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 }
 
@@ -286,8 +277,6 @@ void TestEQPathFromFD( SLObjectItf sl, const char* path
 //-----------------------------------------------------------------
 int main(int argc, char* const argv[])
 {
-    LOGV("Starting %s\n", argv[0]);
-
     SLresult    result;
     SLObjectItf sl;
 
@@ -303,7 +292,7 @@ int main(int argc, char* const argv[])
     if (argc < 3) {
         fprintf(stdout, "Usage: \t%s path offsetInBytes [sizeInBytes]\n", argv[0]);
         fprintf(stdout, "Example: \"%s /sdcard/my.mp3 0 344460\" \n", argv[0]);
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 #endif
 
@@ -332,7 +321,6 @@ int main(int argc, char* const argv[])
 
     /* Shutdown OpenSL ES */
     (*sl)->Destroy(sl);
-    exit(0);
 
-    return 0;
+    return EXIT_SUCCESS;
 }
index 395c44c..e4b8b94 100644 (file)
  * limitations under the License.
  */
 
-#define LOG_NDEBUG 0
-#define LOG_TAG "slesTest_playFdPath"
-
-#include <utils/Log.h>
-#include <getopt.h>
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
@@ -31,7 +26,6 @@
 
 
 #define MAX_NUMBER_INTERFACES 3
-#define MAX_NUMBER_OUTPUT_DEVICES 6
 
 #define TEST_MUTE 0
 #define TEST_SOLO 1
@@ -45,7 +39,7 @@ void ExitOnErrorFunc( SLresult result , int line)
 {
     if (SL_RESULT_SUCCESS != result) {
         fprintf(stdout, "%lu error code encountered at line %d, exiting\n", result, line);
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 }
 
@@ -91,7 +85,7 @@ void TestPlayPathFromFD( SLObjectItf sl, const char* path, SLAint64 offset, SLAi
     /* Configuration of the output mix  */
 
     /* Create Output Mix object to be used by the player */
-     result = (*EngineItf)->CreateOutputMix(EngineItf, &outputMix, 1, iidArray, required);
+     result = (*EngineItf)->CreateOutputMix(EngineItf, &outputMix, 0, iidArray, required);
      ExitOnError(result);
 
     /* Realize the Output Mix object in synchronous mode */
@@ -116,7 +110,8 @@ void TestPlayPathFromFD( SLObjectItf sl, const char* path, SLAint64 offset, SLAi
     locatorFd.locatorType = SL_DATALOCATOR_ANDROIDFD;
     int fd = open(path, O_RDONLY);
     if (fd == -1) {
-        ExitOnError(SL_RESULT_RESOURCE_ERROR);
+        perror(path);
+        exit(EXIT_FAILURE);
     }
     locatorFd.fd = (SLint32) fd;
     locatorFd.length = size;
@@ -195,8 +190,6 @@ void TestPlayPathFromFD( SLObjectItf sl, const char* path, SLAint64 offset, SLAi
 //-----------------------------------------------------------------
 int main(int argc, char* const argv[])
 {
-    LOGV("Starting %s\n", argv[0]);
-
     SLresult    result;
     SLObjectItf sl;
 
@@ -209,7 +202,7 @@ int main(int argc, char* const argv[])
     if (argc < 3) {
         fprintf(stdout, "Usage: \t%s path offsetInBytes [sizeInBytes]\n", argv[0]);
         fprintf(stdout, "Example: \"%s /sdcard/my.mp3 0 344460\" \n", argv[0]);
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     SLEngineOption EngineOption[] = {
@@ -224,7 +217,7 @@ int main(int argc, char* const argv[])
     ExitOnError(result);
 
     if (argc == 3) {
-        fprintf(stdout, "\nno file size given, using SL_DATALOCATOR_ANDROIDFD_USE_FILE_SIZE\n\n");
+        fprintf(stdout, "no file size given, using SL_DATALOCATOR_ANDROIDFD_USE_FILE_SIZE\n");
         TestPlayPathFromFD(sl, argv[1], (SLAint64)atoi(argv[2]),
                 SL_DATALOCATOR_ANDROIDFD_USE_FILE_SIZE);
     } else {
@@ -233,7 +226,6 @@ int main(int argc, char* const argv[])
 
     /* Shutdown OpenSL ES */
     (*sl)->Destroy(sl);
-    exit(0);
 
-    return 0;
+    return EXIT_SUCCESS;
 }
index 64f7bc1..6a24762 100644 (file)
@@ -14,7 +14,6 @@
  * limitations under the License.
  */
 
-#include <getopt.h>
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
@@ -50,7 +49,7 @@ void ExitOnErrorFunc( SLresult result , int line)
 {
     if (SL_RESULT_SUCCESS != result) {
         fprintf(stdout, "%lu error code encountered at line %d, exiting\n", result, line);
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 }
 
@@ -291,8 +290,6 @@ void TestRecToBuffQueue( SLObjectItf sl, const char* path, SLAint64 durationInSe
 //-----------------------------------------------------------------
 int main(int argc, char* const argv[])
 {
-    //LOGV("Starting %s\n", argv[0]);
-
     SLresult    result;
     SLObjectItf sl;
 
@@ -303,7 +300,7 @@ int main(int argc, char* const argv[])
     if (argc < 2) {
         fprintf(stdout, "Usage: \t%s destination_file duration_in_seconds\n", argv[0]);
         fprintf(stdout, "Example: \"%s /sdcard/myrec.raw 4\" \n", argv[0]);
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     SLEngineOption EngineOption[] = {
@@ -321,7 +318,6 @@ int main(int argc, char* const argv[])
 
     /* Shutdown OpenSL ES */
     (*sl)->Destroy(sl);
-    exit(0);
 
-    return 0;
+    return EXIT_SUCCESS;
 }
index c1022ca..d14f8ec 100644 (file)
  * MATERIALS.
  */
 
-#define LOG_NDEBUG 0
-#define LOG_TAG "Sawtooth"
-
-#ifdef ANDROID
-#include <utils/Log.h>
-#else
-#define LOGV printf
-#endif
-
-#include <getopt.h>
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
 
 #include "SLES/OpenSLES.h"
 
-/*using namespace android;*/
-
-#define SLEEP(x) /* Client system sleep function to sleep x milliseconds
-would replace SLEEP macro */
 
 #define MAX_NUMBER_INTERFACES 3
-#define MAX_NUMBER_OUTPUT_DEVICES 6
 
 /* Local storage for Audio data in 16 bit words */
 #define AUDIO_DATA_STORAGE_SIZE 4096 * 100
@@ -76,7 +61,7 @@ void CheckErr( SLresult res )
     if ( res != SL_RESULT_SUCCESS )
         {
             fprintf(stdout, "%lu SL failure, exiting\n", res);
-            exit(1);
+            exit(EXIT_FAILURE);
         }
     else {
         //fprintf(stdout, "%d SL success, proceeding...\n", res);
@@ -164,15 +149,17 @@ void TestPlaySawtoothBufferQueue( SLObjectItf sl )
     required[0] = SL_BOOLEAN_TRUE;
     iidArray[0] = SL_IID_VOLUME;
     // Create Output Mix object to be used by player
-    res = (*EngineItf)->CreateOutputMix(EngineItf, &OutputMix, 1,
+    res = (*EngineItf)->CreateOutputMix(EngineItf, &OutputMix, 0,
             iidArray, required); CheckErr(res);
 
     // Realizing the Output Mix object in synchronous mode.
     res = (*OutputMix)->Realize(OutputMix, SL_BOOLEAN_FALSE);
     CheckErr(res);
 
+#if 0
     res = (*OutputMix)->GetInterface(OutputMix, SL_IID_VOLUME,
             (void*)&volumeItf); CheckErr(res);
+#endif
 
     /* Setup the data source structure for the buffer queue */
     bufferQueue.locatorType = SL_DATALOCATOR_BUFFERQUEUE;
@@ -233,8 +220,10 @@ void TestPlaySawtoothBufferQueue( SLObjectItf sl )
     res = (*bufferQueueItf)->RegisterCallback(bufferQueueItf,
             BufferQueueCallback, &cntxt); CheckErr(res);
 
+#if 0
     /* Before we start set volume to -3dB (-300mB) */
     res = (*volumeItf)->SetVolumeLevel(volumeItf, -300); CheckErr(res);
+#endif
 
     /* Enqueue a few buffers to get the ball rolling */
     res = (*bufferQueueItf)->Enqueue(bufferQueueItf, cntxt.pData,
@@ -285,8 +274,6 @@ void TestPlaySawtoothBufferQueue( SLObjectItf sl )
 
 int main(int argc, char* const argv[])
 {
-    LOGV("Starting sawtoothPlayer\n");
-
     SLresult    res;
     SLObjectItf sl;
 
@@ -304,8 +291,6 @@ int main(int argc, char* const argv[])
 
     /* Shutdown OpenSL ES */
     (*sl)->Destroy(sl);
-    exit(0);
-
 
-    return 0;
+    return EXIT_SUCCESS;
 }
index 3fe8c80..4a71785 100644 (file)
  * limitations under the License.
  */
 
-#ifdef ANDROID
-#define LOG_NDEBUG 0
-#define LOG_TAG "slesTest_sendToPresetReverb"
-
-#include <utils/Log.h>
-#else
-#define LOGV printf
-#endif
-
-#include <getopt.h>
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
@@ -49,7 +39,7 @@ void ExitOnErrorFunc( SLresult result , int line)
 {
     if (SL_RESULT_SUCCESS != result) {
         fprintf(stderr, "%lu error code encountered at line %d, exiting\n", result, line);
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 }
 
@@ -259,8 +249,6 @@ void TestSendToPresetReverb( SLObjectItf sl, const char* path, int preset, SLmil
 //-----------------------------------------------------------------
 int main(int argc, char* const argv[])
 {
-    LOGV("Starting %s\n", argv[0]);
-
     SLresult    result;
     SLObjectItf sl;
 
@@ -275,7 +263,7 @@ int main(int argc, char* const argv[])
     if (argc < 5) {
         fprintf(stdout, "Usage: \t%s path preset directLevel sendLevel\n", argv[0]);
         fprintf(stdout, "Example: \"%s /sdcard/my.mp3 6 -2000 0\" \n", argv[0]);
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     SLEngineOption EngineOption[] = {
@@ -295,7 +283,6 @@ int main(int argc, char* const argv[])
 
     /* Shutdown OpenSL ES */
     (*sl)->Destroy(sl);
-    exit(0);
 
-    return 0;
+    return EXIT_SUCCESS;
 }
index c01e315..87abbaf 100644 (file)
  * limitations under the License.
  */
 
-#ifdef ANDROID
-#define LOG_NDEBUG 0
-#define LOG_TAG "slesTest_virtualizer"
-
-#include <utils/Log.h>
-#else
-#define LOGV printf
-#endif
-
-#include <getopt.h>
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
@@ -49,7 +39,7 @@ void ExitOnErrorFunc( SLresult result , int line)
 {
     if (SL_RESULT_SUCCESS != result) {
         fprintf(stderr, "%lu error code encountered at line %d, exiting\n", result, line);
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 }
 
@@ -100,7 +90,7 @@ void TestVirtualizerPathFromFD( SLObjectItf sl, const char* path, int16_t virtSt
     /* Configuration of the output mix  */
 
     /* Create Output Mix object to be used by the player */
-     result = (*EngineItf)->CreateOutputMix(EngineItf, &outputMix, 1, iidArray, required);
+     result = (*EngineItf)->CreateOutputMix(EngineItf, &outputMix, 0, iidArray, required);
      ExitOnError(result);
 
     /* Realize the Output Mix object in synchronous mode */
@@ -256,8 +246,6 @@ void TestVirtualizerPathFromFD( SLObjectItf sl, const char* path, int16_t virtSt
 //-----------------------------------------------------------------
 int main(int argc, char* const argv[])
 {
-    LOGV("Starting %s\n", argv[0]);
-
     SLresult    result;
     SLObjectItf sl;
 
@@ -272,7 +260,7 @@ int main(int argc, char* const argv[])
     if (argc < 3) {
         fprintf(stdout, "Usage: \t%s path virtualization_strength\n", argv[0]);
         fprintf(stdout, "Example: \"%s /sdcard/my.mp3 1000\" \n", argv[0]);
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     SLEngineOption EngineOption[] = {
@@ -291,7 +279,6 @@ int main(int argc, char* const argv[])
 
     /* Shutdown OpenSL ES */
     (*sl)->Destroy(sl);
-    exit(0);
 
-    return 0;
+    return EXIT_SUCCESS;
 }
index d142cf4..94f0c78 100644 (file)
  * limitations under the License.
  */
 
-#define LOG_NDEBUG 0
-#define LOG_TAG "slesTest_playMuteSolo"
-
-#ifdef ANDROID
-#include <utils/Log.h>
-#else
-#define LOGV printf
-#endif
-
-#include <getopt.h>
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
@@ -52,7 +42,7 @@ void ExitOnErrorFunc( SLresult result , int line)
 {
     if (SL_RESULT_SUCCESS != result) {
         fprintf(stdout, "%lu error code encountered at line %d, exiting\n", result, line);
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 }
 
@@ -158,7 +148,7 @@ void TestPlayUri( SLObjectItf sl, const char* path)
     /* Configuration of the output mix  */
 
     /* Create Output Mix object to be used by the player */
-     result = (*EngineItf)->CreateOutputMix(EngineItf, &outputMix, 1, iidArray, required);
+     result = (*EngineItf)->CreateOutputMix(EngineItf, &outputMix, 0, iidArray, required);
      ExitOnError(result);
 
     /* Realize the Output Mix object in synchronous mode */
@@ -295,8 +285,6 @@ destroyKillKill:
 //-----------------------------------------------------------------
 int main(int argc, char* const argv[])
 {
-    LOGV("Starting %s\n", argv[0]);
-
     SLresult    result;
     SLObjectItf sl;
 
@@ -310,7 +298,7 @@ int main(int argc, char* const argv[])
     if (argc == 1) {
         fprintf(stdout, "Usage: \t%s url\n", argv[0]);
         fprintf(stdout, "Example: \"%s /sdcard/my.mp3\"\n", argv[0]);
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     SLEngineOption EngineOption[] = {
@@ -330,7 +318,6 @@ int main(int argc, char* const argv[])
 
     /* Shutdown OpenSL ES */
     (*sl)->Destroy(sl);
-    exit(0);
 
-    return 0;
+    return EXIT_SUCCESS;
 }
index 466e25f..d19b9d9 100644 (file)
@@ -142,4 +142,4 @@ endif
 
 LOCAL_MODULE:= slesTest_slowDownUri
 
-include $(BUILD_EXECUTABLE)
\ No newline at end of file
+include $(BUILD_EXECUTABLE)
index 6afba09..8bad9cb 100644 (file)
  * limitations under the License.
  */
 
-#define LOG_NDEBUG 0
-#define LOG_TAG "slesTestLoopUri"
-
-#ifdef ANDROID
-#include <utils/Log.h>
-#else
-#define LOGV printf
-#endif
-#include <getopt.h>
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
@@ -44,7 +35,7 @@ void ExitOnErrorFunc( SLresult result , int line)
 {
     if (SL_RESULT_SUCCESS != result) {
         fprintf(stderr, "%lu error code encountered at line %d, exiting\n", result, line);
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 }
 
@@ -60,7 +51,7 @@ void PrefetchEventCallback( SLPrefetchStatusItf caller,  void *pContext, SLuint3
     if ((event & (SL_PREFETCHEVENT_STATUSCHANGE|SL_PREFETCHEVENT_FILLLEVELCHANGE))
             && (level == 0) && (status == SL_PREFETCHSTATUS_UNDERFLOW)) {
         fprintf(stdout, "\t\tPrefetchEventCallback: Error while prefetching data, exiting\n");
-        //exit(1);
+        //exit(EXIT_FAILURE);
     }
     if (event & SL_PREFETCHEVENT_FILLLEVELCHANGE) {
         fprintf(stdout, "\t\tPrefetchEventCallback: Buffer fill level is = %d\n", level);
@@ -114,7 +105,7 @@ void TestLoopUri( SLObjectItf sl, const char* path)
     required[0] = SL_BOOLEAN_TRUE;
     iidArray[0] = SL_IID_VOLUME;
     // Create Output Mix object to be used by player
-    res = (*EngineItf)->CreateOutputMix(EngineItf, &OutputMix, 1,
+    res = (*EngineItf)->CreateOutputMix(EngineItf, &OutputMix, 0,
             iidArray, required); CheckErr(res);
 
     // Realizing the Output Mix object in synchronous mode.
@@ -241,8 +232,6 @@ destroyRes:
 //-----------------------------------------------------------------
 int main(int argc, char* const argv[])
 {
-    LOGV("Starting slesTestLoopUri\n");
-
     SLresult    res;
     SLObjectItf sl;
 
@@ -254,7 +243,7 @@ int main(int argc, char* const argv[])
         fprintf(stdout, "Usage: \n\t%s path \n\t%s url\n", argv[0], argv[0]);
         fprintf(stdout, "Example: \"%s /sdcard/my.mp3\"  or \"%s file:///sdcard/my.mp3\"\n",
                 argv[0], argv[0]);
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     SLEngineOption EngineOption[] = {
@@ -271,7 +260,6 @@ int main(int argc, char* const argv[])
 
     /* Shutdown OpenSL ES */
     (*sl)->Destroy(sl);
-    exit(0);
 
-    return 0;
+    return EXIT_SUCCESS;
 }
index f726ee5..ad5c394 100644 (file)
  * limitations under the License.
  */
 
-#ifdef ANDROID
-#define LOG_NDEBUG 0
-#define LOG_TAG "slesTest_playStreamType"
-
-#include <utils/Log.h>
-#else
-#define LOGV printf
-#endif
-#include <getopt.h>
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
@@ -47,7 +38,7 @@ void ExitOnErrorFunc( SLresult result , int line)
 {
     if (SL_RESULT_SUCCESS != result) {
         fprintf(stdout, "%lu error code encountered at line %d, exiting\n", result, line);
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 }
 
@@ -96,7 +87,7 @@ void TestStreamTypeConfiguration( SLObjectItf sl, const char* path, const SLint3
     /* Configuration of the output mix  */
 
     /* Create Output Mix object to be used by the player */
-     result = (*EngineItf)->CreateOutputMix(EngineItf, &outputMix, 1, iidArray, required);
+     result = (*EngineItf)->CreateOutputMix(EngineItf, &outputMix, 0, iidArray, required);
      ExitOnError(result);
 
     /* Realize the Output Mix object in synchronous mode */
@@ -238,8 +229,6 @@ void TestStreamTypeConfiguration( SLObjectItf sl, const char* path, const SLint3
 //-----------------------------------------------------------------
 int main(int argc, char* const argv[])
 {
-    LOGV("Starting %s\n", argv[0]);
-
     SLresult    result;
     SLObjectItf sl;
 
@@ -252,7 +241,7 @@ int main(int argc, char* const argv[])
         fprintf(stdout, "Usage: \t%s url stream_type\n", argv[0]);
         fprintf(stdout, " where stream_type is one of the SL_ANDROID_STREAM_ constants.\n");
         fprintf(stdout, "Example: \"%s /sdcard/my.mp3 3\" \n", argv[0]);
-        exit(1);
+        return EXIT_FAILURE;
     }
 
     SLEngineOption EngineOption[] = {
@@ -270,7 +259,6 @@ int main(int argc, char* const argv[])
 
     /* Shutdown OpenSL ES */
     (*sl)->Destroy(sl);
-    exit(0);
 
-    return 0;
+    return EXIT_SUCCESS;
 }
index ba0ffcc..819f9cf 100644 (file)
  * MATERIALS.
  */
 
-#define LOG_NDEBUG 0
-#define LOG_TAG "slesTestPlayUri"
-
-#ifdef ANDROID
-#include <utils/Log.h>
-#else
-#define LOGV printf
-#endif
-#include <getopt.h>
 #include <stdlib.h>
 #include <stdio.h>
-#include <string.h>
+//#include <string.h>
 #include <unistd.h>
-#include <sys/time.h>
+//#include <sys/time.h>
 
 #include "SLES/OpenSLES.h"
 
@@ -65,7 +56,7 @@ void ExitOnErrorFunc( SLresult result , int line)
 {
     if (SL_RESULT_SUCCESS != result) {
         fprintf(stderr, "%lu error code encountered at line %d, exiting\n", result, line);
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 }
 
@@ -76,18 +67,18 @@ void PrefetchEventCallback( SLPrefetchStatusItf caller,  void *pContext, SLuint3
     SLpermille level = 0;
     (*caller)->GetFillLevel(caller, &level);
     SLuint32 status;
-    //fprintf(stdout, "\t\tPrefetchEventCallback: received event %lu\n", event);
+    //fprintf(stdout, "PrefetchEventCallback: received event %lu\n", event);
     (*caller)->GetPrefetchStatus(caller, &status);
     if ((event & (SL_PREFETCHEVENT_STATUSCHANGE|SL_PREFETCHEVENT_FILLLEVELCHANGE))
             && (level == 0) && (status == SL_PREFETCHSTATUS_UNDERFLOW)) {
-        fprintf(stdout, "\t\tPrefetchEventCallback: Error while prefetching data, exiting\n");
-        //exit(1);
+        fprintf(stdout, "PrefetchEventCallback: Error while prefetching data, exiting\n");
+        //exit(EXIT_FAILURE);
     }
     if (event & SL_PREFETCHEVENT_FILLLEVELCHANGE) {
-        fprintf(stdout, "\t\tPrefetchEventCallback: Buffer fill level is = %d\n", level);
+        fprintf(stdout, "PrefetchEventCallback: Buffer fill level is = %d\n", level);
     }
     if (event & SL_PREFETCHEVENT_STATUSCHANGE) {
-        fprintf(stdout, "\t\tPrefetchEventCallback: Prefetch Status is = %lu\n", status);
+        fprintf(stdout, "PrefetchEventCallback: Prefetch Status is = %lu\n", status);
     }
 
 }
@@ -138,7 +129,7 @@ void TestPlayUri( SLObjectItf sl, const char* path)
     required[1] = SL_BOOLEAN_TRUE;
     iidArray[1] = SL_IID_PREFETCHSTATUS;
     // Create Output Mix object to be used by player
-    res = (*EngineItf)->CreateOutputMix(EngineItf, &OutputMix, 1,
+    res = (*EngineItf)->CreateOutputMix(EngineItf, &OutputMix, 0,
             iidArray, required); CheckErr(res);
 
     // Realizing the Output Mix object in synchronous mode.
@@ -204,9 +195,9 @@ void TestPlayUri( SLObjectItf sl, const char* path)
 
     /* Play the URI */
     /*     first cause the player to prefetch the data */
-    fprintf(stdout, "\nbefore set to PAUSED\n\n");
+    fprintf(stdout, "Before set to PAUSED\n");
     res = (*playItf)->SetPlayState( playItf, SL_PLAYSTATE_PAUSED );
-    fprintf(stdout, "\nafter set to PAUSED\n\n");
+    fprintf(stdout, "After set to PAUSED\n");
     CheckErr(res);
 
     /*     wait until there's data to play */
@@ -220,7 +211,7 @@ void TestPlayUri( SLObjectItf sl, const char* path)
     }
 
     if (timeOutIndex == 0) {
-        fprintf(stderr, "\nWe\'re done waiting, failed to prefetch data in time, exiting\n");
+        fprintf(stderr, "We\'re done waiting, failed to prefetch data in time, exiting\n");
         goto destroyRes;
     }
 
@@ -257,8 +248,6 @@ destroyRes:
 //-----------------------------------------------------------------
 int main(int argc, char* const argv[])
 {
-    LOGV("Starting slesTestPlayUri\n");
-
     SLresult    res;
     SLObjectItf sl;
 
@@ -267,10 +256,10 @@ int main(int argc, char* const argv[])
     fprintf(stdout, "Plays a sound and stops after its reported duration\n\n");
 
     if (argc == 1) {
-        fprintf(stdout, "Usage: \n\t%s path \n\t%s url\n", argv[0], argv[0]);
+        fprintf(stdout, "Usage: %s path \n\t%s url\n", argv[0], argv[0]);
         fprintf(stdout, "Example: \"%s /sdcard/my.mp3\"  or \"%s file:///sdcard/my.mp3\"\n",
                 argv[0], argv[0]);
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     SLEngineOption EngineOption[] = {
@@ -287,7 +276,6 @@ int main(int argc, char* const argv[])
 
     /* Shutdown OpenSL ES */
     (*sl)->Destroy(sl);
-    exit(0);
 
-    return 0;
+    return EXIT_SUCCESS;
 }
index c80f67c..29a2a9f 100644 (file)
  * limitations under the License.
  */
 
-#define LOG_NDEBUG 0
-#define LOG_TAG "slesTestPlayUri"
-
-#ifdef ANDROID
-#include <utils/Log.h>
-#else
-#define LOGV printf
-#endif
-
-#include <getopt.h>
 #include <stdlib.h>
 #include <stdio.h>
-#include <string.h>
 #include <unistd.h>
-#include <sys/time.h>
 
 #include "SLES/OpenSLES.h"
 
 
 #define MAX_NUMBER_INTERFACES 3
-#define MAX_NUMBER_OUTPUT_DEVICES 6
 
 
 //-----------------------------------------------------------------
@@ -43,7 +30,7 @@ void ExitOnError( SLresult result )
 {
     if (SL_RESULT_SUCCESS != result) {
         fprintf(stdout, "%lu error code encountered, exiting\n", result);
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 }
 
@@ -118,7 +105,7 @@ void TestPlayUri( SLObjectItf sl, const char* path, const char* path2)
     /* Configuration of the output mix  */
 
     /* Create Output Mix object to be used each player */
-     result = (*EngineItf)->CreateOutputMix(EngineItf, &outputMix, 1, iidArray, required);
+     result = (*EngineItf)->CreateOutputMix(EngineItf, &outputMix, 0, iidArray, required);
      ExitOnError(result);
 
     /* Realize the Output Mix object in synchronous mode */
@@ -261,8 +248,6 @@ void TestPlayUri( SLObjectItf sl, const char* path, const char* path2)
 //-----------------------------------------------------------------
 int main(int argc, char* const argv[])
 {
-    LOGV("Starting %s\n", argv[0]);
-
     SLresult    result;
     SLObjectItf sl;
 
@@ -276,7 +261,7 @@ int main(int argc, char* const argv[])
         fprintf(stdout, "Usage: \n\t%s url1 url2 \n\t%s url\n", argv[0], argv[0]);
         fprintf(stdout, "Example: \"%s /sdcard/my.mp3 http://blabla/my.wav\" ", argv[0]);
         fprintf(stdout, "or \"%s file:///sdcard/my.mp3\"\n", argv[0]);
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     SLEngineOption EngineOption[] = {
@@ -298,7 +283,6 @@ int main(int argc, char* const argv[])
 
     /* Shutdown OpenSL ES */
     (*sl)->Destroy(sl);
-    exit(0);
 
-    return 0;
+    return EXIT_SUCCESS;
 }
index fe5aa33..52ba237 100644 (file)
  * limitations under the License.
  */
 
-#define LOG_NDEBUG 0
-#define LOG_TAG "slesTestSlowDownUri"
-
-#ifdef ANDROID
-#include <utils/Log.h>
-#else
-#define LOGV printf
-#endif
-#include <getopt.h>
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
@@ -46,7 +37,7 @@ void ExitOnErrorFunc( SLresult result , int line)
 {
     if (SL_RESULT_SUCCESS != result) {
         fprintf(stderr, "%lu error code encountered at line %d, exiting\n", result, line);
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 }
 
@@ -99,7 +90,7 @@ void PrefetchEventCallback( SLPrefetchStatusItf caller,  void *pContext, SLuint3
     if ((event & (SL_PREFETCHEVENT_STATUSCHANGE|SL_PREFETCHEVENT_FILLLEVELCHANGE))
             && (level == 0) && (status == SL_PREFETCHSTATUS_UNDERFLOW)) {
         fprintf(stdout, "\t\tPrefetchEventCallback: Error while prefetching data, exiting\n");
-        //exit(1);
+        //exit(EXIT_FAILURE);
     }
     if (event & SL_PREFETCHEVENT_FILLLEVELCHANGE) {
         fprintf(stdout, "\t\tPrefetchEventCallback: Buffer fill level is = %d\n", level);
@@ -153,7 +144,7 @@ void TestSlowDownUri( SLObjectItf sl, const char* path)
     required[0] = SL_BOOLEAN_TRUE;
     iidArray[0] = SL_IID_VOLUME;
     // Create Output Mix object to be used by player
-    res = (*EngineItf)->CreateOutputMix(EngineItf, &OutputMix, 1,
+    res = (*EngineItf)->CreateOutputMix(EngineItf, &OutputMix, 0,
             iidArray, required);  CheckErr(res);
 
     // Realizing the Output Mix object in synchronous mode.
@@ -284,8 +275,6 @@ destroyRes:
 //-----------------------------------------------------------------
 int main(int argc, char* const argv[])
 {
-    LOGV("Starting slesTestSlowDownUri\n");
-
     SLresult    res;
     SLObjectItf sl;
 
@@ -299,7 +288,7 @@ int main(int argc, char* const argv[])
         fprintf(stdout, "Usage: \n\t%s path \n\t%s url\n", argv[0], argv[0]);
         fprintf(stdout, "Example: \"%s /sdcard/my.mp3\"  or \"%s file:///sdcard/my.mp3\"\n",
                 argv[0], argv[0]);
-        exit(1);
+        return EXIT_FAILURE;
     }
 
     SLEngineOption EngineOption[] = {
@@ -316,7 +305,6 @@ int main(int argc, char* const argv[])
 
     /* Shutdown OpenSL ES */
     (*sl)->Destroy(sl);
-    exit(0);
 
-    return 0;
+    return EXIT_SUCCESS;
 }
index b056725..58356d7 100644 (file)
  * limitations under the License.
  */
 
-#define LOG_NDEBUG 0
-#define LOG_TAG "slesTest_playStates"
-
-#include <utils/Log.h>
-#include <getopt.h>
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
@@ -42,7 +37,7 @@ void ExitOnErrorFunc( SLresult result , int line)
 {
     if (SL_RESULT_SUCCESS != result) {
         fprintf(stdout, "%lu error code encountered at line %d, exiting\n", result, line);
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 }
 
@@ -89,7 +84,7 @@ void TestPlayUri( SLObjectItf sl, const char* path)
     /* Configuration of the output mix  */
 
     /* Create Output Mix object to be used by the player */
-     result = (*EngineItf)->CreateOutputMix(EngineItf, &outputMix, 1, iidArray, required);
+     result = (*EngineItf)->CreateOutputMix(EngineItf, &outputMix, 0, iidArray, required);
      ExitOnError(result);
 
     /* Realize the Output Mix object in synchronous mode */
@@ -208,8 +203,6 @@ destroyKillKill:
 //-----------------------------------------------------------------
 int main(int argc, char* const argv[])
 {
-    LOGV("Starting %s\n", argv[0]);
-
     SLresult    result;
     SLObjectItf sl;
 
@@ -223,7 +216,7 @@ int main(int argc, char* const argv[])
     if (argc == 1) {
         fprintf(stdout, "Usage: \t%s url\n", argv[0]);
         fprintf(stdout, "Example: \"%s /sdcard/my.mp3\"\n", argv[0]);
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     SLEngineOption EngineOption[] = {
@@ -243,7 +236,6 @@ int main(int argc, char* const argv[])
 
     /* Shutdown OpenSL ES */
     (*sl)->Destroy(sl);
-    exit(0);
 
-    return 0;
+    return EXIT_SUCCESS;
 }
index 84543a3..87cc000 100644 (file)
@@ -138,7 +138,7 @@ void TestPlayUri( SLObjectItf sl, const char* path)
     required[1] = SL_BOOLEAN_TRUE;
     iidArray[1] = SL_IID_PREFETCHSTATUS;
     // Create Output Mix object to be used by player
-    res = (*EngineItf)->CreateOutputMix(EngineItf, &OutputMix, 1,
+    res = (*EngineItf)->CreateOutputMix(EngineItf, &OutputMix, 0,
             iidArray, required); CheckErr(res);
 
     // Realizing the Output Mix object in synchronous mode.
index 0926b59..3e84cc2 100644 (file)
@@ -20,6 +20,7 @@
 #include <math.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <unistd.h>
 
 #include "SLES/OpenSLES.h"
 
index 0fe3ada..f65cf11 100644 (file)
@@ -21,6 +21,7 @@
 #include <string.h>
 #include <stdlib.h>
 #include <stdio.h>
+#include <unistd.h>
 
 // Describes the state of one player
 
@@ -126,10 +127,11 @@ int main(int argc, char **argv)
     const SLInterfaceID mix_ids[] = {SL_IID_VOLUME};
     const SLboolean mix_req[] = {SL_BOOLEAN_TRUE};
     SLObjectItf mixObject;
-    result = (*engineEngine)->CreateOutputMix(engineEngine, &mixObject, 1, mix_ids, mix_req);
+    result = (*engineEngine)->CreateOutputMix(engineEngine, &mixObject, 0, mix_ids, mix_req);
     check(result);
     result = (*mixObject)->Realize(mixObject, SL_BOOLEAN_FALSE);
     check(result);
+#if 0
     SLVolumeItf mixVolume;
     result = (*mixObject)->GetInterface(mixObject, SL_IID_VOLUME, &mixVolume);
     check(result);
@@ -137,6 +139,7 @@ int main(int argc, char **argv)
     result = (*mixVolume)->GetVolumeLevel(mixVolume, &mixVolumeLevelDefault);
     check(result);
     printf("default mix volume level = %d\n", mixVolumeLevelDefault);
+#endif
 
     printf("numPathnames=%d\n", numPathnames);
     printf("numPlayers=%d\n", numPlayers);
index 18b6906..df953be 100644 (file)
@@ -21,6 +21,7 @@
 #include <string.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <unistd.h>
 
 // Table of I3DL2 named environmental reverb settings
 
index b7f9a6e..c179032 100644 (file)
@@ -20,6 +20,7 @@
 #include <math.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <unistd.h>
 
 #include "SLES/OpenSLES.h"
 #ifdef ANDROID