(sampleRate int, channelCount int, format mux.Format, bufferSizeInBytes int)
| 39 | } |
| 40 | |
| 41 | func newContext(sampleRate int, channelCount int, format mux.Format, bufferSizeInBytes int) (*context, chan struct{}, error) { |
| 42 | ctx := &context{ |
| 43 | sampleRate: sampleRate, |
| 44 | channelCount: channelCount, |
| 45 | mux: mux.New(sampleRate, channelCount, format), |
| 46 | ready: make(chan struct{}), |
| 47 | } |
| 48 | |
| 49 | // Initializing drivers might take some time. Do this asynchronously. |
| 50 | go func() { |
| 51 | defer close(ctx.ready) |
| 52 | |
| 53 | xc, err0 := newWASAPIContext(sampleRate, channelCount, ctx.mux, bufferSizeInBytes) |
| 54 | if err0 == nil { |
| 55 | ctx.wasapiContext = xc |
| 56 | return |
| 57 | } |
| 58 | |
| 59 | wc, err1 := newWinMMContext(sampleRate, channelCount, ctx.mux, bufferSizeInBytes) |
| 60 | if err1 == nil { |
| 61 | ctx.winmmContext = wc |
| 62 | return |
| 63 | } |
| 64 | |
| 65 | if errors.Is(err0, errDeviceNotFound) && errors.Is(err1, errDeviceNotFound) { |
| 66 | ctx.nullContext = newNullContext(sampleRate, channelCount, ctx.mux) |
| 67 | return |
| 68 | } |
| 69 | |
| 70 | ctx.err.TryStore(fmt.Errorf("oto: initialization failed: WASAPI: %v, WinMM: %v", err0, err1)) |
| 71 | }() |
| 72 | |
| 73 | return ctx, ctx.ready, nil |
| 74 | } |
| 75 | |
| 76 | func (c *context) Suspend() error { |
| 77 | <-c.ready |
nothing calls this directly
no test coverage detected
searching dependent graphs…