diff options
Diffstat (limited to 'www/chromium/files/sndio_output.cc')
-rw-r--r-- | www/chromium/files/sndio_output.cc | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/www/chromium/files/sndio_output.cc b/www/chromium/files/sndio_output.cc index 27c6c1db285a..e9053d34b8aa 100644 --- a/www/chromium/files/sndio_output.cc +++ b/www/chromium/files/sndio_output.cc @@ -11,6 +11,8 @@ namespace media { +static const SampleFormat kSampleFormat = kSampleFormatS16; + void sndio_onmove(void *arg, int delta) { SndioAudioOutputStream* self = static_cast<SndioAudioOutputStream*>(arg); @@ -35,7 +37,7 @@ SndioAudioOutputStream::SndioAudioOutputStream(const AudioParameters& params, : manager(manager), params(params), audio_bus(AudioBus::Create(params)), - bytes_per_frame(params.GetBytesPerFrame()), + bytes_per_frame(params.GetBytesPerFrame(kSampleFormat)), state(kClosed), mutex(PTHREAD_MUTEX_INITIALIZER) { } @@ -57,7 +59,7 @@ bool SndioAudioOutputStream::Open() { sio_initpar(&par); par.rate = params.sample_rate(); par.pchan = params.channels(); - par.bits = params.bits_per_sample(); + par.bits = SampleFormatToBitsPerChannel(kSampleFormat); par.bps = par.bits / 8; par.sig = sig = par.bits != 8 ? 1 : 0; par.le = SIO_LE_NATIVE; @@ -74,7 +76,7 @@ bool SndioAudioOutputStream::Open() { } if (par.rate != (unsigned int)params.sample_rate() || par.pchan != (unsigned int)params.channels() || - par.bits != (unsigned int)params.bits_per_sample() || + par.bits != (unsigned int)SampleFormatToBitsPerChannel(kSampleFormat) || par.sig != (unsigned int)sig || (par.bps > 1 && par.le != SIO_LE_NATIVE) || (par.bits != par.bps * 8)) { @@ -84,7 +86,7 @@ bool SndioAudioOutputStream::Open() { state = kStopped; volpending = 0; vol = 0; - buffer = new char[audio_bus->frames() * params.GetBytesPerFrame()]; + buffer = new char[audio_bus->frames() * params.GetBytesPerFrame(kSampleFormat)]; sio_onmove(hdl, sndio_onmove, this); sio_onvol(hdl, sndio_onvol, this); return true; @@ -153,16 +155,16 @@ void SndioAudioOutputStream::RealTimeThread(void) { // Get data to play const base::TimeDelta delay = AudioTimestampHelper::FramesToTime(hw_delay, params.sample_rate() * 1000); count = source->OnMoreData(delay, base::TimeTicks::Now(), 0, audio_bus.get()); - audio_bus->ToInterleaved(count, params.bits_per_sample() / 8, buffer); + audio_bus->ToInterleaved(count, SampleFormatToBytesPerChannel(kSampleFormat), buffer); if (count == 0) { // We have to submit something to the device count = audio_bus->frames(); - memset(buffer, 0, count * params.GetBytesPerFrame()); + memset(buffer, 0, count * params.GetBytesPerFrame(kSampleFormat)); LOG(WARNING) << "No data to play, running empty cycle."; } // Submit data to the device - avail = count * params.GetBytesPerFrame(); + avail = count * params.GetBytesPerFrame(kSampleFormat); count = sio_write(hdl, buffer, avail); if (count == 0) { LOG(WARNING) << "Audio device disconnected."; |