Tutorial: Custom Media Streaming for Android's MediaPlayer

Tutorials with advanced 'difficulty' and more Lines of Code.

Tutorial: Custom Media Streaming for Android's MediaPlayer

Postby biosopher » Sat Apr 05, 2008 12:15 am

I have had absolutely no luck streaming audio using the built-in MediaPlayer functionality so I decided to write my own streaming utility for the MediaPlayer.

My solution is now documented as a tutorial on my blog including including source code:

blog.pocketjourney.com.

Here's a sneak peak at a few screenshots:

Image

Please check it out & leave a comment on my blog if you have questions.

Best of luck,
biosopher
Last edited by biosopher on Mon Aug 25, 2008 11:47 pm, edited 1 time in total.
biosopher
Developer
Developer
 
Posts: 26
Joined: Sat Mar 15, 2008 8:14 pm
Location: San Francisco, California

Top

Postby plusminus » Sat Apr 05, 2008 12:15 pm

Hello acopernicus,

I haven't actually tried it, but it looks really nice :!:
I assume there is a short break, when the MediaPlayer is stopped, file copied and MediaPlayer restarted, right :?:

Did you think about submitting that tutorial to the Android Tutorial Challenge :?:
Image

You could win an Android Shirt :)
Looking at the text you have written, the chance is pretty good ;)

Best Regards,
plusminus
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Postby biosopher » Sat Apr 05, 2008 6:01 pm

Thanks for the recommendation about submitting into the tutorial challenge, +-. The TC is an excellent idea for getting more people to contribute back to the community.

As for the copying of the file while streaming, it's actually very quick and typically only occurs once. So while their is a slight stutter in audio playback, it's barely noticeable & isn't any different from your experience streaming a Quicktime or Flash video.

Cheers & thanks much for hosting this great site!

Biosopher
biosopher
Developer
Developer
 
Posts: 26
Joined: Sat Mar 15, 2008 8:14 pm
Location: San Francisco, California

Postby Stephen.Ada » Sun Apr 20, 2008 6:04 am

hi, acopernicus
i can't open ur blog on browser, it always displayed "The requested URL could not be retrieved", could u pls post the code here or upload it as attachment?
thx very much ^_^
Stephen.Ada
Junior Developer
Junior Developer
 
Posts: 10
Joined: Mon Mar 10, 2008 3:18 pm

Postby biosopher » Mon Apr 21, 2008 6:26 am

Everything appears to be working fine from my browser:

Here are the links again:


blog
http://blog.pocketjourney.com

I would advice visiting the blog, as the tutorial description should be very helpful. If you want though, you can get the code directly here:

Tutorial #3 source
http://www.pocketjourney.com/downloads/pj/tutorials/tutorial3.zip
Last edited by biosopher on Mon Aug 25, 2008 11:46 pm, edited 2 times in total.
biosopher
Developer
Developer
 
Posts: 26
Joined: Sat Mar 15, 2008 8:14 pm
Location: San Francisco, California

Postby vol » Mon Apr 21, 2008 8:40 pm

I'm glad to know that I'm not the only one getting confused and frustrated here. I'm assuming that the error codes of "what" and "extra" mean "google" and "developer" as in "google 1, developer 0" :x

Oh well. I guess I'll have to work on something else. I was hoping to the media player to teach myself services, but I suppose there's no joy for streaming, so I'll have to stick with local files, or just predownload them first.
vol
Junior Developer
Junior Developer
 
Posts: 15
Joined: Wed Apr 16, 2008 1:35 pm

Top

Problems streamming audio

Postby marielisacr » Wed May 21, 2008 10:19 pm

Hello acopernicus,

This is a great tutorial. I’m traying to add a funtionality, when i press a button i would like to change to the next song (i am playing a list of songs). It start play the music ok but after listening a few songs or after a while the emulator crash, it restart by itself, i don’t know what is going on.

I think than can be a problem of memory, but i am erasing all the files and making flush of the FileOutputStream.

I really appreciate your help. Thanks
marielisacr
Junior Developer
Junior Developer
 
Posts: 13
Joined: Wed May 21, 2008 10:04 pm

Postby biosopher » Thu May 22, 2008 4:00 am

Hi marielisacr,

