[Webkit-unassigned] [Bug 51424] Add WebKitClient::createAudioDevice() for Chromium port of web audio API

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Tue Dec 21 15:46:24 PST 2010


https://bugs.webkit.org/show_bug.cgi?id=51424


Darin Fisher (:fishd, Google) <fishd at chromium.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  Attachment #77154|review?                     |review-
               Flag|                            |




--- Comment #5 from Darin Fisher (:fishd, Google) <fishd at chromium.org>  2010-12-21 15:46:24 PST ---
(From update of attachment 77154)
View in context: https://bugs.webkit.org/attachment.cgi?id=77154&action=review

> WebKit/chromium/public/WebAudioDevice.h:45
> +    typedef void (*RenderCallback)(std::vector<float*>& audioData, size_t numberOfFrames, void* userData);

note: we do not use STL types in the WebKit API.  please use WebVector, or just use a raw float* here.  do you need the callee to allocate the audioData buffer, or will it be preallocated to the maximum size by the caller?  if it will be preallocated, then passing a raw float* would seem fine.

> WebKit/chromium/public/WebKitClient.h:282
> +    // Audio --------------------------------------------------------------
> +    virtual WebAudioDevice* createAudioDevice(size_t bufferSize, unsigned numberOfChannels, double sampleRate, WebAudioDevice::RenderCallback, void* userData) { return 0; }

nit: add a new line below the section header.

The C++ way of passing user data to a function pointer is to define an interface
that folks can subclass.  Why not do that here?

class WebAudioRenderCallback {
public:
    virtual void renderFrames(float* audioData, size_t numberOfFrames) = 0;
protected:
    virtual ~WebAudioRenderCallback() {}
};

or you could also do this as an inner class:

class WebAudioDevice {
public:
    class RenderCallback {
    public:
        ...
    };
};

however the downside to it being an inner class is that you force WebKitClient.h
to also #include WebAudioDevice.h.  it would be nice to avoid that.

> WebKit/chromium/src/AudioDestinationChromium.cpp:40
> +using namespace std;

please avoid using the "std" namespace for container types in webkit code.

> WebKit/chromium/src/AudioDestinationChromium.cpp:41
> +using WebKit::webKitClient;

it is more commonplace to just do "using namespace WebKit" in WebKit code.

> WebKit/chromium/src/AudioDestinationChromium.cpp:102
> +void AudioDestinationChromium::renderDispatch(vector<float*>& audioData, size_t numberOfFrames, void* userData)

if you define an interface for the render callback function, then you would
not need to implement this thunk function yourself.

-- 
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.



More information about the webkit-unassigned mailing list