Android :: Service + AudioTrack - WAKE_LOCK?

Jan 25, 2010

I'm currently writing an app that uses a Service. A thread in the service generates an infinite stream of audio, and writes it to the AudioTrack. I want the audio to keep playing indefinitely until the user stops it. Based on my understanding of the PowerManager class, it looks like I should need a PARTIAL_WAKE_LOCK to keep the CPU awake so the audio can continue playing.

However, I left the audio playing on my phone with no wake lock, running on battery, in airplane mode, with all five items on the power control widget disabled, and the audio just kept right on playing for at least 15 minutes. Afterwards, I looked at the battery history, and it showed "Running (100%)", even though the Partial wake usage was negligible. Is there something special about AudioTrack which prevents the CPU from entering its deep sleep state? Should it be necessary for my service to grab a PARTIAL_WAKE_LOCK and its associated permission?

Android :: Service + AudioTrack - WAKE_LOCK?


Android :: AudioTrack Stop/release - AudioTrack Plays In The STREAM Mode

Dec 25, 2009

I need to stop the AudioTrack, regardless what's in the buffer, immediately when executing the stop/release. The AudioTrack plays in the STREAM mode. It appears that the AudioTrack finishes playing what's in the buffer and than stops. It seems that it's such a fundamental flaw since there are so many audio applications out there.

View 4 Replies View Related

Android :: How To Use AudioRecord And AudioTrack?

Apr 30, 2009

I want to use AudioRecord and AudioTrack classes(in SDK 1.5) in my program. Where can I find how to use it. Is there any API demo program for this?. If not it is greatly appreciated if someone can post a sample code in this forum.

View 7 Replies View Related

Android :: How Do We Use AudioTrack Class?

Apr 23, 2009

I'm currently initiating the AudioTrack() for MODE_STREAM. I load some bytes using the write() and I see that it is working but once hit the play() call nothing happens. what is the matter? should I do something else that is not obvious? Any tips Google friends? My settings: streamType - STREAM_MUSIC sampleRateInHz - 44100 channel Config - CHANNEL _CONFIGURATION_STEREO audioFormat - ENCODING_PCM_16BIT bufferSizeInBytes - 256K the total size (in bytes) of the buffer where audio data is read from for playback. mode - MODE_STREAM.

View 21 Replies View Related

Android :: How To Play Music From AudioTrack

Feb 15, 2010

I want to play music from online mp3 link.I am reading the music data into a stream and trying to play it using audio track. But itz giving only noise.No music i could listen.Same buffer I can play in Media Player,But i could not play in audio track.

View 16 Replies View Related

Android :: AudioTrack - Clicking Sound

Dec 15, 2009

I am getting this clicking sound when playing static pcm data. Anybody out there is having the same problem? This is not the data issue.

View 7 Replies View Related

Android :: Synchronizing AudioTrack And AudioRecord

Jan 21, 2010

My application uses AudioTrack in streaming mode and AudioRecord simultaneously.My problem is that I start them at the same time, but I have no guarantee that they will actually start playback ecording in the same timestamp. The reason I need this kind of accuracy is because I use echo cancellation (subtracting audio played to speaker from the recording).My echo canceller doesn't require an exact delay, but the delay introduced between AudioTrack and AudioRecord moves in the range of 250ms (between different runs), and that's too much - each run is different because they start themselves asynchronously. The API doesn't provide me a way to make sure they start in the same time, so I thought about measuring this starting delay somehow and then using it in my calculation.Does anyone have an idea how to do that, utilizing their API or in any other way?

View 2 Replies View Related

Android :: Audio Stuttering When Using AudioTrack

Apr 13, 2010