Not sure if you mean your app is crashing (which I haven't experienced myself) or the app is crashing (which means you should try to catch exception that's being thrown) or just the MediaPlayer is crashing (which I've experienced and means you need to look at the stack trace).

I've experienced I/O problems & threading issues that initially made me think my MediaPlayer problems were in Android. Now though, I've developed a very robust framework around MediaPlayer as a Service that has been able to successfully play tens of audio files in a row without crashing.

So the short answer is that I need to know more about what you mean by crashing and whether you've got a stack trace yet.

Thanks,
Biosopher
biosopher
Developer
Developer
 
Posts: 26
Joined: Sat Mar 15, 2008 8:14 pm
Location: San Francisco, California

Postby marielisacr » Thu May 22, 2008 3:23 pm

Hi,

this is the problem. I have a list of songs that i want to play. The songs play ok. I have a button to change the songs. I wait until the buffer is almost full to change to another song and i do that many times, after a few songs the emulator restart the application, it doesn´t show any message or error in the screen and i put down what i have in the logs.

I am using your tutorial to play the songs and when i change to another song i am calling a method that set the variable isInterrupted to true so the thread can end and then put goblal variable to they initial state. In this case i am watting to the current thread ends to return to the initial method and avoid problems with the global variables and have threads that never die. After all this i call to the function startStreamingAudio with the new path.

This is the log:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. INFO/dalvikvm-heap(515): GC! (525 sec since last GC)
  2.  
  3. INFO/dalvikvm-heap(564): GC! (525 sec since last GC)
  4.  
  5. INFO/dalvikvm-heap(568): GC! (525 sec since last GC)
  6.  
  7. INFO/dalvikvm-heap(564): GC old usage 50.0%; now 1.041MB used / 2.083MB soft max (3.127MB real max)
  8.  
  9. INFO/dalvikvm-heap(564): GC freed 4 objects / 152 bytes in 89ms
  10.  
  11. INFO/dalvikvm-heap(568): GC old usage 49.8%; now 0.846MB used / 1.694MB soft max (2.062MB real max)
  12.  
  13. INFO/dalvikvm-heap(568): GC freed 1678 objects / 83248 bytes in 120ms
  14.  
  15. INFO/dalvikvm-heap(731): GC! (640 sec since last GC)
  16.  
  17. INFO/dalvikvm-heap(515): GC old usage 56.3%; now 2.026MB used / 4.026MB real max
  18.  
  19. INFO/dalvikvm-heap(515): GC freed 12675 objects / 982996 bytes in 265ms
  20.  
  21. INFO/dalvikvm-heap(731): GC old usage 82.4%; now 0.896MB used / 1.793MB soft max (2.062MB real max)
  22.  
  23. INFO/dalvikvm-heap(731): GC freed 2940 objects / 199920 bytes in 198ms
  24.  
  25. WARN/global(731): May 22, 2008 1:56:55 PM java.io.BufferedReader <init>
  26.  
  27. WARN/global(731): WARNING: Default buffer size used in BufferedReader constructor. It would be
  28.  
  29. WARN/global(731): better to be explicit if a 8k-char buffer is required.
  30.  
  31. INFO/ActivityManager(515): Starting activity: Intent { comp={com.android.ubuket.graphics/com.android.ubuket.graphics.PlayListTabs} }
  32.  
  33. INFO/ActivityThread(515): Loading resource-only package com.android.ubuket.graphics (in null)
  34.  
  35. DEBUG/SurfaceFlinger(515): Surface 1, heap=0x1573e8 destroyed
  36.  
  37. DEBUG/SurfaceFlinger(515): Surface 0, heap=0x1573e8 destroyed
  38.  
  39. DEBUG/SurfaceFlinger(515): Surface 1, heap=0xf9c90 destroyed
  40.  
  41. WARN/ActivityManager(515): Activity pause timeout for HistoryRecord{40162f08 {com.android.ubuket.graphics/com.android.ubuket.graphics.Ubuket}} ({com.android.ubuket.graphics/com.android.ubuket.graphics.Ubuket})
  42.  
  43. WARN/ActivityManager(515): activityPaused called for HistoryRecord{40162f08 {com.android.ubuket.graphics/com.android.ubuket.graphics.Ubuket}} but currently pausing null
  44.  
  45. DEBUG/ActivityThread(731): Performing launch of ActivityRecord{4001e6f0 token=android.os.BinderProxy@40071c58 {com.android.ubuket.graphics/com.android.ubuket.graphics.PlayListTabs}}
  46.  
  47. DEBUG/ActivityThread(731): Performing launch of ActivityRecord{40105478 token=android.app.LocalActivityManager$LocalActivityRecord@40105440 {com.android.ubuket.graphics/com.android.ubuket.graphics.ListMusic}}
  48.  
  49. DEBUG/AudioFlinger(515): Audio hardware entering standby
  50.  
  51. WARN/global(731): May 22, 2008 1:56:58 PM java.io.BufferedReader <init>
  52.  
  53. WARN/global(731): WARNING: Default buffer size used in BufferedReader constructor. It would be
  54.  
  55. WARN/global(731): better to be explicit if a 8k-char buffer is required.
  56.  
  57. WARN/global(731): May 22, 2008 1:57:00 PM java.io.BufferedReader <init>
  58.  
  59. WARN/global(731): WARNING: Default buffer size used in BufferedReader constructor. It would be
  60.  
  61. WARN/global(731): better to be explicit if a 8k-char buffer is required.
  62.  
  63. INFO/dalvikvm-heap(731): GC! (5083ms since last GC)
  64.  
  65. INFO/dalvikvm-heap(731): GC old usage 69.7%; now 1.251MB used / 2.503MB real max
  66.  
  67. INFO/dalvikvm-heap(731): GC freed 8465 objects / 554500 bytes in 65ms
  68.  
  69. DEBUG/dalvikvm(731): Exception Ljava/lang/IllegalStateException; from SQLiteCursor.java:403 not caught locally
  70.  
  71. INFO/dalvikvm(731): Uncaught exception thrown by finalizer (will be discarded):
  72.  
  73. INFO/dalvikvm(731): Ljava/lang/IllegalStateException;: Finalizing cursor android.database.sqlite.SQLiteCursor@401ae3d8 on login that has not been deactivated or closed
  74.  
  75. INFO/dalvikvm(731):     at android.database.sqlite.SQLiteCursor.finalize(SQLiteCursor.java:403)
  76.  
  77. INFO/dalvikvm(731):     at android.dalvik.NativeStart.run(Native Method)
  78.  
  79. DEBUG/dalvikvm(731): Exception Ljava/lang/IllegalStateException; from SQLiteCursor.java:403 not caught locally
  80.  
  81. INFO/dalvikvm(731): Uncaught exception thrown by finalizer (will be discarded):
  82.  
  83. INFO/dalvikvm(731): Ljava/lang/IllegalStateException;: Finalizing cursor android.database.sqlite.SQLiteCursor@4018e6f8 on login that has not been deactivated or closed
  84.  
  85. INFO/dalvikvm(731):     at android.database.sqlite.SQLiteCursor.finalize(SQLiteCursor.java:403)
  86.  
  87. INFO/dalvikvm(731):     at android.dalvik.NativeStart.run(Native Method)
  88.  
  89. DEBUG/dalvikvm(731): Exception Ljava/lang/IllegalStateException; from SQLiteCursor.java:403 not caught locally
  90.  
  91. INFO/dalvikvm(731): Uncaught exception thrown by finalizer (will be discarded):
  92.  
  93. INFO/dalvikvm(731): Ljava/lang/IllegalStateException;: Finalizing cursor android.database.sqlite.SQLiteCursor@4016e408 on login that has not been deactivated or closed
  94.  
  95. INFO/dalvikvm(731):     at android.database.sqlite.SQLiteCursor.finalize(SQLiteCursor.java:403)
  96.  
  97. INFO/dalvikvm(731):     at android.dalvik.NativeStart.run(Native Method)
  98.  
  99. WARN/global(731): May 22, 2008 1:57:01 PM java.io.BufferedReader <init>
  100.  
  101. WARN/global(731): WARNING: Default buffer size used in BufferedReader constructor. It would be
  102.  
  103. WARN/global(731): better to be explicit if a 8k-char buffer is required.
  104.  
  105. WARN/global(731): May 22, 2008 1:57:02 PM java.io.BufferedReader <init>
  106.  
  107. WARN/global(731): WARNING: Default buffer size used in BufferedReader constructor. It would be
  108.  
  109. WARN/global(731): better to be explicit if a 8k-char buffer is required.
  110.  
  111. INFO/ActivityManager(515): Displayed activity {com.android.ubuket.graphics/com.android.ubuket.graphics.PlayListTabs}: 6551 ms
  112.  
  113. INFO/ActivityManager(515): Done launching {com.android.ubuket.graphics/com.android.ubuket.graphics.PlayListTabs}: 6784 ms
  114.  
  115. DEBUG/ActivityManager(515): Stopping: HistoryRecord{40162f08 {com.android.ubuket.graphics/com.android.ubuket.graphics.Ubuket}}
  116.  
  117. INFO/JavaBinder(549): ***** ##### Had 200 binder operations without a GC, so GC NOW!
  118.  
  119. INFO/dalvikvm-heap(549): GC! (758 sec since last GC)
  120.  
  121. INFO/dalvikvm-heap(549): GC old usage 55.8%; now 1.956MB used / 3.912MB real max
  122.  
  123. INFO/dalvikvm-heap(549): GC freed 16489 objects / 1416404 bytes in 154ms
Parsed in 0.050 seconds, using GeSHi 1.0.8.4
marielisacr
Junior Developer
Junior Developer
 
Posts: 13
Joined: Wed May 21, 2008 10:04 pm

Postby biosopher » Thu May 22, 2008 4:03 pm

Hmmm...it's curious that you're not getting more of an error dump.

What version of the SDK are you using?
biosopher
Developer
Developer
 
Posts: 26
Joined: Sat Mar 15, 2008 8:14 pm
Location: San Francisco, California

Postby biosopher » Thu May 22, 2008 4:19 pm

How big are your audio files? If they're too big, you may be running out of disk space on the device. That should cause an IOException though and would be caught (I assume you're writing all those error to the log).

