static void start_playback(ALCdevice *pDevice) { opesles_data_t *devState = NULL; int i; if (pDevice->ExtraData == NULL) { alc_opensles_init_extradata(pDevice); devState = pDevice->ExtraData; assert(devState != NULL); } else { devState = (opesles_data_t *) pDevice->ExtraData; } if (devState->threadShouldRun == 1) { // Gratuitous resume return; } // start/restart playback thread devState->threadShouldRun = 1; pthread_attr_t playbackThreadAttr; pthread_attr_init(&playbackThreadAttr); struct sched_param playbackThreadParam; playbackThreadParam.sched_priority = sched_get_priority_max(SCHED_RR); pthread_attr_setschedpolicy(&playbackThreadAttr, SCHED_RR); pthread_attr_setschedparam(&playbackThreadAttr, &playbackThreadParam); pthread_create(&(devState->playbackThread), &playbackThreadAttr, playback_function, (void *) pDevice); while (devState->threadShouldRun && (0 == devState->threadIsReady)) { sched_yield(); } }
// Backend functions, in same order as type BackendFuncs static ALCboolean opensles_open_playback(ALCdevice *pDevice, const ALCchar *deviceName) { LOGV("opensles_open_playback pDevice=%p, deviceName=%s", pDevice, deviceName); // Check if probe has linked the opensl symbols if (pslCreateEngine == NULL) { alc_opensles_probe(DEVICE_PROBE); if (pslCreateEngine == NULL) { return ALC_FALSE; } } if (!deviceName) { deviceName = opensles_device; } else if (strcmp(deviceName, opensles_device) != 0) { return ALC_FALSE; } pDevice->szDeviceName = strdup(deviceName); if (pDevice->ExtraData == NULL) { alc_opensles_init_extradata(pDevice); } // create the engine and output mix objects alc_opensles_create_native_audio_engine(); return ALC_TRUE; }
// Backend functions, in same order as type BackendFuncs static ALCboolean opensles_open_playback(ALCdevice *pDevice, const ALCchar *deviceName) { LOGV("opensles_open_playback pDevice=%p, deviceName=%s", pDevice, deviceName); opesles_data_t *devState; // Check if probe has linked the opensl symbols if (pslCreateEngine == NULL) { alc_opensles_probe(DEVICE_PROBE); if (pslCreateEngine == NULL) { return ALC_FALSE; } } if (pDevice->ExtraData == NULL) { alc_opensles_init_extradata(pDevice); } else { devState = (opesles_data_t *) pDevice->ExtraData; } // create the engine and output mix objects SLresult result = alc_opensles_create_native_audio_engine(); return ALC_TRUE; }