I'm in the process of wring a music player that can play SID tracks (music from the Commodore 64), and everything is progressing nicely, except that I sometimes get audio stuttering.The stuttering only happens when the player is in the background, and another application has focus. It's most noticeable when a cpu heavy app(like Google Earth) is running in the foreground.I have tried adjusting the priority of my thread and increasing the AudioTrack buffer size, but nothing has solved the stuttering problem.I believe the problem is that generating the audio takes quite a lot of cycles (I'm at 15-30% cpu load), and that my audio thread is being starved and cant keep up with AudioTrack's constant need for data.I'm must be doing something wrong, I can't imagine that gui threads should be able to starve a high priority audio thread.I hope someone have some ideas on how to get my player stutter free, as I'm at a loss :)

View 9 Replies View Related

Android :: Memory Leak In AudioTrack?

Jun 27, 2009

If I create and release multiple AudioTrack objects, the GREF count continually increases which eventually causes an application crash. Even with a forced garbage collection, I end up with the same high GREF count at the end of the loop.In my application, I continuously create AudioTracks from variable lenght buffers.I guess I can try and use a fixed size pool of AudioTracks each with a buffer large enough to fit my longest sound, and try and reuse them.Is there a better/correct way to completely clear resources used by an AudioTrack?

View 5 Replies View Related

Android :: How To Realize AudioTrack Class In SDK 1.1?

Aug 10, 2009

There is a AudioTrack Class in SDK 1.5 which can play PCM buffer directly.But it is not exist in SDK 1.1. I want to play PCM buffer in SDK1.1,but i don't know how.

View 2 Replies View Related

Android :: AudioTrack Sanity Test

Oct 2, 2009

I am trying to determine if I should go the ndk way to work on a music synth app, but first wanted to do a sanity check in the java layer by testing how many sine tones i could play concurrently, and so I tried this. And it's pretty low: I can only play about 4 or 5 tones before the obtainBuffer timeouts start increasing in number. Also, changing the media volume while the tones are playing disrupts the output.

View 3 Replies View Related

Android :: AudioTrack - Clicking Error

Jan 21, 2010

I am trying to resolve the clicking problem while using the AudioTrack. It takes place only when playing the first part of the wave (pcm) buffer when the offset to the write is 0 (zero). track.write(buffer, offset, minBufferSize); It tells me that there is something wrong with the pcm data. Could it be because the wave data, I generate using Audacity, has some header as opposed to the pure pcm which does not? I was looking for the converter tools to generate pure pcm but found none. Applications I found generate only wave data so I am not able to test this assumption. At this point I am sure that filling the buffer is correct. Any ideas?

View 2 Replies View Related

Android :: AudioTrack Stop - Release ?

Dec 16, 2009

It doesn't seems as if the the stop and release immediately terminates the audio played by the MODE_STREAM track. It looks like it finishes playing the rest of the buffer and then stops.

View 3 Replies View Related

Android :: AudioTrack Start Called From Thread

Dec 8, 2009

I am getting the 'AudioTrack::start called from thread' when starting an AudioTrack. I am using it in a thread. I asume I shouldn't but why? I see it as a major limitation.

View 4 Replies View Related

Android :: Is AudioTrack Fundamentally Designed To Be Singleton?

Dec 14, 2009

Is the AudioTrack fundamentally designed to be a singleton? Methods on the OnPlaybackPositionUpdateListener receive just one argument, which is the AudioTrack itself. And since the AudioTrack does not have getTag/setTag methods I don't see any way to distinguish among multiple AudioTracks in the OnPlaybackPositionUpdateListener methods short of keeping track of references. So, if it's so why it's not implemented as a singleton? Any thoughts. I am trying to implement concurrent use of the AudioTrack. Anybody has any experience with this approach? Am I wasting time?

View 3 Replies View Related

Android :: Increase Speaker Volume Using AudioTrack

Jun 26, 2009

how to increase the volume of speaker using AudioTrack? the streamed audio is playing in speaker, but not loud as voice call. Here my code..............

View 2 Replies View Related

Android :: AudioTrack Cutting Audio Short

Dec 15, 2009

I am trying to play a 0.1s tone using audio track. I have done this succesfully in stream mode by calling play() then writing the array of short containing the data. However when I use STATIC mode and also in stream mode if I write the data before i call play() only about 0.06s of the audio is played. I have tried changing the buffer size but this has not effect.My understanding is that I have to write the data before I call play for static mode to work. Does anyone know what could be going wrong here?

View 5 Replies View Related

Android :: Continuous Raw Audio Playback Using AudioTrack

Dec 29, 2009

I am trying to play raw audio samples ( 16 bit, stereo, @ 32000KHz) using AudioTrack, in "MODE_STREAM" mode. I could play the first video buffer successfully but, After having received "onMarkerReached" for that raw audio buffer, I wonder how to push more audio data in AudioTrack ? without closing/stopping it. Writing more data to AudioTrack in "onMarkerReached" callback does not help. I am using the same thread to construct the AudioTrack and pump in audio - buffers and receive callbacks.

View 2 Replies View Related

Android :: ObtainBuffer Timed Out In AudioTrack.write

Sep 1, 2010

After stopping and restarting playback of an audiotrack stream, on some devices I consistently get;

W/AudioTrack( 2453): obtainBuffer timed out (is the CPU pegged?) 0x64acc0 user=00010000, server=00000000

after freezing for a couple of seconds. This happens whether I just pause() and flush() my audiotrack or release() and recreate it.

View 4 Replies View Related

Android :: AudioTrack - 51 - WARNING - ObtainBuffer() Timed Out

Nov 4, 2009

I am using MediaPlayer to play background music and SoundPool to play sound effects. All Audio data is stored in .ogg file format. Sometimes it happens that the MediaPlayer playback is interrupted for a fraction of a second if SoundPool.play() is called. Whenever this happens, the following two warnings are printed to logcat:

11-04 01:49:05.113: WARN/AudioTrack(51): obtainBuffer timed out (is the CPU pegged?) 0x2b6e8 user=000cc520, server=000cb710 11-04 01:49:05.113: WARN/AudioTrack(51): *** SERIOUS WARNING *** obtainBuffer() timed out but didn't need to be locked. We recovered, but this shouldn't happen (user=000cc520, server=000cb710)

Do you have any ideas what could cause the warning messages and/or how to avoid them? I.e. how to prevent SoundPool.play() from interrupting MediaPlayer playback?

An other warning that's sometimes appearing is: 11-04 01:55:49.793: WARN/AudioFlinger(51): write blocked for 89 msecs There seems to be no connection to the above messages, but do you have any ideas what causes this message and/or how to avoid it?

Here's some more detailed background information, maybe they are useful: My OpenGL powered game is split into three threads: One for rendering, one to take care about the game logic and the main thread to process user input. All Audio data is accessed through a central AudioManager class, which is only used in the game logic thread. (So this does not seem like a threading issue. Needless to say that synchronizing all methods has not solved the problem). The game runs smoothly at ~60 frames per second. According to DDMS the game causes ~33% system load (~10% in kernel space and ~23% in user space) on a G1. Even the idle task gets ~24% CPU time assigned while the game is running and input happens through the touch screen! (So it does not look like a performance problem) The MediaPlayer playback interruption always happens if SoundPool.play () is called in response of a touch screen input. Although touch screen input and SoundPool.play() happen in different threads. I've tried suspending the UI thread for various different delays between 8 and 32 msec after a MotionEvent has been processed, but again, without success...

View 3 Replies View Related

Android :: Playing AudioTrack Multiple Times Producing Crash

Mar 16, 2010

I am trying to play audio buffered sound (.wav) using AudioTrack. Please see the code below. I need to call this function under a Thread to support simultaneous play. It is fine being under a Thread. It is working fine playing the sound normally. But if i execute playing the sound using AudioTrack one after another continuously (i.e. executing second play before completing the first play sound), produces device crash (force close unexpectedly error). Does anyone come across such problems and resolve it in a way?

View 1 Replies View Related

Android :: Low Level Audio - Latency In SoundPool - AudioTrack For Real Time

Oct 26, 2009

I first have to say that I'm biased, 'cus I like to write music apps (like music generation apps). However, this affects games as well. It's somewhat disappointing how OpenGL has made it into the NDK now but there isn't any NDK methods to get to sound to have faster access. Over the weekend I did some more testing and if you make a "drum" app, for example, and play the sound using either SoundPool or AudioTrack, you will get about a 100ms delay buffer, which is clearly audible (gap).

I made a test app where when you touch the screen, upon the DOWN event, it would play a short sound (like a drum sound). It clearly was not real time responsive or even close - you could hear the delay. I'd be interested to know if anyone who has made a game has any trouble with sounds? It seems like they aren't going to really trigger real time enough if you use SoundPool, for example. Am I completely wrong? Seems like your game is going to perform an action, play a sound, but the sound will have latency which I would think would throw off the game a bit..................

View 12 Replies View Related

Android :: Android AudioRecord And AudioTrack Codec Options?

Feb 3, 2010

I currently use the AudioTrack and AudioRecord classes in Android.I use the pure PCM data but I was wondering what my options are for other codecs?From this page it seems I can only encode and decode using AMR narrowband?The code runs properly but I'm wondering does it actually encode the Audio as AMR_NB and if this is not a proper way to do it?I was getting a buffer overflow when using raw PCM but none have appeared since using the new code with the MediaRecorder.AudioEncoder.AMR_NB used instead of the AudioFormat.PCM

View 2 Replies View Related

Android :: Possible To Use Android.media.AudioTrack Class In Non Blocking Way?

Sep 29, 2009

I have some questions about the AudioTrack class that I can't seem to answer by reading the class documentation.Is it possible to use the android.media.AudioTrack class in a non- blocking way?If so, what conditions must be true to ensure that the write() method doesnt block?How do the position marker notifications work?They seem to be measured in "frames", what is a frame?Where can I find documentation on frames?When the marker notification occurs, is the callback made from a thread that called write() or from some other thread?

View 3 Replies View Related

Android ::PCM Output Code From Java To Android AudioTrack API

Apr 25, 2010

I'm attempting to port an application that plays chiptunes (NSF, SPC, etc) music files from Java SE to Android. The Android API seems to lack the javax multimedia classes that this application uses to output raw PCM audio. The closest analog I've found in the API is AudioTrack and so I've been wrestling with that. However, when I try to run one of my sample music files through my port-in-progress, all I get back is static. My suspicion is that it's the AudioTrack I've setup which is at fault. I've tried various different constructors but it all just outputs static in the end. The DataLine setup in the original code is something like I've replaced constants and variables in those so they make sense as concisely as possible, but my basic question is if there are any obvious problems in the assumptions I made when going from one format to the other.

View 1 Replies View Related

Android :: Using AudioTrack In Android To Play A WAV File

Oct 13, 2010

I'm working with Android, trying to make my AudioTrack application play a Windows .wav file (Tada.wav). Frankly, it shouldn't be this hard, but I'm hearing a lot of strange stuff. The file is saved on my phone's mini SD card and reading the contents doesn't seem to be a problem, but when I play the file (with parameters I'm only PRETTY SURE are right), I get a few seconds of white noise before the sound seems to resolve itself into something that just may be right. I have successfully recorded and played my own voice back on the phone I created a .pcm file according to the directions in this example:http://emeadev.blogspot.com/2009/09/ raw-audio-manipulation-in-android.html Anybody got some suggestions or awareness of an example on the web for playing a .wav file on an Android?

