diff options
Diffstat (limited to 'chromium/media/audio/alsa/alsa_output.cc')
-rw-r--r-- | chromium/media/audio/alsa/alsa_output.cc | 54 |
1 files changed, 26 insertions, 28 deletions
diff --git a/chromium/media/audio/alsa/alsa_output.cc b/chromium/media/audio/alsa/alsa_output.cc index 74ea72b610c..c2cc61d1d8c 100644 --- a/chromium/media/audio/alsa/alsa_output.cc +++ b/chromium/media/audio/alsa/alsa_output.cc @@ -75,7 +75,7 @@ static const ChannelLayout kDefaultOutputChannelLayout = CHANNEL_LAYOUT_STEREO; // http://0pointer.de/blog/projects/guide-to-sound-apis.html // // This function makes a best guess at the specific > 2 channel device name -// based on the number of channels requested. NULL is returned if no device +// based on the number of channels requested. nullptr is returned if no device // can be found to match the channel numbers. In this case, using // kDefaultDevice is probably the best bet. // @@ -103,7 +103,7 @@ static const char* GuessSpecificDeviceName(uint32_t channels) { return "surround40"; default: - return NULL; + return nullptr; } } @@ -165,11 +165,11 @@ AlsaPcmOutputStream::AlsaPcmOutputStream(const std::string& device_name, wrapper_(wrapper), manager_(manager), task_runner_(base::ThreadTaskRunnerHandle::Get()), - playback_handle_(NULL), + playback_handle_(nullptr), frames_per_packet_(packet_size_ / bytes_per_frame_), state_(kCreated), volume_(1.0f), - source_callback_(NULL), + source_callback_(nullptr), audio_bus_(AudioBus::Create(params)), tick_clock_(base::DefaultTickClock::GetInstance()) { DCHECK(manager_->GetTaskRunner()->BelongsToCurrentThread()); @@ -221,7 +221,7 @@ bool AlsaPcmOutputStream::Open() { } // Finish initializing the stream if the device was opened successfully. - if (playback_handle_ == NULL) { + if (playback_handle_ == nullptr) { stop_stream_ = true; TransitionTo(kInError); return false; @@ -260,7 +260,7 @@ void AlsaPcmOutputStream::Close() { if (alsa_util::CloseDevice(wrapper_, playback_handle_) < 0) { LOG(WARNING) << "Unable to close audio device. Leaking handle."; } - playback_handle_ = NULL; + playback_handle_ = nullptr; // Release the buffer. buffer_.reset(); @@ -330,7 +330,7 @@ void AlsaPcmOutputStream::Stop() { DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); // Reset the callback, so that it is not called anymore. - set_source_callback(NULL); + set_source_callback(nullptr); weak_factory_.InvalidateWeakPtrs(); TransitionTo(kIsStopped); @@ -559,19 +559,19 @@ std::string AlsaPcmOutputStream::FindDeviceForChannels(uint32_t channels) { return std::string(); std::string guessed_device; - void** hints = NULL; + void** hints = nullptr; int error = wrapper_->DeviceNameHint(kGetAllDevices, kPcmInterfaceName, &hints); if (error == 0) { // NOTE: Do not early return from inside this if statement. The // hints above need to be freed. - for (void** hint_iter = hints; *hint_iter != NULL; hint_iter++) { + for (void** hint_iter = hints; *hint_iter != nullptr; hint_iter++) { // Only examine devices that are output capable.. Valid values are - // "Input", "Output", and NULL which means both input and output. + // "Input", "Output", and nullptr which means both input and output. std::unique_ptr<char, base::FreeDeleter> io( wrapper_->DeviceNameGetHint(*hint_iter, kIoHintName)); - if (io != NULL && strcmp(io.get(), "Input") == 0) + if (io != nullptr && strcmp(io.get(), "Input") == 0) continue; // Attempt to select the closest device for number of channels. @@ -585,7 +585,7 @@ std::string AlsaPcmOutputStream::FindDeviceForChannels(uint32_t channels) { // Destroy the hint now that we're done with it. wrapper_->DeviceNameFreeHint(hints); - hints = NULL; + hints = nullptr; } else { LOG(ERROR) << "Unable to get hints for devices: " << wrapper_->StrError(error); @@ -673,24 +673,22 @@ snd_pcm_t* AlsaPcmOutputStream::AutoSelectDevice(unsigned int latency) { // 4) Fallback to kDefaultDevice. // 5) If that fails too, try the "plug:" version of kDefaultDevice. // 6) Give up. - snd_pcm_t* handle = NULL; + snd_pcm_t* handle = nullptr; device_name_ = FindDeviceForChannels(channels_); // Step 1. if (!device_name_.empty()) { - if ((handle = alsa_util::OpenPlaybackDevice(wrapper_, device_name_.c_str(), - channels_, sample_rate_, - pcm_format_, - latency)) != NULL) { + if ((handle = alsa_util::OpenPlaybackDevice( + wrapper_, device_name_.c_str(), channels_, sample_rate_, + pcm_format_, latency)) != nullptr) { return handle; } // Step 2. device_name_ = kPlugPrefix + device_name_; - if ((handle = alsa_util::OpenPlaybackDevice(wrapper_, device_name_.c_str(), - channels_, sample_rate_, - pcm_format_, - latency)) != NULL) { + if ((handle = alsa_util::OpenPlaybackDevice( + wrapper_, device_name_.c_str(), channels_, sample_rate_, + pcm_format_, latency)) != nullptr) { return handle; } @@ -700,7 +698,7 @@ snd_pcm_t* AlsaPcmOutputStream::AutoSelectDevice(unsigned int latency) { device_name_ = kPlugPrefix + device_name_; if ((handle = alsa_util::OpenPlaybackDevice( wrapper_, device_name_.c_str(), channels_, sample_rate_, - pcm_format_, latency)) != NULL) { + pcm_format_, latency)) != nullptr) { return handle; } } @@ -722,22 +720,22 @@ snd_pcm_t* AlsaPcmOutputStream::AutoSelectDevice(unsigned int latency) { // Step 4. device_name_ = kDefaultDevice; if ((handle = alsa_util::OpenPlaybackDevice( - wrapper_, device_name_.c_str(), default_channels, sample_rate_, - pcm_format_, latency)) != NULL) { + wrapper_, device_name_.c_str(), default_channels, sample_rate_, + pcm_format_, latency)) != nullptr) { return handle; } // Step 5. device_name_ = kPlugPrefix + device_name_; if ((handle = alsa_util::OpenPlaybackDevice( - wrapper_, device_name_.c_str(), default_channels, sample_rate_, - pcm_format_, latency)) != NULL) { + wrapper_, device_name_.c_str(), default_channels, sample_rate_, + pcm_format_, latency)) != nullptr) { return handle; } // Unable to open any device. device_name_.clear(); - return NULL; + return nullptr; } bool AlsaPcmOutputStream::CanTransitionTo(InternalState to) { @@ -800,7 +798,7 @@ void AlsaPcmOutputStream::RunErrorCallback(int code) { source_callback_->OnError(AudioSourceCallback::ErrorType::kUnknown); } -// Changes the AudioSourceCallback to proxy calls to. Pass in NULL to +// Changes the AudioSourceCallback to proxy calls to. Pass in nullptr to // release ownership of the currently registered callback. void AlsaPcmOutputStream::set_source_callback(AudioSourceCallback* callback) { DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); |