diff options
| author | Ricardo Cerqueira <cyanogenmod@cerqueira.org> | 2013-07-24 22:58:45 +0100 |
|---|---|---|
| committer | Ricardo Cerqueira <cyanogenmod@cerqueira.org> | 2013-07-24 22:58:45 +0100 |
| commit | 073b5888c2af197c129b1b8d2a4deeaf9870e2ed (patch) | |
| tree | f18692e254bc8ad735e8f6f126cbc1d36d1cfeb8 | |
| parent | 4a4c728965b10df683d37b4b7ac27211e02006ad (diff) | |
| parent | 3f73d418d3738c05fbb872644edc90765d1de00a (diff) | |
| download | android_frameworks_wilhelm-cm-10.2.tar.gz android_frameworks_wilhelm-cm-10.2.tar.bz2 android_frameworks_wilhelm-cm-10.2.zip | |
Merge tag 'android-4.3_r2.1' into cm-10.2cm-10.2.1cm-10.2.0cm-10.2-M1stable/cm-10.2cm-10.2
Android 4.3 release 2.1
| -rw-r--r-- | src/Android.mk | 2 | ||||
| -rw-r--r-- | src/android/AudioPlayer_to_android.cpp | 24 | ||||
| -rw-r--r-- | src/android/MediaPlayer_to_android.cpp | 16 | ||||
| -rw-r--r-- | src/android/android_GenericMediaPlayer.cpp | 8 | ||||
| -rw-r--r-- | src/android/android_GenericMediaPlayer.h | 6 | ||||
| -rw-r--r-- | src/android/android_GenericPlayer.h | 2 | ||||
| -rw-r--r-- | src/android/android_LocAVPlayer.cpp | 4 | ||||
| -rw-r--r-- | src/android/android_StreamPlayer.cpp | 2 | ||||
| -rw-r--r-- | src/android/android_sles_conversions.h | 6 | ||||
| -rw-r--r-- | src/assert.c | 4 | ||||
| -rw-r--r-- | tests/mimeUri/slesTestSlowDownUri.cpp | 6 | ||||
| -rw-r--r-- | tests/native-media/jni/Android.mk | 2 | ||||
| -rw-r--r-- | tests/native-media/jni/native-media-jni.c | 2 | ||||
| -rw-r--r-- | tests/sandbox/Android.mk | 26 | ||||
| -rw-r--r-- | tests/sandbox/playbq.c | 90 | ||||
| l--------- | tests/sandbox/playbq.cpp | 1 |
16 files changed, 135 insertions, 66 deletions
diff --git a/src/Android.mk b/src/Android.mk index 60a7cab..3b482ba 100644 --- a/src/Android.mk +++ b/src/Android.mk @@ -175,9 +175,9 @@ LOCAL_STATIC_LIBRARIES += \ libOpenSLESUT LOCAL_SHARED_LIBRARIES := \ + liblog \ libutils \ libmedia \ - libmedia_native \ libbinder \ libstagefright \ libstagefright_foundation \ diff --git a/src/android/AudioPlayer_to_android.cpp b/src/android/AudioPlayer_to_android.cpp index 73ee427..43a9353 100644 --- a/src/android/AudioPlayer_to_android.cpp +++ b/src/android/AudioPlayer_to_android.cpp @@ -163,30 +163,6 @@ static size_t adecoder_writeToBufferQueue(const uint8_t *data, size_t size, CAud return sizeConsumed; } -//----------------------------------------------------------------------------- -int android_getMinFrameCount(uint32_t sampleRate) { - int afSampleRate; - if (android::AudioSystem::getOutputSamplingRate(&afSampleRate, - ANDROID_DEFAULT_OUTPUT_STREAM_TYPE) != android::NO_ERROR) { - return ANDROID_DEFAULT_AUDIOTRACK_BUFFER_SIZE; - } - int afFrameCount; - if (android::AudioSystem::getOutputFrameCount(&afFrameCount, - ANDROID_DEFAULT_OUTPUT_STREAM_TYPE) != android::NO_ERROR) { - return ANDROID_DEFAULT_AUDIOTRACK_BUFFER_SIZE; - } - uint32_t afLatency; - if (android::AudioSystem::getOutputLatency(&afLatency, - ANDROID_DEFAULT_OUTPUT_STREAM_TYPE) != android::NO_ERROR) { - return ANDROID_DEFAULT_AUDIOTRACK_BUFFER_SIZE; - } - // minimum nb of buffers to cover output latency, given the size of each hardware audio buffer - uint32_t minBufCount = afLatency / ((1000 * afFrameCount)/afSampleRate); - if (minBufCount < 2) minBufCount = 2; - // minimum number of frames to cover output latency at the sample rate of the content - return (afFrameCount*sampleRate*minBufCount)/afSampleRate; -} - //----------------------------------------------------------------------------- #define LEFT_CHANNEL_MASK 0x1 << 0 diff --git a/src/android/MediaPlayer_to_android.cpp b/src/android/MediaPlayer_to_android.cpp index 981a6bd..69eb0aa 100644 --- a/src/android/MediaPlayer_to_android.cpp +++ b/src/android/MediaPlayer_to_android.cpp @@ -738,20 +738,12 @@ SLresult android_Player_setNativeWindow(CMediaPlayer *mp, ANativeWindow *nativeW result = SL_RESULT_PARAMETER_INVALID; } else { switch (value) { - case NATIVE_WINDOW_SURFACE: { // Surface + case NATIVE_WINDOW_SURFACE: { // Surface SL_LOGV("Displaying on ANativeWindow of type NATIVE_WINDOW_SURFACE"); - android::sp<android::Surface> nativeSurface( + android::sp<android::Surface> surface( static_cast<android::Surface *>(nativeWindow)); - mp->mAVPlayer->setVideoSurfaceTexture( - nativeSurface->getSurfaceTexture()); - result = SL_RESULT_SUCCESS; - } break; - case NATIVE_WINDOW_SURFACE_TEXTURE_CLIENT: { // SurfaceTextureClient - SL_LOGV("Displaying on ANativeWindow of type NATIVE_WINDOW_SURFACE_TEXTURE_CLIENT"); - android::sp<android::SurfaceTextureClient> surfaceTextureClient( - static_cast<android::SurfaceTextureClient *>(nativeWindow)); - android::sp<android::ISurfaceTexture> nativeSurfaceTexture( - surfaceTextureClient->getISurfaceTexture()); + android::sp<android::IGraphicBufferProducer> nativeSurfaceTexture( + surface->getIGraphicBufferProducer()); mp->mAVPlayer->setVideoSurfaceTexture(nativeSurfaceTexture); result = SL_RESULT_SUCCESS; } break; diff --git a/src/android/android_GenericMediaPlayer.cpp b/src/android/android_GenericMediaPlayer.cpp index 629c54e..b0d4798 100644 --- a/src/android/android_GenericMediaPlayer.cpp +++ b/src/android/android_GenericMediaPlayer.cpp @@ -296,16 +296,16 @@ void GenericMediaPlayer::getPositionMsec(int* msec) { } //-------------------------------------------------- -void GenericMediaPlayer::setVideoSurfaceTexture(const sp<ISurfaceTexture> &surfaceTexture) { +void GenericMediaPlayer::setVideoSurfaceTexture(const sp<IGraphicBufferProducer> &bufferProducer) { SL_LOGV("GenericMediaPlayer::setVideoSurfaceTexture()"); // FIXME bug - race condition, should do in looper - if (mVideoSurfaceTexture.get() == surfaceTexture.get()) { + if (mVideoSurfaceTexture.get() == bufferProducer.get()) { return; } if ((mStateFlags & kFlagPrepared) && (mPlayer != 0)) { - mPlayer->setVideoSurfaceTexture(surfaceTexture); + mPlayer->setVideoSurfaceTexture(bufferProducer); } - mVideoSurfaceTexture = surfaceTexture; + mVideoSurfaceTexture = bufferProducer; } //-------------------------------------------------- diff --git a/src/android/android_GenericMediaPlayer.h b/src/android/android_GenericMediaPlayer.h index e4e556b..be129cc 100644 --- a/src/android/android_GenericMediaPlayer.h +++ b/src/android/android_GenericMediaPlayer.h @@ -20,7 +20,7 @@ #include "android_GenericPlayer.h" #include <binder/IServiceManager.h> -#include <gui/ISurfaceTexture.h> +#include <gui/IGraphicBufferProducer.h> //-------------------------------------------------------------------------------------------------- @@ -89,7 +89,7 @@ public: // overridden from GenericPlayer virtual void getPositionMsec(int* msec); // ANDROID_UNKNOWN_TIME if unknown - virtual void setVideoSurfaceTexture(const sp<ISurfaceTexture> &surfaceTexture); + virtual void setVideoSurfaceTexture(const sp<IGraphicBufferProducer> &bufferProducer); virtual void setPlaybackRate(int32_t ratePermille); @@ -111,7 +111,7 @@ protected: const bool mHasVideo; // const allows MediaPlayerNotificationClient::notify to safely access int32_t mSeekTimeMsec; - sp<ISurfaceTexture> mVideoSurfaceTexture; + sp<IGraphicBufferProducer> mVideoSurfaceTexture; // only safe to access from within Realize and looper sp<IMediaPlayer> mPlayer; diff --git a/src/android/android_GenericPlayer.h b/src/android/android_GenericPlayer.h index f73eb3e..3aee9e4 100644 --- a/src/android/android_GenericPlayer.h +++ b/src/android/android_GenericPlayer.h @@ -78,7 +78,7 @@ public: void getDurationMsec(int* msec); //msec != NULL, ANDROID_UNKNOWN_TIME if unknown virtual void getPositionMsec(int* msec) = 0; //msec != NULL, ANDROID_UNKNOWN_TIME if unknown - virtual void setVideoSurfaceTexture(const sp<ISurfaceTexture> &surfaceTexture) {} + virtual void setVideoSurfaceTexture(const sp<IGraphicBufferProducer> &bufferProducer) {} void setVolume(float leftVol, float rightVol); void attachAuxEffect(int32_t effectId); diff --git a/src/android/android_LocAVPlayer.cpp b/src/android/android_LocAVPlayer.cpp index 90e7b5f..3902cad 100644 --- a/src/android/android_LocAVPlayer.cpp +++ b/src/android/android_LocAVPlayer.cpp @@ -46,7 +46,7 @@ void LocAVPlayer::onPrepare() { if (mediaPlayerService != NULL) { switch (mDataLocatorType) { case kDataLocatorUri: - mPlayer = mediaPlayerService->create(getpid(), mPlayerClient /*IMediaPlayerClient*/, + mPlayer = mediaPlayerService->create(mPlayerClient /*IMediaPlayerClient*/, mPlaybackParams.sessionId); if (mPlayer == NULL) { SL_LOGE("media player service failed to create player by URI"); @@ -56,7 +56,7 @@ void LocAVPlayer::onPrepare() { } break; case kDataLocatorFd: - mPlayer = mediaPlayerService->create(getpid(), mPlayerClient /*IMediaPlayerClient*/, + mPlayer = mediaPlayerService->create(mPlayerClient /*IMediaPlayerClient*/, mPlaybackParams.sessionId); if (mPlayer == NULL) { SL_LOGE("media player service failed to create player by FD"); diff --git a/src/android/android_StreamPlayer.cpp b/src/android/android_StreamPlayer.cpp index 86501ae..f66b85e 100644 --- a/src/android/android_StreamPlayer.cpp +++ b/src/android/android_StreamPlayer.cpp @@ -385,7 +385,7 @@ void StreamPlayer::onPrepare() { SL_LOGD("StreamPlayer::onPrepare()"); sp<IMediaPlayerService> mediaPlayerService(getMediaPlayerService()); if (mediaPlayerService != NULL) { - mPlayer = mediaPlayerService->create(getpid(), mPlayerClient /*IMediaPlayerClient*/, + mPlayer = mediaPlayerService->create(mPlayerClient /*IMediaPlayerClient*/, mPlaybackParams.sessionId); if (mPlayer == NULL) { SL_LOGE("media player service failed to create player by app proxy"); diff --git a/src/android/android_sles_conversions.h b/src/android/android_sles_conversions.h index 9f6aac4..cab6578 100644 --- a/src/android/android_sles_conversions.h +++ b/src/android/android_sles_conversions.h @@ -62,13 +62,15 @@ static inline audio_format_t sles_to_android_sampleFormat(SLuint32 pcmFormat) { } -static inline audio_channel_mask_t sles_to_android_channelMaskIn(SLuint32 nbChannels, SLuint32 channelMask) { +static inline audio_channel_mask_t sles_to_android_channelMaskIn(SLuint32 nbChannels, + SLuint32 channelMask) { // FIXME handle channel mask mapping between SL ES and Android return audio_channel_in_mask_from_count(nbChannels); } -static inline audio_channel_mask_t sles_to_android_channelMaskOut(SLuint32 nbChannels, SLuint32 channelMask) { +static inline audio_channel_mask_t sles_to_android_channelMaskOut(SLuint32 nbChannels, + SLuint32 channelMask) { // FIXME handle channel mask mapping between SL ES and Android return audio_channel_out_mask_from_count(nbChannels); } diff --git a/src/assert.c b/src/assert.c index b315422..0f88e59 100644 --- a/src/assert.c +++ b/src/assert.c @@ -19,6 +19,8 @@ #include <utils/Log.h> +#pragma GCC visibility push(default) + void __assert(const char *file, int line, const char *failedexpr) { LOG_ALWAYS_FATAL("assertion \"%s\" failed: file \"%s\", line %d", failedexpr, file, line); @@ -31,3 +33,5 @@ void __assert2(const char *file, int line, const char *func, const char *failede failedexpr, file, line, func); // not reached } + +#pragma GCC visibility pop diff --git a/tests/mimeUri/slesTestSlowDownUri.cpp b/tests/mimeUri/slesTestSlowDownUri.cpp index 0c2dc7e..2fc472d 100644 --- a/tests/mimeUri/slesTestSlowDownUri.cpp +++ b/tests/mimeUri/slesTestSlowDownUri.cpp @@ -282,7 +282,8 @@ void TestSlowDownUri( SLObjectItf sl, const char* path) res = (*seekItf)->SetLoop(seekItf, SL_BOOLEAN_TRUE, 0, SL_TIME_UNKNOWN); CheckErr(res); /* Set up marker and position callbacks */ - res = (*playItf)->RegisterCallback(playItf, PlayEventCallback, (void *) rateItf); CheckErr(res); + res = (*playItf)->RegisterCallback(playItf, PlayEventCallback, (void *) rateItf); + CheckErr(res); res = (*playItf)->SetCallbackEventsMask(playItf, SL_PLAYEVENT_HEADATEND | SL_PLAYEVENT_HEADATMARKER | SL_PLAYEVENT_HEADATNEWPOS); res = (*playItf)->SetMarkerPosition(playItf, 1500); CheckErr(res); @@ -307,7 +308,8 @@ void TestSlowDownUri( SLObjectItf sl, const char* path) for (index = 0; ; ++index) { SLpermille minRate, maxRate, stepSize; SLuint32 capabilities; - res = (*rateItf)->GetRateRange(rateItf, index, &minRate, &maxRate, &stepSize, &capabilities); + res = (*rateItf)->GetRateRange(rateItf, index, &minRate, &maxRate, &stepSize, + &capabilities); if (res == SL_RESULT_PARAMETER_INVALID) { if (index == 0) { fprintf(stderr, "implementation supports no rate ranges\n"); diff --git a/tests/native-media/jni/Android.mk b/tests/native-media/jni/Android.mk index ad5e806..83b86a0 100644 --- a/tests/native-media/jni/Android.mk +++ b/tests/native-media/jni/Android.mk @@ -9,7 +9,7 @@ LOCAL_CFLAGS += -I$(call include-path-for, wilhelm) LOCAL_CFLAGS += -UNDEBUG LOCAL_PRELINK_MODULE := false -LOCAL_SHARED_LIBRARIES += libutils libOpenMAXAL libandroid +LOCAL_SHARED_LIBRARIES += libutils liblog libOpenMAXAL libandroid include $(BUILD_SHARED_LIBRARY) diff --git a/tests/native-media/jni/native-media-jni.c b/tests/native-media/jni/native-media-jni.c index 6d7ec28..044e51a 100644 --- a/tests/native-media/jni/native-media-jni.c +++ b/tests/native-media/jni/native-media-jni.c @@ -366,7 +366,7 @@ jboolean Java_com_example_nativemedia_NativeMedia_createStreamingMediaPlayer(JNI // configure image video sink XADataLocator_NativeDisplay loc_nd = { XA_DATALOCATOR_NATIVEDISPLAY, // locatorType - // the video sink must be an ANativeWindow created from a Surface or SurfaceTexture + // the video sink must be an ANativeWindow created from a Surface or SurfaceTextureClient (void*)theNativeWindow, // hWindow // must be NULL NULL // hDisplay diff --git a/tests/sandbox/Android.mk b/tests/sandbox/Android.mk index 4f39385..dab840d 100644 --- a/tests/sandbox/Android.mk +++ b/tests/sandbox/Android.mk @@ -15,6 +15,7 @@ LOCAL_SRC_FILES:= \ LOCAL_SHARED_LIBRARIES := \ libutils \ + liblog \ libOpenSLES ifeq ($(TARGET_OS),linux) @@ -42,6 +43,7 @@ LOCAL_SRC_FILES:= \ LOCAL_SHARED_LIBRARIES := \ libutils \ + liblog \ libOpenSLES ifeq ($(TARGET_OS),linux) @@ -69,6 +71,7 @@ LOCAL_SRC_FILES:= \ LOCAL_SHARED_LIBRARIES := \ libutils \ + liblog \ libOpenSLES LOCAL_STATIC_LIBRARIES := \ @@ -99,6 +102,7 @@ LOCAL_SRC_FILES:= \ LOCAL_SHARED_LIBRARIES := \ libutils \ + liblog \ libOpenSLES LOCAL_STATIC_LIBRARIES := \ @@ -128,6 +132,7 @@ LOCAL_SRC_FILES:= \ LOCAL_SHARED_LIBRARIES := \ libutils \ + liblog \ libOpenSLES ifeq ($(TARGET_OS),linux) @@ -154,6 +159,7 @@ LOCAL_SRC_FILES:= \ LOCAL_SHARED_LIBRARIES := \ libutils \ + liblog \ libOpenSLES LOCAL_STATIC_LIBRARIES := \ @@ -183,6 +189,7 @@ LOCAL_SRC_FILES:= \ LOCAL_SHARED_LIBRARIES := \ libutils \ + liblog \ libOpenSLES LOCAL_STATIC_LIBRARIES := \ @@ -213,6 +220,7 @@ LOCAL_SRC_FILES:= \ LOCAL_SHARED_LIBRARIES := \ libutils \ + liblog \ libOpenSLES LOCAL_STATIC_LIBRARIES := \ @@ -242,6 +250,7 @@ LOCAL_SRC_FILES:= \ LOCAL_SHARED_LIBRARIES := \ libutils \ + liblog \ libOpenSLES LOCAL_STATIC_LIBRARIES := \ @@ -271,6 +280,7 @@ LOCAL_SRC_FILES:= \ LOCAL_SHARED_LIBRARIES := \ libutils \ + liblog \ libOpenSLES LOCAL_STATIC_LIBRARIES := \ @@ -300,6 +310,7 @@ LOCAL_SRC_FILES:= \ LOCAL_SHARED_LIBRARIES := \ libutils \ + liblog \ libOpenSLES LOCAL_STATIC_LIBRARIES := \ @@ -322,13 +333,17 @@ include $(CLEAR_VARS) LOCAL_MODULE_TAGS := tests LOCAL_C_INCLUDES:= \ - $(call include-path-for, wilhelm) + $(call include-path-for, wilhelm) \ + $(call include-path-for, audio-utils) LOCAL_SRC_FILES:= \ - playbq.c + playbq.cpp LOCAL_SHARED_LIBRARIES := \ + libaudioutils \ + libnbaio \ libutils \ + liblog \ libOpenSLES LOCAL_STATIC_LIBRARIES := \ @@ -343,8 +358,7 @@ LOCAL_CFLAGS += -UNDEBUG LOCAL_MODULE:= slesTest_playbq -# commented out because libsndfile is not yet standard -#include $(BUILD_EXECUTABLE) +include $(BUILD_EXECUTABLE) # monkey @@ -360,6 +374,7 @@ LOCAL_SRC_FILES:= \ LOCAL_SHARED_LIBRARIES := \ libutils \ + liblog \ libOpenSLES LOCAL_STATIC_LIBRARIES := \ @@ -389,6 +404,7 @@ LOCAL_SRC_FILES:= \ LOCAL_SHARED_LIBRARIES := \ libutils \ + liblog \ libOpenMAXAL LOCAL_STATIC_LIBRARIES := \ @@ -418,6 +434,7 @@ LOCAL_SRC_FILES:= \ LOCAL_SHARED_LIBRARIES := \ libutils \ + liblog \ libOpenSLES \ libOpenMAXAL @@ -448,6 +465,7 @@ LOCAL_SRC_FILES:= \ LOCAL_SHARED_LIBRARIES := \ libutils \ + liblog \ libOpenMAXAL \ libgui \ libbinder \ diff --git a/tests/sandbox/playbq.c b/tests/sandbox/playbq.c index 68e236a..9a33f4d 100644 --- a/tests/sandbox/playbq.c +++ b/tests/sandbox/playbq.c @@ -18,6 +18,7 @@ #include <assert.h> #include <math.h> +#include <pthread.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -26,11 +27,14 @@ #include <SLES/OpenSLES.h> #ifdef ANDROID -#include "sndfile.h" +#include <audio_utils/sndfile.h> #else #include <sndfile.h> #endif +#include <media/nbaio/MonoPipe.h> +#include <media/nbaio/MonoPipeReader.h> + #define max(a, b) ((a) > (b) ? (a) : (b)) #define min(a, b) ((a) < (b) ? (a) : (b)) @@ -71,6 +75,10 @@ static void squeeze(const short *from, unsigned char *to, ssize_t n) } } +static android::MonoPipeReader *pipeReader; +static android::MonoPipe *pipeWriter; +static unsigned underruns = 0; + // This callback is called each time a buffer finishes playing static void callback(SLBufferQueueItf bufq, void *param) @@ -78,11 +86,14 @@ static void callback(SLBufferQueueItf bufq, void *param) assert(NULL == param); if (!eof) { short *buffer = &buffers[framesPerBuffer * sfinfo.channels * which]; - sf_count_t count; - count = sf_readf_short(sndfile, buffer, (sf_count_t) framesPerBuffer); + ssize_t count = pipeReader->read(buffer, framesPerBuffer, (int64_t) -1); + // on underrun from pipe, substitute silence if (0 >= count) { - eof = SL_BOOLEAN_TRUE; - } else { + memset(buffer, 0, framesPerBuffer * sfinfo.channels * sizeof(short)); + count = framesPerBuffer; + ++underruns; + } + if (count > 0) { SLuint32 nbytes = count * sfinfo.channels * sizeof(short); if (byteOrder != nativeByteOrder) { swab(buffer, buffer, nbytes); @@ -99,6 +110,43 @@ static void callback(SLBufferQueueItf bufq, void *param) } } +// This thread reads from a (slow) filesystem with unpredictable latency and writes to pipe + +static void *file_reader_loop(void *arg) +{ +#define READ_FRAMES 256 + short *temp = (short *) malloc(READ_FRAMES * sfinfo.channels * sizeof(short)); + sf_count_t total = 0; + for (;;) { + sf_count_t count = sf_readf_short(sndfile, temp, (sf_count_t) READ_FRAMES); + if (0 >= count) { + eof = SL_BOOLEAN_TRUE; + break; + } + const short *ptr = temp; + while (count > 0) { + ssize_t actual = pipeWriter->write(ptr, (size_t) count); + if (actual < 0) { + break; + } + if ((sf_count_t) actual < count) { + usleep(10000); + } + ptr += actual * sfinfo.channels; + count -= actual; + total += actual; + } + // simulate occasional filesystem latency + if ((total & 0xFF00) == 0xFF00) { + usleep(100000); + } + } + free(temp); + return NULL; +} + +// Main program + int main(int argc, char **argv) { // Determine the native byte order (SL_BYTEORDER_NATIVE not available until 1.1) @@ -188,6 +236,9 @@ int main(int argc, char **argv) return EXIT_FAILURE; } + // The sample rate is a lie, but it doesn't actually matter + const android::NBAIO_Format nbaio_format = android::Format_from_SR_C(44100, sfinfo.channels); + // verify the file format switch (sfinfo.channels) { case 1: @@ -225,15 +276,14 @@ int main(int argc, char **argv) switch (sfinfo.format & SF_FORMAT_SUBMASK) { case SF_FORMAT_PCM_16: case SF_FORMAT_PCM_U8: - case SF_FORMAT_ULAW: - case SF_FORMAT_ALAW: - case SF_FORMAT_IMA_ADPCM: break; default: fprintf(stderr, "unsupported sub-format 0x%x\n", sfinfo.format & SF_FORMAT_SUBMASK); goto close_sndfile; } + { + buffers = (short *) malloc(framesPerBuffer * sfinfo.channels * sizeof(short) * numBuffers); // create engine @@ -305,6 +355,8 @@ int main(int argc, char **argv) goto no_player; } + { + // realize the player result = (*playerObject)->Realize(playerObject, SL_BOOLEAN_FALSE); assert(SL_RESULT_SUCCESS == result); @@ -403,6 +455,24 @@ int main(int argc, char **argv) result = (*playerBufferQueue)->RegisterCallback(playerBufferQueue, callback, NULL); assert(SL_RESULT_SUCCESS == result); + pipeWriter = new android::MonoPipe(16384, nbaio_format, false /*writeCanBlock*/); + android::NBAIO_Format offer = nbaio_format; + size_t numCounterOffers = 0; + ssize_t neg = pipeWriter->negotiate(&offer, 1, NULL, numCounterOffers); + assert(0 == neg); + pipeReader = new android::MonoPipeReader(pipeWriter); + numCounterOffers = 0; + neg = pipeReader->negotiate(&offer, 1, NULL, numCounterOffers); + assert(0 == neg); + + // create thread to read from file + pthread_t thread; + int ok = pthread_create(&thread, (const pthread_attr_t *) NULL, file_reader_loop, NULL); + assert(0 == ok); + + // give thread a head start so that the pipe is initially filled + sleep(1); + // set the player's state to playing result = (*playerPlay)->SetPlayState(playerPlay, SL_PLAYSTATE_PLAYING); assert(SL_RESULT_SUCCESS == result); @@ -458,6 +528,8 @@ int main(int argc, char **argv) // destroy audio player (*playerObject)->Destroy(playerObject); + } + no_player: // destroy output mix @@ -466,6 +538,8 @@ no_player: // destroy engine (*engineObject)->Destroy(engineObject); + } + close_sndfile: (void) sf_close(sndfile); diff --git a/tests/sandbox/playbq.cpp b/tests/sandbox/playbq.cpp new file mode 120000 index 0000000..a438ce1 --- /dev/null +++ b/tests/sandbox/playbq.cpp @@ -0,0 +1 @@ +playbq.c
\ No newline at end of file |
