summaryrefslogtreecommitdiffstats
path: root/include/media/AudioTrack.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/media/AudioTrack.h')
-rw-r--r--include/media/AudioTrack.h50
1 files changed, 27 insertions, 23 deletions
diff --git a/include/media/AudioTrack.h b/include/media/AudioTrack.h
index 3de0774..d9b7057 100644
--- a/include/media/AudioTrack.h
+++ b/include/media/AudioTrack.h
@@ -91,7 +91,7 @@ public:
void* raw;
short* i16; // signed 16-bit
int8_t* i8; // unsigned 8-bit, offset by 0x80
- }; // input: unused, output: pointer to buffer
+ }; // input to obtainBuffer(): unused, output: pointer to buffer
};
/* As a convenience, if a callback is supplied, a handler thread
@@ -125,6 +125,7 @@ public:
* - BAD_VALUE: unsupported configuration
* frameCount is guaranteed to be non-zero if status is NO_ERROR,
* and is undefined otherwise.
+ * FIXME This API assumes a route, and so should be deprecated.
*/
static status_t getMinFrameCount(size_t* frameCount,
@@ -136,7 +137,7 @@ public:
enum transfer_type {
TRANSFER_DEFAULT, // not specified explicitly; determine from the other parameters
TRANSFER_CALLBACK, // callback EVENT_MORE_DATA
- TRANSFER_OBTAIN, // FIXME deprecated: call obtainBuffer() and releaseBuffer()
+ TRANSFER_OBTAIN, // call obtainBuffer() and releaseBuffer()
TRANSFER_SYNC, // synchronous write()
TRANSFER_SHARED, // shared memory
};
@@ -149,9 +150,6 @@ public:
/* Creates an AudioTrack object and registers it with AudioFlinger.
* Once created, the track needs to be started before it can be used.
* Unspecified values are set to appropriate default values.
- * With this constructor, the track is configured for streaming mode.
- * Data to be rendered is supplied by write() or by the callback EVENT_MORE_DATA.
- * Intermixing a combination of write() and non-ignored EVENT_MORE_DATA is not allowed.
*
* Parameters:
*
@@ -169,20 +167,28 @@ public:
* configuration. Zero means to use a default value.
* flags: See comments on audio_output_flags_t in <system/audio.h>.
* cbf: Callback function. If not null, this function is called periodically
- * to provide new data and inform of marker, position updates, etc.
+ * to provide new data in TRANSFER_CALLBACK mode
+ * and inform of marker, position updates, etc.
* user: Context for use by the callback receiver.
* notificationFrames: The callback function is called each time notificationFrames PCM
* frames have been consumed from track input buffer.
* This is expressed in units of frames at the initial source sample rate.
* sessionId: Specific session ID, or zero to use default.
* transferType: How data is transferred to AudioTrack.
+ * offloadInfo: If not NULL, provides offload parameters for
+ * AudioSystem::getOutputForAttr().
+ * uid: User ID of the app which initially requested this AudioTrack
+ * for power management tracking, or -1 for current user ID.
+ * pid: Process ID of the app which initially requested this AudioTrack
+ * for power management tracking, or -1 for current process ID.
+ * pAttributes: If not NULL, supersedes streamType for use case selection.
* threadCanCallJava: Not present in parameter list, and so is fixed at false.
*/
AudioTrack( audio_stream_type_t streamType,
uint32_t sampleRate,
audio_format_t format,
- audio_channel_mask_t,
+ audio_channel_mask_t channelMask,
size_t frameCount = 0,
audio_output_flags_t flags = AUDIO_OUTPUT_FLAG_NONE,
callback_t cbf = NULL,
@@ -198,7 +204,9 @@ public:
/* Creates an audio track and registers it with AudioFlinger.
* With this constructor, the track is configured for static buffer mode.
* Data to be rendered is passed in a shared memory buffer
- * identified by the argument sharedBuffer, which must be non-0.
+ * identified by the argument sharedBuffer, which should be non-0.
+ * If sharedBuffer is zero, this constructor is equivalent to the previous constructor
+ * but without the ability to specify a non-zero value for the frameCount parameter.
* The memory should be initialized to the desired data before calling start().
* The write() method is not supported in this case.
* It is recommended to pass a callback function to be notified of playback end by an
@@ -230,6 +238,7 @@ public:
/* Initialize an AudioTrack that was created using the AudioTrack() constructor.
* Don't call set() more than once, or after the AudioTrack() constructors that take parameters.
+ * set() is not multi-thread safe.
* Returned status (from utils/Errors.h) can be:
* - NO_ERROR: successful initialization
* - INVALID_OPERATION: AudioTrack is already initialized
@@ -464,7 +473,9 @@ public:
* handle on audio hardware output, or AUDIO_IO_HANDLE_NONE if the
* track needed to be re-created but that failed
*/
+private:
audio_io_handle_t getOutput() const;
+public:
/* Returns the unique session ID associated with this track.
*
@@ -511,9 +522,6 @@ public:
* or return WOULD_BLOCK depending on the value of the "waitCount"
* parameter.
*
- * obtainBuffer() and releaseBuffer() are deprecated for direct use by applications,
- * which should use write() or callback EVENT_MORE_DATA instead.
- *
* Interpretation of waitCount:
* +n limits wait time to n * WAIT_PERIOD_MS,
* -1 causes an (almost) infinite wait time,
@@ -533,10 +541,8 @@ public:
* size actual number of bytes available
* raw pointer to the buffer
*/
- /* FIXME Deprecated public API for TRANSFER_OBTAIN mode */
status_t obtainBuffer(Buffer* audioBuffer, int32_t waitCount,
- size_t *nonContig = NULL)
- __attribute__((__deprecated__));
+ size_t *nonContig = NULL);
private:
/* If nonContig is non-NULL, it is an output parameter that will be set to the number of
@@ -559,9 +565,7 @@ public:
* frameCount currently ignored but recommend to set to actual number of frames filled
* size actual number of bytes filled, must be multiple of frameSize
* raw ignored
- *
*/
- // FIXME make private when obtainBuffer() for TRANSFER_OBTAIN is removed
void releaseBuffer(const Buffer* audioBuffer);
/* As a convenience we provide a write() interface to the audio buffer.
@@ -574,7 +578,7 @@ public:
* WOULD_BLOCK when obtainBuffer() returns same, or
* AudioTrack was stopped during the write
* or any other error code returned by IAudioTrack::start() or restoreTrack_l().
- * Default behavior is to only return until all data has been transferred. Set 'blocking' to
+ * Default behavior is to only return when all data has been transferred. Set 'blocking' to
* false for the method to return immediately without waiting to try multiple times to write
* the full content of the buffer.
*/
@@ -582,6 +586,7 @@ public:
/*
* Dumps the state of an audio track.
+ * Not a general-purpose API; intended only for use by media player service to dump its tracks.
*/
status_t dump(int fd, const Vector<String16>& args) const;
@@ -623,8 +628,6 @@ protected:
AudioTrack(const AudioTrack& other);
AudioTrack& operator = (const AudioTrack& other);
- void setAttributesFromStreamType(audio_stream_type_t streamType);
-
/* a small internal class to handle the callback */
class AudioTrackThread : public Thread
{
@@ -667,10 +670,6 @@ protected:
static const nsecs_t NS_WHENEVER = -1, NS_INACTIVE = -2, NS_NEVER = -3;
nsecs_t processAudioBuffer();
- bool isOffloaded() const;
- bool isDirect() const;
- bool isOffloadedOrDirect() const;
-
// caller must hold lock on mLock for all _l methods
status_t createTrack_l();
@@ -683,6 +682,10 @@ protected:
// FIXME enum is faster than strcmp() for parameter 'from'
status_t restoreTrack_l(const char *from);
+ bool isOffloaded() const;
+ bool isDirect() const;
+ bool isOffloadedOrDirect() const;
+
bool isOffloaded_l() const
{ return (mFlags & AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD) != 0; }
@@ -773,6 +776,7 @@ protected:
bool mMarkerReached;
uint32_t mNewPosition; // in frames
uint32_t mUpdatePeriod; // in frames, zero means no EVENT_NEW_POS
+
uint32_t mServer; // in frames, last known mProxy->getPosition()
// which is count of frames consumed by server,
// reset by new IAudioTrack,