Loading include/media/AudioTrack.h +11 −0 Original line number Diff line number Diff line Loading @@ -102,6 +102,17 @@ public: typedef void (*callback_t)(int event, void* user, void *info); /* Returns the minimum frame count required for the successful creation of * an AudioTrack object. * Returned status (from utils/Errors.h) can be: * - NO_ERROR: successful operation * - NO_INIT: audio server or audio hardware not initialized */ static status_t getMinFrameCount(int* frameCount, int streamType =-1, uint32_t sampleRate = 0); /* Constructs an uninitialized AudioTrack. No connection with * AudioFlinger takes place. */ Loading media/libmedia/AudioTrack.cpp +29 −0 Original line number Diff line number Diff line Loading @@ -41,6 +41,35 @@ #define UNLIKELY( exp ) (__builtin_expect( (exp) != 0, false )) namespace android { // --------------------------------------------------------------------------- // static status_t AudioTrack::getMinFrameCount( int* frameCount, int streamType, uint32_t sampleRate) { int afSampleRate; if (AudioSystem::getOutputSamplingRate(&afSampleRate, streamType) != NO_ERROR) { return NO_INIT; } int afFrameCount; if (AudioSystem::getOutputFrameCount(&afFrameCount, streamType) != NO_ERROR) { return NO_INIT; } uint32_t afLatency; if (AudioSystem::getOutputLatency(&afLatency, streamType) != NO_ERROR) { return NO_INIT; } // Ensure that buffer depth covers at least audio hardware latency uint32_t minBufCount = afLatency / ((1000 * afFrameCount) / afSampleRate); if (minBufCount < 2) minBufCount = 2; *frameCount = (sampleRate == 0) ? afFrameCount * minBufCount : afFrameCount * minBufCount * sampleRate / afSampleRate; return NO_ERROR; } // --------------------------------------------------------------------------- Loading Loading
include/media/AudioTrack.h +11 −0 Original line number Diff line number Diff line Loading @@ -102,6 +102,17 @@ public: typedef void (*callback_t)(int event, void* user, void *info); /* Returns the minimum frame count required for the successful creation of * an AudioTrack object. * Returned status (from utils/Errors.h) can be: * - NO_ERROR: successful operation * - NO_INIT: audio server or audio hardware not initialized */ static status_t getMinFrameCount(int* frameCount, int streamType =-1, uint32_t sampleRate = 0); /* Constructs an uninitialized AudioTrack. No connection with * AudioFlinger takes place. */ Loading
media/libmedia/AudioTrack.cpp +29 −0 Original line number Diff line number Diff line Loading @@ -41,6 +41,35 @@ #define UNLIKELY( exp ) (__builtin_expect( (exp) != 0, false )) namespace android { // --------------------------------------------------------------------------- // static status_t AudioTrack::getMinFrameCount( int* frameCount, int streamType, uint32_t sampleRate) { int afSampleRate; if (AudioSystem::getOutputSamplingRate(&afSampleRate, streamType) != NO_ERROR) { return NO_INIT; } int afFrameCount; if (AudioSystem::getOutputFrameCount(&afFrameCount, streamType) != NO_ERROR) { return NO_INIT; } uint32_t afLatency; if (AudioSystem::getOutputLatency(&afLatency, streamType) != NO_ERROR) { return NO_INIT; } // Ensure that buffer depth covers at least audio hardware latency uint32_t minBufCount = afLatency / ((1000 * afFrameCount) / afSampleRate); if (minBufCount < 2) minBufCount = 2; *frameCount = (sampleRate == 0) ? afFrameCount * minBufCount : afFrameCount * minBufCount * sampleRate / afSampleRate; return NO_ERROR; } // --------------------------------------------------------------------------- Loading