View 2 Replies View Related

Android :: Showing Toasts In A Service From Worker Threads With Service Reference

Jun 24, 2009

I have a service running in the background.I have a background thread that gets a reference to the service from the application's main activity. But when the background thread calls a method in the service to display a toast, I get the "Looper not initialized exception".Why,if I have a valid, bound reference to a Service, does this still happen?

View 4 Replies View Related

Android :: Unable To Start Service Intent Service Not Found

Aug 20, 2009

I am getting following message when i try to launch service.Also is there any specific path on file system where we need to place the .apk file which contains my serivce component only.

View 2 Replies View Related

Android :: Service Auto Restarts On Breakpoint When Debugging A Service

Jul 22, 2010

I am trying to run the sample soft keyboard included in the SDK. I am using the debugger, and the literature says that to use a breakpoint while debugging a SERVICE, I need to include:

android.os.Debug.waitForDebugger();

So here is the portion of the code I modified:

CODE:...........

I have put a couple of breakpoints, at the statements indicated by the comments.

This is what happens: the debugger first stops at the breakpoint1, for a few seconds. But then the service restarts. For the life of me I can't figure out what makes the service to restart.

View 3 Replies View Related

Android :: How To Get Interface On Service Without Destroying Service At Unbind?

Mar 1, 2009

My service works exactly the way i want as long as i use start and stop and communicate using intents. However my activity needs to change the state of my service as well as retrieving state information.So i thought it would be nice to broadcast some kind of state_changed event from my service and use a binder interface to pull information from the service or change the services state based on user input.This works fine too. The only problem is that my service gets killed when i unbind it just as the documentation says.Is there any way to keep the service alive but still get an interface to control it directly. My activity offers the user a way to stop the service and the service kills itself anyway after it's work is done but i don't want the service to stop every time the activity is destroyed.

View 3 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved