On Jun 25, 2015, at 6:20 PM, Seth Willits <[email protected]> wrote:
> Now, assuming the above is all correct, then I'm really confused about
> WriteMix's behavior because according to the above (based on my
> interpretation of the header comments), during a WriteMix operation, the main
> buffer passed to DoIOOperation contains the fully mixed audio from all of the
> various clients. So if there are two applications sending audio to my device,
> I expect to get once DoIOOperation/WriteMix call per sample time range, where
> the main buffer contains the mix of the two apps' audio, in my device's
> native format.
>
> Instead, DoIOOperation/WriteMix is called *for each client*, and they have
> overlapping sample time ranges. For example (sample times are on the end:)
>
> WriteMix: Client 205 -- 2091040.000000
> WriteMix: Client 348 -- 2091500.000000
> WriteMix: Client 205 -- 2091552.000000
> WriteMix: Client 348 -- 2092012.000000
>
> Notice that they completely overlap, so that I always have two WriteMix calls
> for each sample. This doesn't make any sense to me. I'd expect just one, and
> the client id for the operation to be 0 since the buffer contains a full mix
> of multiple clients.
>
>
> What's really odd is if I only copy the audio from the WriteMix operations
> that are "from" just one of these clients (either one), it sounds garbled and
> terrible. If I copy the audio from both (despite the sample times completely
> overlapping), it sounds correct.
It occurred to me while eating some Frosted Flakes that I was _assuming_ that
the inIOBufferFrameSize to the DoIOOperation function was 512 for all calls. It
turns out that's not the case. So this is what's actually going on:
WriteMix: Client 326 -- Starting at 892004 for 36 frames
WriteMix: Client 348 -- Starting at 892040 for 476 frames
WriteMix: Client 326 -- Starting at 892516 for 36 frames
WriteMix: Client 348 -- Starting at 892552 for 476 frames
So I'm getting various client ids in the WriteMix calls, but the audio in the
buffer really is the mix of *all clients*, and the sample times of the calls do
not overlap, they're just of varying lengths. So now it adds up perfectly.
Mystery solved. Just ignore the client id in WriteMix. I don't see any use for
it, and it sent me on a multi-hour wild goose chase because I thought it had to
mean *something*. Nope. Seems Radar-worthy to me.
> And a second thing, why when only recording from my device (which is both an
> input and an output device) does WriteMix happen with the client id matching
> that of the client which is recording from my device (aka ReadInput is
> happening)? (The main io buffer during these WriteMix calls is all zeros.)
This one still puzzles me though. I don't understand this.
--
Seth Willits
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list ([email protected])
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/coreaudio-api/archive%40mail-archive.com
This email sent to [email protected]