As a first step though, you can ensure you are deleting all your files after playing them. I actually have created a cache of for my audio files that is set to a max of 50MB. Since I have no problem storing and playing files up to that size limit, I doubt your disk is filling up...but it's possible.

When exactly does the error occur?

1) Right after you click the button & before the next audio starts to download.
2) While the new audio is buffering.
3) After the new audio is buffered and is being transferred to the player
4) After the new audio starts playing a little
5) ....?....

- Biosopher
biosopher
Developer
Developer
 
Posts: 26
Joined: Sat Mar 15, 2008 8:14 pm
Location: San Francisco, California

Postby marielisacr » Thu May 22, 2008 4:54 pm

I'm using regular audio files, like about 4 MB. the problem occurs after the new audio starts playing a little, I mean everything is going fine and suddently it restarts. I am deleting the two files so i guess it can't be a memory problem eather.

Here is how I am doing:

First I call to the method play after i have the song selected by the user. Then i call to the fuction initControls with the path and the song's name

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. public void play(int position){
  2.  
  3.                 setContentView(player);        
  4.  
  5.                 initControls(music_src[playing_song],songs_names[playing_song]);               
  6.  
  7.  
  8.  
  9.         }
Parsed in 0.031 seconds, using GeSHi 1.0.8.4


In initControls i setup all the layout content and i create a instance of StreamingMediaPlayer and call to startStreamingAudio with the àth of the file.

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. private void initControls(final String path,String song_name) {
  2.  
  3.  
  4.  
  5.                 //Set up all the layout elements and then//    
  6.  
  7.                 audioStreamer = new StreamingMediaPlayer(playButton,progressBar);
  8.  
  9.                 startStreamingAudio(path);
  10.  
  11.         }
