|
Lines 14-20
Link Here
|
| 14 |
+ |
14 |
+ |
| 15 |
+namespace media { |
15 |
+namespace media { |
| 16 |
+ |
16 |
+ |
| 17 |
+static const SampleFormat kSampleFormat = kSampleFormatS16; |
17 |
+static const SampleFormat kSampleFormatAO = kSampleFormatS16; |
| 18 |
+ |
18 |
+ |
| 19 |
+void SndioAudioOutputStream::OnMoveCallback(void *arg, int delta) { |
19 |
+void SndioAudioOutputStream::OnMoveCallback(void *arg, int delta) { |
| 20 |
+ SndioAudioOutputStream* self = static_cast<SndioAudioOutputStream*>(arg); |
20 |
+ SndioAudioOutputStream* self = static_cast<SndioAudioOutputStream*>(arg); |
|
Lines 58-64
Link Here
|
| 58 |
+ state = kStopped; |
58 |
+ state = kStopped; |
| 59 |
+ volpending = 0; |
59 |
+ volpending = 0; |
| 60 |
+ vol = SIO_MAXVOL; |
60 |
+ vol = SIO_MAXVOL; |
| 61 |
+ buffer = new char[audio_bus->frames() * params.GetBytesPerFrame(kSampleFormat)]; |
61 |
+ buffer = new char[audio_bus->frames() * params.GetBytesPerFrame(kSampleFormatAO)]; |
| 62 |
+ return true; |
62 |
+ return true; |
| 63 |
+} |
63 |
+} |
| 64 |
+ |
64 |
+ |
|
Lines 80-86
Link Here
|
| 80 |
+ sio_initpar(&par); |
80 |
+ sio_initpar(&par); |
| 81 |
+ par.rate = params.sample_rate(); |
81 |
+ par.rate = params.sample_rate(); |
| 82 |
+ par.pchan = params.channels(); |
82 |
+ par.pchan = params.channels(); |
| 83 |
+ par.bits = SampleFormatToBitsPerChannel(kSampleFormat); |
83 |
+ par.bits = SampleFormatToBitsPerChannel(kSampleFormatAO); |
| 84 |
+ par.bps = par.bits / 8; |
84 |
+ par.bps = par.bits / 8; |
| 85 |
+ par.sig = sig = par.bits != 8 ? 1 : 0; |
85 |
+ par.sig = sig = par.bits != 8 ? 1 : 0; |
| 86 |
+ par.le = SIO_LE_NATIVE; |
86 |
+ par.le = SIO_LE_NATIVE; |
|
Lines 98-104
Link Here
|
| 98 |
+ } |
98 |
+ } |
| 99 |
+ if (par.rate != (unsigned int)params.sample_rate() || |
99 |
+ if (par.rate != (unsigned int)params.sample_rate() || |
| 100 |
+ par.pchan != (unsigned int)params.channels() || |
100 |
+ par.pchan != (unsigned int)params.channels() || |
| 101 |
+ par.bits != (unsigned int)SampleFormatToBitsPerChannel(kSampleFormat) || |
101 |
+ par.bits != (unsigned int)SampleFormatToBitsPerChannel(kSampleFormatAO) || |
| 102 |
+ par.sig != (unsigned int)sig || |
102 |
+ par.sig != (unsigned int)sig || |
| 103 |
+ (par.bps > 1 && par.le != SIO_LE_NATIVE) || |
103 |
+ (par.bps > 1 && par.le != SIO_LE_NATIVE) || |
| 104 |
+ (par.bits != par.bps * 8)) { |
104 |
+ (par.bits != par.bps * 8)) { |
|
Lines 170-181
Link Here
|
| 170 |
+ if (count == 0) { |
170 |
+ if (count == 0) { |
| 171 |
+ // We have to submit something to the device |
171 |
+ // We have to submit something to the device |
| 172 |
+ count = audio_bus->frames(); |
172 |
+ count = audio_bus->frames(); |
| 173 |
+ memset(buffer, 0, count * params.GetBytesPerFrame(kSampleFormat)); |
173 |
+ memset(buffer, 0, count * params.GetBytesPerFrame(kSampleFormatAO)); |
| 174 |
+ LOG(WARNING) << "No data to play, running empty cycle."; |
174 |
+ LOG(WARNING) << "No data to play, running empty cycle."; |
| 175 |
+ } |
175 |
+ } |
| 176 |
+ |
176 |
+ |
| 177 |
+ // Submit data to the device |
177 |
+ // Submit data to the device |
| 178 |
+ avail = count * params.GetBytesPerFrame(kSampleFormat); |
178 |
+ avail = count * params.GetBytesPerFrame(kSampleFormatAO); |
| 179 |
+ result = sio_write(hdl, buffer, avail); |
179 |
+ result = sio_write(hdl, buffer, avail); |
| 180 |
+ if (result == 0) { |
180 |
+ if (result == 0) { |
| 181 |
+ LOG(WARNING) << "Audio device disconnected."; |
181 |
+ LOG(WARNING) << "Audio device disconnected."; |