| 210 | } |
| 211 | |
| 212 | dmSound::Result DeviceOpenSLOpen(const dmSound::OpenDeviceParams* params, dmSound::HDevice* device) |
| 213 | { |
| 214 | assert(params); |
| 215 | assert(device); |
| 216 | SLObjectItf sl = 0; |
| 217 | SLEngineItf engine = 0; |
| 218 | SLObjectItf output_mix = 0; |
| 219 | SLObjectItf player = 0; |
| 220 | SLPlayItf play = 0; |
| 221 | SLBufferQueueItf buffer_queue = 0; |
| 222 | SLVolumeItf volume = 0; |
| 223 | |
| 224 | SLEngineOption options[] = { |
| 225 | { (SLuint32) SL_ENGINEOPTION_THREADSAFE, |
| 226 | (SLuint32) SL_BOOLEAN_FALSE } |
| 227 | }; |
| 228 | |
| 229 | const SLboolean required[] = { }; |
| 230 | SLInterfaceID ids[] = { }; |
| 231 | |
| 232 | const SLboolean required_player[] = {SL_BOOLEAN_TRUE, SL_BOOLEAN_TRUE}; |
| 233 | SLInterfaceID ids_player[] = {SL_IID_VOLUME, SL_IID_BUFFERQUEUE}; |
| 234 | assert(sizeof(required_player)/sizeof(required_player[0]) == sizeof(ids_player)/sizeof(ids_player[0])); |
| 235 | |
| 236 | OpenSLDevice* opensl = 0; |
| 237 | |
| 238 | // Actual initalization starts here. |
| 239 | |
| 240 | const int rate = GetSampleRate(); |
| 241 | const int samples_per_second = rate * 1000; |
| 242 | |
| 243 | uint32_t frame_count = params->m_FrameCount; |
| 244 | if (frame_count == 0) |
| 245 | { |
| 246 | frame_count = dmSound::GetDefaultFrameCount(samples_per_second); |
| 247 | } |
| 248 | |
| 249 | SLresult res = slCreateEngine(&sl, 1, options, 0, NULL, NULL); |
| 250 | if (CheckAndPrintError(res)) |
| 251 | return dmSound::RESULT_UNKNOWN_ERROR; |
| 252 | |
| 253 | res = (*sl)->Realize(sl, SL_BOOLEAN_FALSE); |
| 254 | if (CheckAndPrintError(res)) |
| 255 | goto cleanup_sl; |
| 256 | |
| 257 | res = (*sl)->GetInterface(sl, SL_IID_ENGINE, &engine); |
| 258 | if (CheckAndPrintError(res)) |
| 259 | goto cleanup_sl; |
| 260 | |
| 261 | res = (*engine)->CreateOutputMix(engine, &output_mix, 0, ids, required); |
| 262 | if (CheckAndPrintError(res)) |
| 263 | goto cleanup_sl; |
| 264 | |
| 265 | res = (*output_mix)->Realize(output_mix, SL_BOOLEAN_FALSE); |
| 266 | if (CheckAndPrintError(res)) |
| 267 | goto cleanup_mix; |
| 268 | |
| 269 | SLDataLocator_BufferQueue locator; |
nothing calls this directly
no test coverage detected