Parsed in 0.034 seconds, using GeSHi 1.0.8.4


And then the method startStreaming is called (for the moment i am not using the size of the file)

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. private void startStreamingAudio(String path) {
  2.  
  3.                 try {          
  4.  
  5.                         audioStreamer.startStreaming(path,3560, 240);
  6.  
  7.                 } catch (IOException e) {
  8.  
  9.                         Log.e(getClass().getName(), "Error starting to stream audio.", e);                     
  10.  
  11.                 }              
  12.  
  13.         }
Parsed in 0.036 seconds, using GeSHi 1.0.8.4


When the button is pressed i do the following: I found the new path and then call to the metohod interrup, after that i start streamming audio again
private View.OnClickListener next = new View.OnClickListener() {

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.                 public void onClick(View v) {
  2.  
  3.  
  4.  
  5. // I found the new path
  6.  
  7.                         if (playing_song>=(songs_names.length-1))
  8.  
  9.                                 playing_song = 0;
  10.  
  11.                         else
  12.  
  13.                                 playing_song +=1;
  14.  
  15.  
  16.  
  17.                         setSongName(songs_names[playing_song]);                
  18.  
  19.                        
  20.  
  21.                         audioStreamer.interrupt();
  22.  
  23.                         startStreamingAudio(music_src[playing_song]);
  24.  
  25.                 }
  26.  
  27.         };
Parsed in 0.037 seconds, using GeSHi 1.0.8.4


The method interrup does the following:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  public void interrupt() {
  2.  
  3.         playButton.setEnabled(false);
  4.  
  5. //Interrup the thread
  6.  
  7.         isInterrupted = true;
  8.  
  9. //It wait until the thread finish to avoid problems with global variables
  10.  
  11.         while (!dead){}
  12.  
  13. //Stops the mediaPlayer
  14.  
  15.         mediaPlayer.stop();
  16.  
  17. //Set up all the variables again for a new song
  18.  
  19.         dead = false;
  20.  
  21.         isInterrupted = false;
  22.  
  23.         totalKbRead = 0;
  24.  
  25.         no_media_player=false;             
  26.  
  27. //And it delete the temp files
  28.  
  29.         deleteFile();
  30.  
  31.     }
Parsed in 0.037 seconds, using GeSHi 1.0.8.4
marielisacr
Junior Developer
Junior Developer
 
Posts: 13
Joined: Wed May 21, 2008 10:04 pm

Postby biosopher » Thu May 22, 2008 5:39 pm

Let's first track down where, in the process of playing the new file, does the crash occur.

1) File plays a little and crashes when it hits the end of the buffered content.
2) File plays and crashes when the fully loaded content is transferred to the MediaPlayer for continued play.

It's hard to tease these two scenarios apart because you're not sending the actual file size & time. If you were, you could look at the progress bar to see what was happening with the buffer.

I recommend logging this information and posting it here:

A) Log when the user presses play
B) Log when the initial buffer starts being downloaded
C) Log every 250Kb of file download
D) Log when the initial buffer download is completed
E) Log when the initial buffer is transferred to a new file for playing
F) Log when you start playing the audio file
G) Continue logging every 250Kb of file download
H) Log when the file is completely downloaded
J) Log when the full file is being transferred to a new file for playing
J) Log when you swap the prior buffered file for the now completely downloaded file
K) Log when you start playing the now completely downloaded file

That should give us enough to see when, in the download process, the crash occurs.

Post you log output here when you have it.

biosopher
biosopher
Developer
Developer
 
