OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 16 matching lines...) Expand all Loading... |
27 */ | 27 */ |
28 | 28 |
29 #ifndef WebAudioDevice_h | 29 #ifndef WebAudioDevice_h |
30 #define WebAudioDevice_h | 30 #define WebAudioDevice_h |
31 | 31 |
32 #include "WebCommon.h" | 32 #include "WebCommon.h" |
33 #include "WebVector.h" | 33 #include "WebVector.h" |
34 | 34 |
35 namespace blink { | 35 namespace blink { |
36 | 36 |
| 37 // Representation of device audio stream position. |
| 38 |
| 39 struct BLINK_PLATFORM_EXPORT WebAudioTimestamp { |
| 40 WebAudioTimestamp() = default; |
| 41 WebAudioTimestamp(size_t frames, double seconds) |
| 42 : frames(frames), seconds(seconds) {} |
| 43 size_t frames; |
| 44 double seconds; |
| 45 }; |
| 46 |
37 // Abstract interface to the Chromium audio system. | 47 // Abstract interface to the Chromium audio system. |
38 | 48 |
39 class WebAudioDevice { | 49 class WebAudioDevice { |
40 public: | 50 public: |
41 class BLINK_PLATFORM_EXPORT RenderCallback { | 51 class BLINK_PLATFORM_EXPORT RenderCallback { |
42 public: | 52 public: |
43 virtual void render(const WebVector<float*>& sourceData, const WebVector
<float*>& destinationData, size_t numberOfFrames); | 53 virtual void render(const WebVector<float*>& sourceData, const WebVector
<float*>& destinationData, size_t numberOfFrames); |
| 54 // An alternate version which provides also a current audio timestamp fo
r the device, default implementation just invokes the above method. |
| 55 virtual void render(const WebVector<float*>& sourceData, const WebVector
<float*>& destinationData, size_t numberOfFrames, const WebAudioTimestamp&); |
44 | 56 |
45 protected: | 57 protected: |
46 virtual ~RenderCallback(); | 58 virtual ~RenderCallback(); |
47 }; | 59 }; |
48 | 60 |
49 virtual ~WebAudioDevice() { } | 61 virtual ~WebAudioDevice() { } |
50 | 62 |
51 virtual void start() = 0; | 63 virtual void start() = 0; |
52 virtual void stop() = 0; | 64 virtual void stop() = 0; |
53 virtual double sampleRate() = 0; | 65 virtual double sampleRate() = 0; |
54 }; | 66 }; |
55 | 67 |
56 } // namespace blink | 68 } // namespace blink |
57 | 69 |
58 #endif // WebAudioDevice_h | 70 #endif // WebAudioDevice_h |
OLD | NEW |