| Index: media/audio/linux/alsa_output.cc
|
| diff --git a/media/audio/linux/alsa_output.cc b/media/audio/linux/alsa_output.cc
|
| index a57c2763511e955667d542a6798c7ce3275527ee..7e4340edfe47d6c2ae4f5e8f16a3f80eff50eb18 100644
|
| --- a/media/audio/linux/alsa_output.cc
|
| +++ b/media/audio/linux/alsa_output.cc
|
| @@ -182,15 +182,15 @@ AlsaPcmOutputStream::AlsaPcmOutputStream(const std::string& device_name,
|
| AlsaWrapper* wrapper,
|
| AudioManagerLinux* manager)
|
| : requested_device_name_(device_name),
|
| - pcm_format_(alsa_util::BitsToFormat(params.bits_per_sample)),
|
| - channels_(params.channels),
|
| - sample_rate_(params.sample_rate),
|
| - bytes_per_sample_(params.bits_per_sample / 8),
|
| - bytes_per_frame_(channels_ * params.bits_per_sample / 8),
|
| + pcm_format_(alsa_util::BitsToFormat(params.bits_per_sample())),
|
| + channels_(params.channels()),
|
| + samples_per_second_(params.samples_per_second()),
|
| + bytes_per_sample_(params.bits_per_sample() / 8),
|
| + bytes_per_frame_(channels_ * params.bits_per_sample() / 8),
|
| should_downmix_(false),
|
| packet_size_(params.GetPacketSize()),
|
| micros_per_packet_(FramesToMicros(
|
| - params.samples_per_packet, sample_rate_)),
|
| + params.samples_per_packet(), samples_per_second_)),
|
| latency_micros_(std::max(AlsaPcmOutputStream::kMinLatencyMicros,
|
| micros_per_packet_ * 2)),
|
| bytes_per_output_frame_(bytes_per_frame_),
|
| @@ -207,19 +207,20 @@ AlsaPcmOutputStream::AlsaPcmOutputStream(const std::string& device_name,
|
| DCHECK(IsOnAudioThread());
|
|
|
| // Sanity check input values.
|
| - if ((params.sample_rate > kAlsaMaxSampleRate) || (params.sample_rate <= 0)) {
|
| + if (params.samples_per_second() > kAlsaMaxSampleRate ||
|
| + params.samples_per_second() <= 0) {
|
| LOG(WARNING) << "Unsupported audio frequency.";
|
| TransitionTo(kInError);
|
| }
|
|
|
| - if (AudioParameters::AUDIO_PCM_LINEAR != params.format &&
|
| - AudioParameters::AUDIO_PCM_LOW_LATENCY != params.format) {
|
| + if (AudioParameters::AUDIO_PCM_LINEAR != params.format() &&
|
| + AudioParameters::AUDIO_PCM_LOW_LATENCY != params.format()) {
|
| LOG(WARNING) << "Unsupported audio format";
|
| TransitionTo(kInError);
|
| }
|
|
|
| if (pcm_format_ == SND_PCM_FORMAT_UNKNOWN) {
|
| - LOG(WARNING) << "Unsupported bits per sample: " << params.bits_per_sample;
|
| + LOG(WARNING) << "Unsupported bits per sample: " << params.bits_per_sample();
|
| TransitionTo(kInError);
|
| }
|
| }
|
| @@ -256,11 +257,9 @@ bool AlsaPcmOutputStream::Open() {
|
| DVLOG(1) << "Auto-selected device: " << device_name_;
|
| } else {
|
| device_name_ = requested_device_name_;
|
| - playback_handle_ = alsa_util::OpenPlaybackDevice(wrapper_,
|
| - device_name_.c_str(),
|
| - channels_, sample_rate_,
|
| - pcm_format_,
|
| - latency_micros_);
|
| + playback_handle_ = alsa_util::OpenPlaybackDevice(
|
| + wrapper_, device_name_.c_str(), channels_, samples_per_second_,
|
| + pcm_format_, latency_micros_);
|
| }
|
|
|
| // Finish initializing the stream if the device was opened successfully.
|
| @@ -565,7 +564,7 @@ void AlsaPcmOutputStream::ScheduleNextWrite(bool source_exhausted) {
|
| // Next write is initially scheduled for the moment when half of a packet
|
| // has been played out.
|
| uint32 next_fill_time_ms =
|
| - FramesToMillis(frames_per_packet_ / 2, sample_rate_);
|
| + FramesToMillis(frames_per_packet_ / 2, samples_per_second_);
|
|
|
| if (frames_in_buffer && (frames_in_buffer <= available_frames)) {
|
| // There is data in the current buffer, consume them immediately if we have
|
| @@ -577,7 +576,7 @@ void AlsaPcmOutputStream::ScheduleNextWrite(bool source_exhausted) {
|
| if (available_frames < frames_avail_wanted) {
|
| uint32 frames_until_empty_enough = frames_avail_wanted - available_frames;
|
| next_fill_time_ms =
|
| - FramesToMillis(frames_until_empty_enough, sample_rate_);
|
| + FramesToMillis(frames_until_empty_enough, samples_per_second_);
|
|
|
| // Adjust for time resolution.
|
| if (next_fill_time_ms > kNoDataSleepMilliseconds)
|
| @@ -613,12 +612,14 @@ void AlsaPcmOutputStream::ScheduleNextWrite(bool source_exhausted) {
|
| }
|
| }
|
|
|
| -uint32 AlsaPcmOutputStream::FramesToMicros(uint32 frames, uint32 sample_rate) {
|
| - return frames * base::Time::kMicrosecondsPerSecond / sample_rate;
|
| +uint32 AlsaPcmOutputStream::FramesToMicros(uint32 frames,
|
| + uint32 samples_per_second) {
|
| + return frames * base::Time::kMicrosecondsPerSecond / samples_per_second;
|
| }
|
|
|
| -uint32 AlsaPcmOutputStream::FramesToMillis(uint32 frames, uint32 sample_rate) {
|
| - return frames * base::Time::kMillisecondsPerSecond / sample_rate;
|
| +uint32 AlsaPcmOutputStream::FramesToMillis(uint32 frames,
|
| + uint32 samples_per_second) {
|
| + return frames * base::Time::kMillisecondsPerSecond / samples_per_second;
|
| }
|
|
|
| std::string AlsaPcmOutputStream::FindDeviceForChannels(uint32 channels) {
|
| @@ -733,7 +734,7 @@ snd_pcm_t* AlsaPcmOutputStream::AutoSelectDevice(unsigned int latency) {
|
| // Step 1.
|
| if (!device_name_.empty()) {
|
| if ((handle = alsa_util::OpenPlaybackDevice(wrapper_, device_name_.c_str(),
|
| - channels_, sample_rate_,
|
| + channels_, samples_per_second_,
|
| pcm_format_,
|
| latency)) != NULL) {
|
| return handle;
|
| @@ -742,7 +743,7 @@ snd_pcm_t* AlsaPcmOutputStream::AutoSelectDevice(unsigned int latency) {
|
| // Step 2.
|
| device_name_ = kPlugPrefix + device_name_;
|
| if ((handle = alsa_util::OpenPlaybackDevice(wrapper_, device_name_.c_str(),
|
| - channels_, sample_rate_,
|
| + channels_, samples_per_second_,
|
| pcm_format_,
|
| latency)) != NULL) {
|
| return handle;
|
| @@ -763,17 +764,17 @@ snd_pcm_t* AlsaPcmOutputStream::AutoSelectDevice(unsigned int latency) {
|
|
|
| // Step 3.
|
| device_name_ = kDefaultDevice;
|
| - if ((handle = alsa_util::OpenPlaybackDevice(wrapper_, device_name_.c_str(),
|
| - default_channels, sample_rate_,
|
| - pcm_format_, latency)) != NULL) {
|
| + if ((handle = alsa_util::OpenPlaybackDevice(
|
| + wrapper_, device_name_.c_str(), default_channels, samples_per_second_,
|
| + pcm_format_, latency)) != NULL) {
|
| return handle;
|
| }
|
|
|
| // Step 4.
|
| device_name_ = kPlugPrefix + device_name_;
|
| - if ((handle = alsa_util::OpenPlaybackDevice(wrapper_, device_name_.c_str(),
|
| - default_channels, sample_rate_,
|
| - pcm_format_, latency)) != NULL) {
|
| + if ((handle = alsa_util::OpenPlaybackDevice(
|
| + wrapper_, device_name_.c_str(), default_channels, samples_per_second_,
|
| + pcm_format_, latency)) != NULL) {
|
| return handle;
|
| }
|
|
|
|
|