From 4b904bbf13f0954a5e61355e8930404c8e7794f9 Mon Sep 17 00:00:00 2001 From: Ken Thomases Date: Thu, 28 Dec 2006 11:06:23 -0600 Subject: [PATCH] winecoreaudio: Do additional setup in AudioUnit_CreateInputUnit. It now returns in an output parameter the frame count that the AU will use. Also, initialize the Audio Unit. --- dlls/winmm/winecoreaudio/audio.c | 8 +++++--- dlls/winmm/winecoreaudio/audiounit.c | 28 +++++++++++++++++++++++++++- 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/dlls/winmm/winecoreaudio/audio.c b/dlls/winmm/winecoreaudio/audio.c index a1398afcbc1..6aac76dcce8 100644 --- a/dlls/winmm/winecoreaudio/audio.c +++ b/dlls/winmm/winecoreaudio/audio.c @@ -211,7 +211,8 @@ extern int AudioUnit_SetVolume(AudioUnit au, float left, float right); extern int AudioUnit_GetVolume(AudioUnit au, float *left, float *right); extern int AudioUnit_CreateInputUnit(void* wwi, AudioUnit* out_au, - WORD nChannels, DWORD nSamplesPerSec, WORD wBitsPerSample); + WORD nChannels, DWORD nSamplesPerSec, WORD wBitsPerSample, + UInt32* outFrameCount); OSStatus CoreAudio_woAudioUnitIOProc(void *inRefCon, AudioUnitRenderActionFlags *ioActionFlags, @@ -1522,7 +1523,8 @@ static DWORD widGetDevCaps(WORD wDevID, LPWAVEINCAPSW lpCaps, DWORD dwSize) */ static DWORD widOpen(WORD wDevID, LPWAVEOPENDESC lpDesc, DWORD dwFlags) { - WINE_WAVEIN* wwi; + WINE_WAVEIN* wwi; + UInt32 frameCount; TRACE("(%u, %p, %08X);\n", wDevID, lpDesc, dwFlags); if (lpDesc == NULL) @@ -1592,7 +1594,7 @@ static DWORD widOpen(WORD wDevID, LPWAVEOPENDESC lpDesc, DWORD dwFlags) if (!AudioUnit_CreateInputUnit(wwi, &wwi->audioUnit, wwi->format.wf.nChannels, wwi->format.wf.nSamplesPerSec, - wwi->format.wBitsPerSample)) + wwi->format.wBitsPerSample, &frameCount)) { ERR("AudioUnit_CreateInputUnit failed\n"); OSSpinLockUnlock(&wwi->lock); diff --git a/dlls/winmm/winecoreaudio/audiounit.c b/dlls/winmm/winecoreaudio/audiounit.c index 03b4d00de17..433cab16633 100644 --- a/dlls/winmm/winecoreaudio/audiounit.c +++ b/dlls/winmm/winecoreaudio/audiounit.c @@ -131,7 +131,8 @@ int AudioUnit_GetVolume(AudioUnit au, float *left, float *right) int AudioUnit_CreateInputUnit(void* wwi, AudioUnit* out_au, - WORD nChannels, DWORD nSamplesPerSec, WORD wBitsPerSample) + WORD nChannels, DWORD nSamplesPerSec, WORD wBitsPerSample, + UInt32* outFrameCount) { OSStatus err = noErr; ComponentDescription description; @@ -143,6 +144,12 @@ int AudioUnit_CreateInputUnit(void* wwi, AudioUnit* out_au, AudioStreamBasicDescription desiredFormat; + if (!outFrameCount) + { + ERR("Invalid parameter\n"); + return 0; + } + /* Open the AudioOutputUnit */ description.componentType = kAudioUnitType_Output; description.componentSubType = kAudioUnitSubType_HALOutput; @@ -244,6 +251,25 @@ int AudioUnit_CreateInputUnit(void* wwi, AudioUnit* out_au, goto error; } + /* Get the number of frames in the IO buffer(s) */ + param = sizeof(*outFrameCount); + err = AudioUnitGetProperty(au, kAudioDevicePropertyBufferFrameSize, kAudioUnitScope_Global, 0, outFrameCount, ¶m); + if (err != noErr) + { + ERR("Failed to get audio sample size: %08lx\n", err); + goto error; + } + + TRACE("Frame count: %lu\n", *outFrameCount); + + /* Initialize the AU */ + err = AudioUnitInitialize(au); + if (err != noErr) + { + ERR("Failed to initialize AU: %08lx\n", err); + goto error; + } + *out_au = au; return 1;