У меня есть некоторые проблемы с моей записью Open Al на разных iOS.Проблемы со звукозаписью в Open Al
Используя самообъявленные хаки, я все-таки исправил все проблемы, но остался проблемой с iOS 8 на iPad. На другом устройстве (на котором я смог проверить) с iOS 5-8 все работает хорошо.
Итак, что часть моего кода:
//hack for iOS 7-8, otherwise program crashes on alcCaptureOpenDevice
if([[UIDevice currentDevice].systemVersion floatValue] >= 7.0f)
alcMakeContextCurrent(nil);
controller->captureDevice = alcCaptureOpenDevice(nil, args->rate, args->format, args->rate * resolution * tracks);
if(controller->captureDevice)
{
//i am trying something like this, but no effect
if([[UIDevice currentDevice].systemVersion floatValue] >= 7.0f)
{
controller->captureContext = alcCreateContext(controller->captureDevice, NULL);
alcMakeContextCurrent(controller->captureContext);
}
if(args->time < 0 || args->time > MAX_RECORDING_TIME)
args->time = MAX_RECORDING_TIME;
//allocate memory for buffers
ALbyte* dataBuffer = new ALbyte[(int)(args->rate * resolution * tracks * ceil(args->time + 1))];
ALbyte* tempBuffer = new ALbyte[(int)(args->rate * resolution * tracks * ceil(args->time + 1))];
ALint dataSamples = 0;
ALint tempSamples = 0;
NSTimeInterval startTime = [[NSDate date] timeIntervalSince1970];
alcCaptureStart(controller->captureDevice);
//cycle of recording
while(controller->recognition)
{
//timing
NSTimeInterval curTime = [[NSDate date] timeIntervalSince1970];
if(curTime - startTime >= args->time)
break;
//check how much audio data has been captured
alcGetIntegerv(controller->captureDevice, ALC_CAPTURE_SAMPLES, resolution * tracks, &tempSamples);
//read the captured audio
alcCaptureSamples(controller->captureDevice, tempBuffer, tempSamples);
//copying from the temporary buffer into the data buffer
int i = 0, j = 0;
for(i = dataSamples * resolution * tracks; i < (dataSamples + tempSamples) * resolution * tracks; i++, j++)
dataBuffer[i] = tempBuffer[j];
dataSamples += tempSamples;
if(!tempSamples)
continue;
//.. using captured data
}
alcCaptureStop(controller->captureDevice);
alcCaptureCloseDevice(controller->captureDevice);
//hack for iOS 7-8, for we will may again play sounds
if([[UIDevice currentDevice].systemVersion floatValue] >= 7.0f)
{
alcDestroyContext(controller->captureContext);
alcMakeContextCurrent(controller->playbackContext);
}
}
Так на IPad воздуха в цикле записи мы не захватить образцы. После alcGetIntegerv и alcCaptureSamples у нас есть пустой буфер и нуль в образцах счетчика. Это происходит при первом начале записи. Во второй попытке мы взяли отсчеты в счетчике, но буфер все равно остается пустым.
У меня проблема с доступом к микрофону. iOS не отображает окно разрешения микрофона. Я пробовал alcIsExtensionPresent, но он вернулся.
Я не знаю, что делать. Я надеюсь на вашу помощь.
И извините за мой плохой английский.