Agreed. It takes about 100 msecs to spin up the audio output once it goes to standby. You will seeing something like this in the log:
W/AudioFlinger( 35): write blocked for 103 msecs If it's taking several seconds, there must be something else involved. On Apr 1, 11:51 am, Marco Nelissen <marc...@android.com> wrote: > I'm surprised that calling start() has no effect, and that it takes several > seconds for playback to work again. > Do you have the same issue when playing a file in the music player, for > example? > > On Tue, Mar 31, 2009 at 5:35 PM, Eric M. Burke <burke.e...@gmail.com> wrote: > > > > > I have an Activity that plays a brief OGG "pop" sound effect when > > bubbles pop. To keep it fast and to ensure I can play several pops, I > > create four MediaPlayer instances. I synchronize access to a pool of > > instances, so I can play up to four pops at once. Once a sound > > completes, I call seekTo(0) and return the MediaPlayer instance to my > > pool. > > > Here is a rough sketch of the code: > > > // when the activity resumes... > > for (int i=0; i<4; i++) { > > MediaPlayer mp = MediaPlayer.create(context, R.raw.pop); > > mp.setOnCompletionListener(this); > > mp.setVolume(1f, 1f); > > players.add(mp); // put into a pool of available players > > } > > > // when a bubble pops... > > MediaPlayer mp = ...get player instance from the pool > > if (mp != null) { > > mp.start(); // works! plays the pop sound > > } > > > // implement the OnCompletionListener interface > > public void onCompletion(MediaPlayer mp) { > > // seek to the start so I can play the sound fast the next time > > mp.seekTo(0); > > ....return the MediaPlayer to the pool > > } > > > Here is the problem. The pops all work so long as my game is active. > > But if I let it sit there for just a few seconds, I see this in the > > LogCat console: (on my G1 phone) > > > AudioHardwareMSM72xx Going to standby > > > Once this happens, the next several calls to MediaPlayer's start() > > method play nothing...but they do cause the audio hardware to wake up > > again, so then my sounds eventually (after a few seconds) start > > playing again. > > > My question is, how do I prevent the AudioHardwareMSM72xx from going > > to standby mode while my Activity is active? > > > One hacky idea...I could loop a continuous sound at extremely low > > volume level in another MediaPlayer instance to force it to stay > > awake. That's not appealing to me. > > > Ideas? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---