2012-07-26 5 views
4

Apple 설명서에 따르면 AudioServices.h는 AudioToolbox 프레임 워크의 일부 여야합니다.AudioServices.h가 AudioToolbox 프레임 워크를 포함하는 목표 -C CISOS 프로젝트에 없습니다.

Xcode 프로젝트에 AudioToolbox 프레임 워크를 추가했지만 # AudioServices를 가져 오면 AudioServices.h 파일을 찾을 수 없습니다.

이것은 내가 # import를 "AudioServices.h"

또는 # import를 "AudioToolbox/AudioServices.h" 을 입력 여부를 발생합니다.

경우에 따라 AudioToolbox 프레임 워크를 제거한 다음 다시 추가해 보았습니다. 효과는 없습니다. AudioServices 파일이 어떻게 든 손상 될 수 있습니까? (그렇다면 누구나 다른 사본을 어디에서 다운로드 할 수 있는지 알고 있습니까?)

XCode 4.2를 사용하고 있지만 이전의 일부 오픈 소스 코드를 변환 할 때 프로젝트는 XCode 3.2와 호환되도록 설정됩니다. 이것이 문제가 될 수 있습니까?

나는 뭔가 간단하다고 생각합니다. 나는 완전히 프로그래밍에 익숙하지 않다 ... 어떤 도움을 주셔서 감사합니다!

-----

편집 ----- (아래 내 댓글 참조) AudioServices.h에서

, 문제의 두 가지 기능 : 샘플에서 SpeakHereController.mm에서

extern OSStatus 
AudioSessionInitialize(CFRunLoopRef      inRunLoop, 
         CFStringRef       inRunLoopMode, 
         AudioSessionInterruptionListener inInterruptionListener, 
         void        *inClientData)    

extern OSStatus 
AudioSessionAddPropertyListener( AudioSessionPropertyID    inID, 
            AudioSessionPropertyListener  inProc, 
            void        *inClientData) 

(애플 내가 내 프로젝트의 다른 파일과 더 나은 협력을 얻기 위해 아크 변환하려고 코드) :

- (void)awakeFromNib 
{  

// Allocate our singleton instance for the recorder & player object 
recorder = new AQRecorder(); 
player = new AQPlayer(); 


OSStatus error = AudioSessionInitialize(NULL, NULL, interruptionListener, self); 
if (error) printf("ERROR INITIALIZING AUDIO SESSION! %ld\n", error); 
else 
{ 
    UInt32 category = kAudioSessionCategory_PlayAndRecord; 
    error = AudioSessionSetProperty(kAudioSessionProperty_AudioCategory, sizeof(category), &category); 
    if (error) printf("couldn't set audio category!"); 

    error = AudioSessionAddPropertyListener(kAudioSessionProperty_AudioRouteChange, propListener, self); 
    if (error) printf("ERROR ADDING AUDIO SESSION PROP LISTENER! %ld\n", error); 
    UInt32 inputAvailable = 0; 
    UInt32 size = sizeof(inputAvailable); 

    // we do not want to allow recording if input is not available 
    error = AudioSessionGetProperty(kAudioSessionProperty_AudioInputAvailable, &size, &inputAvailable); 
    if (error) printf("ERROR GETTING INPUT AVAILABILITY! %ld\n", error); 
    btn_record.enabled = (inputAvailable) ? YES : NO; 

    // we also need to listen to see if input availability changes 
    error = AudioSessionAddPropertyListener(kAudioSessionProperty_AudioInputAvailable, propListener, self); 
    if (error) printf("ERROR ADDING AUDIO SESSION PROP LISTENER! %ld\n", error); 

    error = AudioSessionSetActive(true); 
    if (error) printf("AudioSessionSetActive (true) failed"); 
} 

답변

16

ARC를 사용할 때 자체을 void *로 자동 변환 할 수 없다는 문제가 있습니다. Self는 AudioSessionInitialize 함수 (및 다른 함수)의 마지막 매개 변수에 사용됩니다.

__bridge를 사용하여 수동으로 void *로 캐스팅하여 메모리 소유권을 제어하는 ​​방법을 ARC에 알려줘야합니다. 이것은 '기억의 소유권을 바꾸지 마십시오'라고 말합니다.

AudioSession 함수를 호출 할 때 self를 (__bridge void *) self로 변경하십시오.

OSStatus error = AudioSessionInitialize(NULL, NULL, interruptionListener, (__bridge void*)self); 
1

시도 "#import <AudioToolbox/AudioServices.h>"당신의 문제가 사라지면 참조하십시오.

< 및> 문자가 달라집니다. "#import"에서 큰 따옴표를 사용한다는 것은 컴파일러가 "사용자 헤더"를 검색하게하고, 여기서 각진 대괄호는 컴파일러가 시스템 프레임 워크에서 검색하도록 함을 의미합니다.

+0

죄송합니다. – Jeanne

+0

그건 내 문제의 일부일뿐 나머지는 Automatic Reference Counting으로 변환하는 것과 관련이 있습니다. 'AudioSessionInitialize'에 대한 호출에 대해 일치하는 함수가 없지만 공개 삼각형에 추가 정보가 있습니다. 후보 함수가 실행 가능하지 않습니다 : 'SpeakHereController * const__strong'형식의 인수를 암시 적으로 변환 할 수 없습니다. 'void *'는 ARC의 4 번째 인수입니다. 이 파일을 수정하는 방법을 잘 모르겠다. 필자가 작성하지 않았고 잘 이해하지 못하는 파일이기 때문이다. 위의 코드를 추가합니다. – Jeanne

관련 문제