2012-12-07 2 views
0

My SoundManager 클래스는 SoundPool을 오디오 용으로 사용합니다. 멈추라는 소리가 들릴 때까지 1 초에서 2 초 정도 반복되는 소리가납니다. 문제는이 작업이 한 번 실행 된 다음 logcat에서 "SoundPool : AudioTrack을 만드는 중 오류가 발생했습니다"라는 오류를 확인한 후 "AudioTrack : AudioFlinger가 트랙을 만들지 못했습니다. 상태 : -12"입니다. 내 코드는 아래에 있습니다. 어떤 오류 메시지가 나옵니까?Android SoundPool : AudioFlinger 오류

public class SoundManager { 

    public SoundManager(Context c) { 
     mContext = c; 
     sp = new SoundPool(1,AudioManager.STREAM_MUSIC,0); 
     spSound = sp.load(mContext, R.raw.tone4402, 1); 
    } 
    public void Tone3(int timer) { 
     (new Thread(t3)).start(); 
    } 
    final Runnable t3 = new Runnable() { 
     public void run() { 
      if(isPlaying == false) { 
       isPlaying = true; 
       Tone3Run(); 
      } 
     } 
    }; 
    public static void Tone3Run() { 
     //1 sec on, 2 sec off, repeat for 2 minute 
     Log.d("Sound", "Tone3 Playing"); 
     long startTime = System.currentTimeMillis(); 
     long currentTime; 
     do 
     { 
      currentTime = System.currentTimeMillis(); 
      Log.e("Sound Manager", "Time:" + (currentTime - startTime)); 
      temp = sp.play(spSound, currentVolume, currentVolume, 1, -1, (float)1.0); 
      try { 
       Thread.sleep(1000); 
      } catch (InterruptedException e) { 
      e.printStackTrace(); 
      } 

      sp.pause(temp); 
      try { 
       Thread.sleep(2000); 
      } catch (InterruptedException e) { 
       e.printStackTrace(); 
      } 
     } while(((currentTime - startTime) < 120000) && (boolStop = false)); 
     sp.release(); 
     sp = new SoundPool(1, 4, 0); 
     spSound = sp.load(mContext, R.raw.tone4402, 1); 
     isPlaying = false; 
} 
+1

'-12'는'ENOMEM'이거나 '메모리 부족'입니다. [오류 코드] (http://www.barricane.com/c-error-codes-include-errno) – Tim

+0

머리를 주셔서 감사합니다 문제를 해결할 수있었습니다. – Dogz1

답변

0

Error : AudioTrack: AudioFlinger could not create track, status: -12
이 활성화 트랙의 총 수에 속하는 32이고, 당신이 다른 트랙을 만들기 위해 노력하고 있습니다.
Android 만 32 개의 트랙 이름을 지원할 수 있습니다.
Obtain Buffer TimeOut과 같은 다른 오류를 확인할 수 있습니까?
다른 Android 기기로 애플리케이션을 사용해 보거나 기기를 재부팅하여 확인하십시오.

관련 문제