diff options
author | Glenn Kasten <gkasten@google.com> | 2013-08-29 16:54:05 -0700 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2013-08-29 16:54:05 -0700 |
commit | 6dc365f0d5a92084517f0c3846e4f07fc7206bab (patch) | |
tree | 5ff7dd98941a347ebfb4ee0f91eae2b73b712082 /include/media | |
parent | 1fe2385623d880264c79eef6a4c6e4e75d91d19b (diff) | |
parent | 73e4f3d44f7022b03943ae34f08363e049e4b46f (diff) | |
download | frameworks_av-6dc365f0d5a92084517f0c3846e4f07fc7206bab.zip frameworks_av-6dc365f0d5a92084517f0c3846e4f07fc7206bab.tar.gz frameworks_av-6dc365f0d5a92084517f0c3846e4f07fc7206bab.tar.bz2 |
am 73e4f3d4: am 865f6f24: Merge "New AudioTrack C++ API for audio timestamps" into klp-dev
* commit '73e4f3d44f7022b03943ae34f08363e049e4b46f':
New AudioTrack C++ API for audio timestamps
Diffstat (limited to 'include/media')
-rw-r--r-- | include/media/AudioTimestamp.h | 33 | ||||
-rw-r--r-- | include/media/AudioTrack.h | 16 |
2 files changed, 49 insertions, 0 deletions
diff --git a/include/media/AudioTimestamp.h b/include/media/AudioTimestamp.h new file mode 100644 index 0000000..c29c7e5 --- /dev/null +++ b/include/media/AudioTimestamp.h @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2013 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. + */ + +#ifndef ANDROID_AUDIO_TIMESTAMP_H +#define ANDROID_AUDIO_TIMESTAMP_H + +#include <time.h> + +class AudioTimestamp { +public: + AudioTimestamp() : mPosition(0) { + mTime.tv_sec = 0; + mTime.tv_nsec = 0; + } + // FIXME change type to match android.media.AudioTrack + uint32_t mPosition; // a frame position in AudioTrack::getPosition() units + struct timespec mTime; // corresponding CLOCK_MONOTONIC when frame is expected to present +}; + +#endif // ANDROID_AUDIO_TIMESTAMP_H diff --git a/include/media/AudioTrack.h b/include/media/AudioTrack.h index d67d5c4..d5e0981 100644 --- a/include/media/AudioTrack.h +++ b/include/media/AudioTrack.h @@ -19,6 +19,7 @@ #include <cutils/sched_policy.h> #include <media/AudioSystem.h> +#include <media/AudioTimestamp.h> #include <media/IAudioTrack.h> #include <utils/threads.h> @@ -62,6 +63,9 @@ public: // voluntary invalidation by mediaserver, or mediaserver crash. EVENT_STREAM_END = 7, // Sent after all the buffers queued in AF and HW are played // back (after stop is called) + EVENT_NEW_TIMESTAMP = 8, // Delivered periodically and when there's a significant change + // in the mapping from frame position to presentation time. + // See AudioTimestamp for the information included with event. }; /* Client should declare Buffer on the stack and pass address to obtainBuffer() @@ -107,6 +111,8 @@ public: * - EVENT_NEW_POS: pointer to const uint32_t containing the new position in frames. * - EVENT_BUFFER_END: unused. * - EVENT_NEW_IAUDIOTRACK: unused. + * - EVENT_STREAM_END: unused. + * - EVENT_NEW_TIMESTAMP: pointer to const AudioTimestamp. */ typedef void (*callback_t)(int event, void* user, void *info); @@ -564,6 +570,16 @@ public: /* Get parameters */ String8 getParameters(const String8& keys); + /* Poll for a timestamp on demand. + * Use if EVENT_NEW_TIMESTAMP is not delivered often enough for your needs, + * or if you need to get the most recent timestamp outside of the event callback handler. + * Caution: calling this method too often may be inefficient; + * if you need a high resolution mapping between frame position and presentation time, + * consider implementing that at application level, based on the low resolution timestamps. + * Returns NO_ERROR if timestamp is valid. + */ + status_t getTimestamp(AudioTimestamp& timestamp); + protected: /* copying audio tracks is not allowed */ AudioTrack(const AudioTrack& other); |