(sampleRate, channelCount int, mux *mux.Mux, bufferSizeInBytes int)
| 100 | ) |
| 101 | |
| 102 | func 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 | |
| 135 | func (c *wasapiContext) isDeviceSwitched() (bool, error) { |
| 136 | // If the audio is suspended, do nothing. |
no test coverage detected
searching dependent graphs…