From 49bf866973cb3b2a6c74c0eab864e9562e4cbab1 Mon Sep 17 00:00:00 2001 From: Derek Sollenberger Date: Tue, 12 Oct 2010 13:31:25 -0400 Subject: [PATCH] Add new API for plugin audio track latency. This CL extends the existing udio API with a new function to measure the latency of a audio track. To preserve binary compatibility with the already released v0 API we have created a v1 extension. Change-Id: I656ac10470f2262bac7039aa45458d2100a37612 http://b/3088633 --- WebCore/plugins/android/PluginViewAndroid.cpp | 2 ++ WebKit/android/plugins/ANPSoundInterface.cpp | 12 ++++++++++++ WebKit/android/plugins/android_npapi.h | 7 +++++++ 3 files changed, 21 insertions(+) diff --git a/WebCore/plugins/android/PluginViewAndroid.cpp b/WebCore/plugins/android/PluginViewAndroid.cpp index cb069bc94..f0890ae9c 100644 --- a/WebCore/plugins/android/PluginViewAndroid.cpp +++ b/WebCore/plugins/android/PluginViewAndroid.cpp @@ -91,6 +91,7 @@ /////////////////////////////////////////////////////////////////////////////// extern void ANPAudioTrackInterfaceV0_Init(ANPInterface* value); +extern void ANPAudioTrackInterfaceV1_Init(ANPInterface* value); extern void ANPBitmapInterfaceV0_Init(ANPInterface* value); extern void ANPCanvasInterfaceV0_Init(ANPInterface* value); extern void ANPEventInterfaceV0_Init(ANPInterface* value); @@ -115,6 +116,7 @@ struct VarProcPair { static const VarProcPair gVarProcs[] = { { VARPROCLINE(AudioTrackInterfaceV0) }, + { VARPROCLINE(AudioTrackInterfaceV1) }, { VARPROCLINE(BitmapInterfaceV0) }, { VARPROCLINE(CanvasInterfaceV0) }, { VARPROCLINE(EventInterfaceV0) }, diff --git a/WebKit/android/plugins/ANPSoundInterface.cpp b/WebKit/android/plugins/ANPSoundInterface.cpp index 8e31d6955..91778e31c 100644 --- a/WebKit/android/plugins/ANPSoundInterface.cpp +++ b/WebKit/android/plugins/ANPSoundInterface.cpp @@ -136,6 +136,10 @@ static bool ANPTrackIsStopped(ANPAudioTrack* track) { return track->mTrack->stopped(); } +static uint32_t ANPTrackLatency(ANPAudioTrack* track) { + return track->mTrack->latency(); +} + /////////////////////////////////////////////////////////////////////////////// void ANPAudioTrackInterfaceV0_Init(ANPInterface* value) { @@ -147,3 +151,11 @@ void ANPAudioTrackInterfaceV0_Init(ANPInterface* value) { si->stop = ANPTrackStop; si->isStopped = ANPTrackIsStopped; } + +void ANPAudioTrackInterfaceV1_Init(ANPInterface* value) { + // initialize the functions from the previous interface + ANPAudioTrackInterfaceV0_Init(value); + // add any new functions or override existing functions + ANPAudioTrackInterfaceV1* si = reinterpret_cast(value); + si->trackLatency = ANPTrackLatency; +} diff --git a/WebKit/android/plugins/android_npapi.h b/WebKit/android/plugins/android_npapi.h index 25cee97b5..87ca8ccba 100644 --- a/WebKit/android/plugins/android_npapi.h +++ b/WebKit/android/plugins/android_npapi.h @@ -120,6 +120,8 @@ typedef uint32_t ANPMatrixFlag; #define kSystemInterfaceV0_ANPGetValue ((NPNVariable)1010) #define kEventInterfaceV0_ANPGetValue ((NPNVariable)1011) +#define kAudioTrackInterfaceV1_ANPGetValue ((NPNVariable)1012) + /** queries for the drawing models supported on this device. NPN_GetValue(inst, kSupportedDrawingModel_ANPGetValue, uint32_t* bits) @@ -762,6 +764,11 @@ struct ANPAudioTrackInterfaceV0 : ANPInterface { bool (*isStopped)(ANPAudioTrack*); }; +struct ANPAudioTrackInterfaceV1 : ANPAudioTrackInterfaceV0 { + /** Returns the track's latency in milliseconds. */ + uint32_t (*trackLatency)(ANPAudioTrack*); +}; + /////////////////////////////////////////////////////////////////////////////// // DEFINITION OF VALUES PASSED THROUGH NPP_HandleEvent