OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "media/audio/sample_rates.h" | 5 #include "media/audio/sample_rates.h" |
6 | 6 |
| 7 #include "base/logging.h" |
| 8 |
7 namespace media { | 9 namespace media { |
8 | 10 |
9 AudioSampleRate AsAudioSampleRate(int sample_rate) { | 11 bool ToAudioSampleRate(int sample_rate, AudioSampleRate* asr) { |
| 12 DCHECK(asr); |
10 switch (sample_rate) { | 13 switch (sample_rate) { |
11 case 8000: return k8000Hz; | 14 case 8000: |
12 case 16000: return k16000Hz; | 15 *asr = k8000Hz; |
13 case 32000: return k32000Hz; | 16 return true; |
14 case 48000: return k48000Hz; | 17 case 16000: |
15 case 96000: return k96000Hz; | 18 *asr = k16000Hz; |
16 case 11025: return k11025Hz; | 19 return true; |
17 case 22050: return k22050Hz; | 20 case 32000: |
18 case 44100: return k44100Hz; | 21 *asr = k32000Hz; |
19 case 88200: return k88200Hz; | 22 return true; |
20 case 176400: return k176400Hz; | 23 case 48000: |
21 case 192000: return k192000Hz; | 24 *asr = k48000Hz; |
| 25 return true; |
| 26 case 96000: |
| 27 *asr = k96000Hz; |
| 28 return true; |
| 29 case 11025: |
| 30 *asr = k11025Hz; |
| 31 return true; |
| 32 case 22050: |
| 33 *asr = k22050Hz; |
| 34 return true; |
| 35 case 44100: |
| 36 *asr = k44100Hz; |
| 37 return true; |
| 38 case 88200: |
| 39 *asr = k88200Hz; |
| 40 return true; |
| 41 case 176400: |
| 42 *asr = k176400Hz; |
| 43 return true; |
| 44 case 192000: |
| 45 *asr = k192000Hz; |
| 46 return true; |
22 } | 47 } |
23 return kUnexpectedAudioSampleRate; | 48 return false; |
24 } | 49 } |
25 | 50 |
26 } // namespace media | 51 } // namespace media |
OLD | NEW |