OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "content/common/media/audio_param_traits.h" |
| 6 |
| 7 #include "base/stringprintf.h" |
| 8 #include "media/audio/audio_parameters.h" |
| 9 |
| 10 namespace IPC { |
| 11 |
| 12 void ParamTraits<AudioParameters>::Write(Message* m, |
| 13 const AudioParameters& p) { |
| 14 m->WriteInt(static_cast<int>(p.format())); |
| 15 m->WriteInt(static_cast<int>(p.channel_layout())); |
| 16 m->WriteInt(p.sample_rate()); |
| 17 m->WriteInt(p.bits_per_sample()); |
| 18 m->WriteInt(p.frames_per_buffer()); |
| 19 m->WriteInt(p.channels()); |
| 20 } |
| 21 |
| 22 bool ParamTraits<AudioParameters>::Read(const Message* m, |
| 23 PickleIterator* iter, |
| 24 AudioParameters* r) { |
| 25 int format, channel_layout, sample_rate, bits_per_sample, |
| 26 frames_per_buffer, channels; |
| 27 |
| 28 if (!m->ReadInt(iter, &format) || |
| 29 !m->ReadInt(iter, &channel_layout) || |
| 30 !m->ReadInt(iter, &sample_rate) || |
| 31 !m->ReadInt(iter, &bits_per_sample) || |
| 32 !m->ReadInt(iter, &frames_per_buffer) || |
| 33 !m->ReadInt(iter, &channels)) |
| 34 return false; |
| 35 r->Reset(static_cast<AudioParameters::Format>(format), |
| 36 static_cast<ChannelLayout>(channel_layout), |
| 37 sample_rate, bits_per_sample, frames_per_buffer); |
| 38 return true; |
| 39 } |
| 40 |
| 41 void ParamTraits<AudioParameters>::Log(const AudioParameters& p, |
| 42 std::string* l) { |
| 43 l->append(base::StringPrintf("<AudioParameters>")); |
| 44 } |
| 45 |
| 46 } |
OLD | NEW |