- Timestamp:
- Mar 16, 2011 5:44:14 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjmedia/src/pjmedia-audiodev/coreaudio_dev.c
r3438 r3454 37 37 38 38 #define AudioDeviceID unsigned 39 40 /** 41 * As in iOS SDK 4 or later, audio route change property listener is 42 * no longer necessary. Just make surethat your application can receive 43 * remote control events by adding the code: 44 * [[UIApplication sharedApplication] 45 * beginReceivingRemoteControlEvents]; 46 * Otherwise audio route change (such as headset plug/unplug) will not be 47 * processed while your application is in the background mode. 48 */ 49 #define USE_AUDIO_ROUTE_CHANGE_PROP_LISTENER 0 50 39 51 #endif 40 52 … … 224 236 unsigned i; 225 237 OSStatus ostatus; 226 UInt32 audioCategory;227 238 #endif 228 239 … … 297 308 } 298 309 299 /* We want to be able to open playback and recording streams */ 300 audioCategory = kAudioSessionCategory_PlayAndRecord; 301 ostatus = AudioSessionSetProperty(kAudioSessionProperty_AudioCategory, 302 sizeof(audioCategory), 303 &audioCategory); 304 if (ostatus != kAudioSessionNoError) { 305 PJ_LOG(4, (THIS_FILE, 306 "Warning: cannot set the audio session category (%i)", 307 ostatus)); 308 } 309 310 /* Listen for audio routing change notifications */ 310 /* Listen for audio routing change notifications. */ 311 #if USE_AUDIO_ROUTE_CHANGE_PROP_LISTENER != 0 311 312 ostatus = AudioSessionAddPropertyListener( 312 313 kAudioSessionProperty_AudioRouteChange, … … 317 318 "notifications (%i)", ostatus)); 318 319 } 319 320 #endif 321 320 322 cf_instance = cf; 321 323 #endif … … 337 339 338 340 #if !COREAUDIO_MAC 341 #if USE_AUDIO_ROUTE_CHANGE_PROP_LISTENER != 0 339 342 AudioSessionRemovePropertyListenerWithUserData( 340 343 kAudioSessionProperty_AudioRouteChange, propListener, cf); 344 #endif 341 345 #endif 342 346 … … 1089 1093 continue; 1090 1094 1091 /* This does not seem necessary anymore. Just make sure1092 * that your application can receive remote control1093 * events by adding the code:1094 * [[UIApplication sharedApplication]1095 * beginReceivingRemoteControlEvents];1096 * Otherwise audio route change (such as headset plug/unplug)1097 * will not be processed while your application is in the1098 * background mode.1099 */1100 1095 /* 1101 1096 status = ca_stream_stop((pjmedia_aud_stream *)it->stream); … … 1131 1126 it->stream->interrupted == PJ_TRUE) 1132 1127 { 1128 UInt32 audioCategory; 1129 OSStatus ostatus; 1130 1133 1131 /* Make sure that your application can receive remote control 1134 1132 * events by adding the code: … … 1138 1136 * application is in the background mode. 1139 1137 */ 1138 /* Make sure we set the correct audio category before restarting */ 1139 audioCategory = kAudioSessionCategory_PlayAndRecord; 1140 ostatus = AudioSessionSetProperty(kAudioSessionProperty_AudioCategory, 1141 sizeof(audioCategory), 1142 &audioCategory); 1143 if (ostatus != kAudioSessionNoError) { 1144 PJ_LOG(4, (THIS_FILE, 1145 "Warning: cannot set the audio session category (%i)", 1146 ostatus)); 1147 } 1148 1149 /* Restart the stream */ 1140 1150 status = ca_stream_start((pjmedia_aud_stream*)it->stream); 1141 1151 if (status != PJ_SUCCESS) { … … 1202 1212 { 1203 1213 OSStatus ostatus; 1204 1214 #if !COREAUDIO_MAC 1215 UInt32 audioCategory = kAudioSessionCategory_PlayAndRecord; 1216 /* We want to be able to open playback and recording streams */ 1217 ostatus = AudioSessionSetProperty(kAudioSessionProperty_AudioCategory, 1218 sizeof(audioCategory), 1219 &audioCategory); 1220 if (ostatus != kAudioSessionNoError) { 1221 PJ_LOG(4, (THIS_FILE, 1222 "Warning: cannot set the audio session category (%i)", 1223 ostatus)); 1224 } 1225 #endif 1226 1205 1227 /* Create an audio unit to interface with the device */ 1206 1228 ostatus = AudioComponentInstanceNew(io_comp, io_unit); … … 1434 1456 strm->audio_buf->mBuffers[0].mNumberChannels = 1435 1457 strm->streamFormat.mChannelsPerFrame; 1458 1436 1459 #endif 1437 1460
Note: See TracChangeset
for help on using the changeset viewer.