Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Side by Side Diff: third_party/grpc/src/core/iomgr/exec_ctx.c

Issue 1932353002: Initial checkin of gRPC to third_party/ Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/grpc/src/core/iomgr/exec_ctx.h ('k') | third_party/grpc/src/core/iomgr/executor.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010 Google Inc. All rights reserved. 2 *
3 * Copyright 2015-2016, Google Inc.
4 * All rights reserved.
3 * 5 *
4 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 7 * modification, are permitted provided that the following conditions are
6 * met: 8 * met:
7 * 9 *
8 * * Redistributions of source code must retain the above copyright 10 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 12 * * Redistributions in binary form must reproduce the above
11 * copyright notice, this list of conditions and the following disclaimer 13 * copyright notice, this list of conditions and the following disclaimer
12 * in the documentation and/or other materials provided with the 14 * in the documentation and/or other materials provided with the
13 * distribution. 15 * distribution.
14 * * Neither the name of Google Inc. nor the names of its 16 * * Neither the name of Google Inc. nor the names of its
15 * contributors may be used to endorse or promote products derived from 17 * contributors may be used to endorse or promote products derived from
16 * this software without specific prior written permission. 18 * this software without specific prior written permission.
17 * 19 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 *
29 */ 32 */
30 33
31 #ifndef AudioDSPKernel_h 34 #include "src/core/iomgr/exec_ctx.h"
32 #define AudioDSPKernel_h
33 35
34 #include "platform/audio/AudioDSPKernelProcessor.h" 36 #include <grpc/support/log.h>
35 #include "wtf/Allocator.h"
36 37
37 namespace blink { 38 #include "src/core/profiling/timers.h"
38 39
39 // AudioDSPKernel does the processing for one channel of an AudioDSPKernelProces sor. 40 bool grpc_exec_ctx_flush(grpc_exec_ctx *exec_ctx) {
41 bool did_something = 0;
42 GPR_TIMER_BEGIN("grpc_exec_ctx_flush", 0);
43 while (!grpc_closure_list_empty(exec_ctx->closure_list)) {
44 grpc_closure *c = exec_ctx->closure_list.head;
45 exec_ctx->closure_list.head = exec_ctx->closure_list.tail = NULL;
46 while (c != NULL) {
47 bool success = (bool)(c->final_data & 1);
48 grpc_closure *next = (grpc_closure *)(c->final_data & ~(uintptr_t)1);
49 did_something = true;
50 GPR_TIMER_BEGIN("grpc_exec_ctx_flush.cb", 0);
51 c->cb(exec_ctx, c->cb_arg, success);
52 GPR_TIMER_END("grpc_exec_ctx_flush.cb", 0);
53 c = next;
54 }
55 }
56 GPR_TIMER_END("grpc_exec_ctx_flush", 0);
57 return did_something;
58 }
40 59
41 class PLATFORM_EXPORT AudioDSPKernel { 60 void grpc_exec_ctx_finish(grpc_exec_ctx *exec_ctx) {
42 USING_FAST_MALLOC(AudioDSPKernel); 61 grpc_exec_ctx_flush(exec_ctx);
43 public: 62 }
44 AudioDSPKernel(AudioDSPKernelProcessor* kernelProcessor)
45 : m_kernelProcessor(kernelProcessor)
46 , m_sampleRate(kernelProcessor->sampleRate())
47 {
48 }
49 63
50 AudioDSPKernel(float sampleRate) 64 void grpc_exec_ctx_enqueue(grpc_exec_ctx *exec_ctx, grpc_closure *closure,
51 : m_kernelProcessor(nullptr) 65 bool success,
52 , m_sampleRate(sampleRate) 66 grpc_workqueue *offload_target_or_null) {
53 { 67 GPR_ASSERT(offload_target_or_null == NULL);
54 } 68 grpc_closure_list_add(&exec_ctx->closure_list, closure, success);
69 }
55 70
56 virtual ~AudioDSPKernel(); 71 void grpc_exec_ctx_enqueue_list(grpc_exec_ctx *exec_ctx,
57 72 grpc_closure_list *list,
58 // Subclasses must override process() to do the processing and reset() to re set DSP state. 73 grpc_workqueue *offload_target_or_null) {
59 virtual void process(const float* source, float* destination, size_t framesT oProcess) = 0; 74 GPR_ASSERT(offload_target_or_null == NULL);
60 virtual void reset() = 0; 75 grpc_closure_list_move(list, &exec_ctx->closure_list);
61 76 }
62 float sampleRate() const { return m_sampleRate; }
63 double nyquist() const { return 0.5 * sampleRate(); }
64
65 AudioDSPKernelProcessor* processor() { return m_kernelProcessor; }
66 const AudioDSPKernelProcessor* processor() const { return m_kernelProcessor; }
67
68 virtual double tailTime() const = 0;
69 virtual double latencyTime() const = 0;
70
71 protected:
72 // This raw pointer is safe because the AudioDSPKernelProcessor object is
73 // guaranteed to be kept alive while the AudioDSPKernel object is alive.
74 AudioDSPKernelProcessor* m_kernelProcessor;
75 float m_sampleRate;
76 };
77
78 } // namespace blink
79
80 #endif // AudioDSPKernel_h
OLDNEW
« no previous file with comments | « third_party/grpc/src/core/iomgr/exec_ctx.h ('k') | third_party/grpc/src/core/iomgr/executor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698