New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Repeated audio route change causes left and right headphones to get out of sync #68
Comments
This is a really great bug find, thanks! The checkSessionProperties is necessary for apps that really need to know what the sample rate is, or more importantly, what the number of channels currently is. A couple other things you might try —
|
I tried the main thread and a custom thread I created via dispatch_queue_create. Neither worked. :/ |
Bummer. I might then try wrapping the call with [pause] and [play], or temporarily turning off the OutputBlock. |
I figured out the problem. It's an extension of #58, the samplingrate/numchannels was out of sync between the AudioManager and AudioFileReader. Putting this code in AudioFileReader.mm fixed it: -(UInt32)numChannels
{
return Novocaine.audioManager.numOutputChannels;
}
-(float)samplingRate
{
return Novocaine.audioManager.samplingRate;
} obviously this is a horrible solution, but yeah :P EDIT Oh man, I just realized I inadvertently fixed #58 in the code I'm using, and instead of it crashing this issue occurs. I'll upload what I have right now in a gist, just a sec. |
Can you make this into a pull request? On Thu, Jan 9, 2014 at 3:16 PM, Reed Weichler notifications@github.comwrote:
|
I don't think it would be a good idea, the code is kind of shitty TBH, and I added some specific functionality for the application I'm using that would be confusing for other people. |
I think what I did to fix it was just running the seeking/loading/buffering the audio in another thread. |
Okee doke. Well, if you ever come up with an in-line solution where the On Thu, Jan 9, 2014 at 3:19 PM, Reed Weichler notifications@github.comwrote:
|
Will do :D |
This is still a bug, lol |
Has anyone solved the issue?? |
nope. |
If you repeatedly take your headphones in and out really fast, the sound that is playing either becomes out of sync in the left and right headphones (usually), or the sound becomes extremely choppy (sometimes).
I noticed that you do a lot of stuff when the audio route changes so I commented that part out and it ended up fixing both symptoms of the issue for me. I'm going to investigate further.
What fixes it:
What doesn't fix it:
SO I think the problem is all of the calls to AudioSessionGetProperty when the audioRoute changes. What I think you should ACTUALLY do is have custom getters for numInputChannels, numOutputChannels, etc. And when the audio route changes, set all of them to -1. When the getter is called, and if they are set to -1, THEN it calls AudioSessionGetProperty.
edit: Nevermind, I tried implementing the above and it didn't fix the problem. I'm stumped.
The text was updated successfully, but these errors were encountered: