(lengthInBytes int)
| 102 | } |
| 103 | |
| 104 | func (p *Player) bufferToInt16(lengthInBytes int) ([]int16, error) { |
| 105 | select { |
| 106 | case p.proceedCh <- make([]int16, lengthInBytes/2): |
| 107 | r := <-p.proceededCh |
| 108 | return r.buf, r.err |
| 109 | case <-p.readLoopEndedCh: |
| 110 | return nil, fmt.Errorf("audio: the player is already closed") |
| 111 | } |
| 112 | } |
| 113 | |
| 114 | // Play plays the player's audio. |
| 115 | func (p *Player) Play() { |