Opened 14 years ago

Closed 14 years ago

Last modified 14 years ago

#5636 closed task (fixed)

Remove reliance on deprecated CoreAudio calls

Reported by: rgovostes Owned by: rgovostes
Milestone: Adium X 1.1 Component: Adium Core
Version: Severity: normal
Keywords: Cc:
Patch Status:

Description (last modified by Chris Forsythe)

QTSoundFilePlayer.m makes a few calls to deprecated CoreAudio functions. The calls should be updated to use the superseding functions.

Attachments (2)

coreaudiosucks.diff (10.4 KB) - added by Ryan Govostes 14 years ago.
coreaudiosucksless.diff (16.4 KB) - added by Ryan Govostes 14 years ago.

Download all attachments as: .zip

Change History (13)

Changed 14 years ago by Ryan Govostes

Attachment: coreaudiosucks.diff added

comment:1 Changed 14 years ago by Ryan Govostes

attachment:coreaudiosucks.diff adds some preprocessor directives to switch between the deprecated and supported code. These are controlled by #define USE_NEW_CORE_AUDIO_CODE 0 at the top of QTSoundFilePlayer.m.

If you switch USE_NEW_CORE_AUDIO_CODE to 1, beware: sounds are distorted, and it sometimes produces loud obnoxious screeches.

comment:2 Changed 14 years ago by Ryan Govostes

Kent Revis, author of QTSoundFilePlayer writes:

If you can, I'd really recommend getting off of my code and switching to something more up-to-date. The CoreAudio example code has gotten a lot better, and I know they have code for playing a file (with nice buffering and everything). Specifically, the way my code uses QuickTime on a separate thread is not 100% correct... see for the right way to do it (which wasn't documented or available when I wrote the code).

There's more details about alternate methods in the README.rtf in my source package.


Hard to say without seeing the code [why it's playing back slowly]. But maybe:

V1 AudioUnits expected to get an interleaved stream of samples. That is, if your audio is stereo, the samples in memory look like this:

L0 R0 L1 R1 L2 R2 ...

This turned out to be a pain for most people, so the V2 AudioUnits changed so they accept individual streams for each channel, non-interleaved. So the AU expects to get two separate streams (buffers), one for each channel:

L0 L1 L2 ...
R0 R1 R2 ...

My code only has one ring buffer holding all the interleaved samples, and it sends those straight to the AU to play. To update the code you have two options:

1. Tell the AU to expect an interleaved stream

This doesn't work with all AUs in general -- they are only required to take noninterleaved streams -- but it's supposed to work for the audio output AU.

When you construct the AudioStreamBasicDescription, make sure you clear kAudioFormatFlagIsNonInterleaved in mFormatFlags.

2. Change the code to use one ring buffer per channel

This is a lot more of a pain, I wouldn't recommend bothering -- switch to some other code before you do this.

comment:3 Changed 14 years ago by Ryan Govostes

Oops, his name is Kurt, not Kent :-)

comment:4 Changed 14 years ago by Chris Forsythe

Description: modified (diff)

Changed 14 years ago by Ryan Govostes

Attachment: coreaudiosucksless.diff added

comment:5 Changed 14 years ago by Ryan Govostes

field_haspatch: 01
Owner: changed from nobody to Ryan Govostes
Status: newassigned

Kurt wrote back with a patched PlayBufferedSoundFile example that removes the deprecated code. I did my best to merge the changes in with Adium. I assumed that Adium's version was newer than the latest version available on Kurt's site; if this is not the case, I foresee many headaches in your near future.

USE_NEW_CORE_AUDIO_CODE remains so that it can be toggled quickly for debugging. Feel free to remove the deprecated code if this is unnecessary.

See attachment:coreaudiosucksless.diff

comment:6 Changed 14 years ago by Ryan Govostes

Unrelated note: Kurt isn't included in the credits... I don't know if it is meant to be a comprehensive list of contributors, though.

comment:7 Changed 14 years ago by David Smith

He should definitely be in the credits. How well tested is that patch, btw? I'm reaaaaaaaally hesitant to go rewriting this stuff before we branch. :/

comment:8 Changed 14 years ago by Ryan Govostes

What would you say to turning on USE_NEW_CORE_AUDIO_CODE for the next beta only and seeing if there are any complaints? If you decide to not use it for the 1.0 release, at least we'll have some feedback about whether it works or not.

comment:9 Changed 14 years ago by Evan Schoenberg

I don't want to add any extra variables to the betas at this point. Let's turn on USE_NEW_CORE_AUDIO_CODE in trunk but not in the 1.0 branch; that way cutting edge folks and developers will test it but the rest of the beta testbase won't.

comment:10 Changed 14 years ago by Evan Schoenberg

Resolution: fixed
Status: assignedclosed

(In [17964]) Patch from Ryan Govostes which removes QTSoundFilePlayer's dependency on deprecated core audio code. This seems to work, but there's no immediate need to have the change in Adium 1.0 (since we'll certainly have more releases before the deprecated turns to unsupported), so let's test it in trunk. Closes #5636

comment:11 Changed 14 years ago by Evan Schoenberg

Milestone: Adium X 1.1
Note: See TracTickets for help on using tickets.