(buf32 []float32)
| 212 | } |
| 213 | |
| 214 | func (c *context) readAndWrite(buf32 []float32) bool { |
| 215 | c.cond.L.Lock() |
| 216 | defer c.cond.L.Unlock() |
| 217 | |
| 218 | for c.suspended && c.err.Load() == nil { |
| 219 | c.cond.Wait() |
| 220 | } |
| 221 | if c.err.Load() != nil { |
| 222 | return false |
| 223 | } |
| 224 | |
| 225 | c.mux.ReadFloat32s(buf32) |
| 226 | |
| 227 | for len(buf32) > 0 { |
| 228 | n := C.snd_pcm_writei(c.handle, unsafe.Pointer(&buf32[0]), C.snd_pcm_uframes_t(len(buf32)/c.channelCount)) |
| 229 | if n < 0 { |
| 230 | n = C.long(C.snd_pcm_recover(c.handle, C.int(n), 1)) |
| 231 | } |
| 232 | if n < 0 { |
| 233 | c.err.TryStore(alsaError("snd_pcm_writei or snd_pcm_recover", C.int(n))) |
| 234 | return false |
| 235 | } |
| 236 | buf32 = buf32[int(n)*c.channelCount:] |
| 237 | } |
| 238 | return true |
| 239 | } |
| 240 | |
| 241 | func (c *context) Suspend() error { |
| 242 | <-c.ready |
no test coverage detected