equal
deleted
inserted
replaced
356 } |
356 } |
357 |
357 |
358 // Set stream format |
358 // Set stream format |
359 streamFormat = toAudioStreamBasicDescription(audioFormat); |
359 streamFormat = toAudioStreamBasicDescription(audioFormat); |
360 |
360 |
361 UInt32 size = sizeof(deviceFormat); |
361 UInt32 size = sizeof(streamFormat); |
362 if (AudioUnitGetProperty(audioUnit, |
|
363 kAudioUnitProperty_StreamFormat, |
|
364 kAudioUnitScope_Input, |
|
365 0, |
|
366 &deviceFormat, |
|
367 &size) != noErr) { |
|
368 qWarning() << "QAudioOutput: Unable to retrieve device format"; |
|
369 return false; |
|
370 } |
|
371 |
|
372 if (AudioUnitSetProperty(audioUnit, |
362 if (AudioUnitSetProperty(audioUnit, |
373 kAudioUnitProperty_StreamFormat, |
363 kAudioUnitProperty_StreamFormat, |
374 kAudioUnitScope_Input, |
364 kAudioUnitScope_Input, |
375 0, |
365 0, |
376 &streamFormat, |
366 &streamFormat, |
390 &size) != noErr) { |
380 &size) != noErr) { |
391 qWarning() << "QAudioInput: Failed to get audio period size"; |
381 qWarning() << "QAudioInput: Failed to get audio period size"; |
392 return false; |
382 return false; |
393 } |
383 } |
394 |
384 |
395 periodSizeBytes = (numberOfFrames * streamFormat.mSampleRate / deviceFormat.mSampleRate) * |
385 periodSizeBytes = numberOfFrames * streamFormat.mBytesPerFrame; |
396 streamFormat.mBytesPerFrame; |
|
397 if (internalBufferSize < periodSizeBytes * 2) |
386 if (internalBufferSize < periodSizeBytes * 2) |
398 internalBufferSize = periodSizeBytes * 2; |
387 internalBufferSize = periodSizeBytes * 2; |
399 else |
388 else |
400 internalBufferSize -= internalBufferSize % streamFormat.mBytesPerFrame; |
389 internalBufferSize -= internalBufferSize % streamFormat.mBytesPerFrame; |
401 |
390 |