Posts: 26
Joined: Sat Mar 15, 2008 8:14 pm
Location: San Francisco, California

Postby marielisacr » Thu May 22, 2008 8:34 pm

Hi, i did what you said, here is the log. At the end i got the message that the apication i dead and then restarted.

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. INFO/ActivityManager(518): Displayed activity {com.android.ubuket.graphics/com.android.ubuket.graphics.PlayListTabs}: 9240 ms
  2.  
  3. INFO/ActivityManager(518): Done launching {com.android.ubuket.graphics/com.android.ubuket.graphics.PlayListTabs}: 9518 ms
  4.  
  5. DEBUG/ActivityManager(518): Stopping: HistoryRecord{401ff5f0 {com.google.android.home/com.google.android.home.NewHome}}
  6.  
  7. DEBUG/ActivityManager(518): Stopping: HistoryRecord{4019c850 {com.android.ubuket.graphics/com.android.ubuket.graphics.Ubuket}}
  8.  
  9. INFO/ActivityManager(518): Done launching {com.android.ubuket.graphics/com.android.ubuket.graphics.Ubuket}: 13678 ms
  10.  
  11. DEBUG/SurfaceFlinger(518): Surface 0, heap=0x1f4cc0 destroyed
  12.  
  13. INFO/dalvikvm-heap(565): GC! (47 sec since last GC)
  14.  
  15. INFO/dalvikvm-heap(565): GC old usage 82.4%; now 1.675MB used / 3.351MB real max
  16.  
  17. INFO/dalvikvm-heap(565): GC freed 4145 objects / 225820 bytes in 111ms
  18.  
  19. WARN/global(603): May 22, 2008 7:05:59 PM java.io.BufferedReader <init>
  20.  
  21. WARN/global(603): WARNING: Default buffer size used in BufferedReader constructor. It would be
  22.  
  23. WARN/global(603): better to be explicit if a 8k-char buffer is required.
  24.  
  25. INFO/dalvikvm-heap(603): GC! (7606ms since last GC)
  26.  
  27. INFO/dalvikvm-heap(603): GC old usage 50.2%; now 1.289MB used / 2.578MB real max
  28.  
  29. INFO/dalvikvm-heap(603): GC freed 6179 objects / 1410044 bytes in 84ms
  30.  
  31. DEBUG/dalvikvm(603): Exception Ljava/lang/IllegalStateException; from SQLiteCursor.java:403 not caught locally
  32.  
  33. INFO/dalvikvm(603): Uncaught exception thrown by finalizer (will be discarded):
  34.  
  35. INFO/dalvikvm(603): Ljava/lang/IllegalStateException;: Finalizing cursor android.database.sqlite.SQLiteCursor@40184d28 on login that has not been deactivated or closed
  36.  
  37. INFO/dalvikvm(603):     at android.database.sqlite.SQLiteCursor.finalize(SQLiteCursor.java:403)
  38.  
  39. INFO/dalvikvm(603):     at android.dalvik.NativeStart.run(Native Method)
  40.  
  41. DEBUG/dalvikvm(603): Exception Ljava/lang/IllegalStateException; from SQLiteCursor.java:403 not caught locally
  42.  
  43. INFO/dalvikvm(603): Uncaught exception thrown by finalizer (will be discarded):
  44.  
  45. INFO/dalvikvm(603): Ljava/lang/IllegalStateException;: Finalizing cursor android.database.sqlite.SQLiteCursor@40168460 on login that has not been deactivated or closed
  46.  
  47. INFO/dalvikvm(603):     at android.database.sqlite.SQLiteCursor.finalize(SQLiteCursor.java:403)
  48.  
  49. INFO/dalvikvm(603):     at android.dalvik.NativeStart.run(Native Method)
  50.  
  51. INFO/dalvikvm-heap(603): GC! (305ms since last GC)
  52.  
  53. INFO/dalvikvm-heap(603): GC old usage 47.5%; now 1.249MB used / 2.498MB soft max (2.627MB real max)
  54.  
  55. INFO/dalvikvm-heap(603): GC freed 752 objects / 1261448 bytes in 75ms
  56.  
  57. INFO/dalvikvm-heap(603): GC! (203ms since last GC)
  58.  
  59. INFO/dalvikvm-heap(603): GC old usage 50.9%; now 1.273MB used / 2.546MB soft max (2.627MB real max)
  60.  
  61. INFO/dalvikvm-heap(603): GC freed 302 objects / 1220112 bytes in 59ms
  62.  
  63. INFO/dalvikvm-heap(603): GC! (168ms since last GC)
  64.  
  65. INFO/dalvikvm-heap(603): GC old usage 50.2%; now 1.278MB used / 2.557MB soft max (2.627MB real max)
  66.  
  67. INFO/dalvikvm-heap(603): GC freed 239 objects / 1111500 bytes in 62ms
  68.  
  69. INFO/dalvikvm-heap(603): GC! (220ms since last GC)
  70.  
  71. INFO/dalvikvm-heap(603): GC old usage 49.6%; now 1.268MB used / 2.538MB soft max (2.627MB real max)
  72.  
  73. INFO/dalvikvm-heap(603): GC freed 227 objects / 1174580 bytes in 79ms
  74.  
  75. INFO/dalvikvm-heap(603): GC! (183ms since last GC)
  76.  
  77. INFO/dalvikvm-heap(603): GC old usage 49.4%; now 1.255MB used / 2.511MB soft max (2.627MB real max)
  78.  
  79. INFO/dalvikvm-heap(603): GC freed 190 objects / 1156296 bytes in 61ms
  80.  
  81. INFO/dalvikvm-heap(603): GC! (163ms since last GC)
  82.  
  83. INFO/dalvikvm-heap(603): GC old usage 50.7%; now 1.274MB used / 2.548MB soft max (2.627MB real max)
  84.  
  85. INFO/dalvikvm-heap(603): GC freed 169 objects / 1100676 bytes in 62ms
  86.  
  87. INFO/dalvikvm-heap(603): GC! (160ms since last GC)
  88.  
  89. INFO/dalvikvm-heap(603): GC old usage 50.8%; now 1.294MB used / 2.589MB soft max (2.627MB real max)
  90.  
  91. INFO/dalvikvm-heap(603): GC freed 170 objects / 1067592 bytes in 62ms
  92.  
  93. INFO/dalvikvm-heap(603): GC! (152ms since last GC)
  94.  
  95. INFO/dalvikvm-heap(603): GC old usage 48.6%; now 1.259MB used / 2.519MB soft max (2.627MB real max)
  96.  
  97. INFO/dalvikvm-heap(603): GC freed 138 objects / 1133456 bytes in 69ms
  98.  
  99. INFO/dalvikvm-heap(603): GC! (161ms since last GC)
  100.  
  101. INFO/dalvikvm-heap(603): GC old usage 50.8%; now 1.281MB used / 2.562MB soft max (2.627MB real max)
  102.  
  103. INFO/dalvikvm-heap(603): GC freed 150 objects / 1116840 bytes in 58ms
  104.  
  105. INFO/dalvikvm-heap(603): GC! (1579ms since last GC)
  106.  
  107. INFO/dalvikvm-heap(603): GC old usage 48.7%; now 1.248MB used / 2.496MB soft max (2.627MB real max)
  108.  
  109. INFO/dalvikvm-heap(603): GC freed 5479 objects / 1378140 bytes in 78ms
  110.  
  111. ERROR/com.android.ubuket.graphics.ListMusic(603): <span style="color: red">user presses play</span>
  112.  
  113. ERROR/com.android.ubuket.logic.StreamingMediaPlayer(603): <span style="color: red">initial buffer starts being downloaded </span>
  114.  
  115. ERROR/com.android.ubuket.logic.StreamingMediaPlayer(603):<span style="color: red">initial buffer is transferred to a new file for playing</span>
  116.  
  117. ERROR/com.android.ubuket.logic.StreamingMediaPlayer$4(603): <span style="color: red">start playing the audio file</span>
  118.  
  119. DEBUG/AudioFlinger(518): Audio hardware exiting standby
  120.  
  121. DEBUG/AudioMixer(518): enable(8192)
  122.  
  123. DEBUG/AudioMixer(518): mixer configuration change: 1 activeTracks (00000001) all16BitsStereoNoResample=1, resampling=0, volumeRamp=1
  124.  
  125. ERROR/com.android.ubuket.logic.StreamingMediaPlayer(603):  <span style="color: red">buffer is transferred to the file for continue playing</span>
  126.  
  127. DEBUG/AudioMixer(518): disable(8192)
  128.  
  129. DEBUG/AudioMixer(518): deleteTrackName(0)
  130.  
  131. DEBUG/AudioMixer(518): enable(8192)
  132.  
  133. DEBUG/AudioMixer(518): mixer configuration change: 1 activeTracks (00000001) all16BitsStereoNoResample=1, resampling=0, volumeRamp=0
  134.  
  135. ERROR/com.android.ubuket.logic.StreamingMediaPlayer(603):  <span style="color: red">initial buffer download is complete </span>
  136.  
  137. ERROR/com.android.ubuket.logic.StreamingMediaPlayer$5(603):  <span style="color: red">full file is being transferred to a new file for playing</span>
  138.  
  139. ERROR/com.android.ubuket.logic.StreamingMediaPlayer(603):  <span style="color: red">swap the prior buffered file for the now completely downloaded file </span>
  140.  
  141. DEBUG/AudioMixer(518): disable(8192)
  142.  
  143. DEBUG/AudioMixer(518): deleteTrackName(0)
  144.  
  145. ERROR/com.android.ubuket.logic.StreamingMediaPlayer(603): <span style="color: red">start playing the now completely downloaded file </span>
  146.  
  147. DEBUG/AudioMixer(518): enable(8192)
  148.  
  149. DEBUG/AudioMixer(518): mixer configuration change: 1 activeTracks (00000001) all16BitsStereoNoResample=1, resampling=0, volumeRamp=0
  150.  
  151. INFO/JavaBinder(518): ***** ##### Had 200 binder operations without a GC, so GC NOW!
  152.  
  153. INFO/dalvikvm-heap(518): GC! (226 sec since last GC)
  154.  
  155. INFO/dalvikvm-heap(518): GC old usage 57.8%; now 1.881MB used / 3.764MB real max
  156.  
  157. INFO/dalvikvm-heap(518): GC freed 12992 objects / 673280 bytes in 293ms
  158.  
  159. DEBUG/SurfaceFlinger(518): Surface 0, heap=0x102c48 destroyed
  160.  
  161. DEBUG/SurfaceFlinger(518): Surface 1, heap=0xfacf8 destroyed
  162.  
  163. INFO/dalvikvm(549): GREF has decreased to 99
  164.  
  165. ERROR/com.android.ubuket.graphics.ListMusic$5(603):<span style="color: red">user presses Next</span>
  166.  
  167. DEBUG/(603): removing file '/tmp/downloadingMedia74880.dat'
  168.  
  169. DEBUG/AudioMixer(518): disable(8192)
  170.  
  171. DEBUG/AudioMixer(518): deleteTrackName(0)
  172.  
  173. ERROR/com.android.ubuket.logic.StreamingMediaPlayer(603): <span style="color: red">initial buffer starts being downloaded </span>
  174.  
  175. DEBUG/AudioFlinger(518): Audio hardware entering standby
  176.  
  177. ERROR/com.android.ubuket.logic.StreamingMediaPlayer(603): <span style="color: red">initial buffer is transferred to a new file for playing</span>
  178.  
  179. ERROR/com.android.ubuket.logic.StreamingMediaPlayer$4(603):  <span style="color: red">start playing the audio file</span>
  180.  
  181. DEBUG/AudioFlinger(518): Audio hardware exiting standby
  182.  
  183. DEBUG/AudioMixer(518): enable(8192)
  184.  
  185. DEBUG/AudioMixer(518): mixer configuration change: 1 activeTracks (00000001) all16BitsStereoNoResample=1, resampling=0, volumeRamp=0
  186.  
  187. ERROR/com.android.ubuket.logic.StreamingMediaPlayer(603): <span style="color: red">buffer is transferred to the file for continue playing</span>
  188.  
  189. DEBUG/AudioMixer(518): disable(8192)
  190.  
  191. DEBUG/AudioMixer(518): deleteTrackName(0)
  192.  
  193. DEBUG/AudioMixer(518): enable(8192)
  194.  
  195. DEBUG/AudioMixer(518): mixer configuration change: 1 activeTracks (00000001) all16BitsStereoNoResample=1, resampling=0, volumeRamp=0
  196.  
  197. ERROR/com.android.ubuket.logic.StreamingMediaPlayer(603): <span style="color: red">buffer is transferred to the file for continue playing</span>
  198.  
  199. DEBUG/AudioMixer(518): disable(8192)
  200.  
  201. DEBUG/AudioMixer(518): deleteTrackName(0)
  202.  
  203. DEBUG/AudioMixer(518): enable(8192)
  204.  
  205. DEBUG/AudioMixer(518): mixer configuration change: 1 activeTracks (00000001) all16BitsStereoNoResample=1, resampling=0, volumeRamp=0
  206.  
  207. ERROR/com.android.ubuket.logic.StreamingMediaPlayer(603): <span style="color: red"> buffer is transferred to the file for continue playing</span>
  208.  
  209. DEBUG/AudioMixer(518): disable(8192)
  210.  
  211. DEBUG/AudioMixer(518): enable(8192)
  212.  
  213. DEBUG/AudioMixer(518): mixer configuration change: 1 activeTracks (00000002) all16BitsStereoNoResample=1, resampling=0, volumeRamp=1
  214.  
  215. ERROR/com.android.ubuket.logic.StreamingMediaPlayer(603): <span style="color: red"> buffer is transferred to the file for continue playing</span>
  216.  
  217. DEBUG/AudioMixer(518): disable(8192)
  218.  
  219. DEBUG/AudioMixer(518): deleteTrackName(1)
  220.  
  221. DEBUG/AudioMixer(518): enable(8192)
  222.  
  223. DEBUG/AudioMixer(518): mixer configuration change: 1 activeTracks (00000002) all16BitsStereoNoResample=1, resampling=0, volumeRamp=0
  224.  
  225. ERROR/com.android.ubuket.logic.StreamingMediaPlayer(603): <span style="color: red"> buffer is transferred to the file for continue playing</span>
  226.  
  227. DEBUG/AudioMixer(518): disable(8192)
  228.  
  229. DEBUG/AudioMixer(518): enable(8192)
  230.  
  231. DEBUG/AudioMixer(518): mixer configuration change: 1 activeTracks (00000004) all16BitsStereoNoResample=1, resampling=0, volumeRamp=1
  232.  
  233. ERROR/com.android.ubuket.graphics.ListMusic$6(603):  <span style="color: red">user presses Previous</span>
  234.  
  235. DEBUG/(603): removing file '/tmp/downloadingMedia74884.dat'
  236.  
  237. DEBUG/AudioMixer(518): disable(8192)
  238.  
  239. DEBUG/AudioMixer(518): deleteTrackName(2)
  240.  
  241. ERROR/com.android.ubuket.logic.StreamingMediaPlayer(603):  <span style="color: red">initial buffer starts being downloaded </span>
  242.  
  243. ERROR/com.android.ubuket.logic.StreamingMediaPlayer(603): <span style="color: red"> initial buffer is transferred to a new file for playing</span>
  244.  
  245. ERROR/com.android.ubuket.logic.StreamingMediaPlayer$4(603):  <span style="color: red">start playing the audio file</span>
  246.  
  247. DEBUG/AudioMixer(518): enable(8192)
  248.  
  249. DEBUG/AudioMixer(518): mixer configuration change: 1 activeTracks (00000004) all16BitsStereoNoResample=1, resampling=0, volumeRamp=0
  250.  
  251. ERROR/com.android.ubuket.logic.StreamingMediaPlayer(603):<span style="color: red"> buffer is transferred to the file for continue playing</span>
  252.  
  253. DEBUG/AudioMixer(518): disable(8192)
  254.  
  255. DEBUG/AudioMixer(518): deleteTrackName(2)
  256.  
  257. <span style="font-weight: bold">INFO/WindowManager(518): WIN DEATH: Window{401f74b8 com.android.ubuket.graphics/com.android.ubuket.graphics.PlayListTabs}
  258. INFO/ActivityManager(518): APP DEATH: com.android.ubuket.graphics</span>
  259.  
  260. DEBUG/SurfaceFlinger(518): Surface 1, heap=0x102c48 destroyed
  261.  
  262. DEBUG/AudioMixer(518): deleteTrackName(1)
  263.  
  264. DEBUG/AudioMixer(518): deleteTrackName(0)
  265.  
  266. INFO/ARMAssembler(518): generated scanline__00000077:03010104_00000504_00000000 [ 18 ipp] (37 ins) at [0xf8cb8:0xf8d4c] in 2999119 ns
  267.  
  268. DEBUG/ActivityManager(518): Restarting: HistoryRecord{4019c850 {com.android.ubuket.graphics/com.android.ubuket.graphics.Ubuket}}
  269.  
  270. INFO/WindowManager(518): WIN DEATH: Window{40282420 com.android.ubuket.graphics/com.android.ubuket.graphics.Ubuket}
  271.  
  272. INFO/ActivityManager(518): Starting app process com.android.ubuket.graphics to host activity {com.android.ubuket.graphics/com.android.ubuket.graphics.Ubuket}: pid=661
  273.  
  274. INFO/jdwp(661): prepping for JDWP over ADB
