Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Apr 15th, 2012  |  syntax: None  |  size: 0.87 KB  |  hits: 12  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. // establish binder interface to AudioFlinger service
  2. const sp<IAudioPolicyService>& AudioSystem::get_audio_policy_service()
  3. {
  4.     gLock.lock();
  5.     if (gAudioPolicyService.get() == 0) {
  6.         sp<IServiceManager> sm = defaultServiceManager();
  7.         sp<IBinder> binder;
  8.         do {
  9.             binder = sm->getService(String16("media.audio_policy"));
  10.             if (binder != 0)
  11.                 break;
  12.             LOGW("AudioPolicyService not published, waiting...");
  13.             usleep(500000); // 0.5 s
  14.         } while(true);
  15.         if (gAudioPolicyServiceClient == NULL) {
  16.             gAudioPolicyServiceClient = new AudioPolicyServiceClient();
  17.         }
  18.         binder->linkToDeath(gAudioPolicyServiceClient);
  19.         gAudioPolicyService = interface_cast<IAudioPolicyService>(binder);
  20.         gLock.unlock();
  21.     } else {
  22.         gLock.unlock();
  23.     }
  24.     return gAudioPolicyService;
  25. }