IPhone allows other applications to play audio while recording audio / shazam

Looking at what Shazam does in terms of sound recording, while another application plays audio.

1) Sound recording is ok, no problem here

2) When the application starts and starts recording, music from another application stops (itunes, etc.).

3) I played with all the spells of the AV Audio settings, not wanting the sound to continue / resume.

4) When Shazam starts, the sound stop is a bit and then resumes. I guess Shazam is doing something to restart the sound using the music player? I searched and could not find if there is a way to do this.

So, if anyone has the right settings to make it work, that would be appreciated.

In addition, the statement, please read the AV documents, this is not the answer, I looked through them with no luck.

I tried to find here

http://developer.apple.com/library/ios/#documentation/Audio/Conceptual/AudioSessionProgrammingGuide/AudioSessionCategories/AudioSessionCategories.html

Tried settings like AV and K. I can see the difference in settings, how accurately MIC works, but in all cases when my application receives a microphone, it stops the sound from another application.

If I have to sacrifice a chicken standing in the direction of Apple, that's fine, just let me know what type of chicken :-)

+3
source share
1 answer

, , , MixWithOthers - . , / ...

FYI AudioQueue

, ...

/ iPod /

  • AudioQueueNewInput
  • AudioQueueAddPropertyListener
  • AudioQueueAllocateBuffer ()
  • AudioQueueEnqueueBuffer ()
  • setupCat
  • setupDuck
  • setupAudioRoute
  • setupMixing
  • AudioSessionSetActive (true)
  • AudioQueueStart

typedef union 
{
    OSStatus propertyResult;
    char a[4];
} unionstatus;

unionstatus u2;

typedef union 
{
    UInt32 UI32sessionCat;
    char a[4];
} unionuint32;

unionuint32 usc2;

bool setAudioUInt32 ( UInt32 property, UInt32 value )
{
    bool result = true;

    UInt32 UI32 = value;
    UInt32 UI32size = sizeof(UI32);

    u2.propertyResult = AudioSessionSetProperty (property, UI32size , &UI32 );

    if ( u2.propertyResult )
    {
        printf("Error Set %ld %lx %c%c%c%c\n",u2.propertyResult,u2.propertyResult,u2.a[3],u2.a[2],u2.a[1],u2.a[0]);
        result = false;
    }
    return result;
}

UInt32 getAudioSettingInt ( UInt32 value )
{
    UInt32  I32;
    UInt32  I32size = sizeof(I32);

    u2.propertyResult = AudioSessionGetProperty ( value , &I32size, &I32 );

    if ( u2.propertyResult )
        printf("Error Get %ld %lx %c%c%c%c\n",u2.propertyResult,u2.propertyResult,u2.a[3],u2.a[2],u2.a[1],u2.a[0]);

    return (I32);
}

/// checking taken out

bool otherPlaying = getAudioSettingInt ( kAudioSessionProperty_OtherAudioIsPlaying );
if ( otherPlaying )
{
    setAudioUInt32 (kAudioSessionProperty_OtherMixableAudioShouldDuck, false);
    // this returns a string, arg, have to look for string values, etc.
    UInt32 audioRoute = getAudioSettingInt ( kAudioSessionProperty_AudioRoute );

    CFStringRef ar = (CFStringRef) audioRoute;
    CFStringEncoding encodingMethod = CFStringGetSystemEncoding();
    const char *car = CFStringGetCStringPtr(ar,encodingMethod);
    CFRange range = CFStringFind(ar,CFSTR("Headphones"),kCFCompareCaseInsensitive);

    if ( range.length == 0 ) // we have speakers
        result = setAudioUInt32 (kAudioSessionProperty_OverrideAudioRoute, kAudioSessionOverrideAudioRoute_Speaker);
    else // we have headphones
        {}
}
+1

All Articles