답변
는 여전히 다이빙을 할해야이 깊은 마법 엉망 내가 함께 내가 여기에있는 코드를 형성 무언가를 만들 수 있었다 : 당신은이 AudioProperties을들을 등록 할
및 'kAudioSessionProperty_AudioRouteChange'에 대한 메시지를 잡으십시오. '이유'와 '이름'을 사용하면 일어난 일을 파서 할 수 있습니다. 또한 여기에 대한 자세한 내용을보실 수 있습니다 :
// Registers this class as the delegate of the audio session.
[[AVAudioSession sharedInstance] setDelegate: self];
// Use this code instead to allow the app sound to continue to play when the screen is locked.
[[AVAudioSession sharedInstance] setCategory: AVAudioSessionCategoryPlayback error: nil];
// Registers the audio route change listener callback function
AudioSessionAddPropertyListener (kAudioSessionProperty_AudioRouteChange, audioRouteChangeListenerCallback, self);
콜백 :
void audioRouteChangeListenerCallback (void *inUserData, AudioSessionPropertyID inPropertyID, UInt32 inPropertyValueSize, const void *inPropertyValue) {
// ensure that this callback was invoked for a route change
if (inPropertyID != kAudioSessionProperty_AudioRouteChange) return;
{
// Determines the reason for the route change, to ensure that it is not
// because of a category change.
CFDictionaryRef routeChangeDictionary = (CFDictionaryRef)inPropertyValue;
CFNumberRef routeChangeReasonRef = (CFNumberRef)CFDictionaryGetValue (routeChangeDictionary, CFSTR (kAudioSession_AudioRouteChangeKey_Reason));
SInt32 routeChangeReason;
CFNumberGetValue (routeChangeReasonRef, kCFNumberSInt32Type, &routeChangeReason);
if (routeChangeReason == kAudioSessionRouteChangeReason_OldDeviceUnavailable) {
//Handle Headset Unplugged
} else if (routeChangeReason == kAudioSessionRouteChangeReason_NewDeviceAvailable) {
//Handle Headset plugged in
}
}
}
이 "것들"중 하나입니다 상황이 당신이 이제까지 또는 알 필요가해서는 안됩니다. 일반적인 아이디어는 사운드를 재생하기 위해 제공된 API를 사용하고 사운드 하위 시스템이 나머지를 처리한다는 것입니다.
특정 구성이 필요한 경우 대화 상자를 통해 사용자에게 특정 방식으로 시스템을 친절하게 구성하도록 요청할 수는 있지만 그게 전부입니다.
편집 : 그 이유는 특히 깊은 마법을 구성에서 일반 및 사운드 프로그래밍에 해당 드라이버 프로그래밍, 그리고 화려 보통 어떤 이유로 기계의 하드웨어를 실패 다툰하려고 모든 응용 프로그램이 있지만, 종종 아주 미묘 .
알려진 닫힌 컴퓨터 집합에 대한 엔터프라이즈 응용 프로그램을 개발하지 않는 한 기계 하드웨어에 대한 가정을하지 마십시오. 알아두기도 전에 iMac의 다음 모델에는 아날로그 잭이 전혀 제공되지 않습니다.
아날로그 잭이 있고 비어 있더라도 사운드는 보드, PCI 또는 USB의 보조 사운드 카드를 통해 전송 될 수 있습니다. 지옥, 저기에 주변에 떠있는 FireWire 사운드 카드가 있습니다.
이것은 내장 된 칩에 존재하거나 존재하지 않는 숨겨진 기능입니다. 제조업체에서 API를 출시 한 경우 API를 제어 할 수 있습니다. 그렇지 않으면 API를 제어 할 수 없습니다.
당신이 스피커 구성에 대한 맥을 조회 할 수 없습니다? – RedX
그러면 어떻게 할 수 있겠습니까? – David