From ce70374bf105f8a6160bf5dd70affea012b2a464 Mon Sep 17 00:00:00 2001 From: Glenn Kasten Date: Fri, 19 Jul 2013 16:33:58 -0700 Subject: New AudioTrack C++ API for audio timestamps This new API is intended to replace latency(), especially for A/V sync. The application will receive periodic timestamp notifications. The period is unspecified, but will likely be more frequent after a pause or stop, set position, underrun, display on/off change, route change, or when audio framework notices drift. It will be up to the higher level application (e.g. Stagefright) to reconstruct a clock that updates more frequently. The current latency() method doesn't indicate when latency changes due to screen on/off state, route changes, etc. Includes squahsed change-Id: I2082f8752040be0c234b1a6f1be2e269abf2ce7c Dummy implementation of AudioTrack:getTimestamp() Rename AudioTrack::Timestamp to AudioTimestamp. Renaming and pulling up to a higher level allows more modules to use it. Change-Id: Ibf7f6a207c3f8d8697f25ede2cd5200697fadb86 (cherry picked from commit dd69eb893867634fd169c03204a6ad7c74b351e7) --- include/media/AudioTimestamp.h | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 include/media/AudioTimestamp.h (limited to 'include/media/AudioTimestamp.h') 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 + +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 -- cgit v1.1