MCPcopy
hub / github.com/ebitengine/oto / newWASAPIContext

Function newWASAPIContext

driver_wasapi_windows.go:102–133  ·  view source on GitHub ↗
(sampleRate, channelCount int, mux *mux.Mux, bufferSizeInBytes int)

Source from the content-addressed store, hash-verified

100)
101
102func newWASAPIContext(sampleRate, channelCount int, mux *mux.Mux, bufferSizeInBytes int) (context *wasapiContext, ferr error) {
103 t, err := newCOMThread()
104 if err != nil {
105 return nil, err
106 }
107
108 c := &wasapiContext{
109 sampleRate: sampleRate,
110 channelCount: channelCount,
111 mux: mux,
112 bufferSizeInBytes: bufferSizeInBytes,
113 comThread: t,
114 suspendedCond: sync.NewCond(&sync.Mutex{}),
115 }
116
117 ev, err := windows.CreateEventEx(nil, nil, 0, windows.EVENT_ALL_ACCESS)
118 if err != nil {
119 return nil, err
120 }
121 defer func() {
122 if ferr != nil {
123 windows.CloseHandle(ev)
124 }
125 }()
126 c.sampleReadyEvent = ev
127
128 if err := c.start(); err != nil {
129 return nil, err
130 }
131
132 return c, nil
133}
134
135func (c *wasapiContext) isDeviceSwitched() (bool, error) {
136 // If the audio is suspended, do nothing.

Callers 1

newContextFunction · 0.85

Calls 2

startMethod · 0.95
newCOMThreadFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…