Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(367)

Unified Diff: remoting/client/audio_player.cc

Issue 2052723002: Adding an interface to allow extention of the audio player for CRD and iOS. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressing comments in CL. Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « remoting/client/audio_player.h ('k') | remoting/client/audio_player_android.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/client/audio_player.cc
diff --git a/remoting/client/audio_player.cc b/remoting/client/audio_player.cc
index 5fc00b7abc5274cdcb840e39eeb98437017dc40a..df4590f3f3d77faee76e417441a1835e4d8cee39 100644
--- a/remoting/client/audio_player.cc
+++ b/remoting/client/audio_player.cc
@@ -5,6 +5,7 @@
#include "remoting/client/audio_player.h"
#include <algorithm>
+#include <string>
#include "base/logging.h"
#include "base/stl_util.h"
@@ -21,12 +22,9 @@ AudioPlayer::AudioPlayer()
bytes_consumed_(0) {
}
-AudioPlayer::~AudioPlayer() {
- base::AutoLock auto_lock(lock_);
- ResetQueue();
-}
+AudioPlayer::~AudioPlayer() {}
-void AudioPlayer::ProcessAudioPacket(std::unique_ptr<AudioPacket> packet) {
+void AudioPlayer::AddAudioPacket(std::unique_ptr<AudioPacket> packet) {
CHECK_EQ(1, packet->data_size());
DCHECK_EQ(AudioPacket::ENCODING_RAW, packet->encoding());
DCHECK_NE(AudioPacket::SAMPLING_RATE_INVALID, packet->sampling_rate());
@@ -59,7 +57,7 @@ void AudioPlayer::ProcessAudioPacket(std::unique_ptr<AudioPacket> packet) {
base::AutoLock auto_lock(lock_);
queued_bytes_ += packet->data(0).size();
- queued_packets_.push_back(packet.release());
+ queued_packets_.push_back(std::move(packet));
int max_buffer_size_ =
kMaxQueueLatencyMs * sampling_rate_ * kSampleSizeBytes * kChannels /
@@ -67,7 +65,6 @@ void AudioPlayer::ProcessAudioPacket(std::unique_ptr<AudioPacket> packet) {
while (queued_bytes_ > max_buffer_size_) {
queued_bytes_ -= queued_packets_.front()->data(0).size() - bytes_consumed_;
DCHECK_GE(queued_bytes_, 0);
- delete queued_packets_.front();
queued_packets_.pop_front();
bytes_consumed_ = 0;
}
@@ -83,7 +80,7 @@ void AudioPlayer::AudioPlayerCallback(void* samples,
void AudioPlayer::ResetQueue() {
lock_.AssertAcquired();
- STLDeleteElements(&queued_packets_);
+ queued_packets_.clear();
queued_bytes_ = 0;
bytes_consumed_ = 0;
}
@@ -109,7 +106,6 @@ void AudioPlayer::FillWithSamples(void* samples, uint32_t buffer_size) {
// Pop off the packet if we've already consumed all its bytes.
if (queued_packets_.front()->data(0).size() == bytes_consumed_) {
- delete queued_packets_.front();
queued_packets_.pop_front();
bytes_consumed_ = 0;
continue;
« no previous file with comments | « remoting/client/audio_player.h ('k') | remoting/client/audio_player_android.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698