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

Unified Diff: content/public/common/common_param_traits.cc

Issue 9655018: Make AudioParameters a class instead of a struct (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix tests Created 8 years, 9 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
Index: content/public/common/common_param_traits.cc
diff --git a/content/public/common/common_param_traits.cc b/content/public/common/common_param_traits.cc
index 22bb7a9dad481284ec099baf1f1e8165a163fd7f..4ca3ffde28be416f6b8f748a7cf23990827f4cf9 100644
--- a/content/public/common/common_param_traits.cc
+++ b/content/public/common/common_param_traits.cc
@@ -508,6 +508,39 @@ void ParamTraits<gfx::Rect>::Log(const gfx::Rect& p, std::string* l) {
p.width(), p.height()));
}
+void ParamTraits<AudioParameters>::Write(Message* m,
+ const AudioParameters& p) {
+ m->WriteInt(static_cast<int>(p.format()));
+ m->WriteInt(static_cast<int>(p.channel_layout()));
+ m->WriteInt(p.samples_per_second());
+ m->WriteInt(p.bits_per_sample());
+ m->WriteInt(p.samples_per_packet());
+ m->WriteInt(p.channels());
+}
+
+bool ParamTraits<AudioParameters>::Read(const Message* m, void** iter,
+ AudioParameters* r) {
+ int format, channel_layout, samples_per_second, bits_per_sample,
+ samples_per_packet, channels;
+
+ if (!m->ReadInt(iter, &format) ||
+ !m->ReadInt(iter, &channel_layout) ||
+ !m->ReadInt(iter, &samples_per_second) ||
+ !m->ReadInt(iter, &bits_per_sample) ||
+ !m->ReadInt(iter, &samples_per_packet) ||
+ !m->ReadInt(iter, &channels))
+ return false;
+ r->Reset(static_cast<AudioParameters::Format>(format),
+ static_cast<ChannelLayout>(channel_layout),
+ samples_per_second, bits_per_sample, samples_per_packet);
+ return true;
+}
+
+void ParamTraits<AudioParameters>::Log(const AudioParameters& p,
+ std::string* l) {
+ l->append(base::StringPrintf("<AudioParameters>"));
+}
+
void ParamTraits<ui::Range>::Write(Message* m, const ui::Range& r) {
m->WriteSize(r.start());
m->WriteSize(r.end());

Powered by Google App Engine
This is Rietveld 408576698