trunk/src/osd/modules/sound/direct_sound.c
| r32070 | r32071 | |
| 23 | 23 | |
| 24 | 24 | // MAMEOS headers |
| 25 | 25 | #include "direct_sound.h" |
| 26 | |
| 27 | #ifdef SDLMAME_WIN32 |
| 28 | #include "../../sdl/osdsdl.h" |
| 29 | #else |
| 26 | 30 | #include "winmain.h" |
| 27 | 31 | #include "window.h" |
| 32 | #endif |
| 28 | 33 | |
| 29 | 34 | //============================================================ |
| 30 | 35 | // DEBUGGING |
| r32070 | r32071 | |
| 234 | 239 | } |
| 235 | 240 | |
| 236 | 241 | // set the cooperative level |
| 242 | #ifndef SDLMAME_WIN32 |
| 237 | 243 | result = IDirectSound_SetCooperativeLevel(dsound, win_window_list->m_hwnd, DSSCL_PRIORITY); |
| 238 | 244 | if (result != DS_OK) |
| 239 | 245 | { |
| 240 | 246 | osd_printf_error("Error setting DirectSound cooperative level: %08x\n", (UINT32)result); |
| 241 | 247 | goto error; |
| 242 | 248 | } |
| 249 | #endif |
| 243 | 250 | |
| 244 | 251 | // make a format description for what we want |
| 245 | 252 | stream_format.wBitsPerSample = 16; |
| r32070 | r32071 | |
| 249 | 256 | stream_format.nBlockAlign = stream_format.wBitsPerSample * stream_format.nChannels / 8; |
| 250 | 257 | stream_format.nAvgBytesPerSec = stream_format.nSamplesPerSec * stream_format.nBlockAlign; |
| 251 | 258 | |
| 259 | |
| 252 | 260 | // compute the buffer size based on the output sample rate |
| 253 | | stream_buffer_size = stream_format.nSamplesPerSec * stream_format.nBlockAlign * downcast<windows_options &>(m_osd.machine().options()).audio_latency() / 10; |
| 261 | int audio_latency; |
| 262 | #ifdef SDLMAME_WIN32 |
| 263 | audio_latency = downcast<sdl_options &>(machine.options()).audio_latency(); |
| 264 | #else |
| 265 | audio_latency = downcast<windows_options &>(m_osd.machine().options()).audio_latency(); |
| 266 | #endif |
| 267 | stream_buffer_size = stream_format.nSamplesPerSec * stream_format.nBlockAlign * audio_latency / 10; |
| 254 | 268 | stream_buffer_size = (stream_buffer_size / 1024) * 1024; |
| 255 | 269 | if (stream_buffer_size < 1024) |
| 256 | 270 | stream_buffer_size = 1024; |