Parsed in 0.083 seconds, using GeSHi 1.0.8.4
marielisacr
Junior Developer
Junior Developer
 
Posts: 13
Joined: Wed May 21, 2008 10:04 pm

Postby biosopher » Fri May 23, 2008 12:06 am

Thanks. Few questions.

1) Why is the StreamingMediaPlayer transfering the downloaded content to a new buffer so often? Is your network connection slow? I.e. is it taking longer than 8 seconds to download your file. From your log, it looks like it takes a minute or so for the file to download.

2) From your debug trace, it appears that the method deleteTrackName() is sometimes called during the the buffer transfer. What does that method do & why is it called only sometimes?

ERROR/com.android.ubuket.logic.StreamingMediaPlayer(603): buffer is transferred to the file for continue playing
DEBUG/AudioMixer(518): disable(8192)
DEBUG/AudioMixer(518): deleteTrackName(1)
DEBUG/AudioMixer(518): enable(8192)

3) It appears the crash is being caused either within deleteTrackName() or directly after

DEBUG/AudioMixer(518): disable(8192)
DEBUG/AudioMixer(518): deleteTrackName(2)
INFO/WindowManager(518): WIN DEATH: Window{401f74b8 com.android.ubuket.graphics/com.android.ubuket.graphics.PlayListTabs}
INFO/ActivityManager(518): APP DEATH: com.android.ubuket.graphics

According to your debug trace, enable() is always called after a disable() when the buffer is transferred. Looks like your error occurs between the disable() & enable() during the buffer transfer.

You'll need to set breakpoints or write more detailed debug traces to the log to determine why this is happening.

- Biosopher
biosopher
Developer
Developer
 
Posts: 26
Joined: Sat Mar 15, 2008 8:14 pm
Location: San Francisco, California

Top
Next

Return to Advanced Tutorials

Who is online

Users browsing this forum: No registered users and 3 guests