Gracefully handle not being able to acquire an audio dataline.
catseye
13 years ago
22 | 22 | private boolean fullSpeed = false; |
23 | 23 | |
24 | 24 | public int available() { |
25 | if (dataLine == null) | |
26 | return 0; | |
25 | 27 | return dataLine.available(); |
26 | 28 | } |
27 | 29 | |
30 | 32 | } |
31 | 33 | |
32 | 34 | public long getMicros() { |
35 | if (dataLine == null) | |
36 | return 0; | |
33 | 37 | return dataLine.getMicrosecondPosition(); |
34 | 38 | } |
35 | 39 | |
75 | 79 | } |
76 | 80 | |
77 | 81 | public void write(byte[] buffer) { |
82 | if (dataLine == null) | |
83 | return; | |
78 | 84 | int bsize = buffer.length; |
79 | 85 | if (!fullSpeed) { |
80 | 86 | while (dataLine.available() < bsize) |