Bug 167656 - [Mac] Update CARingBuffer class
Summary: [Mac] Update CARingBuffer class
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Media (show other bugs)
Version: Other
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Eric Carlson
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2017-01-31 11:47 PST by Eric Carlson
Modified: 2017-02-01 17:50 PST (History)
5 users (show)

See Also:


Attachments
Proposed patch (6.62 KB, patch)
2017-01-31 12:48 PST, Eric Carlson
no flags Details | Formatted Diff | Diff
Updated patch, with API test. (45.00 KB, patch)
2017-02-01 15:13 PST, Eric Carlson
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Eric Carlson 2017-01-31 11:47:20 PST
Update class to be able to copy or mix input, and to allocate storage from the information in a stream description.
Comment 1 Eric Carlson 2017-01-31 12:48:45 PST
Created attachment 300248 [details]
Proposed patch
Comment 2 WebKit Commit Bot 2017-01-31 12:51:16 PST
Attachment 300248 [details] did not pass style-queue:


ERROR: Source/WebCore/platform/audio/mac/CARingBuffer.h:58:  The parameter name "mode" adds no information, so it should be removed.  [readability/parameter_name] [5]
Total errors found: 1 in 3 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 3 Jer Noble 2017-01-31 14:17:22 PST
Comment on attachment 300248 [details]
Proposed patch

View in context: https://bugs.webkit.org/attachment.cgi?id=300248&action=review

> Source/WebCore/platform/audio/mac/CARingBuffer.cpp:140
> +        case CARingBuffer::Mix:
> +            float* destination = static_cast<float*>(dest->mData);
> +            vadd(destination, 1, reinterpret_cast<float*>(*buffers + srcOffset), 1, destination, 1, std::min<size_t>(nbytes, dest->mDataByteSize - destOffset));
> +            break;

This doesn't feel right. A float is not the same size as a byte, so I feel like this is going to overrun outside the bounds of the passed in list. (Well, the std::min will keep that from happening, but it'll still not behave correctly.)

> Source/WebCore/platform/audio/mac/CARingBuffer.cpp:163
> +    ZeroRange(static_cast<Byte**>(m_buffers->data()), m_channelCount, 0, m_capacityBytes);

You shouldn't have to zero anything here. Rather, just update the bounds below.

> Source/WebCore/platform/audio/mac/CARingBuffer.cpp:184
> +    uint64_t start, end;
> +    getCurrentFrameBounds(start, end);
> +    if (start == end)
> +        setCurrentFrameBounds(startFrame, startFrame);
> +

What's this for?
Comment 4 Eric Carlson 2017-02-01 15:12:40 PST
Comment on attachment 300248 [details]
Proposed patch

View in context: https://bugs.webkit.org/attachment.cgi?id=300248&action=review

>> Source/WebCore/platform/audio/mac/CARingBuffer.cpp:140
>> +            break;
> 
> This doesn't feel right. A float is not the same size as a byte, so I feel like this is going to overrun outside the bounds of the passed in list. (Well, the std::min will keep that from happening, but it'll still not behave correctly.)

Good point. While we the upcoming patches only use it with floats, we might as well support other the formats.

>> Source/WebCore/platform/audio/mac/CARingBuffer.cpp:163
>> +    ZeroRange(static_cast<Byte**>(m_buffers->data()), m_channelCount, 0, m_capacityBytes);
> 
> You shouldn't have to zero anything here. Rather, just update the bounds below.

Fixed.

>> Source/WebCore/platform/audio/mac/CARingBuffer.cpp:184
>> +
> 
> What's this for?

Oops, leftover testing.
Comment 5 Eric Carlson 2017-02-01 15:13:29 PST
Created attachment 300359 [details]
Updated patch, with API test.
Comment 6 WebKit Commit Bot 2017-02-01 15:16:36 PST
Attachment 300359 [details] did not pass style-queue:


ERROR: Source/WebCore/platform/audio/mac/CARingBuffer.h:59:  The parameter name "mode" adds no information, so it should be removed.  [readability/parameter_name] [5]
Total errors found: 1 in 14 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 7 Jer Noble 2017-02-01 15:20:08 PST
Comment on attachment 300359 [details]
Updated patch, with API test.

View in context: https://bugs.webkit.org/attachment.cgi?id=300359&action=review

r=me, with nit

> LayoutTests/webaudio/mediastreamaudiosourcenode.html:32
> -                stream.getAudioTracks()[0].stop();
> +//                stream.getAudioTracks()[0].stop();

We probably still need this. :)
Comment 8 Eric Carlson 2017-02-01 15:51:59 PST
Committed r211539 and r211540: https://trac.webkit.org/r211539, https://trac.webkit.org/r211540
Comment 9 Radar WebKit Bug Importer 2017-02-01 15:53:25 PST
<rdar://problem/30318329>
Comment 10 Eric Carlson 2017-02-01 17:50:39 PST
Plus https://trac.webkit.org/r211545 to fix the 32-bit build.