Bug 215591

Summary: AudioContext.getOutputTimestamp() is missing
Product: WebKit Reporter: Chris Dumez <cdumez>
Component: Web AudioAssignee: Chris Dumez <cdumez>
Status: RESOLVED FIXED    
Severity: Normal CC: annulen, benjamin, calvaris, clark_wang, cmarcelo, darin, eric.carlson, esprehn+autocc, ews-watchlist, ggaren, glenn, gyuyoung.kim, jer.noble, kondapallykalyan, philipj, pnormand, ryuan.choi, sergio, vjaquez, webkit-bug-importer, youennf
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
URL: https://www.w3.org/TR/webaudio/#dom-audiocontext-getoutputtimestamp
Bug Depends on:    
Bug Blocks: 212611    
Attachments:
Description Flags
Patch
none
Patch
none
Patch
none
Patch
none
Patch none

Chris Dumez
Reported 2020-08-17 16:05:50 PDT
AudioContext.getOutputTimestamp() is missing: - https://www.w3.org/TR/webaudio/#dom-audiocontext-getoutputtimestamp
Attachments
Patch (37.63 KB, patch)
2020-08-17 16:10 PDT, Chris Dumez
no flags
Patch (38.33 KB, patch)
2020-08-17 16:20 PDT, Chris Dumez
no flags
Patch (39.73 KB, patch)
2020-08-17 17:49 PDT, Chris Dumez
no flags
Patch (39.76 KB, patch)
2020-08-17 17:52 PDT, Chris Dumez
no flags
Patch (39.78 KB, patch)
2020-08-17 18:06 PDT, Chris Dumez
no flags
Chris Dumez
Comment 1 2020-08-17 16:10:57 PDT
Chris Dumez
Comment 2 2020-08-17 16:20:49 PDT
Darin Adler
Comment 3 2020-08-17 17:28:58 PDT
Comment on attachment 406753 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=406753&action=review > Source/WebCore/Modules/webaudio/AudioContext.cpp:105 > + return AudioTimestamp { 0, 0 }; Should not need to write the class name here. > Source/WebCore/Modules/webaudio/AudioContext.cpp:114 > + if (position.position.seconds() > currentTime()) > + position.position = Seconds { currentTime() }; We often write this kind of clamping using std::max instead of an if statement. > Source/WebCore/Modules/webaudio/AudioContext.cpp:118 > + if (performanceTime < 0.0) > + performanceTime = 0.0; We often write this kind of clamping using std::max instead of an if statement. > Source/WebCore/Modules/webaudio/AudioContext.cpp:120 > + return AudioTimestamp { position.position.seconds(), performanceTime }; Should not need to write the class name here. > Source/WebCore/Modules/webaudio/AudioContext.h:33 > +struct AudioTimestamp; Typically the struct paragraph is separate and below the class paragraph. > Source/WebCore/Modules/webaudio/BaseAudioContext.cpp:771 > + AutoLocker locker(*this); > + return m_outputPosition; The locking here doesn’t prevent races, but I suppose it prevents undefined behavior or getting mismatched structure values. > Source/WebCore/platform/audio/AudioIOCallback.h:30 > #ifndef AudioIOCallback_h > #define AudioIOCallback_h #pragma once > Source/WebCore/platform/audio/AudioIOCallback.h:53 > + static WARN_UNUSED_RETURN bool decode(Decoder& decoder, AudioIOPosition& result) I think we want the version that returns Optional rather than the version that returns bool. > Source/WebCore/platform/audio/cocoa/AudioDestinationCocoa.cpp:161 > +static MonotonicTime machAbsoluteTimeToMonotonicTime(uint64_t machAbsoluteTime) > +{ > + // Based on listing #2 from Apple QA 1398, but modified to be thread-safe. > + static mach_timebase_info_data_t timebaseInfo; > + static std::once_flag initializeTimerOnceFlag; > + std::call_once(initializeTimerOnceFlag, [] { > + kern_return_t kr = mach_timebase_info(&timebaseInfo); > + ASSERT_UNUSED(kr, kr == KERN_SUCCESS); > + ASSERT(timebaseInfo.denom); > + }); > + > + return MonotonicTime::fromRawSeconds((machAbsoluteTime * timebaseInfo.numer) / (1.0e9 * timebaseInfo.denom)); > +} This seems like a peculiar place for this function, which doesn’t seem to be specific to audio, just to Cocoa. Should we put this alongside the MonotonicTime class instead? > Source/WebCore/platform/audio/cocoa/AudioDestinationCocoa.h:70 > + OSStatus render(const AudioTimeStamp* timestamp, UInt32 numberOfFrames, AudioBufferList* ioData); No need for the argument name "timestamp" here.
Chris Dumez
Comment 4 2020-08-17 17:49:26 PDT
Chris Dumez
Comment 5 2020-08-17 17:52:12 PDT
Chris Dumez
Comment 6 2020-08-17 18:06:46 PDT
EWS
Comment 7 2020-08-17 19:16:18 PDT
Committed r265797: <https://trac.webkit.org/changeset/265797> All reviewed patches have been landed. Closing bug and clearing flags on attachment 406761 [details].
Radar WebKit Bug Importer
Comment 8 2020-08-17 19:17:15 PDT
Chris Dumez
Comment 9 2020-08-18 09:32:20 PDT
Follow-up landed in <https://trac.webkit.org/changeset/265819> to address fast/mediastream/getUserMedia-webaudio.html test failure.
Note You need to log in before you can comment on or make changes to this bug.