Skip to content
This repository has been archived by the owner on Jul 30, 2022. It is now read-only.

Commit

Permalink
Add new API for plugin audio track latency.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
drWulf committed Oct 12, 2010
1 parent a39c13e commit 49bf866
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
2 changes: 2 additions & 0 deletions WebCore/plugins/android/PluginViewAndroid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -115,6 +116,7 @@ struct VarProcPair {

static const VarProcPair gVarProcs[] = {
{ VARPROCLINE(AudioTrackInterfaceV0) },
{ VARPROCLINE(AudioTrackInterfaceV1) },
{ VARPROCLINE(BitmapInterfaceV0) },
{ VARPROCLINE(CanvasInterfaceV0) },
{ VARPROCLINE(EventInterfaceV0) },
Expand Down
12 changes: 12 additions & 0 deletions WebKit/android/plugins/ANPSoundInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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<ANPAudioTrackInterfaceV1*>(value);
si->trackLatency = ANPTrackLatency;
}
7 changes: 7 additions & 0 deletions WebKit/android/plugins/android_npapi.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 49bf866

Please sign in to comment.