The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2008 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | //#define LOG_NDEBUG 0 |
| 18 | #define LOG_TAG "ToneGenerator" |
| 19 | #include <utils/threads.h> |
| 20 | |
| 21 | #include <stdio.h> |
| 22 | #include <math.h> |
| 23 | #include <utils/Log.h> |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 24 | #include <utils/RefBase.h> |
| 25 | #include <utils/Timers.h> |
Eric Laurent | f3af740 | 2009-05-05 00:49:01 -0700 | [diff] [blame] | 26 | #include <cutils/properties.h> |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 27 | #include "media/ToneGenerator.h" |
| 28 | |
Eric Laurent | f3af740 | 2009-05-05 00:49:01 -0700 | [diff] [blame] | 29 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 30 | namespace android { |
| 31 | |
Eric Laurent | f3af740 | 2009-05-05 00:49:01 -0700 | [diff] [blame] | 32 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 33 | // Descriptors for all available tones (See ToneGenerator::ToneDescriptor class declaration for details) |
Eric Laurent | f3af740 | 2009-05-05 00:49:01 -0700 | [diff] [blame] | 34 | const ToneGenerator::ToneDescriptor ToneGenerator::sToneDescriptors[] = { |
David Krause | b6d90ca | 2009-06-17 15:46:13 -0500 | [diff] [blame] | 35 | { segments: {{ duration: ToneGenerator::TONEGEN_INF, waveFreq: { 1336, 941, 0 }, 0, 0}, |
| 36 | { duration: 0 , waveFreq: { 0 }, 0, 0}}, |
Eric Laurent | f3af740 | 2009-05-05 00:49:01 -0700 | [diff] [blame] | 37 | repeatCnt: ToneGenerator::TONEGEN_INF, |
| 38 | repeatSegment: 0 }, // TONE_DTMF_0 |
David Krause | b6d90ca | 2009-06-17 15:46:13 -0500 | [diff] [blame] | 39 | { segments: { { duration: ToneGenerator::TONEGEN_INF, waveFreq: { 1209, 697, 0 }, 0, 0 }, |
| 40 | { duration: 0 , waveFreq: { 0 }, 0, 0}}, |
Eric Laurent | f3af740 | 2009-05-05 00:49:01 -0700 | [diff] [blame] | 41 | repeatCnt: ToneGenerator::TONEGEN_INF, |
| 42 | repeatSegment: 0 }, // TONE_DTMF_1 |
David Krause | b6d90ca | 2009-06-17 15:46:13 -0500 | [diff] [blame] | 43 | { segments: { { duration: ToneGenerator::TONEGEN_INF, waveFreq: { 1336, 697, 0 }, 0, 0 }, |
| 44 | { duration: 0 , waveFreq: { 0 }, 0, 0}}, |
Eric Laurent | f3af740 | 2009-05-05 00:49:01 -0700 | [diff] [blame] | 45 | repeatCnt: ToneGenerator::TONEGEN_INF, |
| 46 | repeatSegment: 0 }, // TONE_DTMF_2 |
David Krause | b6d90ca | 2009-06-17 15:46:13 -0500 | [diff] [blame] | 47 | { segments: { { duration: ToneGenerator::TONEGEN_INF, waveFreq: { 1477, 697, 0 }, 0, 0 }, |
| 48 | { duration: 0 , waveFreq: { 0 }, 0, 0}}, |
Eric Laurent | f3af740 | 2009-05-05 00:49:01 -0700 | [diff] [blame] | 49 | repeatCnt: ToneGenerator::TONEGEN_INF, |
| 50 | repeatSegment: 0 }, // TONE_DTMF_3 |
David Krause | b6d90ca | 2009-06-17 15:46:13 -0500 | [diff] [blame] | 51 | { segments: { { duration: ToneGenerator::TONEGEN_INF, waveFreq: { 1209, 770, 0 }, 0, 0 }, |
| 52 | { duration: 0 , waveFreq: { 0 }, 0, 0}}, |
Eric Laurent | f3af740 | 2009-05-05 00:49:01 -0700 | [diff] [blame] | 53 | repeatCnt: ToneGenerator::TONEGEN_INF, |
| 54 | repeatSegment: 0 }, // TONE_DTMF_4 |
David Krause | b6d90ca | 2009-06-17 15:46:13 -0500 | [diff] [blame] | 55 | { segments: { { duration: ToneGenerator::TONEGEN_INF, waveFreq: { 1336, 770, 0 }, 0, 0 }, |
| 56 | { duration: 0 , waveFreq: { 0 }, 0, 0}}, |
Eric Laurent | f3af740 | 2009-05-05 00:49:01 -0700 | [diff] [blame] | 57 | repeatCnt: ToneGenerator::TONEGEN_INF, |
| 58 | repeatSegment: 0 }, // TONE_DTMF_5 |
David Krause | b6d90ca | 2009-06-17 15:46:13 -0500 | [diff] [blame] | 59 | { segments: { { duration: ToneGenerator::TONEGEN_INF, waveFreq: { 1477, 770, 0 }, 0, 0 }, |
| 60 | { duration: 0 , waveFreq: { 0 }, 0, 0}}, |
Eric Laurent | f3af740 | 2009-05-05 00:49:01 -0700 | [diff] [blame] | 61 | repeatCnt: ToneGenerator::TONEGEN_INF, |
| 62 | repeatSegment: 0 }, // TONE_DTMF_6 |
David Krause | b6d90ca | 2009-06-17 15:46:13 -0500 | [diff] [blame] | 63 | { segments: { { duration: ToneGenerator::TONEGEN_INF, waveFreq: { 1209, 852, 0 }, 0, 0 }, |
| 64 | { duration: 0 , waveFreq: { 0 }, 0, 0}}, |
Eric Laurent | f3af740 | 2009-05-05 00:49:01 -0700 | [diff] [blame] | 65 | repeatCnt: ToneGenerator::TONEGEN_INF, |
| 66 | repeatSegment: 0 }, // TONE_DTMF_7 |
David Krause | b6d90ca | 2009-06-17 15:46:13 -0500 | [diff] [blame] | 67 | { segments: { { duration: ToneGenerator::TONEGEN_INF, waveFreq: { 1336, 852, 0 }, 0, 0 }, |
| 68 | { duration: 0 , waveFreq: { 0 }, 0, 0}}, |
Eric Laurent | f3af740 | 2009-05-05 00:49:01 -0700 | [diff] [blame] | 69 | repeatCnt: ToneGenerator::TONEGEN_INF, |
| 70 | repeatSegment: 0 }, // TONE_DTMF_8 |
David Krause | b6d90ca | 2009-06-17 15:46:13 -0500 | [diff] [blame] | 71 | { segments: { { duration: ToneGenerator::TONEGEN_INF, waveFreq: { 1477, 852, 0 }, 0, 0 }, |
| 72 | { duration: 0 , waveFreq: { 0 }, 0, 0}}, |
Eric Laurent | f3af740 | 2009-05-05 00:49:01 -0700 | [diff] [blame] | 73 | repeatCnt: ToneGenerator::TONEGEN_INF, |
| 74 | repeatSegment: 0 }, // TONE_DTMF_9 |
David Krause | b6d90ca | 2009-06-17 15:46:13 -0500 | [diff] [blame] | 75 | { segments: { { duration: ToneGenerator::TONEGEN_INF, waveFreq: { 1209, 941, 0 }, 0, 0 }, |
| 76 | { duration: 0 , waveFreq: { 0 }, 0, 0}}, |
Eric Laurent | f3af740 | 2009-05-05 00:49:01 -0700 | [diff] [blame] | 77 | repeatCnt: ToneGenerator::TONEGEN_INF, |
| 78 | repeatSegment: 0 }, // TONE_DTMF_S |
David Krause | b6d90ca | 2009-06-17 15:46:13 -0500 | [diff] [blame] | 79 | { segments: { { duration: ToneGenerator::TONEGEN_INF, waveFreq: { 1477, 941, 0 }, 0, 0 }, |
| 80 | { duration: 0 , waveFreq: { 0 }, 0, 0}}, |
Eric Laurent | f3af740 | 2009-05-05 00:49:01 -0700 | [diff] [blame] | 81 | repeatCnt: ToneGenerator::TONEGEN_INF, |
| 82 | repeatSegment: 0 }, // TONE_DTMF_P |
David Krause | b6d90ca | 2009-06-17 15:46:13 -0500 | [diff] [blame] | 83 | { segments: { { duration: ToneGenerator::TONEGEN_INF, waveFreq: { 1633, 697, 0 }, 0, 0 }, |
| 84 | { duration: 0 , waveFreq: { 0 }, 0, 0}}, |
Eric Laurent | f3af740 | 2009-05-05 00:49:01 -0700 | [diff] [blame] | 85 | repeatCnt: ToneGenerator::TONEGEN_INF, |
| 86 | repeatSegment: 0 }, // TONE_DTMF_A |
David Krause | b6d90ca | 2009-06-17 15:46:13 -0500 | [diff] [blame] | 87 | { segments: { { duration: ToneGenerator::TONEGEN_INF, waveFreq: { 1633, 770, 0 }, 0, 0 }, |
| 88 | { duration: 0 , waveFreq: { 0 }, 0, 0}}, |
Eric Laurent | f3af740 | 2009-05-05 00:49:01 -0700 | [diff] [blame] | 89 | repeatCnt: ToneGenerator::TONEGEN_INF, |
| 90 | repeatSegment: 0 }, // TONE_DTMF_B |
David Krause | b6d90ca | 2009-06-17 15:46:13 -0500 | [diff] [blame] | 91 | { segments: { { duration: ToneGenerator::TONEGEN_INF, waveFreq: { 1633, 852, 0 }, 0, 0 }, |
| 92 | { duration: 0 , waveFreq: { 0 }, 0, 0}}, |
Eric Laurent | f3af740 | 2009-05-05 00:49:01 -0700 | [diff] [blame] | 93 | repeatCnt: ToneGenerator::TONEGEN_INF, |
| 94 | repeatSegment: 0 }, // TONE_DTMF_C |
David Krause | b6d90ca | 2009-06-17 15:46:13 -0500 | [diff] [blame] | 95 | { segments: { { duration: ToneGenerator::TONEGEN_INF, waveFreq: { 1633, 941, 0 }, 0, 0 }, |
| 96 | { duration: 0 , waveFreq: { 0 }, 0, 0}}, |
Eric Laurent | f3af740 | 2009-05-05 00:49:01 -0700 | [diff] [blame] | 97 | repeatCnt: ToneGenerator::TONEGEN_INF, |
| 98 | repeatSegment: 0 }, // TONE_DTMF_D |
David Krause | b6d90ca | 2009-06-17 15:46:13 -0500 | [diff] [blame] | 99 | { segments: { { duration: ToneGenerator::TONEGEN_INF, waveFreq: { 425, 0 }, 0, 0 }, |
| 100 | { duration: 0 , waveFreq: { 0 }, 0, 0}}, |
Eric Laurent | f3af740 | 2009-05-05 00:49:01 -0700 | [diff] [blame] | 101 | repeatCnt: ToneGenerator::TONEGEN_INF, |
| 102 | repeatSegment: 0 }, // TONE_SUP_DIAL |
David Krause | b6d90ca | 2009-06-17 15:46:13 -0500 | [diff] [blame] | 103 | { segments: { { duration: 500 , waveFreq: { 425, 0 }, 0, 0}, |
| 104 | { duration: 500, waveFreq: { 0 }, 0, 0}, |
| 105 | { duration: 0 , waveFreq: { 0 }, 0, 0}}, |
Eric Laurent | f3af740 | 2009-05-05 00:49:01 -0700 | [diff] [blame] | 106 | repeatCnt: ToneGenerator::TONEGEN_INF, |
| 107 | repeatSegment: 0 }, // TONE_SUP_BUSY |
David Krause | b6d90ca | 2009-06-17 15:46:13 -0500 | [diff] [blame] | 108 | { segments: { { duration: 200, waveFreq: { 425, 0 }, 0, 0 }, |
| 109 | { duration: 200, waveFreq: { 0 }, 0, 0 }, |
| 110 | { duration: 0 , waveFreq: { 0 }, 0, 0}}, |
Eric Laurent | f3af740 | 2009-05-05 00:49:01 -0700 | [diff] [blame] | 111 | repeatCnt: ToneGenerator::TONEGEN_INF, |
| 112 | repeatSegment: 0 }, // TONE_SUP_CONGESTION |
David Krause | b6d90ca | 2009-06-17 15:46:13 -0500 | [diff] [blame] | 113 | { segments: { { duration: 200, waveFreq: { 425, 0 }, 0, 0 }, |
| 114 | { duration: 0 , waveFreq: { 0 }, 0, 0}}, |
Eric Laurent | f3af740 | 2009-05-05 00:49:01 -0700 | [diff] [blame] | 115 | repeatCnt: 0, |
| 116 | repeatSegment: 0 }, // TONE_SUP_RADIO_ACK |
David Krause | b6d90ca | 2009-06-17 15:46:13 -0500 | [diff] [blame] | 117 | { segments: { { duration: 200, waveFreq: { 425, 0 }, 0, 0}, |
| 118 | { duration: 200, waveFreq: { 0 }, 0, 0}, |
| 119 | { duration: 0 , waveFreq: { 0 }, 0, 0}}, |
Eric Laurent | f3af740 | 2009-05-05 00:49:01 -0700 | [diff] [blame] | 120 | repeatCnt: 2, |
| 121 | repeatSegment: 0 }, // TONE_SUP_RADIO_NOTAVAIL |
David Krause | b6d90ca | 2009-06-17 15:46:13 -0500 | [diff] [blame] | 122 | { segments: { { duration: 330, waveFreq: { 950, 1400, 1800, 0 }, 0, 0}, |
| 123 | { duration: 1000, waveFreq: { 0 }, 0, 0}, |
| 124 | { duration: 0 , waveFreq: { 0 }, 0, 0}}, |
Eric Laurent | f3af740 | 2009-05-05 00:49:01 -0700 | [diff] [blame] | 125 | repeatCnt: ToneGenerator::TONEGEN_INF, |
| 126 | repeatSegment: 0 }, // TONE_SUP_ERROR |
David Krause | b6d90ca | 2009-06-17 15:46:13 -0500 | [diff] [blame] | 127 | { segments: { { duration: 200, waveFreq: { 425, 0 }, 0, 0 }, |
| 128 | { duration: 600, waveFreq: { 0 }, 0, 0 }, |
| 129 | { duration: 200, waveFreq: { 425, 0 }, 0, 0 }, |
| 130 | { duration: 3000, waveFreq: { 0 }, 0, 0 }, |
| 131 | { duration: 0 , waveFreq: { 0 }, 0, 0}}, |
Eric Laurent | f3af740 | 2009-05-05 00:49:01 -0700 | [diff] [blame] | 132 | repeatCnt: ToneGenerator::TONEGEN_INF, |
| 133 | repeatSegment: 0 }, // TONE_SUP_CALL_WAITING |
David Krause | b6d90ca | 2009-06-17 15:46:13 -0500 | [diff] [blame] | 134 | { segments: { { duration: 1000, waveFreq: { 425, 0 }, 0, 0 }, |
| 135 | { duration: 4000, waveFreq: { 0 }, 0, 0 }, |
| 136 | { duration: 0 , waveFreq: { 0 }, 0, 0}}, |
Eric Laurent | f3af740 | 2009-05-05 00:49:01 -0700 | [diff] [blame] | 137 | repeatCnt: ToneGenerator::TONEGEN_INF, |
| 138 | repeatSegment: 0 }, // TONE_SUP_RINGTONE |
David Krause | b6d90ca | 2009-06-17 15:46:13 -0500 | [diff] [blame] | 139 | { segments: { { duration: 40, waveFreq: { 400, 1200, 0 }, 0, 0 }, |
| 140 | { duration: 0 , waveFreq: { 0 }, 0, 0}}, |
Eric Laurent | f3af740 | 2009-05-05 00:49:01 -0700 | [diff] [blame] | 141 | repeatCnt: 0, |
| 142 | repeatSegment: 0 }, // TONE_PROP_BEEP |
David Krause | b6d90ca | 2009-06-17 15:46:13 -0500 | [diff] [blame] | 143 | { segments: { { duration: 100, waveFreq: { 1200, 0 }, 0, 0 }, |
| 144 | { duration: 100, waveFreq: { 0 }, 0, 0 }, |
| 145 | { duration: 0 , waveFreq: { 0 }, 0, 0}}, |
Eric Laurent | f3af740 | 2009-05-05 00:49:01 -0700 | [diff] [blame] | 146 | repeatCnt: 1, |
| 147 | repeatSegment: 0 }, // TONE_PROP_ACK |
David Krause | b6d90ca | 2009-06-17 15:46:13 -0500 | [diff] [blame] | 148 | { segments: { { duration: 400, waveFreq: { 300, 400, 500, 0 }, 0, 0 }, |
| 149 | { duration: 0 , waveFreq: { 0 }, 0, 0}}, |
Eric Laurent | f3af740 | 2009-05-05 00:49:01 -0700 | [diff] [blame] | 150 | repeatCnt: 0, |
| 151 | repeatSegment: 0 }, // TONE_PROP_NACK |
David Krause | b6d90ca | 2009-06-17 15:46:13 -0500 | [diff] [blame] | 152 | { segments: { { duration: 200, waveFreq: { 400, 1200, 0 }, 0, 0 }, |
| 153 | { duration: 0 , waveFreq: { 0 }, 0, 0}}, |
Eric Laurent | f3af740 | 2009-05-05 00:49:01 -0700 | [diff] [blame] | 154 | repeatCnt: 0, |
| 155 | repeatSegment: 0 }, // TONE_PROP_PROMPT |
David Krause | b6d90ca | 2009-06-17 15:46:13 -0500 | [diff] [blame] | 156 | { segments: { { duration: 40, waveFreq: { 400, 1200, 0 }, 0, 0 }, |
| 157 | { duration: 200, waveFreq: { 0 }, 0, 0 }, |
| 158 | { duration: 40, waveFreq: { 400, 1200, 0 }, 0, 0 }, |
| 159 | { duration: 0 , waveFreq: { 0 }, 0, 0}}, |
Eric Laurent | f3af740 | 2009-05-05 00:49:01 -0700 | [diff] [blame] | 160 | repeatCnt: 0, |
| 161 | repeatSegment: 0 }, // TONE_PROP_BEEP2 |
David Krause | b6d90ca | 2009-06-17 15:46:13 -0500 | [diff] [blame] | 162 | { segments: { { duration: 250, waveFreq: { 440, 0 }, 0, 0 }, |
| 163 | { duration: 250, waveFreq: { 620, 0 }, 0, 0 }, |
| 164 | { duration: 0 , waveFreq: { 0 }, 0, 0 }}, |
Eric Laurent | f3af740 | 2009-05-05 00:49:01 -0700 | [diff] [blame] | 165 | repeatCnt: ToneGenerator::TONEGEN_INF, |
| 166 | repeatSegment: 0 }, // TONE_SUP_INTERCEPT |
David Krause | b6d90ca | 2009-06-17 15:46:13 -0500 | [diff] [blame] | 167 | { segments: { { duration: 250, waveFreq: { 440, 0 }, 0, 0 }, |
| 168 | { duration: 250, waveFreq: { 620, 0 }, 0, 0 }, |
| 169 | { duration: 0 , waveFreq: { 0 }, 0, 0}}, |
Eric Laurent | f3af740 | 2009-05-05 00:49:01 -0700 | [diff] [blame] | 170 | repeatCnt: 7, |
| 171 | repeatSegment: 0 }, // TONE_SUP_INTERCEPT_ABBREV |
David Krause | b6d90ca | 2009-06-17 15:46:13 -0500 | [diff] [blame] | 172 | { segments: { { duration: 250, waveFreq: { 480, 620, 0 }, 0, 0 }, |
| 173 | { duration: 250, waveFreq: { 0 }, 0, 0 }, |
| 174 | { duration: 0 , waveFreq: { 0 }, 0, 0}}, |
Eric Laurent | f3af740 | 2009-05-05 00:49:01 -0700 | [diff] [blame] | 175 | repeatCnt: 7, |
| 176 | repeatSegment: 0 }, // TONE_SUP_CONGESTION_ABBREV |
David Krause | b6d90ca | 2009-06-17 15:46:13 -0500 | [diff] [blame] | 177 | { segments: { { duration: 100, waveFreq: { 350, 440, 0 }, 0, 0 }, |
| 178 | { duration: 100, waveFreq: { 0 }, 0, 0 }, |
| 179 | { duration: 0 , waveFreq: { 0 }, 0, 0}}, |
Eric Laurent | f3af740 | 2009-05-05 00:49:01 -0700 | [diff] [blame] | 180 | repeatCnt: 2, |
| 181 | repeatSegment: 0 }, // TONE_SUP_CONFIRM |
David Krause | b6d90ca | 2009-06-17 15:46:13 -0500 | [diff] [blame] | 182 | { segments: { { duration: 100, waveFreq: { 480, 0 }, 0, 0 }, |
| 183 | { duration: 100, waveFreq: { 0 }, 0, 0 }, |
| 184 | { duration: 0 , waveFreq: { 0 }, 0, 0}}, |
Eric Laurent | f3af740 | 2009-05-05 00:49:01 -0700 | [diff] [blame] | 185 | repeatCnt: 3, |
| 186 | repeatSegment: 0 }, // TONE_SUP_PIP |
David Krause | b6d90ca | 2009-06-17 15:46:13 -0500 | [diff] [blame] | 187 | { segments: {{ duration: ToneGenerator::TONEGEN_INF, waveFreq: { 425, 0 }, 0, 0}, |
| 188 | { duration: 0 , waveFreq: { 0 }, 0, 0}}, |
| 189 | repeatCnt: ToneGenerator::TONEGEN_INF, |
| 190 | repeatSegment: 0 }, // TONE_CDMA_DIAL_TONE_LITE |
| 191 | { segments: { { duration: 2000, waveFreq: { 440, 480, 0 }, 0, 0 }, |
| 192 | { duration: 4000, waveFreq: { 0 }, 0, 0 }, |
| 193 | { duration: 0 , waveFreq: { 0 }, 0, 0}}, |
| 194 | repeatCnt: ToneGenerator::TONEGEN_INF, |
| 195 | repeatSegment: 0 }, // TONE_CDMA_NETWORK_USA_RINGBACK |
| 196 | { segments: { { duration: 250, waveFreq: { 440, 0 }, 0, 0 }, |
| 197 | { duration: 250, waveFreq: { 620, 0 }, 0, 0 }, |
| 198 | { duration: 0 , waveFreq: { 0 }, 0, 0}}, |
| 199 | repeatCnt: ToneGenerator::TONEGEN_INF, |
| 200 | repeatSegment: 0 }, // TONE_CDMA_INTERCEPT |
| 201 | { segments: { { duration: 250, waveFreq: { 440, 0 }, 0, 0 }, |
| 202 | { duration: 250, waveFreq: { 620, 0 }, 0, 0 }, |
| 203 | { duration: 0 , waveFreq: { 0 }, 0, 0}}, |
| 204 | repeatCnt: 0, |
| 205 | repeatSegment: 0 }, // TONE_CDMA_ABBR_INTERCEPT |
| 206 | { segments: { { duration: 250, waveFreq: { 480, 620, 0 }, 0, 0 }, |
| 207 | { duration: 250, waveFreq: { 0 }, 0, 0 }, |
| 208 | { duration: 0 , waveFreq: { 0 }, 0, 0}}, |
| 209 | repeatCnt: ToneGenerator::TONEGEN_INF, |
| 210 | repeatSegment: 0 }, // TONE_CDMA_REORDER |
| 211 | { segments: { { duration: 250, waveFreq: { 480, 620, 0 }, 0, 0 }, |
| 212 | { duration: 250, waveFreq: { 0 }, 0, 0 }, |
| 213 | { duration: 0 , waveFreq: { 0 }, 0, 0}}, |
| 214 | repeatCnt: 7, |
| 215 | repeatSegment: 0 }, // TONE_CDMA_ABBR_REORDER |
| 216 | { segments: { { duration: 500, waveFreq: { 480, 620, 0 }, 0, 0 }, |
| 217 | { duration: 500, waveFreq: { 0 }, 0, 0 }, |
| 218 | { duration: 0 , waveFreq: { 0 }, 0, 0}}, |
| 219 | repeatCnt: ToneGenerator::TONEGEN_INF, |
| 220 | repeatSegment: 0 }, // TONE_CDMA_NETWORK_BUSY |
| 221 | { segments: { { duration: 100, waveFreq: { 350, 440, 0 }, 0, 0 }, |
| 222 | { duration: 100, waveFreq: { 0 }, 0, 0 }, |
| 223 | { duration: 0 , waveFreq: { 0 }, 0, 0}}, |
| 224 | repeatCnt: 2, |
| 225 | repeatSegment: 0 }, // TONE_CDMA_CONFIRM |
Naveen Kalla | 6c84d73 | 2009-10-13 15:29:47 -0700 | [diff] [blame] | 226 | { segments: { { duration: 500, waveFreq: { 660, 1000, 0 }, 0, 0 }, |
| 227 | { duration: 0 , waveFreq: { 0 }, 0, 0}}, |
David Krause | b6d90ca | 2009-06-17 15:46:13 -0500 | [diff] [blame] | 228 | repeatCnt: 0, |
| 229 | repeatSegment: 0 }, // TONE_CDMA_ANSWER |
| 230 | { segments: { { duration: 300, waveFreq: { 440, 0 }, 0, 0 }, |
| 231 | { duration: 0 , waveFreq: { 0 }, 0, 0}}, |
| 232 | repeatCnt: 0, |
| 233 | repeatSegment: 0 }, // TONE_CDMA_NETWORK_CALLWAITING |
| 234 | { segments: { { duration: 100, waveFreq: { 480, 0 }, 0, 0 }, |
| 235 | { duration: 100, waveFreq: { 0 }, 0, 0 }, |
| 236 | { duration: 0 , waveFreq: { 0 }, 0, 0}}, |
| 237 | repeatCnt: 3, |
| 238 | repeatSegment: 0 }, // TONE_CDMA_PIP |
| 239 | |
| 240 | { segments: { { duration: 32, waveFreq: { 2091, 0}, 0, 0 }, |
| 241 | { duration: 64, waveFreq: { 2556, 0}, 19, 0}, |
| 242 | { duration: 32, waveFreq: { 2091, 0}, 0, 0}, |
| 243 | { duration: 48, waveFreq: { 2556, 0}, 0, 0}, |
| 244 | { duration: 4000, waveFreq: { 0 }, 0, 0}, |
| 245 | { duration: 0, waveFreq: { 0 }, 0, 0}}, |
| 246 | repeatCnt: 0, |
| 247 | repeatSegment: 0 }, // TONE_CDMA_CALL_SIGNAL_ISDN_NORMAL |
| 248 | { segments: { { duration: 32, waveFreq: { 2091, 0}, 0, 0 }, |
| 249 | { duration: 64, waveFreq: { 2556, 0}, 7, 0 }, |
| 250 | { duration: 32, waveFreq: { 2091, 0}, 0, 0 }, |
| 251 | { duration: 400, waveFreq: { 0 }, 0, 0 }, |
| 252 | { duration: 32, waveFreq: { 2091, 0}, 0, 0 }, |
| 253 | { duration: 64, waveFreq: { 2556, 0}, 7, 4 }, |
| 254 | { duration: 32, waveFreq: { 2091, 0}, 0, 0 }, |
| 255 | { duration: 4000, waveFreq: { 0 }, 0, 0 }, |
| 256 | { duration: 0, waveFreq: { 0 }, 0, 0 } }, |
| 257 | repeatCnt: 0, |
| 258 | repeatSegment: 0 }, // TONE_CDMA_CALL_SIGNAL_ISDN_INTERGROUP |
| 259 | { segments: { { duration: 32, waveFreq: { 2091, 0}, 0, 0 }, |
| 260 | { duration: 64, waveFreq: { 2556, 0}, 3, 0 }, |
| 261 | { duration: 16, waveFreq: { 2091, 0}, 0, 0 }, |
| 262 | { duration: 200, waveFreq: { 0 }, 0, 0 }, |
| 263 | { duration: 32, waveFreq: { 2091, 0}, 0, 0 }, |
| 264 | { duration: 64, waveFreq: { 2556, 0}, 3, 4 }, |
| 265 | { duration: 16, waveFreq: { 2091, 0}, 0, 0 }, |
| 266 | { duration: 200, waveFreq: { 0 }, 0, 0 }, |
| 267 | { duration: 0, waveFreq: { 0 }, 0, 0 } }, |
| 268 | repeatCnt: 0, |
| 269 | repeatSegment: 0 }, // TONE_CDMA_CALL_SIGNAL_ISDN_SP_PRI |
| 270 | { segments: { { duration: 0, waveFreq: { 0 }, 0, 0} }, |
| 271 | repeatCnt: 0, |
| 272 | repeatSegment: 0 }, // TONE_CDMA_CALL_SIGNAL_ISDN_PAT3 |
| 273 | { segments: { { duration: 32, waveFreq: { 2091, 0 }, 0, 0 }, |
| 274 | { duration: 64, waveFreq: { 2556, 0 }, 4, 0 }, |
| 275 | { duration: 20, waveFreq: { 2091, 0 }, 0, 0 }, |
| 276 | { duration: 0, waveFreq: { 0 } , 0, 0 } }, |
| 277 | repeatCnt: 0, |
| 278 | repeatSegment: 0 }, // TONE_CDMA_CALL_SIGNAL_ISDN_PING_RING |
| 279 | { segments: { { duration: 0, waveFreq: { 0 }, 0, 0} }, |
| 280 | repeatCnt: 0, |
| 281 | repeatSegment: 0 }, // TONE_CDMA_CALL_SIGNAL_ISDN_PAT5 |
| 282 | { segments: { { duration: 0, waveFreq: { 0 }, 0, 0} }, |
| 283 | repeatCnt: 0, |
| 284 | repeatSegment: 0 }, // TONE_CDMA_CALL_SIGNAL_ISDN_PAT6 |
| 285 | { segments: { { duration: 0, waveFreq: { 0 }, 0, 0} }, |
| 286 | repeatCnt: 0, |
| 287 | repeatSegment: 0 }, // TONE_CDMA_CALL_SIGNAL_ISDN_PAT7 |
| 288 | |
| 289 | { segments: { { duration: 25, waveFreq: { 3700, 0 }, 0, 0 }, |
| 290 | { duration: 25, waveFreq: { 4000, 0 }, 39, 0 }, |
| 291 | { duration: 4000, waveFreq: { 0 }, 0, 0 }, |
| 292 | { duration: 0, waveFreq: { 0 }, 0, 0 } }, |
| 293 | repeatCnt: ToneGenerator::TONEGEN_INF, |
| 294 | repeatSegment: 0 }, // TONE_CDMA_HIGH_L |
| 295 | { segments: { { duration: 25, waveFreq: { 2600, 0 }, 0, 0 }, |
| 296 | { duration: 25, waveFreq: { 2900, 0 }, 39, 0 }, |
| 297 | { duration: 4000, waveFreq: { 0 }, 0, 0 }, |
| 298 | { duration: 0, waveFreq: { 0 }, 0, 0 } }, |
| 299 | repeatCnt: ToneGenerator::TONEGEN_INF, |
| 300 | repeatSegment: 0 }, // TONE_CDMA_MED_L |
| 301 | { segments: { { duration: 25, waveFreq: { 1300, 0 }, 0, 0 }, |
| 302 | { duration: 25, waveFreq: { 1450, 0 }, 39, 0 }, |
| 303 | { duration: 4000, waveFreq: { 0 }, 0, 0 }, |
| 304 | { duration: 0, waveFreq: { 0 }, 0, 0 } }, |
| 305 | repeatCnt: ToneGenerator::TONEGEN_INF, |
| 306 | repeatSegment: 0 }, // TONE_CDMA_LOW_L |
| 307 | { segments: { { duration: 25, waveFreq: { 3700, 0 }, 0, 0 }, |
| 308 | { duration: 25, waveFreq: { 4000, 0 }, 15, 0 }, |
| 309 | { duration: 400, waveFreq: { 0 }, 0, 0 }, |
| 310 | { duration: 0, waveFreq: { 0 }, 0, 0 } }, |
| 311 | repeatCnt: ToneGenerator::TONEGEN_INF, |
| 312 | repeatSegment: 0 }, // TONE_CDMA_HIGH_SS |
| 313 | { segments: { { duration: 25, waveFreq: { 2600, 0 }, 0, 0 }, |
| 314 | { duration: 25, waveFreq: { 2900, 0 }, 15, 0 }, |
| 315 | { duration: 400, waveFreq: { 0 }, 0, 0 }, |
| 316 | { duration: 0, waveFreq: { 0 }, 0, 0 }}, |
| 317 | repeatCnt: ToneGenerator::TONEGEN_INF, |
| 318 | repeatSegment: 0 }, // TONE_CDMA_MED_SS |
| 319 | { segments: { { duration: 25, waveFreq: { 1300, 0 }, 0, 0 }, |
| 320 | { duration: 25, waveFreq: { 1450, 0 }, 15, 0 }, |
| 321 | { duration: 400, waveFreq: { 0 }, 0, 0 }, |
| 322 | { duration: 0, waveFreq: { 0 }, 0, 0 }}, |
| 323 | repeatCnt: ToneGenerator::TONEGEN_INF, |
| 324 | repeatSegment: 0 }, // TONE_CDMA_LOW_SS |
| 325 | { segments: { { duration: 25, waveFreq: { 3700, 0 }, 0, 0 }, |
| 326 | { duration: 25, waveFreq: { 4000, 0 }, 7, 0 }, |
| 327 | { duration: 200, waveFreq: { 0 }, 0, 0 }, |
| 328 | { duration: 25, waveFreq: { 3700, 0 }, 0, 0 }, |
| 329 | { duration: 25, waveFreq: { 4000, 0 }, 7, 3 }, |
| 330 | { duration: 200, waveFreq: { 0 }, 0, 0 }, |
| 331 | { duration: 25, waveFreq: { 3700, 0 }, 0, 0 }, |
| 332 | { duration: 25, waveFreq: { 4000, 0 }, 15, 6 }, |
| 333 | { duration: 4000, waveFreq: { 0 }, 0, 0 }, |
| 334 | { duration: 0, waveFreq: { 0 }, 0, 0 }}, |
| 335 | repeatCnt: ToneGenerator::TONEGEN_INF, |
| 336 | repeatSegment: 0 }, // TONE_CDMA_HIGH_SSL |
| 337 | { segments: { { duration: 25, waveFreq: { 2600, 0 }, 0, 0 }, |
| 338 | { duration: 25, waveFreq: { 2900, 0 }, 7, 0 }, |
| 339 | { duration: 200, waveFreq: { 0 }, 0, 0 }, |
| 340 | { duration: 25, waveFreq: { 2600, 0 }, 0, 0 }, |
| 341 | { duration: 25, waveFreq: { 2900, 0 }, 7, 3 }, |
| 342 | { duration: 200, waveFreq: { 0 }, 0, 0 }, |
| 343 | { duration: 25, waveFreq: { 2600, 0 }, 0, 0 }, |
| 344 | { duration: 25, waveFreq: { 2900, 0 }, 15, 6 }, |
| 345 | { duration: 4000, waveFreq: { 0 }, 0, 0 }, |
| 346 | { duration: 0, waveFreq: { 0 }, 0, 0 }}, |
| 347 | repeatCnt: ToneGenerator::TONEGEN_INF, |
| 348 | repeatSegment: 0 }, // TONE_CDMA_MED_SSL |
| 349 | { segments: { { duration: 25, waveFreq: { 1300, 0 }, 0, 0 }, |
| 350 | { duration: 25, waveFreq: { 1450, 0 }, 7, 0 }, |
| 351 | { duration: 200, waveFreq: { 0 }, 0, 0 }, |
| 352 | { duration: 25, waveFreq: { 1300, 0 }, 0, 0 }, |
| 353 | { duration: 25, waveFreq: { 1450, 0 }, 7, 3 }, |
| 354 | { duration: 200, waveFreq: { 0 }, 0, 0 }, |
| 355 | { duration: 25, waveFreq: { 1300, 0 }, 0, 0 }, |
| 356 | { duration: 25, waveFreq: { 1450, 0 }, 15, 6 }, |
| 357 | { duration: 4000, waveFreq: { 0 }, 0, 0 }, |
| 358 | { duration: 0, waveFreq: { 0 }, 0, 0 }}, |
| 359 | repeatCnt: ToneGenerator::TONEGEN_INF, |
| 360 | repeatSegment: 0 }, // TONE_CDMA_LOW_SSL |
| 361 | { segments: { { duration: 25, waveFreq: { 3700, 0 }, 0, 0 }, |
| 362 | { duration: 25, waveFreq: { 4000, 0 }, 19, 0 }, |
| 363 | { duration: 1000, waveFreq: { 0 }, 0, 0 }, |
| 364 | { duration: 25, waveFreq: { 3700, 0 }, 0, 0 }, |
| 365 | { duration: 25, waveFreq: { 4000, 0 }, 19, 3 }, |
| 366 | { duration: 3000, waveFreq: { 0 }, 0, 0 }, |
| 367 | { duration: 0, waveFreq: { 0 }, 0, 0 }}, |
| 368 | repeatCnt: ToneGenerator::TONEGEN_INF, |
| 369 | repeatSegment: 0 }, // TONE_CDMA_HIGH_SS_2 |
| 370 | { segments: { { duration: 25, waveFreq: { 2600, 0 }, 0, 0 }, |
| 371 | { duration: 25, waveFreq: { 2900, 0 }, 19, 0 }, |
| 372 | { duration: 1000, waveFreq: { 0 }, 0, 0 }, |
| 373 | { duration: 25, waveFreq: { 2600, 0 }, 0, 0 }, |
| 374 | { duration: 25, waveFreq: { 2900, 0 }, 19, 3 }, |
| 375 | { duration: 3000, waveFreq: { 0 }, 0, 0 }, |
| 376 | { duration: 0, waveFreq: { 0 }, 0, 0 }}, |
| 377 | repeatCnt: ToneGenerator::TONEGEN_INF, |
| 378 | repeatSegment: 0 }, // TONE_CDMA_MED_SS_2 |
| 379 | { segments: { { duration: 25, waveFreq: { 1300, 0 }, 0, 0 }, |
| 380 | { duration: 25, waveFreq: { 1450, 0 }, 19, 0 }, |
| 381 | { duration: 1000, waveFreq: { 0 }, 0, 0 }, |
| 382 | { duration: 25, waveFreq: { 1300, 0 }, 0, 0 }, |
| 383 | { duration: 25, waveFreq: { 1450, 0 }, 19, 3 }, |
| 384 | { duration: 3000, waveFreq: { 0 }, 0, 0 }, |
| 385 | { duration: 0, waveFreq: { 0 }, 0, 0 }}, |
| 386 | repeatCnt: ToneGenerator::TONEGEN_INF, |
| 387 | repeatSegment: 0 }, // TONE_CDMA_LOW_SS_2 |
| 388 | { segments: { { duration: 25, waveFreq: { 3700, 0 }, 0, 0 }, |
| 389 | { duration: 25, waveFreq: { 4000, 0 }, 9, 0 }, |
| 390 | { duration: 500, waveFreq: { 0 }, 0, 0 }, |
| 391 | { duration: 25, waveFreq: { 3700, 0 }, 0, 0 }, |
| 392 | { duration: 25, waveFreq: { 4000, 0 }, 19, 3 }, |
| 393 | { duration: 500, waveFreq: { 0 }, 0, 0 }, |
| 394 | { duration: 25, waveFreq: { 3700, 0 }, 0, 0 }, |
| 395 | { duration: 25, waveFreq: { 4000, 0 }, 9, 6 }, |
| 396 | { duration: 3000, waveFreq: { 0 }, 0, 0 }, |
| 397 | { duration: 0, waveFreq: { 0 }, 0, 0 }}, |
| 398 | repeatCnt: ToneGenerator::TONEGEN_INF, |
| 399 | repeatSegment: 0 }, // TONE_CDMA_HIGH_SLS |
| 400 | { segments: { { duration: 25, waveFreq: { 2600, 0 }, 0, 0 }, |
| 401 | { duration: 25, waveFreq: { 2900, 0 }, 9, 0 }, |
| 402 | { duration: 500, waveFreq: { 0 }, 0, 0 }, |
| 403 | { duration: 25, waveFreq: { 2600, 0 }, 0, 0 }, |
| 404 | { duration: 25, waveFreq: { 2900, 0 }, 19, 3 }, |
| 405 | { duration: 500, waveFreq: { 0 }, 0, 0 }, |
| 406 | { duration: 25, waveFreq: { 2600, 0 }, 0, 0 }, |
| 407 | { duration: 25, waveFreq: { 2900, 0 }, 9, 6 }, |
| 408 | { duration: 3000, waveFreq: { 0 }, 0, 0 }, |
| 409 | { duration: 0, waveFreq: { 0 }, 0, 0 }}, |
| 410 | repeatCnt: ToneGenerator::TONEGEN_INF, |
| 411 | repeatSegment: 0 }, // TONE_CDMA_MED_SLS |
| 412 | { segments: { { duration: 25, waveFreq: { 1300, 0 }, 0, 0 }, |
| 413 | { duration: 25, waveFreq: { 1450, 0 }, 9, 0 }, |
| 414 | { duration: 500, waveFreq: { 0 }, 0, 0 }, |
| 415 | { duration: 25, waveFreq: { 1300, 0 }, 0, 0 }, |
| 416 | { duration: 25, waveFreq: { 1450, 0 }, 19, 3 }, |
| 417 | { duration: 500, waveFreq: { 0 }, 0, 0 }, |
| 418 | { duration: 25, waveFreq: { 1300, 0 }, 0, 0 }, |
| 419 | { duration: 25, waveFreq: { 1450, 0 }, 9, 6 }, |
| 420 | { duration: 3000, waveFreq: { 0 }, 0, 0 }, |
| 421 | { duration: 0, waveFreq: { 0 }, 0, 0 }}, |
| 422 | repeatCnt: ToneGenerator::TONEGEN_INF, |
| 423 | repeatSegment: 0 }, // TONE_CDMA_LOW_SLS |
| 424 | { segments: { { duration: 25, waveFreq: { 3700, 0 }, 0, 0 }, |
| 425 | { duration: 25, waveFreq: { 4000, 0 }, 9, 0 }, |
| 426 | { duration: 500, waveFreq: { 0 }, 0, 0 }, |
| 427 | { duration: 25, waveFreq: { 3700, 0 }, 0, 0 }, |
| 428 | { duration: 25, waveFreq: { 4000, 0 }, 9, 3 }, |
| 429 | { duration: 500, waveFreq: { 0 }, 0, 0 }, |
| 430 | { duration: 25, waveFreq: { 3700, 0 }, 0, 0 }, |
| 431 | { duration: 25, waveFreq: { 4000, 0 }, 9, 6 }, |
| 432 | { duration: 500, waveFreq: { 0 }, 0, 0 }, |
| 433 | { duration: 25, waveFreq: { 3700, 0 }, 0, 0 }, |
| 434 | { duration: 25, waveFreq: { 4000, 0 }, 9, 9 }, |
| 435 | { duration: 2500, waveFreq: { 0 }, 0, 0 }, |
| 436 | { duration: 0, waveFreq: { 0 }, 0, 0 }}, |
| 437 | repeatCnt: ToneGenerator::TONEGEN_INF, |
| 438 | repeatSegment: 0 }, // TONE_CDMA_HIGH_S_X4 |
| 439 | { segments: { { duration: 25, waveFreq: { 2600, 0 }, 0, 0 }, |
| 440 | { duration: 25, waveFreq: { 2900, 0 }, 9, 0 }, |
| 441 | { duration: 500, waveFreq: { 0 }, 0, 0 }, |
| 442 | { duration: 25, waveFreq: { 2600, 0 }, 0, 0 }, |
| 443 | { duration: 25, waveFreq: { 2900, 0 }, 9, 3 }, |
| 444 | { duration: 500, waveFreq: { 0 }, 0, 0 }, |
| 445 | { duration: 25, waveFreq: { 2600, 0 }, 0, 0 }, |
| 446 | { duration: 25, waveFreq: { 2900, 0 }, 9, 6 }, |
| 447 | { duration: 500, waveFreq: { 0 }, 0, 0 }, |
| 448 | { duration: 25, waveFreq: { 2600, 0 }, 0, 0 }, |
| 449 | { duration: 25, waveFreq: { 2900, 0 }, 9, 9 }, |
| 450 | { duration: 2500, waveFreq: { 0 }, 0, 0 }, |
| 451 | { duration: 0, waveFreq: { 0 }, 0, 0 }}, |
| 452 | repeatCnt: ToneGenerator::TONEGEN_INF, |
| 453 | repeatSegment: 0 }, // TONE_CDMA_MED_S_X4 |
| 454 | { segments: { { duration: 25, waveFreq: { 1300, 0 }, 0, 0 }, |
| 455 | { duration: 25, waveFreq: { 1450, 0 }, 9, 0 }, |
| 456 | { duration: 500, waveFreq: { 0 }, 0, 0 }, |
| 457 | { duration: 25, waveFreq: { 1300, 0 }, 0, 0 }, |
| 458 | { duration: 25, waveFreq: { 1450, 0 }, 9, 3 }, |
| 459 | { duration: 500, waveFreq: { 0 }, 0, 0 }, |
| 460 | { duration: 25, waveFreq: { 1300, 0 }, 0, 0 }, |
| 461 | { duration: 25, waveFreq: { 1450, 0 }, 9, 6 }, |
| 462 | { duration: 500, waveFreq: { 0 }, 0, 0 }, |
| 463 | { duration: 25, waveFreq: { 1300, 0 }, 0, 0 }, |
| 464 | { duration: 25, waveFreq: { 1450, 0 }, 9, 9 }, |
| 465 | { duration: 2500, waveFreq: { 0 }, 0, 0 }, |
| 466 | { duration: 0, waveFreq: { 0 }, 0, 0 }}, |
| 467 | repeatCnt: ToneGenerator::TONEGEN_INF, |
| 468 | repeatSegment: 0 }, // TONE_CDMA_LOW_S_X4 |
| 469 | { segments: { { duration: 25, waveFreq: { 3700, 0 }, 0, 0 }, |
| 470 | { duration: 25, waveFreq: { 4000, 0 }, 19, 0 }, |
| 471 | { duration: 2000, waveFreq: { 0 }, 0, 0 }, |
| 472 | { duration: 0, waveFreq: { 0 }, 0, 0 }}, |
| 473 | repeatCnt: ToneGenerator::TONEGEN_INF, |
| 474 | repeatSegment: 0 }, // TONE_CDMA_HIGH_PBX_L |
| 475 | { segments: { { duration: 25, waveFreq: { 2600, 0 }, 0, 0 }, |
| 476 | { duration: 25, waveFreq: { 2900, 0 }, 19, 0 }, |
| 477 | { duration: 2000, waveFreq: { 0 }, 0, 0 }, |
| 478 | { duration: 0, waveFreq: { 0 }, 0, 0 }}, |
| 479 | repeatCnt: ToneGenerator::TONEGEN_INF, |
| 480 | repeatSegment: 0 }, // TONE_CDMA_MED_PBX_L |
| 481 | { segments: { { duration: 25, waveFreq: { 1300, 0 }, 0, 0 }, |
| 482 | { duration: 25, waveFreq: { 1450, 0 }, 19, 0 }, |
| 483 | { duration: 2000, waveFreq: { 0 }, 0, 0 }, |
| 484 | { duration: 0, waveFreq: { 0 }, 0, 0 }}, |
| 485 | repeatCnt: ToneGenerator::TONEGEN_INF, |
| 486 | repeatSegment: 0 }, // TONE_CDMA_LOW_PBX_L |
| 487 | { segments: { { duration: 25, waveFreq: { 3700, 0 }, 0, 0 }, |
| 488 | { duration: 25, waveFreq: { 4000, 0 }, 7, 0 }, |
| 489 | { duration: 200, waveFreq: { 0 }, 0, 0 }, |
| 490 | { duration: 25, waveFreq: { 3700, 0 }, 0, 0 }, |
| 491 | { duration: 25, waveFreq: { 4000, 0 }, 7, 3 }, |
| 492 | { duration: 2000, waveFreq: { 0 }, 0, 0 }, |
| 493 | { duration: 0, waveFreq: { 0 }, 0, 0 }}, |
| 494 | repeatCnt: ToneGenerator::TONEGEN_INF, |
| 495 | repeatSegment: 0 }, // TONE_CDMA_HIGH_PBX_SS |
| 496 | { segments: { { duration: 25, waveFreq: { 2600, 0 }, 0, 0 }, |
| 497 | { duration: 25, waveFreq: { 2900, 0 }, 7, 0 }, |
| 498 | { duration: 200, waveFreq: { 0 }, 0, 0 }, |
| 499 | { duration: 25, waveFreq: { 2600, 0 }, 0, 0 }, |
| 500 | { duration: 25, waveFreq: { 2900, 0 }, 7, 3 }, |
| 501 | { duration: 2000, waveFreq: { 0 }, 0, 0 }, |
| 502 | { duration: 0, waveFreq: { 0 }, 0, 0 }}, |
| 503 | repeatCnt: ToneGenerator::TONEGEN_INF, |
| 504 | repeatSegment: 0 }, // TONE_CDMA_MED_PBX_SS |
| 505 | { segments: { { duration: 25, waveFreq: { 1300, 0 }, 0, 0 }, |
| 506 | { duration: 25, waveFreq: { 1450, 0 }, 7, 0 }, |
| 507 | { duration: 200, waveFreq: { 0 }, 0, 0 }, |
| 508 | { duration: 25, waveFreq: { 1300, 0 }, 0, 0 }, |
| 509 | { duration: 25, waveFreq: { 1450, 0 }, 7, 3 }, |
| 510 | { duration: 2000, waveFreq: { 0 }, 0, 0 }, |
| 511 | { duration: 0, waveFreq: { 0 }, 0, 0 }}, |
| 512 | repeatCnt: ToneGenerator::TONEGEN_INF, |
| 513 | repeatSegment: 0 }, // TONE_CDMA_LOW_PBX_SS |
| 514 | { segments: { { duration: 25, waveFreq: { 3700, 0 }, 0, 0 }, |
| 515 | { duration: 25, waveFreq: { 4000, 0 }, 7, 0 }, |
| 516 | { duration: 200, waveFreq: { 0 }, 0, 0 }, |
| 517 | { duration: 25, waveFreq: { 3700, 0 }, 0, 0 }, |
| 518 | { duration: 25, waveFreq: { 4000, 0 }, 7, 3 }, |
| 519 | { duration: 200, waveFreq: { 0 }, 0, 0 }, |
| 520 | { duration: 25, waveFreq: { 3700, 0 }, 0, 0 }, |
| 521 | { duration: 25, waveFreq: { 4000, 0 }, 15, 6 }, |
| 522 | { duration: 1000, waveFreq: { 0 }, 0, 0 }, |
| 523 | { duration: 0, waveFreq: { 0 }, 0, 0 }}, |
| 524 | repeatCnt: ToneGenerator::TONEGEN_INF, |
| 525 | repeatSegment: 0 }, // TONE_CDMA_HIGH_PBX_SSL |
| 526 | { segments: { { duration: 25, waveFreq: { 2600, 0 }, 0, 0 }, |
| 527 | { duration: 25, waveFreq: { 2900, 0 }, 7, 0 }, |
| 528 | { duration: 200, waveFreq: { 0 }, 0, 0 }, |
| 529 | { duration: 25, waveFreq: { 2600, 0 }, 0, 0 }, |
| 530 | { duration: 25, waveFreq: { 2900, 0 }, 7, 3 }, |
| 531 | { duration: 200, waveFreq: { 0 }, 0, 0 }, |
| 532 | { duration: 25, waveFreq: { 2600, 0 }, 0, 0 }, |
| 533 | { duration: 25, waveFreq: { 2900, 0 }, 15, 6 }, |
| 534 | { duration: 1000, waveFreq: { 0 }, 0, 0 }, |
| 535 | { duration: 0, waveFreq: { 0 }, 0, 0 }}, |
| 536 | repeatCnt: ToneGenerator::TONEGEN_INF, |
| 537 | repeatSegment: 0 }, // TONE_CDMA_MED_PBX_SSL |
| 538 | { segments: { { duration: 25, waveFreq: { 1300, 0 }, 0, 0 }, |
| 539 | { duration: 25, waveFreq: { 1450, 0 }, 7, 0 }, |
| 540 | { duration: 200, waveFreq: { 0 }, 0, 0 }, |
| 541 | { duration: 25, waveFreq: { 1300, 0 }, 0, 0 }, |
| 542 | { duration: 25, waveFreq: { 1450, 0 }, 7, 3 }, |
| 543 | { duration: 200, waveFreq: { 0 }, 0, 0 }, |
| 544 | { duration: 25, waveFreq: { 1300, 0 }, 0, 0 }, |
| 545 | { duration: 25, waveFreq: { 1450, 0 }, 15, 6 }, |
| 546 | { duration: 1000, waveFreq: { 0 }, 0, 0 }, |
| 547 | { duration: 0, waveFreq: { 0 }, 0, 0 }}, |
| 548 | repeatCnt: ToneGenerator::TONEGEN_INF, |
| 549 | repeatSegment: 0 }, // TONE_CDMA_LOW_PBX_SSL |
| 550 | { segments: { { duration: 25, waveFreq: { 3700, 0 }, 0, 0 }, |
| 551 | { duration: 25, waveFreq: { 4000, 0 }, 7, 0 }, |
| 552 | { duration: 200, waveFreq: { 0 }, 0, 0 }, |
| 553 | { duration: 25, waveFreq: { 3700, 0 }, 0, 0 }, |
| 554 | { duration: 25, waveFreq: { 4000, 0 }, 15, 3 }, |
| 555 | { duration: 200, waveFreq: { 0 }, 0, 0 }, |
| 556 | { duration: 25, waveFreq: { 3700, 0 }, 0, 0 }, |
| 557 | { duration: 25, waveFreq: { 4000, 0 }, 7, 6 }, |
| 558 | { duration: 1000, waveFreq: { 0 }, 0, 0 }, |
| 559 | { duration: 0, waveFreq: { 0 }, 0, 0 }}, |
| 560 | repeatCnt: ToneGenerator::TONEGEN_INF, |
| 561 | repeatSegment: 0 }, // TONE_CDMA_HIGH_PBX_SLS |
| 562 | { segments: { { duration: 25, waveFreq: { 2600, 0 }, 0, 0 }, |
| 563 | { duration: 25, waveFreq: { 2900, 0 }, 7, 0 }, |
| 564 | { duration: 200, waveFreq: { 0 }, 0, 0 }, |
| 565 | { duration: 25, waveFreq: { 2600, 0 }, 0, 0 }, |
| 566 | { duration: 25, waveFreq: { 2900, 0 }, 15, 3 }, |
| 567 | { duration: 200, waveFreq: { 0 }, 0, 0 }, |
| 568 | { duration: 25, waveFreq: { 2600, 0 }, 0, 0 }, |
| 569 | { duration: 25, waveFreq: { 2900, 0 }, 7, 6 }, |
| 570 | { duration: 1000, waveFreq: { 0 }, 0, 0 }, |
| 571 | { duration: 0, waveFreq: { 0 }, 0, 0 }}, |
| 572 | repeatCnt: ToneGenerator::TONEGEN_INF, |
| 573 | repeatSegment: 0 }, // TONE_CDMA_MED_PBX_SLS |
| 574 | { segments: { { duration: 25, waveFreq: { 1300, 0 }, 0, 0 }, |
| 575 | { duration: 25, waveFreq: { 1450, 0 }, 7, 0 }, |
| 576 | { duration: 200, waveFreq: { 0 }, 0, 0 }, |
| 577 | { duration: 25, waveFreq: { 1300, 0 }, 0, 0 }, |
| 578 | { duration: 25, waveFreq: { 1450, 0 }, 15, 3 }, |
| 579 | { duration: 200, waveFreq: { 0 }, 0, 0 }, |
| 580 | { duration: 25, waveFreq: { 1300, 0 }, 0, 0 }, |
| 581 | { duration: 25, waveFreq: { 1450, 0 }, 7, 6 }, |
| 582 | { duration: 1000, waveFreq: { 0 }, 0, 0 }, |
| 583 | { duration: 0, waveFreq: { 0 }, 0, 0 }}, |
| 584 | repeatCnt: ToneGenerator::TONEGEN_INF, |
| 585 | repeatSegment: 0 }, // TONE_CDMA_LOW_PBX_SLS |
| 586 | { segments: { { duration: 25, waveFreq: { 3700, 0 }, 0, 0 }, |
| 587 | { duration: 25, waveFreq: { 4000, 0 }, 7, 0 }, |
| 588 | { duration: 200, waveFreq: { 0 }, 0, 0 }, |
| 589 | { duration: 25, waveFreq: { 3700, 0 }, 0, 0 }, |
| 590 | { duration: 25, waveFreq: { 4000, 0 }, 7, 3 }, |
| 591 | { duration: 200, waveFreq: { 0 }, 0, 0 }, |
| 592 | { duration: 25, waveFreq: { 3700, 0 }, 0, 0 }, |
| 593 | { duration: 25, waveFreq: { 4000, 0 }, 7, 6 }, |
| 594 | { duration: 200, waveFreq: { 0 }, 0, 0 }, |
| 595 | { duration: 25, waveFreq: { 3700, 0 }, 0, 0 }, |
| 596 | { duration: 25, waveFreq: { 4000, 0 }, 7, 9 }, |
| 597 | { duration: 800, waveFreq: { 0 }, 0, 0 }, |
| 598 | { duration: 0, waveFreq: { 0 }, 0, 0 }}, |
| 599 | repeatCnt: ToneGenerator::TONEGEN_INF, |
| 600 | repeatSegment: 0 }, // TONE_CDMA_HIGH_PBX_S_X4 |
| 601 | { segments: { { duration: 25, waveFreq: { 2600, 0 }, 0, 0 }, |
| 602 | { duration: 25, waveFreq: { 2900, 0 }, 7, 0 }, |
| 603 | { duration: 200, waveFreq: { 0 }, 0, 0 }, |
| 604 | { duration: 25, waveFreq: { 2600, 0 }, 0, 0 }, |
| 605 | { duration: 25, waveFreq: { 2900, 0 }, 7, 3 }, |
| 606 | { duration: 200, waveFreq: { 0 }, 0, 0 }, |
| 607 | { duration: 25, waveFreq: { 2600, 0 }, 0, 0 }, |
| 608 | { duration: 25, waveFreq: { 2900, 0 }, 7, 6 }, |
| 609 | { duration: 200, waveFreq: { 0 }, 0, 0 }, |
| 610 | { duration: 25, waveFreq: { 2600, 0 }, 0, 0 }, |
| 611 | { duration: 25, waveFreq: { 2900, 0 }, 7, 9 }, |
| 612 | { duration: 800, waveFreq: { 0 }, 0, 0 }, |
| 613 | { duration: 0, waveFreq: { 0 }, 0, 0 }}, |
| 614 | repeatCnt: ToneGenerator::TONEGEN_INF, |
| 615 | repeatSegment: 0 }, // TONE_CDMA_MED_PBX_S_X4 |
| 616 | { segments: { { duration: 25, waveFreq: { 1300, 0 }, 0, 0 }, |
| 617 | { duration: 25, waveFreq: { 1450, 0 }, 7, 0 }, |
| 618 | { duration: 200, waveFreq: { 0 }, 0, 0 }, |
| 619 | { duration: 25, waveFreq: { 1300, 0 }, 0, 0 }, |
| 620 | { duration: 25, waveFreq: { 1450, 0 }, 7, 3 }, |
| 621 | { duration: 200, waveFreq: { 0 }, 0, 0 }, |
| 622 | { duration: 25, waveFreq: { 1300, 0 }, 0, 0 }, |
| 623 | { duration: 25, waveFreq: { 1450, 0 }, 7, 6 }, |
| 624 | { duration: 200, waveFreq: { 0 }, 0, 0 }, |
| 625 | { duration: 25, waveFreq: { 1300, 0 }, 0, 0 }, |
| 626 | { duration: 25, waveFreq: { 1450, 0 }, 7, 9 }, |
| 627 | { duration: 800, waveFreq: { 0 }, 0, 0 }, |
| 628 | { duration: 0, waveFreq: { 0 }, 0, 0 }}, |
| 629 | repeatCnt: ToneGenerator::TONEGEN_INF, |
| 630 | repeatSegment: 0 }, // TONE_CDMA_LOW_PBX_S_X4 |
| 631 | |
| 632 | { segments: { { duration: 62, waveFreq: { 1109, 0 }, 0, 0 }, |
| 633 | { duration: 62, waveFreq: { 784, 0 }, 0, 0 }, |
| 634 | { duration: 62, waveFreq: { 740, 0 }, 0, 0 }, |
| 635 | { duration: 62, waveFreq: { 622, 0 }, 0, 0 }, |
| 636 | { duration: 62, waveFreq: { 1109, 0 }, 0, 0 }, |
| 637 | { duration: 0, waveFreq: { 0 }, 0, 0 } }, |
| 638 | repeatCnt: 0, |
| 639 | repeatSegment: 0 }, // TONE_CDMA_ALERT_NETWORK_LITE |
| 640 | { segments: { { duration: 62, waveFreq: { 1245, 0 }, 0, 0 }, |
| 641 | { duration: 62, waveFreq: { 659, 0 }, 2, 0 }, |
| 642 | { duration: 62, waveFreq: { 1245, 0 }, 0, 0 }, |
| 643 | { duration: 0, waveFreq: { 0 }, 0, 0 } }, |
| 644 | repeatCnt: 0, |
| 645 | repeatSegment: 0 }, // TONE_CDMA_ALERT_AUTOREDIAL_LITE |
| 646 | { segments: { { duration: 400, waveFreq: { 1150, 770, 0 }, 0, 0 }, |
| 647 | { duration: 0, waveFreq: { 0 }, 0, 0 } }, |
| 648 | repeatCnt: 0, |
| 649 | repeatSegment: 0 }, // TONE_CDMA_ONE_MIN_BEEP |
| 650 | { segments: { { duration: 120, waveFreq: { 941, 1477, 0 }, 0, 0 }, |
| 651 | { duration: 0, waveFreq: { 0 }, 0, 0 } }, |
| 652 | repeatCnt: 0, |
| 653 | repeatSegment: 0 }, // TONE_CDMA_KEYPAD_VOLUME_KEY_LITE |
| 654 | { segments: { { duration: 375, waveFreq: { 587, 0 }, 0, 0 }, |
| 655 | { duration: 125, waveFreq: { 1175, 0 }, 0, 0 }, |
| 656 | { duration: 0, waveFreq: { 0 }, 0, 0 } }, |
| 657 | repeatCnt: 0, |
| 658 | repeatSegment: 0 }, // TONE_CDMA_PRESSHOLDKEY_LITE |
| 659 | { segments: { { duration: 62, waveFreq: { 587, 0 }, 0, 0 }, |
| 660 | { duration: 62, waveFreq: { 784, 0 }, 0, 0 }, |
| 661 | { duration: 62, waveFreq: { 831, 0 }, 0, 0 }, |
| 662 | { duration: 62, waveFreq: { 784, 0 }, 0, 0 }, |
| 663 | { duration: 62, waveFreq: { 1109, 0 }, 0, 0 }, |
| 664 | { duration: 62, waveFreq: { 784, 0 }, 0, 0 }, |
| 665 | { duration: 62, waveFreq: { 831, 0 }, 0, 0 }, |
| 666 | { duration: 62, waveFreq: { 784, 0 }, 0, 0 }, |
| 667 | { duration: 0, waveFreq: { 0 }, 0, 0 } }, |
| 668 | repeatCnt: 0, |
| 669 | repeatSegment: 0 }, // TONE_CDMA_ALERT_INCALL_LITE |
| 670 | { segments: { { duration: 125, waveFreq: { 941, 0 }, 0, 0 }, |
| 671 | { duration: 10, waveFreq: { 0 }, 2, 0 }, |
| 672 | { duration: 4990, waveFreq: { 0 }, 0, 0 }, |
| 673 | { duration: 0, waveFreq: { 0 }, 0, 0 } }, |
| 674 | repeatCnt: ToneGenerator::TONEGEN_INF, |
| 675 | repeatSegment: 0 }, // TONE_CDMA_EMERGENCY_RINGBACK |
| 676 | { segments: { { duration: 125, waveFreq: { 1319, 0 }, 0, 0 }, |
| 677 | { duration: 125, waveFreq: { 0 }, 0, 0 }, |
| 678 | { duration: 0, waveFreq: { 0 }, 0, 0 } }, |
| 679 | repeatCnt: 2, |
| 680 | repeatSegment: 0 }, // TONE_CDMA_ALERT_CALL_GUARD |
| 681 | { segments: { { duration: 125, waveFreq: { 1047, 0 }, 0, 0 }, |
| 682 | { duration: 125, waveFreq: { 370, 0 }, 0, 0 }, |
| 683 | { duration: 0, waveFreq: { 0 }, 0, 0 } }, |
| 684 | repeatCnt: 0, |
| 685 | repeatSegment: 0 }, // TONE_CDMA_SOFT_ERROR_LITE |
| 686 | { segments: { { duration: 125, waveFreq: { 1480, 0 }, 0, 0 }, |
| 687 | { duration: 125, waveFreq: { 1397, 0 }, 0, 0 }, |
| 688 | { duration: 125, waveFreq: { 784, 0 }, 0, 0 }, |
| 689 | { duration: 0, waveFreq: { 0 }, 0, 0 } }, |
| 690 | repeatCnt: 0, |
| 691 | repeatSegment: 0 }, // TONE_CDMA_CALLDROP_LITE |
| 692 | |
| 693 | { segments: { { duration: 500, waveFreq: { 425, 0 }, 0, 0 }, |
| 694 | { duration: 500, waveFreq: { 0 }, 0, 0 }, |
| 695 | { duration: 0, waveFreq: { 0 }, 0, 0 }}, |
| 696 | repeatCnt: 0, |
| 697 | repeatSegment: 0 }, // TONE_CDMA_NETWORK_BUSY_ONE_SHOT |
| 698 | { segments: { { duration: 400, waveFreq: { 1150, 770 }, 0, 0 }, |
| 699 | { duration: 0, waveFreq: { 0 }, 0, 0 }}, |
| 700 | repeatCnt: 0, |
| 701 | repeatSegment: 0 }, // TONE_CDMA_ABBR_ALERT |
| 702 | { segments: { { duration: 0, waveFreq: { 0 }, 0, 0 }}, |
| 703 | repeatCnt: 0, |
| 704 | repeatSegment: 0 }, // TONE_CDMA_SIGNAL_OFF |
| 705 | |
| 706 | { segments: { { duration: ToneGenerator::TONEGEN_INF, waveFreq: { 350, 440, 0 }, 0, 0 }, |
| 707 | { duration: 0 , waveFreq: { 0 }, 0, 0}}, |
Eric Laurent | f3af740 | 2009-05-05 00:49:01 -0700 | [diff] [blame] | 708 | repeatCnt: ToneGenerator::TONEGEN_INF, |
| 709 | repeatSegment: 0 }, // TONE_ANSI_DIAL |
David Krause | b6d90ca | 2009-06-17 15:46:13 -0500 | [diff] [blame] | 710 | { segments: { { duration: 500, waveFreq: { 480, 620, 0 }, 0, 0 }, |
| 711 | { duration: 500, waveFreq: { 0 }, 0, 0 }, |
| 712 | { duration: 0 , waveFreq: { 0 }, 0, 0}}, |
Eric Laurent | f3af740 | 2009-05-05 00:49:01 -0700 | [diff] [blame] | 713 | repeatCnt: ToneGenerator::TONEGEN_INF, |
| 714 | repeatSegment: 0 }, // TONE_ANSI_BUSY |
David Krause | b6d90ca | 2009-06-17 15:46:13 -0500 | [diff] [blame] | 715 | { segments: { { duration: 250, waveFreq: { 480, 620, 0 }, 0, 0 }, |
| 716 | { duration: 250, waveFreq: { 0 }, 0, 0 }, |
| 717 | { duration: 0 , waveFreq: { 0 }, 0, 0}}, |
Eric Laurent | f3af740 | 2009-05-05 00:49:01 -0700 | [diff] [blame] | 718 | repeatCnt: ToneGenerator::TONEGEN_INF, |
| 719 | repeatSegment: 0 }, // TONE_ANSI_CONGESTION |
David Krause | b6d90ca | 2009-06-17 15:46:13 -0500 | [diff] [blame] | 720 | { segments: { { duration: 300, waveFreq: { 440, 0 }, 0, 0 }, |
| 721 | { duration: 9700, waveFreq: { 0 }, 0, 0 }, |
| 722 | { duration: 100, waveFreq: { 440, 0 }, 0, 0 }, |
| 723 | { duration: 100, waveFreq: { 0 }, 0, 0 }, |
| 724 | { duration: 100, waveFreq: { 440, 0 }, 0, 0 }, |
| 725 | { duration: 0 , waveFreq: { 0 }, 0, 0}}, |
Eric Laurent | f3af740 | 2009-05-05 00:49:01 -0700 | [diff] [blame] | 726 | repeatCnt: ToneGenerator::TONEGEN_INF, |
| 727 | repeatSegment: 1 }, // TONE_ANSI_CALL_WAITING |
David Krause | b6d90ca | 2009-06-17 15:46:13 -0500 | [diff] [blame] | 728 | { segments: { { duration: 2000, waveFreq: { 440, 480, 0 }, 0, 0 }, |
| 729 | { duration: 4000, waveFreq: { 0 }, 0, 0 }, |
| 730 | { duration: 0 , waveFreq: { 0 }, 0, 0}}, |
Eric Laurent | f3af740 | 2009-05-05 00:49:01 -0700 | [diff] [blame] | 731 | repeatCnt: ToneGenerator::TONEGEN_INF, |
| 732 | repeatSegment: 0 }, // TONE_ANSI_RINGTONE |
David Krause | b6d90ca | 2009-06-17 15:46:13 -0500 | [diff] [blame] | 733 | { segments: { { duration: ToneGenerator::TONEGEN_INF, waveFreq: { 400, 0 }, 0, 0 }, |
| 734 | { duration: 0 , waveFreq: { 0 }, 0, 0}}, |
Eric Laurent | f3af740 | 2009-05-05 00:49:01 -0700 | [diff] [blame] | 735 | repeatCnt: ToneGenerator::TONEGEN_INF, |
| 736 | repeatSegment: 0 }, // TONE_JAPAN_DIAL |
David Krause | b6d90ca | 2009-06-17 15:46:13 -0500 | [diff] [blame] | 737 | { segments: { { duration: 500, waveFreq: { 400, 0 }, 0, 0 }, |
| 738 | { duration: 500, waveFreq: { 0 }, 0, 0 }, |
| 739 | { duration: 0 , waveFreq: { 0 }, 0, 0}}, |
Eric Laurent | f3af740 | 2009-05-05 00:49:01 -0700 | [diff] [blame] | 740 | repeatCnt: ToneGenerator::TONEGEN_INF, |
| 741 | repeatSegment: 0 }, // TONE_JAPAN_BUSY |
David Krause | b6d90ca | 2009-06-17 15:46:13 -0500 | [diff] [blame] | 742 | { segments: { { duration: 1000, waveFreq: { 400, 0 }, 0, 0 }, |
| 743 | { duration: 2000, waveFreq: { 0 }, 0, 0 }, |
| 744 | { duration: 0 , waveFreq: { 0 }, 0, 0}}, |
Eric Laurent | f3af740 | 2009-05-05 00:49:01 -0700 | [diff] [blame] | 745 | repeatCnt: ToneGenerator::TONEGEN_INF, |
| 746 | repeatSegment: 0 }, // TONE_JAPAN_RADIO_ACK |
David Krause | b6d90ca | 2009-06-17 15:46:13 -0500 | [diff] [blame] | 747 | |
| 748 | |
| 749 | |
Eric Laurent | f3af740 | 2009-05-05 00:49:01 -0700 | [diff] [blame] | 750 | }; |
| 751 | |
| 752 | // Used by ToneGenerator::getToneForRegion() to convert user specified supervisory tone type |
| 753 | // to actual tone for current region. |
| 754 | const unsigned char ToneGenerator::sToneMappingTable[NUM_REGIONS-1][NUM_SUP_TONES] = { |
| 755 | { // ANSI |
| 756 | TONE_ANSI_DIAL, // TONE_SUP_DIAL |
| 757 | TONE_ANSI_BUSY, // TONE_SUP_BUSY |
| 758 | TONE_ANSI_CONGESTION, // TONE_SUP_CONGESTION |
| 759 | TONE_SUP_RADIO_ACK, // TONE_SUP_RADIO_ACK |
| 760 | TONE_SUP_RADIO_NOTAVAIL, // TONE_SUP_RADIO_NOTAVAIL |
| 761 | TONE_SUP_ERROR, // TONE_SUP_ERROR |
| 762 | TONE_ANSI_CALL_WAITING, // TONE_SUP_CALL_WAITING |
| 763 | TONE_ANSI_RINGTONE // TONE_SUP_RINGTONE |
| 764 | }, |
| 765 | { // JAPAN |
| 766 | TONE_JAPAN_DIAL, // TONE_SUP_DIAL |
| 767 | TONE_JAPAN_BUSY, // TONE_SUP_BUSY |
| 768 | TONE_SUP_CONGESTION, // TONE_SUP_CONGESTION |
| 769 | TONE_JAPAN_RADIO_ACK, // TONE_SUP_RADIO_ACK |
| 770 | TONE_SUP_RADIO_NOTAVAIL, // TONE_SUP_RADIO_NOTAVAIL |
| 771 | TONE_SUP_ERROR, // TONE_SUP_ERROR |
| 772 | TONE_SUP_CALL_WAITING, // TONE_SUP_CALL_WAITING |
| 773 | TONE_SUP_RINGTONE // TONE_SUP_RINGTONE |
| 774 | } |
| 775 | }; |
| 776 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 777 | |
| 778 | //////////////////////////////////////////////////////////////////////////////// |
| 779 | // ToneGenerator class Implementation |
| 780 | //////////////////////////////////////////////////////////////////////////////// |
| 781 | |
| 782 | |
| 783 | //---------------------------------- public methods ---------------------------- |
| 784 | |
| 785 | |
| 786 | //////////////////////////////////////////////////////////////////////////////// |
| 787 | // |
| 788 | // Method: ToneGenerator::ToneGenerator() |
| 789 | // |
| 790 | // Description: Constructor. Initializes the tone sequencer, intantiates required sine wave |
| 791 | // generators, instantiates output audio track. |
| 792 | // |
| 793 | // Input: |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 794 | // streamType: Type of stream used for tone playback (enum AudioTrack::stream_type) |
| 795 | // volume: volume applied to tone (0.0 to 1.0) |
| 796 | // |
| 797 | // Output: |
| 798 | // none |
| 799 | // |
| 800 | //////////////////////////////////////////////////////////////////////////////// |
Eric Laurent | bda7469 | 2009-11-04 08:27:26 -0800 | [diff] [blame] | 801 | ToneGenerator::ToneGenerator(int streamType, float volume, bool threadCanCallJava) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 802 | |
Steve Block | 71f2cf1 | 2011-10-20 11:56:00 +0100 | [diff] [blame^] | 803 | ALOGV("ToneGenerator constructor: streamType=%d, volume=%f\n", streamType, volume); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 804 | |
| 805 | mState = TONE_IDLE; |
| 806 | |
| 807 | if (AudioSystem::getOutputSamplingRate(&mSamplingRate, streamType) != NO_ERROR) { |
| 808 | LOGE("Unable to marshal AudioFlinger"); |
| 809 | return; |
| 810 | } |
Eric Laurent | bda7469 | 2009-11-04 08:27:26 -0800 | [diff] [blame] | 811 | mThreadCanCallJava = threadCanCallJava; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 812 | mStreamType = streamType; |
| 813 | mVolume = volume; |
| 814 | mpAudioTrack = 0; |
| 815 | mpToneDesc = 0; |
| 816 | mpNewToneDesc = 0; |
| 817 | // Generate tone by chunks of 20 ms to keep cadencing precision |
| 818 | mProcessSize = (mSamplingRate * 20) / 1000; |
| 819 | |
Eric Laurent | f3af740 | 2009-05-05 00:49:01 -0700 | [diff] [blame] | 820 | char value[PROPERTY_VALUE_MAX]; |
| 821 | property_get("gsm.operator.iso-country", value, ""); |
| 822 | if (strcmp(value,"us") == 0 || |
| 823 | strcmp(value,"ca") == 0) { |
| 824 | mRegion = ANSI; |
| 825 | } else if (strcmp(value,"jp") == 0) { |
| 826 | mRegion = JAPAN; |
| 827 | } else { |
| 828 | mRegion = CEPT; |
| 829 | } |
| 830 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 831 | if (initAudioTrack()) { |
Steve Block | 71f2cf1 | 2011-10-20 11:56:00 +0100 | [diff] [blame^] | 832 | ALOGV("ToneGenerator INIT OK, time: %d\n", (unsigned int)(systemTime()/1000000)); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 833 | } else { |
Steve Block | 71f2cf1 | 2011-10-20 11:56:00 +0100 | [diff] [blame^] | 834 | ALOGV("!!!ToneGenerator INIT FAILED!!!\n"); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 835 | } |
| 836 | } |
| 837 | |
| 838 | |
| 839 | |
| 840 | |
| 841 | //////////////////////////////////////////////////////////////////////////////// |
| 842 | // |
| 843 | // Method: ToneGenerator::~ToneGenerator() |
| 844 | // |
| 845 | // Description: Destructor. Stop sound playback and delete audio track if |
| 846 | // needed and delete sine wave generators. |
| 847 | // |
| 848 | // Input: |
| 849 | // none |
| 850 | // |
| 851 | // Output: |
| 852 | // none |
| 853 | // |
| 854 | //////////////////////////////////////////////////////////////////////////////// |
| 855 | ToneGenerator::~ToneGenerator() { |
Steve Block | 71f2cf1 | 2011-10-20 11:56:00 +0100 | [diff] [blame^] | 856 | ALOGV("ToneGenerator destructor\n"); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 857 | |
| 858 | if (mpAudioTrack) { |
| 859 | stopTone(); |
Steve Block | 71f2cf1 | 2011-10-20 11:56:00 +0100 | [diff] [blame^] | 860 | ALOGV("Delete Track: %p\n", mpAudioTrack); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 861 | delete mpAudioTrack; |
| 862 | } |
| 863 | } |
| 864 | |
| 865 | //////////////////////////////////////////////////////////////////////////////// |
| 866 | // |
| 867 | // Method: ToneGenerator::startTone() |
| 868 | // |
| 869 | // Description: Starts tone playback. |
| 870 | // |
| 871 | // Input: |
Eric Laurent | 96c08a6 | 2009-09-07 08:38:38 -0700 | [diff] [blame] | 872 | // toneType: Type of tone generated (values in enum tone_type) |
| 873 | // durationMs: The tone duration in milliseconds. If the tone is limited in time by definition, |
| 874 | // the actual duration will be the minimum of durationMs and the defined tone duration. |
| 875 | // Ommiting or setting durationMs to -1 does not limit tone duration. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 876 | // |
| 877 | // Output: |
| 878 | // none |
| 879 | // |
| 880 | //////////////////////////////////////////////////////////////////////////////// |
Eric Laurent | 96c08a6 | 2009-09-07 08:38:38 -0700 | [diff] [blame] | 881 | bool ToneGenerator::startTone(int toneType, int durationMs) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 882 | bool lResult = false; |
Eric Laurent | 62443f5 | 2009-10-05 20:29:18 -0700 | [diff] [blame] | 883 | status_t lStatus; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 884 | |
Dave Sparks | 4c92247 | 2009-05-07 09:26:06 -0700 | [diff] [blame] | 885 | if ((toneType < 0) || (toneType >= NUM_TONES)) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 886 | return lResult; |
| 887 | |
| 888 | if (mState == TONE_IDLE) { |
Steve Block | 71f2cf1 | 2011-10-20 11:56:00 +0100 | [diff] [blame^] | 889 | ALOGV("startTone: try to re-init AudioTrack"); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 890 | if (!initAudioTrack()) { |
| 891 | return lResult; |
| 892 | } |
| 893 | } |
| 894 | |
Steve Block | 71f2cf1 | 2011-10-20 11:56:00 +0100 | [diff] [blame^] | 895 | ALOGV("startTone\n"); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 896 | |
| 897 | mLock.lock(); |
| 898 | |
| 899 | // Get descriptor for requested tone |
Eric Laurent | f3af740 | 2009-05-05 00:49:01 -0700 | [diff] [blame] | 900 | toneType = getToneForRegion(toneType); |
| 901 | mpNewToneDesc = &sToneDescriptors[toneType]; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 902 | |
Eric Laurent | 62443f5 | 2009-10-05 20:29:18 -0700 | [diff] [blame] | 903 | mDurationMs = durationMs; |
| 904 | |
| 905 | if (mState == TONE_STOPPED) { |
Steve Block | 71f2cf1 | 2011-10-20 11:56:00 +0100 | [diff] [blame^] | 906 | ALOGV("Start waiting for previous tone to stop"); |
Eric Laurent | dd28d56 | 2009-10-23 04:46:30 -0700 | [diff] [blame] | 907 | lStatus = mWaitCbkCond.waitRelative(mLock, seconds(3)); |
Eric Laurent | 62443f5 | 2009-10-05 20:29:18 -0700 | [diff] [blame] | 908 | if (lStatus != NO_ERROR) { |
| 909 | LOGE("--- start wait for stop timed out, status %d", lStatus); |
| 910 | mState = TONE_IDLE; |
Eric Laurent | dd28d56 | 2009-10-23 04:46:30 -0700 | [diff] [blame] | 911 | mLock.unlock(); |
Eric Laurent | 62443f5 | 2009-10-05 20:29:18 -0700 | [diff] [blame] | 912 | return lResult; |
Eric Laurent | 96c08a6 | 2009-09-07 08:38:38 -0700 | [diff] [blame] | 913 | } |
Eric Laurent | 96c08a6 | 2009-09-07 08:38:38 -0700 | [diff] [blame] | 914 | } |
| 915 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 916 | if (mState == TONE_INIT) { |
| 917 | if (prepareWave()) { |
Steve Block | 71f2cf1 | 2011-10-20 11:56:00 +0100 | [diff] [blame^] | 918 | ALOGV("Immediate start, time %d\n", (unsigned int)(systemTime()/1000000)); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 919 | lResult = true; |
| 920 | mState = TONE_STARTING; |
| 921 | mLock.unlock(); |
| 922 | mpAudioTrack->start(); |
| 923 | mLock.lock(); |
| 924 | if (mState == TONE_STARTING) { |
Steve Block | 71f2cf1 | 2011-10-20 11:56:00 +0100 | [diff] [blame^] | 925 | ALOGV("Wait for start callback"); |
Eric Laurent | dd28d56 | 2009-10-23 04:46:30 -0700 | [diff] [blame] | 926 | lStatus = mWaitCbkCond.waitRelative(mLock, seconds(3)); |
The Android Open Source Project | b2a3dd8 | 2009-03-09 11:52:12 -0700 | [diff] [blame] | 927 | if (lStatus != NO_ERROR) { |
| 928 | LOGE("--- Immediate start timed out, status %d", lStatus); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 929 | mState = TONE_IDLE; |
| 930 | lResult = false; |
| 931 | } |
| 932 | } |
| 933 | } else { |
Eric Laurent | c4e58c0 | 2009-08-11 01:26:35 -0700 | [diff] [blame] | 934 | mState = TONE_IDLE; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 935 | } |
| 936 | } else { |
Steve Block | 71f2cf1 | 2011-10-20 11:56:00 +0100 | [diff] [blame^] | 937 | ALOGV("Delayed start\n"); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 938 | mState = TONE_RESTARTING; |
Eric Laurent | dd28d56 | 2009-10-23 04:46:30 -0700 | [diff] [blame] | 939 | lStatus = mWaitCbkCond.waitRelative(mLock, seconds(3)); |
The Android Open Source Project | b2a3dd8 | 2009-03-09 11:52:12 -0700 | [diff] [blame] | 940 | if (lStatus == NO_ERROR) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 941 | if (mState != TONE_IDLE) { |
| 942 | lResult = true; |
| 943 | } |
Steve Block | 71f2cf1 | 2011-10-20 11:56:00 +0100 | [diff] [blame^] | 944 | ALOGV("cond received"); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 945 | } else { |
The Android Open Source Project | b2a3dd8 | 2009-03-09 11:52:12 -0700 | [diff] [blame] | 946 | LOGE("--- Delayed start timed out, status %d", lStatus); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 947 | mState = TONE_IDLE; |
| 948 | } |
| 949 | } |
| 950 | mLock.unlock(); |
| 951 | |
Steve Block | 71f2cf1 | 2011-10-20 11:56:00 +0100 | [diff] [blame^] | 952 | ALOGV_IF(lResult, "Tone started, time %d\n", (unsigned int)(systemTime()/1000000)); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 953 | LOGW_IF(!lResult, "Tone start failed!!!, time %d\n", (unsigned int)(systemTime()/1000000)); |
| 954 | |
| 955 | return lResult; |
| 956 | } |
| 957 | |
| 958 | //////////////////////////////////////////////////////////////////////////////// |
| 959 | // |
| 960 | // Method: ToneGenerator::stopTone() |
| 961 | // |
| 962 | // Description: Stops tone playback. |
| 963 | // |
| 964 | // Input: |
| 965 | // none |
| 966 | // |
| 967 | // Output: |
| 968 | // none |
| 969 | // |
| 970 | //////////////////////////////////////////////////////////////////////////////// |
| 971 | void ToneGenerator::stopTone() { |
Steve Block | 71f2cf1 | 2011-10-20 11:56:00 +0100 | [diff] [blame^] | 972 | ALOGV("stopTone"); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 973 | |
| 974 | mLock.lock(); |
| 975 | if (mState == TONE_PLAYING || mState == TONE_STARTING || mState == TONE_RESTARTING) { |
| 976 | mState = TONE_STOPPING; |
Steve Block | 71f2cf1 | 2011-10-20 11:56:00 +0100 | [diff] [blame^] | 977 | ALOGV("waiting cond"); |
Eric Laurent | dd28d56 | 2009-10-23 04:46:30 -0700 | [diff] [blame] | 978 | status_t lStatus = mWaitCbkCond.waitRelative(mLock, seconds(3)); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 979 | if (lStatus == NO_ERROR) { |
Steve Block | 71f2cf1 | 2011-10-20 11:56:00 +0100 | [diff] [blame^] | 980 | ALOGV("track stop complete, time %d", (unsigned int)(systemTime()/1000000)); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 981 | } else { |
| 982 | LOGE("--- Stop timed out"); |
| 983 | mState = TONE_IDLE; |
| 984 | mpAudioTrack->stop(); |
| 985 | } |
| 986 | } |
| 987 | |
| 988 | clearWaveGens(); |
| 989 | |
| 990 | mLock.unlock(); |
| 991 | } |
| 992 | |
| 993 | //---------------------------------- private methods --------------------------- |
| 994 | |
| 995 | |
| 996 | |
| 997 | |
| 998 | //////////////////////////////////////////////////////////////////////////////// |
| 999 | // |
| 1000 | // Method: ToneGenerator::initAudioTrack() |
| 1001 | // |
| 1002 | // Description: Allocates and configures AudioTrack used for PCM output. |
| 1003 | // |
| 1004 | // Input: |
| 1005 | // none |
| 1006 | // |
| 1007 | // Output: |
| 1008 | // none |
| 1009 | // |
| 1010 | //////////////////////////////////////////////////////////////////////////////// |
| 1011 | bool ToneGenerator::initAudioTrack() { |
| 1012 | |
| 1013 | if (mpAudioTrack) { |
| 1014 | delete mpAudioTrack; |
| 1015 | mpAudioTrack = 0; |
| 1016 | } |
| 1017 | |
| 1018 | // Open audio track in mono, PCM 16bit, default sampling rate, default buffer size |
Eric Laurent | bda7469 | 2009-11-04 08:27:26 -0800 | [diff] [blame] | 1019 | mpAudioTrack = new AudioTrack(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1020 | if (mpAudioTrack == 0) { |
| 1021 | LOGE("AudioTrack allocation failed"); |
| 1022 | goto initAudioTrack_exit; |
| 1023 | } |
Steve Block | 71f2cf1 | 2011-10-20 11:56:00 +0100 | [diff] [blame^] | 1024 | ALOGV("Create Track: %p\n", mpAudioTrack); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1025 | |
Eric Laurent | bda7469 | 2009-11-04 08:27:26 -0800 | [diff] [blame] | 1026 | mpAudioTrack->set(mStreamType, |
| 1027 | 0, |
Dima Zavin | 24fc2fb | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 1028 | AUDIO_FORMAT_PCM_16_BIT, |
| 1029 | AUDIO_CHANNEL_OUT_MONO, |
Eric Laurent | bda7469 | 2009-11-04 08:27:26 -0800 | [diff] [blame] | 1030 | 0, |
| 1031 | 0, |
| 1032 | audioCallback, |
| 1033 | this, |
| 1034 | 0, |
| 1035 | 0, |
| 1036 | mThreadCanCallJava); |
| 1037 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1038 | if (mpAudioTrack->initCheck() != NO_ERROR) { |
| 1039 | LOGE("AudioTrack->initCheck failed"); |
| 1040 | goto initAudioTrack_exit; |
| 1041 | } |
| 1042 | |
| 1043 | mpAudioTrack->setVolume(mVolume, mVolume); |
| 1044 | |
| 1045 | mState = TONE_INIT; |
| 1046 | |
| 1047 | return true; |
| 1048 | |
| 1049 | initAudioTrack_exit: |
| 1050 | |
| 1051 | // Cleanup |
| 1052 | if (mpAudioTrack) { |
Steve Block | 71f2cf1 | 2011-10-20 11:56:00 +0100 | [diff] [blame^] | 1053 | ALOGV("Delete Track I: %p\n", mpAudioTrack); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1054 | delete mpAudioTrack; |
| 1055 | mpAudioTrack = 0; |
| 1056 | } |
| 1057 | |
| 1058 | return false; |
| 1059 | } |
| 1060 | |
| 1061 | |
| 1062 | //////////////////////////////////////////////////////////////////////////////// |
| 1063 | // |
| 1064 | // Method: ToneGenerator::audioCallback() |
| 1065 | // |
| 1066 | // Description: AudioTrack callback implementation. Generates a block of |
| 1067 | // PCM samples |
| 1068 | // and manages tone generator sequencer: tones pulses, tone duration... |
| 1069 | // |
| 1070 | // Input: |
| 1071 | // user reference (pointer to our ToneGenerator) |
| 1072 | // info audio buffer descriptor |
| 1073 | // |
| 1074 | // Output: |
| 1075 | // returned value: always true. |
| 1076 | // |
| 1077 | //////////////////////////////////////////////////////////////////////////////// |
Glenn Kasten | e46a86f | 2011-06-01 15:20:35 -0700 | [diff] [blame] | 1078 | void ToneGenerator::audioCallback(int event, void* user, void *info) { |
David Krause | b6d90ca | 2009-06-17 15:46:13 -0500 | [diff] [blame] | 1079 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1080 | if (event != AudioTrack::EVENT_MORE_DATA) return; |
David Krause | b6d90ca | 2009-06-17 15:46:13 -0500 | [diff] [blame] | 1081 | |
Eric Laurent | af141d5 | 2009-09-24 07:03:14 -0700 | [diff] [blame] | 1082 | AudioTrack::Buffer *buffer = static_cast<AudioTrack::Buffer *>(info); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1083 | ToneGenerator *lpToneGen = static_cast<ToneGenerator *>(user); |
| 1084 | short *lpOut = buffer->i16; |
| 1085 | unsigned int lNumSmp = buffer->size/sizeof(short); |
Eric Laurent | f3af740 | 2009-05-05 00:49:01 -0700 | [diff] [blame] | 1086 | const ToneDescriptor *lpToneDesc = lpToneGen->mpToneDesc; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1087 | |
| 1088 | if (buffer->size == 0) return; |
| 1089 | |
| 1090 | |
| 1091 | // Clear output buffer: WaveGenerator accumulates into lpOut buffer |
| 1092 | memset(lpOut, 0, buffer->size); |
| 1093 | |
| 1094 | while (lNumSmp) { |
| 1095 | unsigned int lReqSmp = lNumSmp < lpToneGen->mProcessSize*2 ? lNumSmp : lpToneGen->mProcessSize; |
| 1096 | unsigned int lGenSmp; |
| 1097 | unsigned int lWaveCmd = WaveGenerator::WAVEGEN_CONT; |
| 1098 | bool lSignal = false; |
David Krause | b6d90ca | 2009-06-17 15:46:13 -0500 | [diff] [blame] | 1099 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1100 | lpToneGen->mLock.lock(); |
| 1101 | |
Eric Laurent | dd28d56 | 2009-10-23 04:46:30 -0700 | [diff] [blame] | 1102 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1103 | // Update pcm frame count and end time (current time at the end of this process) |
| 1104 | lpToneGen->mTotalSmp += lReqSmp; |
David Krause | b6d90ca | 2009-06-17 15:46:13 -0500 | [diff] [blame] | 1105 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1106 | // Update tone gen state machine and select wave gen command |
| 1107 | switch (lpToneGen->mState) { |
| 1108 | case TONE_PLAYING: |
| 1109 | lWaveCmd = WaveGenerator::WAVEGEN_CONT; |
| 1110 | break; |
| 1111 | case TONE_STARTING: |
Steve Block | 71f2cf1 | 2011-10-20 11:56:00 +0100 | [diff] [blame^] | 1112 | ALOGV("Starting Cbk"); |
David Krause | b6d90ca | 2009-06-17 15:46:13 -0500 | [diff] [blame] | 1113 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1114 | lWaveCmd = WaveGenerator::WAVEGEN_START; |
| 1115 | break; |
| 1116 | case TONE_STOPPING: |
| 1117 | case TONE_RESTARTING: |
Steve Block | 71f2cf1 | 2011-10-20 11:56:00 +0100 | [diff] [blame^] | 1118 | ALOGV("Stop/restart Cbk"); |
David Krause | b6d90ca | 2009-06-17 15:46:13 -0500 | [diff] [blame] | 1119 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1120 | lWaveCmd = WaveGenerator::WAVEGEN_STOP; |
| 1121 | lpToneGen->mNextSegSmp = TONEGEN_INF; // forced to skip state machine management below |
| 1122 | break; |
Eric Laurent | af141d5 | 2009-09-24 07:03:14 -0700 | [diff] [blame] | 1123 | case TONE_STOPPED: |
Steve Block | 71f2cf1 | 2011-10-20 11:56:00 +0100 | [diff] [blame^] | 1124 | ALOGV("Stopped Cbk"); |
Eric Laurent | af141d5 | 2009-09-24 07:03:14 -0700 | [diff] [blame] | 1125 | goto audioCallback_EndLoop; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1126 | default: |
Steve Block | 71f2cf1 | 2011-10-20 11:56:00 +0100 | [diff] [blame^] | 1127 | ALOGV("Extra Cbk"); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1128 | goto audioCallback_EndLoop; |
| 1129 | } |
David Krause | b6d90ca | 2009-06-17 15:46:13 -0500 | [diff] [blame] | 1130 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1131 | // Exit if tone sequence is over |
Eric Laurent | 96c08a6 | 2009-09-07 08:38:38 -0700 | [diff] [blame] | 1132 | if (lpToneDesc->segments[lpToneGen->mCurSegment].duration == 0 || |
| 1133 | lpToneGen->mTotalSmp > lpToneGen->mMaxSmp) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1134 | if (lpToneGen->mState == TONE_PLAYING) { |
David Krause | b6d90ca | 2009-06-17 15:46:13 -0500 | [diff] [blame] | 1135 | lpToneGen->mState = TONE_STOPPING; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1136 | } |
Eric Laurent | 96c08a6 | 2009-09-07 08:38:38 -0700 | [diff] [blame] | 1137 | if (lpToneDesc->segments[lpToneGen->mCurSegment].duration == 0) { |
| 1138 | goto audioCallback_EndLoop; |
| 1139 | } |
Eric Laurent | af141d5 | 2009-09-24 07:03:14 -0700 | [diff] [blame] | 1140 | // fade out before stopping if maximum duration reached |
Eric Laurent | 96c08a6 | 2009-09-07 08:38:38 -0700 | [diff] [blame] | 1141 | lWaveCmd = WaveGenerator::WAVEGEN_STOP; |
| 1142 | lpToneGen->mNextSegSmp = TONEGEN_INF; // forced to skip state machine management below |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1143 | } |
David Krause | b6d90ca | 2009-06-17 15:46:13 -0500 | [diff] [blame] | 1144 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1145 | if (lpToneGen->mTotalSmp > lpToneGen->mNextSegSmp) { |
| 1146 | // Time to go to next sequence segment |
David Krause | b6d90ca | 2009-06-17 15:46:13 -0500 | [diff] [blame] | 1147 | |
Steve Block | 71f2cf1 | 2011-10-20 11:56:00 +0100 | [diff] [blame^] | 1148 | ALOGV("End Segment, time: %d\n", (unsigned int)(systemTime()/1000000)); |
David Krause | b6d90ca | 2009-06-17 15:46:13 -0500 | [diff] [blame] | 1149 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1150 | lGenSmp = lReqSmp; |
Eric Laurent | f3af740 | 2009-05-05 00:49:01 -0700 | [diff] [blame] | 1151 | |
| 1152 | // If segment, ON -> OFF transition : ramp volume down |
| 1153 | if (lpToneDesc->segments[lpToneGen->mCurSegment].waveFreq[0] != 0) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1154 | lWaveCmd = WaveGenerator::WAVEGEN_STOP; |
Eric Laurent | f3af740 | 2009-05-05 00:49:01 -0700 | [diff] [blame] | 1155 | unsigned int lFreqIdx = 0; |
| 1156 | unsigned short lFrequency = lpToneDesc->segments[lpToneGen->mCurSegment].waveFreq[lFreqIdx]; |
| 1157 | |
| 1158 | while (lFrequency != 0) { |
| 1159 | WaveGenerator *lpWaveGen = lpToneGen->mWaveGens.valueFor(lFrequency); |
| 1160 | lpWaveGen->getSamples(lpOut, lGenSmp, lWaveCmd); |
| 1161 | lFrequency = lpToneDesc->segments[lpToneGen->mCurSegment].waveFreq[++lFreqIdx]; |
| 1162 | } |
Steve Block | 71f2cf1 | 2011-10-20 11:56:00 +0100 | [diff] [blame^] | 1163 | ALOGV("ON->OFF, lGenSmp: %d, lReqSmp: %d\n", lGenSmp, lReqSmp); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1164 | } |
Eric Laurent | f3af740 | 2009-05-05 00:49:01 -0700 | [diff] [blame] | 1165 | |
David Krause | b6d90ca | 2009-06-17 15:46:13 -0500 | [diff] [blame] | 1166 | // check if we need to loop and loop for the reqd times |
| 1167 | if (lpToneDesc->segments[lpToneGen->mCurSegment].loopCnt) { |
| 1168 | if (lpToneGen->mLoopCounter < lpToneDesc->segments[lpToneGen->mCurSegment].loopCnt) { |
Steve Block | 71f2cf1 | 2011-10-20 11:56:00 +0100 | [diff] [blame^] | 1169 | ALOGV ("in if loop loopCnt(%d) loopctr(%d), CurSeg(%d) \n", |
David Krause | b6d90ca | 2009-06-17 15:46:13 -0500 | [diff] [blame] | 1170 | lpToneDesc->segments[lpToneGen->mCurSegment].loopCnt, |
| 1171 | lpToneGen->mLoopCounter, |
| 1172 | lpToneGen->mCurSegment); |
| 1173 | lpToneGen->mCurSegment = lpToneDesc->segments[lpToneGen->mCurSegment].loopIndx; |
| 1174 | ++lpToneGen->mLoopCounter; |
| 1175 | } else { |
| 1176 | // completed loop. go to next segment |
| 1177 | lpToneGen->mLoopCounter = 0; |
| 1178 | lpToneGen->mCurSegment++; |
Steve Block | 71f2cf1 | 2011-10-20 11:56:00 +0100 | [diff] [blame^] | 1179 | ALOGV ("in else loop loopCnt(%d) loopctr(%d), CurSeg(%d) \n", |
David Krause | b6d90ca | 2009-06-17 15:46:13 -0500 | [diff] [blame] | 1180 | lpToneDesc->segments[lpToneGen->mCurSegment].loopCnt, |
| 1181 | lpToneGen->mLoopCounter, |
| 1182 | lpToneGen->mCurSegment); |
| 1183 | } |
| 1184 | } else { |
| 1185 | lpToneGen->mCurSegment++; |
Steve Block | 71f2cf1 | 2011-10-20 11:56:00 +0100 | [diff] [blame^] | 1186 | ALOGV ("Goto next seg loopCnt(%d) loopctr(%d), CurSeg(%d) \n", |
David Krause | b6d90ca | 2009-06-17 15:46:13 -0500 | [diff] [blame] | 1187 | lpToneDesc->segments[lpToneGen->mCurSegment].loopCnt, |
| 1188 | lpToneGen->mLoopCounter, |
| 1189 | lpToneGen->mCurSegment); |
| 1190 | |
| 1191 | } |
Eric Laurent | f3af740 | 2009-05-05 00:49:01 -0700 | [diff] [blame] | 1192 | |
| 1193 | // Handle loop if last segment reached |
| 1194 | if (lpToneDesc->segments[lpToneGen->mCurSegment].duration == 0) { |
Steve Block | 71f2cf1 | 2011-10-20 11:56:00 +0100 | [diff] [blame^] | 1195 | ALOGV("Last Seg: %d\n", lpToneGen->mCurSegment); |
David Krause | b6d90ca | 2009-06-17 15:46:13 -0500 | [diff] [blame] | 1196 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1197 | // Pre increment loop count and restart if total count not reached. Stop sequence otherwise |
Eric Laurent | f3af740 | 2009-05-05 00:49:01 -0700 | [diff] [blame] | 1198 | if (++lpToneGen->mCurCount <= lpToneDesc->repeatCnt) { |
Steve Block | 71f2cf1 | 2011-10-20 11:56:00 +0100 | [diff] [blame^] | 1199 | ALOGV("Repeating Count: %d\n", lpToneGen->mCurCount); |
David Krause | b6d90ca | 2009-06-17 15:46:13 -0500 | [diff] [blame] | 1200 | |
Eric Laurent | f3af740 | 2009-05-05 00:49:01 -0700 | [diff] [blame] | 1201 | lpToneGen->mCurSegment = lpToneDesc->repeatSegment; |
| 1202 | if (lpToneDesc->segments[lpToneDesc->repeatSegment].waveFreq[0] != 0) { |
| 1203 | lWaveCmd = WaveGenerator::WAVEGEN_START; |
| 1204 | } |
David Krause | b6d90ca | 2009-06-17 15:46:13 -0500 | [diff] [blame] | 1205 | |
Steve Block | 71f2cf1 | 2011-10-20 11:56:00 +0100 | [diff] [blame^] | 1206 | ALOGV("New segment %d, Next Time: %d\n", lpToneGen->mCurSegment, |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1207 | (lpToneGen->mNextSegSmp*1000)/lpToneGen->mSamplingRate); |
David Krause | b6d90ca | 2009-06-17 15:46:13 -0500 | [diff] [blame] | 1208 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1209 | } else { |
Eric Laurent | f3af740 | 2009-05-05 00:49:01 -0700 | [diff] [blame] | 1210 | lGenSmp = 0; |
Steve Block | 71f2cf1 | 2011-10-20 11:56:00 +0100 | [diff] [blame^] | 1211 | ALOGV("End repeat, time: %d\n", (unsigned int)(systemTime()/1000000)); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1212 | } |
| 1213 | } else { |
Steve Block | 71f2cf1 | 2011-10-20 11:56:00 +0100 | [diff] [blame^] | 1214 | ALOGV("New segment %d, Next Time: %d\n", lpToneGen->mCurSegment, |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1215 | (lpToneGen->mNextSegSmp*1000)/lpToneGen->mSamplingRate); |
Eric Laurent | f3af740 | 2009-05-05 00:49:01 -0700 | [diff] [blame] | 1216 | if (lpToneDesc->segments[lpToneGen->mCurSegment].waveFreq[0] != 0) { |
| 1217 | // If next segment is not silent, OFF -> ON transition : reset wave generator |
| 1218 | lWaveCmd = WaveGenerator::WAVEGEN_START; |
| 1219 | |
Steve Block | 71f2cf1 | 2011-10-20 11:56:00 +0100 | [diff] [blame^] | 1220 | ALOGV("OFF->ON, lGenSmp: %d, lReqSmp: %d\n", lGenSmp, lReqSmp); |
Eric Laurent | f3af740 | 2009-05-05 00:49:01 -0700 | [diff] [blame] | 1221 | } else { |
| 1222 | lGenSmp = 0; |
| 1223 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1224 | } |
David Krause | b6d90ca | 2009-06-17 15:46:13 -0500 | [diff] [blame] | 1225 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1226 | // Update next segment transition position. No harm to do it also for last segment as lpToneGen->mNextSegSmp won't be used any more |
| 1227 | lpToneGen->mNextSegSmp |
Eric Laurent | f3af740 | 2009-05-05 00:49:01 -0700 | [diff] [blame] | 1228 | += (lpToneDesc->segments[lpToneGen->mCurSegment].duration * lpToneGen->mSamplingRate) / 1000; |
David Krause | b6d90ca | 2009-06-17 15:46:13 -0500 | [diff] [blame] | 1229 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1230 | } else { |
| 1231 | // Inside a segment keep tone ON or OFF |
Eric Laurent | f3af740 | 2009-05-05 00:49:01 -0700 | [diff] [blame] | 1232 | if (lpToneDesc->segments[lpToneGen->mCurSegment].waveFreq[0] == 0) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1233 | lGenSmp = 0; // If odd segment, tone is currently OFF |
| 1234 | } else { |
| 1235 | lGenSmp = lReqSmp; // If event segment, tone is currently ON |
| 1236 | } |
| 1237 | } |
David Krause | b6d90ca | 2009-06-17 15:46:13 -0500 | [diff] [blame] | 1238 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1239 | if (lGenSmp) { |
| 1240 | // If samples must be generated, call all active wave generators and acumulate waves in lpOut |
Eric Laurent | f3af740 | 2009-05-05 00:49:01 -0700 | [diff] [blame] | 1241 | unsigned int lFreqIdx = 0; |
| 1242 | unsigned short lFrequency = lpToneDesc->segments[lpToneGen->mCurSegment].waveFreq[lFreqIdx]; |
David Krause | b6d90ca | 2009-06-17 15:46:13 -0500 | [diff] [blame] | 1243 | |
Eric Laurent | f3af740 | 2009-05-05 00:49:01 -0700 | [diff] [blame] | 1244 | while (lFrequency != 0) { |
| 1245 | WaveGenerator *lpWaveGen = lpToneGen->mWaveGens.valueFor(lFrequency); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1246 | lpWaveGen->getSamples(lpOut, lGenSmp, lWaveCmd); |
Eric Laurent | f3af740 | 2009-05-05 00:49:01 -0700 | [diff] [blame] | 1247 | lFrequency = lpToneDesc->segments[lpToneGen->mCurSegment].waveFreq[++lFreqIdx]; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1248 | } |
| 1249 | } |
David Krause | b6d90ca | 2009-06-17 15:46:13 -0500 | [diff] [blame] | 1250 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1251 | lNumSmp -= lReqSmp; |
| 1252 | lpOut += lReqSmp; |
David Krause | b6d90ca | 2009-06-17 15:46:13 -0500 | [diff] [blame] | 1253 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1254 | audioCallback_EndLoop: |
David Krause | b6d90ca | 2009-06-17 15:46:13 -0500 | [diff] [blame] | 1255 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1256 | switch (lpToneGen->mState) { |
| 1257 | case TONE_RESTARTING: |
Steve Block | 71f2cf1 | 2011-10-20 11:56:00 +0100 | [diff] [blame^] | 1258 | ALOGV("Cbk restarting track\n"); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1259 | if (lpToneGen->prepareWave()) { |
| 1260 | lpToneGen->mState = TONE_STARTING; |
Eric Laurent | 5964e73 | 2009-07-09 01:56:20 -0700 | [diff] [blame] | 1261 | // must reload lpToneDesc as prepareWave() may change mpToneDesc |
| 1262 | lpToneDesc = lpToneGen->mpToneDesc; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1263 | } else { |
| 1264 | LOGW("Cbk restarting prepareWave() failed\n"); |
| 1265 | lpToneGen->mState = TONE_IDLE; |
| 1266 | lpToneGen->mpAudioTrack->stop(); |
| 1267 | // Force loop exit |
| 1268 | lNumSmp = 0; |
| 1269 | } |
| 1270 | lSignal = true; |
| 1271 | break; |
| 1272 | case TONE_STOPPING: |
Steve Block | 71f2cf1 | 2011-10-20 11:56:00 +0100 | [diff] [blame^] | 1273 | ALOGV("Cbk Stopping\n"); |
Eric Laurent | af141d5 | 2009-09-24 07:03:14 -0700 | [diff] [blame] | 1274 | lpToneGen->mState = TONE_STOPPED; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1275 | // Force loop exit |
| 1276 | lNumSmp = 0; |
| 1277 | break; |
Eric Laurent | af141d5 | 2009-09-24 07:03:14 -0700 | [diff] [blame] | 1278 | case TONE_STOPPED: |
| 1279 | lpToneGen->mState = TONE_INIT; |
Steve Block | 71f2cf1 | 2011-10-20 11:56:00 +0100 | [diff] [blame^] | 1280 | ALOGV("Cbk Stopped track\n"); |
Eric Laurent | af141d5 | 2009-09-24 07:03:14 -0700 | [diff] [blame] | 1281 | lpToneGen->mpAudioTrack->stop(); |
| 1282 | // Force loop exit |
| 1283 | lNumSmp = 0; |
| 1284 | buffer->size = 0; |
| 1285 | lSignal = true; |
| 1286 | break; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1287 | case TONE_STARTING: |
Steve Block | 71f2cf1 | 2011-10-20 11:56:00 +0100 | [diff] [blame^] | 1288 | ALOGV("Cbk starting track\n"); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1289 | lpToneGen->mState = TONE_PLAYING; |
| 1290 | lSignal = true; |
| 1291 | break; |
Eric Laurent | af141d5 | 2009-09-24 07:03:14 -0700 | [diff] [blame] | 1292 | case TONE_PLAYING: |
| 1293 | break; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1294 | default: |
Eric Laurent | af141d5 | 2009-09-24 07:03:14 -0700 | [diff] [blame] | 1295 | // Force loop exit |
| 1296 | lNumSmp = 0; |
| 1297 | buffer->size = 0; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1298 | break; |
| 1299 | } |
| 1300 | |
| 1301 | if (lSignal) |
| 1302 | lpToneGen->mWaitCbkCond.signal(); |
| 1303 | lpToneGen->mLock.unlock(); |
| 1304 | } |
| 1305 | } |
| 1306 | |
| 1307 | |
| 1308 | //////////////////////////////////////////////////////////////////////////////// |
| 1309 | // |
| 1310 | // Method: ToneGenerator::prepareWave() |
| 1311 | // |
| 1312 | // Description: Prepare wave generators and reset tone sequencer state machine. |
Eric Laurent | f3af740 | 2009-05-05 00:49:01 -0700 | [diff] [blame] | 1313 | // mpNewToneDesc must have been initialized before calling this function. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1314 | // Input: |
| 1315 | // none |
| 1316 | // |
| 1317 | // Output: |
| 1318 | // returned value: true if wave generators have been created, false otherwise |
| 1319 | // |
| 1320 | //////////////////////////////////////////////////////////////////////////////// |
| 1321 | bool ToneGenerator::prepareWave() { |
Eric Laurent | f3af740 | 2009-05-05 00:49:01 -0700 | [diff] [blame] | 1322 | unsigned int segmentIdx = 0; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1323 | |
| 1324 | if (!mpNewToneDesc) { |
| 1325 | return false; |
| 1326 | } |
Eric Laurent | f3af740 | 2009-05-05 00:49:01 -0700 | [diff] [blame] | 1327 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1328 | // Remove existing wave generators if any |
| 1329 | clearWaveGens(); |
| 1330 | |
| 1331 | mpToneDesc = mpNewToneDesc; |
| 1332 | |
Eric Laurent | 62443f5 | 2009-10-05 20:29:18 -0700 | [diff] [blame] | 1333 | if (mDurationMs == -1) { |
| 1334 | mMaxSmp = TONEGEN_INF; |
| 1335 | } else { |
| 1336 | if (mDurationMs > (int)(TONEGEN_INF / mSamplingRate)) { |
| 1337 | mMaxSmp = (mDurationMs / 1000) * mSamplingRate; |
| 1338 | } else { |
| 1339 | mMaxSmp = (mDurationMs * mSamplingRate) / 1000; |
| 1340 | } |
Steve Block | 71f2cf1 | 2011-10-20 11:56:00 +0100 | [diff] [blame^] | 1341 | ALOGV("prepareWave, duration limited to %d ms", mDurationMs); |
Eric Laurent | 62443f5 | 2009-10-05 20:29:18 -0700 | [diff] [blame] | 1342 | } |
| 1343 | |
Eric Laurent | f3af740 | 2009-05-05 00:49:01 -0700 | [diff] [blame] | 1344 | while (mpToneDesc->segments[segmentIdx].duration) { |
| 1345 | // Get total number of sine waves: needed to adapt sine wave gain. |
| 1346 | unsigned int lNumWaves = numWaves(segmentIdx); |
| 1347 | unsigned int freqIdx = 0; |
| 1348 | unsigned int frequency = mpToneDesc->segments[segmentIdx].waveFreq[freqIdx]; |
| 1349 | while (frequency) { |
| 1350 | // Instantiate a wave generator if ot already done for this frequency |
| 1351 | if (mWaveGens.indexOfKey(frequency) == NAME_NOT_FOUND) { |
| 1352 | ToneGenerator::WaveGenerator *lpWaveGen = |
| 1353 | new ToneGenerator::WaveGenerator((unsigned short)mSamplingRate, |
| 1354 | frequency, |
| 1355 | TONEGEN_GAIN/lNumWaves); |
| 1356 | if (lpWaveGen == 0) { |
| 1357 | goto prepareWave_exit; |
| 1358 | } |
| 1359 | mWaveGens.add(frequency, lpWaveGen); |
| 1360 | } |
| 1361 | frequency = mpNewToneDesc->segments[segmentIdx].waveFreq[++freqIdx]; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1362 | } |
Eric Laurent | f3af740 | 2009-05-05 00:49:01 -0700 | [diff] [blame] | 1363 | segmentIdx++; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1364 | } |
| 1365 | |
| 1366 | // Initialize tone sequencer |
| 1367 | mTotalSmp = 0; |
| 1368 | mCurSegment = 0; |
| 1369 | mCurCount = 0; |
David Krause | b6d90ca | 2009-06-17 15:46:13 -0500 | [diff] [blame] | 1370 | mLoopCounter = 0; |
Eric Laurent | f3af740 | 2009-05-05 00:49:01 -0700 | [diff] [blame] | 1371 | if (mpToneDesc->segments[0].duration == TONEGEN_INF) { |
| 1372 | mNextSegSmp = TONEGEN_INF; |
| 1373 | } else{ |
| 1374 | mNextSegSmp = (mpToneDesc->segments[0].duration * mSamplingRate) / 1000; |
| 1375 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1376 | |
| 1377 | return true; |
| 1378 | |
| 1379 | prepareWave_exit: |
| 1380 | |
| 1381 | clearWaveGens(); |
| 1382 | |
| 1383 | return false; |
| 1384 | } |
| 1385 | |
| 1386 | |
| 1387 | //////////////////////////////////////////////////////////////////////////////// |
| 1388 | // |
| 1389 | // Method: ToneGenerator::numWaves() |
| 1390 | // |
Eric Laurent | f3af740 | 2009-05-05 00:49:01 -0700 | [diff] [blame] | 1391 | // Description: Count number of sine waves needed to generate a tone segment (e.g 2 for DTMF). |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1392 | // |
| 1393 | // Input: |
Eric Laurent | f3af740 | 2009-05-05 00:49:01 -0700 | [diff] [blame] | 1394 | // segmentIdx tone segment index |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1395 | // |
| 1396 | // Output: |
| 1397 | // returned value: nummber of sine waves |
| 1398 | // |
| 1399 | //////////////////////////////////////////////////////////////////////////////// |
Eric Laurent | f3af740 | 2009-05-05 00:49:01 -0700 | [diff] [blame] | 1400 | unsigned int ToneGenerator::numWaves(unsigned int segmentIdx) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1401 | unsigned int lCnt = 0; |
| 1402 | |
Eric Laurent | f3af740 | 2009-05-05 00:49:01 -0700 | [diff] [blame] | 1403 | if (mpToneDesc->segments[segmentIdx].duration) { |
| 1404 | while (mpToneDesc->segments[segmentIdx].waveFreq[lCnt]) { |
| 1405 | lCnt++; |
| 1406 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1407 | lCnt++; |
| 1408 | } |
| 1409 | |
| 1410 | return lCnt; |
| 1411 | } |
| 1412 | |
| 1413 | |
| 1414 | //////////////////////////////////////////////////////////////////////////////// |
| 1415 | // |
| 1416 | // Method: ToneGenerator::clearWaveGens() |
| 1417 | // |
| 1418 | // Description: Removes all wave generators. |
| 1419 | // |
| 1420 | // Input: |
| 1421 | // none |
| 1422 | // |
| 1423 | // Output: |
| 1424 | // none |
| 1425 | // |
| 1426 | //////////////////////////////////////////////////////////////////////////////// |
| 1427 | void ToneGenerator::clearWaveGens() { |
Steve Block | 71f2cf1 | 2011-10-20 11:56:00 +0100 | [diff] [blame^] | 1428 | ALOGV("Clearing mWaveGens:"); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1429 | |
Eric Laurent | f3af740 | 2009-05-05 00:49:01 -0700 | [diff] [blame] | 1430 | for (size_t lIdx = 0; lIdx < mWaveGens.size(); lIdx++) { |
| 1431 | delete mWaveGens.valueAt(lIdx); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1432 | } |
Eric Laurent | f3af740 | 2009-05-05 00:49:01 -0700 | [diff] [blame] | 1433 | mWaveGens.clear(); |
| 1434 | } |
| 1435 | |
| 1436 | //////////////////////////////////////////////////////////////////////////////// |
| 1437 | // |
| 1438 | // Method: ToneGenerator::getToneForRegion() |
| 1439 | // |
| 1440 | // Description: Get correct ringtone type according to current region. |
| 1441 | // The corrected ring tone type is the tone descriptor index in sToneDescriptors[]. |
| 1442 | // |
| 1443 | // Input: |
| 1444 | // none |
| 1445 | // |
| 1446 | // Output: |
| 1447 | // none |
| 1448 | // |
| 1449 | //////////////////////////////////////////////////////////////////////////////// |
| 1450 | int ToneGenerator::getToneForRegion(int toneType) { |
| 1451 | int regionTone; |
| 1452 | |
| 1453 | if (mRegion == CEPT || toneType < FIRST_SUP_TONE || toneType > LAST_SUP_TONE) { |
| 1454 | regionTone = toneType; |
| 1455 | } else { |
| 1456 | regionTone = sToneMappingTable[mRegion][toneType - FIRST_SUP_TONE]; |
| 1457 | } |
| 1458 | |
Steve Block | 71f2cf1 | 2011-10-20 11:56:00 +0100 | [diff] [blame^] | 1459 | ALOGV("getToneForRegion, tone %d, region %d, regionTone %d", toneType, mRegion, regionTone); |
Eric Laurent | f3af740 | 2009-05-05 00:49:01 -0700 | [diff] [blame] | 1460 | |
| 1461 | return regionTone; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1462 | } |
| 1463 | |
| 1464 | |
| 1465 | //////////////////////////////////////////////////////////////////////////////// |
| 1466 | // WaveGenerator::WaveGenerator class Implementation |
| 1467 | //////////////////////////////////////////////////////////////////////////////// |
| 1468 | |
| 1469 | //---------------------------------- public methods ---------------------------- |
| 1470 | |
| 1471 | //////////////////////////////////////////////////////////////////////////////// |
| 1472 | // |
| 1473 | // Method: WaveGenerator::WaveGenerator() |
| 1474 | // |
| 1475 | // Description: Constructor. |
| 1476 | // |
| 1477 | // Input: |
| 1478 | // samplingRate: Output sampling rate in Hz |
| 1479 | // frequency: Frequency of the sine wave to generate in Hz |
| 1480 | // volume: volume (0.0 to 1.0) |
| 1481 | // |
| 1482 | // Output: |
| 1483 | // none |
| 1484 | // |
| 1485 | //////////////////////////////////////////////////////////////////////////////// |
| 1486 | ToneGenerator::WaveGenerator::WaveGenerator(unsigned short samplingRate, |
| 1487 | unsigned short frequency, float volume) { |
| 1488 | double d0; |
| 1489 | double F_div_Fs; // frequency / samplingRate |
| 1490 | |
| 1491 | F_div_Fs = frequency / (double)samplingRate; |
| 1492 | d0 = - (float)GEN_AMP * sin(2 * M_PI * F_div_Fs); |
| 1493 | mS2_0 = (short)d0; |
| 1494 | mS1 = 0; |
| 1495 | mS2 = mS2_0; |
| 1496 | |
| 1497 | mAmplitude_Q15 = (short)(32767. * 32767. * volume / GEN_AMP); |
| 1498 | // take some margin for amplitude fluctuation |
| 1499 | if (mAmplitude_Q15 > 32500) |
| 1500 | mAmplitude_Q15 = 32500; |
| 1501 | |
| 1502 | d0 = 32768.0 * cos(2 * M_PI * F_div_Fs); // Q14*2*cos() |
| 1503 | if (d0 > 32767) |
| 1504 | d0 = 32767; |
| 1505 | mA1_Q14 = (short) d0; |
| 1506 | |
Steve Block | 71f2cf1 | 2011-10-20 11:56:00 +0100 | [diff] [blame^] | 1507 | ALOGV("WaveGenerator init, mA1_Q14: %d, mS2_0: %d, mAmplitude_Q15: %d\n", |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1508 | mA1_Q14, mS2_0, mAmplitude_Q15); |
| 1509 | } |
| 1510 | |
| 1511 | //////////////////////////////////////////////////////////////////////////////// |
| 1512 | // |
| 1513 | // Method: WaveGenerator::~WaveGenerator() |
| 1514 | // |
| 1515 | // Description: Destructor. |
| 1516 | // |
| 1517 | // Input: |
| 1518 | // none |
| 1519 | // |
| 1520 | // Output: |
| 1521 | // none |
| 1522 | // |
| 1523 | //////////////////////////////////////////////////////////////////////////////// |
| 1524 | ToneGenerator::WaveGenerator::~WaveGenerator() { |
| 1525 | } |
| 1526 | |
| 1527 | //////////////////////////////////////////////////////////////////////////////// |
| 1528 | // |
| 1529 | // Method: WaveGenerator::getSamples() |
| 1530 | // |
| 1531 | // Description: Generates count samples of a sine wave and accumulates |
| 1532 | // result in outBuffer. |
| 1533 | // |
| 1534 | // Input: |
| 1535 | // outBuffer: Output buffer where to accumulate samples. |
| 1536 | // count: number of samples to produce. |
| 1537 | // command: special action requested (see enum gen_command). |
| 1538 | // |
| 1539 | // Output: |
| 1540 | // none |
| 1541 | // |
| 1542 | //////////////////////////////////////////////////////////////////////////////// |
| 1543 | void ToneGenerator::WaveGenerator::getSamples(short *outBuffer, |
| 1544 | unsigned int count, unsigned int command) { |
| 1545 | long lS1, lS2; |
| 1546 | long lA1, lAmplitude; |
| 1547 | long Sample; // current sample |
| 1548 | |
| 1549 | // init local |
| 1550 | if (command == WAVEGEN_START) { |
| 1551 | lS1 = (long)0; |
| 1552 | lS2 = (long)mS2_0; |
| 1553 | } else { |
| 1554 | lS1 = (long)mS1; |
| 1555 | lS2 = (long)mS2; |
| 1556 | } |
| 1557 | lA1 = (long)mA1_Q14; |
| 1558 | lAmplitude = (long)mAmplitude_Q15; |
| 1559 | |
| 1560 | if (command == WAVEGEN_STOP) { |
| 1561 | lAmplitude <<= 16; |
| 1562 | if (count == 0) { |
| 1563 | return; |
| 1564 | } |
| 1565 | long dec = lAmplitude/count; |
| 1566 | // loop generation |
| 1567 | while (count--) { |
| 1568 | Sample = ((lA1 * lS1) >> S_Q14) - lS2; |
| 1569 | // shift delay |
| 1570 | lS2 = lS1; |
| 1571 | lS1 = Sample; |
| 1572 | Sample = ((lAmplitude>>16) * Sample) >> S_Q15; |
| 1573 | *(outBuffer++) += (short)Sample; // put result in buffer |
| 1574 | lAmplitude -= dec; |
| 1575 | } |
| 1576 | } else { |
| 1577 | // loop generation |
| 1578 | while (count--) { |
| 1579 | Sample = ((lA1 * lS1) >> S_Q14) - lS2; |
| 1580 | // shift delay |
| 1581 | lS2 = lS1; |
| 1582 | lS1 = Sample; |
| 1583 | Sample = (lAmplitude * Sample) >> S_Q15; |
| 1584 | *(outBuffer++) += (short)Sample; // put result in buffer |
| 1585 | } |
| 1586 | } |
| 1587 | |
| 1588 | // save status |
| 1589 | mS1 = (short)lS1; |
| 1590 | mS2 = (short)lS2; |
| 1591 | } |
| 1592 | |
| 1593 | } // end namespace android |
| 1594 | |