trunk/src/osd/modules/sound/coreaudio_sound.c
| r245447 | r245448 | |
| 26 | 26 | osd_module(OSD_SOUND_PROVIDER, "coreaudio"), |
| 27 | 27 | sound_module(), |
| 28 | 28 | m_open(false), |
| 29 | | m_started(false), |
| 30 | 29 | m_attenuation(0), |
| 31 | 30 | m_scale(128), |
| 32 | 31 | m_sample_bytes(0), |
| r245447 | r245448 | |
| 87 | 86 | AudioBufferList *data); |
| 88 | 87 | |
| 89 | 88 | bool m_open; |
| 90 | | bool m_started; |
| 91 | 89 | AudioUnit m_output; |
| 92 | 90 | int m_attenuation; |
| 93 | | UINT32 m_scale; |
| 91 | INT32 m_scale; |
| 94 | 92 | UINT32 m_sample_bytes; |
| 95 | 93 | UINT32 m_headroom; |
| 96 | 94 | UINT32 m_buffer_size; |
| r245447 | r245448 | |
| 200 | 198 | return -1; |
| 201 | 199 | } |
| 202 | 200 | m_open = true; |
| 203 | | m_started = true; |
| 204 | 201 | osd_printf_verbose("Audio: End initialization\n"); |
| 205 | 202 | return 0; |
| 206 | 203 | } |
| r245447 | r245448 | |
| 215 | 212 | AudioUnitUninitialize(m_output); |
| 216 | 213 | CloseComponent(m_output); |
| 217 | 214 | m_open = false; |
| 218 | | m_started = false; |
| 219 | 215 | } |
| 220 | 216 | if (m_buffer) |
| 221 | 217 | { |
| r245447 | r245448 | |
| 257 | 253 | |
| 258 | 254 | void sound_coreaudio::set_mastervolume(int attenuation) |
| 259 | 255 | { |
| 260 | | m_attenuation = MAX(MIN(attenuation, 0), -32); |
| 261 | | m_scale = (UINT32)(pow(10.0, m_attenuation / 20.0) * 128); |
| 262 | | if (m_open) |
| 263 | | { |
| 264 | | if (-32 == m_attenuation) |
| 265 | | { |
| 266 | | if (m_started) |
| 267 | | { |
| 268 | | if (noErr == AudioOutputUnitStop(m_output)) |
| 269 | | m_started = false; |
| 270 | | } |
| 271 | | } |
| 272 | | else |
| 273 | | { |
| 274 | | if (!m_started) |
| 275 | | { |
| 276 | | if (noErr == AudioOutputUnitStart(m_output)) |
| 277 | | m_started = true; |
| 278 | | } |
| 279 | | } |
| 280 | | } |
| 256 | m_attenuation = MAX(MIN(attenuation, 0), -32); |
| 257 | m_scale = (-32 == m_attenuation) ? 0 : (INT32)(pow(10.0, m_attenuation / 20.0) * 128); |
| 281 | 258 | } |
| 282 | 259 | |
| 283 | 260 | |