Discussion:
ERROR/MediaPlayer(1066): setDataSource called in state 128
ATrubka
2009-04-07 20:28:41 UTC
Permalink
Hi, guys.

I'm using MediaPlayer and sometimes when first audio is about to end
and I click to the next audio I get the exception below. Looks like
the MediaPlayer is in some weird state of stopping playing and cannot
accept audio at the moment.

The exception goes to the native code which is greeks to me.
I couldn't find anything about this error on the internet either.

Is anyone here familiar with the problem?

Thank you in advance!

04-07 20:19:35.855: ERROR/MediaPlayer(1066): setDataSource called in
state 128
04-07 20:19:35.855: ERROR/AudioPlayerService(1066): Unable to play
chapter audio
04-07 20:19:35.855: ERROR/AudioPlayerService(1066):
java.lang.IllegalStateException
04-07 20:19:35.855: ERROR/AudioPlayerService(1066): at
android.media.MediaPlayer.setDataSource(Native Method)
04-07 20:19:35.855: ERROR/AudioPlayerService(1066): at
com.tourizo.android.services.AudioPlayerService.playResource
(AudioPlayerService.java:291)
04-07 20:19:35.855: ERROR/AudioPlayerService(1066): at
com.tourizo.android.services.AudioPlayerService.access$3
(AudioPlayerService.java:287)
04-07 20:19:35.855: ERROR/AudioPlayerService(1066): at
com.tourizo.android.services.AudioPlayerService$1.playCurrentChapter
(AudioPlayerService.java:89)
04-07 20:19:35.855: ERROR/AudioPlayerService(1066): at
com.tourizo.android.services.AudioPlayerRemoteInterface$Stub.onTransact
(AudioPlayerRemoteInterface.java:99)
04-07 20:19:35.855: ERROR/AudioPlayerService(1066): at
android.os.Binder.execTransact(Binder.java:276)
04-07 20:19:35.855: ERROR/AudioPlayerService(1066): at
dalvik.system.NativeStart.run(Native Method)
Marco Nelissen
2009-04-08 02:20:09 UTC
Permalink
Looks like you're calling MediaPlayer.setDataSource() on a MediaPlayer
that was already initialized, without first calling
MediaPlayer.reset()
Post by ATrubka
Hi, guys.
I'm using MediaPlayer and sometimes when first audio is about to end
and I click to the next audio I get the exception below. Looks like
the MediaPlayer is in some weird state of stopping playing and cannot
accept audio at the moment.
The exception goes to the native code which is greeks to me.
I couldn't find anything about this error on the internet either.
Is anyone here familiar with the problem?
Thank you in advance!
04-07 20:19:35.855: ERROR/MediaPlayer(1066): setDataSource called in
state 128
04-07 20:19:35.855: ERROR/AudioPlayerService(1066): Unable to play
chapter audio
java.lang.IllegalStateException
04-07 20:19:35.855: ERROR/AudioPlayerService(1066):     at
android.media.MediaPlayer.setDataSource(Native Method)
04-07 20:19:35.855: ERROR/AudioPlayerService(1066):     at
com.tourizo.android.services.AudioPlayerService.playResource
(AudioPlayerService.java:291)
04-07 20:19:35.855: ERROR/AudioPlayerService(1066):     at
com.tourizo.android.services.AudioPlayerService.access$3
(AudioPlayerService.java:287)
04-07 20:19:35.855: ERROR/AudioPlayerService(1066):     at
com.tourizo.android.services.AudioPlayerService$1.playCurrentChapter
(AudioPlayerService.java:89)
04-07 20:19:35.855: ERROR/AudioPlayerService(1066):     at
com.tourizo.android.services.AudioPlayerRemoteInterface$Stub.onTransact
(AudioPlayerRemoteInterface.java:99)
04-07 20:19:35.855: ERROR/AudioPlayerService(1066):     at
android.os.Binder.execTransact(Binder.java:276)
04-07 20:19:35.855: ERROR/AudioPlayerService(1066):     at
dalvik.system.NativeStart.run(Native Method)
ATrubka
2009-04-08 05:38:56 UTC
Permalink
MediaPlayer.reset() always gets invoked. Here's the exact lines of
code:

_mediaPlayer.reset();
_mediaPlayer.setDataSource(resource);
_mediaPlayer.prepare();
_mediaPlayer.start();

Additionally, the error occurs only when next audio starts while
previous audio is about to end.
If next audio starts in the middle of the playback or after it has
completely stopped playing, then everything works fine.

It looks pretty much like a synchronization issue to me.
This method is not synchronized at the moment.
Since most of the MediaPlayer code is native I'm not sure what should
be synchronized.
Post by Marco Nelissen
Looks like you're calling MediaPlayer.setDataSource() on a MediaPlayer
that was already initialized, without first calling
MediaPlayer.reset()
Post by ATrubka
Hi, guys.
I'm using MediaPlayer and sometimes when first audio is about to end
and I click to the next audio I get the exception below. Looks like
the MediaPlayer is in some weird state of stopping playing and cannot
accept audio at the moment.
The exception goes to the native code which is greeks to me.
I couldn't find anything about this error on the internet either.
Is anyone here familiar with the problem?
Thank you in advance!
04-07 20:19:35.855: ERROR/MediaPlayer(1066): setDataSource called in
state 128
04-07 20:19:35.855: ERROR/AudioPlayerService(1066): Unable to play
chapter audio
java.lang.IllegalStateException
04-07 20:19:35.855: ERROR/AudioPlayerService(1066):     at
android.media.MediaPlayer.setDataSource(Native Method)
04-07 20:19:35.855: ERROR/AudioPlayerService(1066):     at
com.tourizo.android.services.AudioPlayerService.playResource
(AudioPlayerService.java:291)
04-07 20:19:35.855: ERROR/AudioPlayerService(1066):     at
com.tourizo.android.services.AudioPlayerService.access$3
(AudioPlayerService.java:287)
04-07 20:19:35.855: ERROR/AudioPlayerService(1066):     at
com.tourizo.android.services.AudioPlayerService$1.playCurrentChapter
(AudioPlayerService.java:89)
04-07 20:19:35.855: ERROR/AudioPlayerService(1066):     at
com.tourizo.android.services.AudioPlayerRemoteInterface$Stub.onTransact
(AudioPlayerRemoteInterface.java:99)
04-07 20:19:35.855: ERROR/AudioPlayerService(1066):     at
android.os.Binder.execTransact(Binder.java:276)
04-07 20:19:35.855: ERROR/AudioPlayerService(1066):     at
dalvik.system.NativeStart.run(Native Method)
ATrubka
2009-04-08 20:05:43 UTC
Permalink
Guys, please...
Is there any Android native code developers around?
Post by ATrubka
MediaPlayer.reset() always gets invoked. Here's the exact lines of
                _mediaPlayer.reset();
                _mediaPlayer.setDataSource(resource);
                _mediaPlayer.prepare();
                _mediaPlayer.start();
Additionally, the error occurs only when next audio starts while
previous audio is about to end.
If next audio starts in the middle of the playback or after it has
completely stopped playing, then everything works fine.
It looks pretty much like a synchronization issue to me.
This method is not synchronized at the moment.
Since most of the MediaPlayer code is native I'm not sure what should
be synchronized.
Post by Marco Nelissen
Looks like you're calling MediaPlayer.setDataSource() on a MediaPlayer
that was already initialized, without first calling
MediaPlayer.reset()
Post by ATrubka
Hi, guys.
I'm using MediaPlayer and sometimes when first audio is about to end
and I click to the next audio I get the exception below. Looks like
the MediaPlayer is in some weird state of stopping playing and cannot
accept audio at the moment.
The exception goes to the native code which is greeks to me.
I couldn't find anything about this error on the internet either.
Is anyone here familiar with the problem?
Thank you in advance!
04-07 20:19:35.855: ERROR/MediaPlayer(1066): setDataSource called in
state 128
04-07 20:19:35.855: ERROR/AudioPlayerService(1066): Unable to play
chapter audio
java.lang.IllegalStateException
04-07 20:19:35.855: ERROR/AudioPlayerService(1066):     at
android.media.MediaPlayer.setDataSource(Native Method)
04-07 20:19:35.855: ERROR/AudioPlayerService(1066):     at
com.tourizo.android.services.AudioPlayerService.playResource
(AudioPlayerService.java:291)
04-07 20:19:35.855: ERROR/AudioPlayerService(1066):     at
com.tourizo.android.services.AudioPlayerService.access$3
(AudioPlayerService.java:287)
04-07 20:19:35.855: ERROR/AudioPlayerService(1066):     at
com.tourizo.android.services.AudioPlayerService$1.playCurrentChapter
(AudioPlayerService.java:89)
04-07 20:19:35.855: ERROR/AudioPlayerService(1066):     at
com.tourizo.android.services.AudioPlayerRemoteInterface$Stub.onTransact
(AudioPlayerRemoteInterface.java:99)
04-07 20:19:35.855: ERROR/AudioPlayerService(1066):     at
android.os.Binder.execTransact(Binder.java:276)
04-07 20:19:35.855: ERROR/AudioPlayerService(1066):     at
dalvik.system.NativeStart.run(Native Method)
Marco Nelissen
2009-04-09 20:23:40 UTC
Permalink
I am one, and the error you posted indicates you called setDataSource
while the MediaPlayer was in the 'playback completed' state.
It could be a race condition in the framework, but since I have never
seen this problem occur with the Android music app, I'm inclined to
think it's a problem with your code. As a workaround, you could create
a new MediaPlayer when you want to play something new.
Post by ATrubka
Guys, please...
Is there any Android native code developers around?
Post by ATrubka
MediaPlayer.reset() always gets invoked. Here's the exact lines of
                _mediaPlayer.reset();
                _mediaPlayer.setDataSource(resource);
                _mediaPlayer.prepare();
                _mediaPlayer.start();
Additionally, the error occurs only when next audio starts while
previous audio is about to end.
If next audio starts in the middle of the playback or after it has
completely stopped playing, then everything works fine.
It looks pretty much like a synchronization issue to me.
This method is not synchronized at the moment.
Since most of the MediaPlayer code is native I'm not sure what should
be synchronized.
Post by Marco Nelissen
Looks like you're calling MediaPlayer.setDataSource() on a MediaPlayer
that was already initialized, without first calling
MediaPlayer.reset()
Post by ATrubka
Hi, guys.
I'm using MediaPlayer and sometimes when first audio is about to end
and I click to the next audio I get the exception below. Looks like
the MediaPlayer is in some weird state of stopping playing and cannot
accept audio at the moment.
The exception goes to the native code which is greeks to me.
I couldn't find anything about this error on the internet either.
Is anyone here familiar with the problem?
Thank you in advance!
04-07 20:19:35.855: ERROR/MediaPlayer(1066): setDataSource called in
state 128
04-07 20:19:35.855: ERROR/AudioPlayerService(1066): Unable to play
chapter audio
java.lang.IllegalStateException
04-07 20:19:35.855: ERROR/AudioPlayerService(1066):     at
android.media.MediaPlayer.setDataSource(Native Method)
04-07 20:19:35.855: ERROR/AudioPlayerService(1066):     at
com.tourizo.android.services.AudioPlayerService.playResource
(AudioPlayerService.java:291)
04-07 20:19:35.855: ERROR/AudioPlayerService(1066):     at
com.tourizo.android.services.AudioPlayerService.access$3
(AudioPlayerService.java:287)
04-07 20:19:35.855: ERROR/AudioPlayerService(1066):     at
com.tourizo.android.services.AudioPlayerService$1.playCurrentChapter
(AudioPlayerService.java:89)
04-07 20:19:35.855: ERROR/AudioPlayerService(1066):     at
com.tourizo.android.services.AudioPlayerRemoteInterface$Stub.onTransact
(AudioPlayerRemoteInterface.java:99)
04-07 20:19:35.855: ERROR/AudioPlayerService(1066):     at
android.os.Binder.execTransact(Binder.java:276)
04-07 20:19:35.855: ERROR/AudioPlayerService(1066):     at
dalvik.system.NativeStart.run(Native Method)
ATrubka
2009-04-10 03:23:30 UTC
Permalink
I agree that it's most likely me doing something wrong.
It looks like when the audio file is about to end the state of
MediaPlayer gets changed in the native code.
And maybe reset() doesn't take effect during this process while
setDataSource(), invoked right after, finds player not to be ready.

Maybe Android music app creates MediaPlayer every time or synchronizes
the invocations somehow.
I wonder whether the situation I described is possible and if it is
whether you can advise on the solution.

I can create MediaPlayer all the time, but I'm afraid to use too many
resources doing so.
I'm usually reluctant to creation of unnecessary objects.

I really appreciate your help and apologize for my not very deep
knowledge of the player functionality.
Post by Marco Nelissen
I am one, and the error you posted indicates you called setDataSource
while the MediaPlayer was in the 'playback completed' state.
It could be a race condition in the framework, but since I have never
seen this problem occur with the Android music app, I'm inclined to
think it's a problem with your code. As a workaround, you could create
a new MediaPlayer when you want to play something new.
Post by ATrubka
Guys, please...
Is there any Android native code developers around?
Post by ATrubka
MediaPlayer.reset() always gets invoked. Here's the exact lines of
                _mediaPlayer.reset();
                _mediaPlayer.setDataSource(resource);
                _mediaPlayer.prepare();
                _mediaPlayer.start();
Additionally, the error occurs only when next audio starts while
previous audio is about to end.
If next audio starts in the middle of the playback or after it has
completely stopped playing, then everything works fine.
It looks pretty much like a synchronization issue to me.
This method is not synchronized at the moment.
Since most of the MediaPlayer code is native I'm not sure what should
be synchronized.
Post by Marco Nelissen
Looks like you're calling MediaPlayer.setDataSource() on a MediaPlayer
that was already initialized, without first calling
MediaPlayer.reset()
Post by ATrubka
Hi, guys.
I'm using MediaPlayer and sometimes when first audio is about to end
and I click to the next audio I get the exception below. Looks like
the MediaPlayer is in some weird state of stopping playing and cannot
accept audio at the moment.
The exception goes to the native code which is greeks to me.
I couldn't find anything about this error on the internet either.
Is anyone here familiar with the problem?
Thank you in advance!
04-07 20:19:35.855: ERROR/MediaPlayer(1066): setDataSource called in
state 128
04-07 20:19:35.855: ERROR/AudioPlayerService(1066): Unable to play
chapter audio
java.lang.IllegalStateException
04-07 20:19:35.855: ERROR/AudioPlayerService(1066):     at
android.media.MediaPlayer.setDataSource(Native Method)
04-07 20:19:35.855: ERROR/AudioPlayerService(1066):     at
com.tourizo.android.services.AudioPlayerService.playResource
(AudioPlayerService.java:291)
04-07 20:19:35.855: ERROR/AudioPlayerService(1066):     at
com.tourizo.android.services.AudioPlayerService.access$3
(AudioPlayerService.java:287)
04-07 20:19:35.855: ERROR/AudioPlayerService(1066):     at
com.tourizo.android.services.AudioPlayerService$1.playCurrentChapter
(AudioPlayerService.java:89)
04-07 20:19:35.855: ERROR/AudioPlayerService(1066):     at
com.tourizo.android.services.AudioPlayerRemoteInterface$Stub.onTransact
(AudioPlayerRemoteInterface.java:99)
04-07 20:19:35.855: ERROR/AudioPlayerService(1066):     at
android.os.Binder.execTransact(Binder.java:276)
04-07 20:19:35.855: ERROR/AudioPlayerService(1066):     at
dalvik.system.NativeStart.run(Native Method)
Dave Sparks
2009-04-10 15:37:32 UTC
Permalink
MediaPlayer states are protected by mutexes in the native layer.
However, the playback complete is an asynchronous event that comes on
a binder worker thread. It's possible that you could call reset() in
the window after the native media player service has posted a playback
complete message to the binder interface, but before the client worker
thread has processed it. In this case, the playback complete message
would reset the client side of the interface to the stopped state.
Your subsequent setDataSource() call would fail.

If you wait for the playback complete message and then post a message
to your handler to start the next playback, you can avoid this
problem. Or as Marco suggests, create a second MediaPlayer object.
Just make sure you call release() on each one after you're done with
it to release the native resources.
Post by ATrubka
I agree that it's most likely me doing something wrong.
It looks like when the audio file is about to end the state of
MediaPlayer gets changed in the native code.
And maybe reset() doesn't take effect during this process while
setDataSource(), invoked right after, finds player not to be ready.
Maybe Android music app creates MediaPlayer every time or synchronizes
the invocations somehow.
I wonder whether the situation I described is possible and if it is
whether you can advise on the solution.
I can create MediaPlayer all the time, but I'm afraid to use too many
resources doing so.
I'm usually reluctant to creation of unnecessary objects.
I really appreciate your help and apologize for my not very deep
knowledge of the player functionality.
Post by Marco Nelissen
I am one, and the error you posted indicates you called setDataSource
while the MediaPlayer was in the 'playback completed' state.
It could be a race condition in the framework, but since I have never
seen this problem occur with the Android music app, I'm inclined to
think it's a problem with your code. As a workaround, you could create
a new MediaPlayer when you want to play something new.
Post by ATrubka
Guys, please...
Is there any Android native code developers around?
Post by ATrubka
MediaPlayer.reset() always gets invoked. Here's the exact lines of
                _mediaPlayer.reset();
                _mediaPlayer.setDataSource(resource);
                _mediaPlayer.prepare();
                _mediaPlayer.start();
Additionally, the error occurs only when next audio starts while
previous audio is about to end.
If next audio starts in the middle of the playback or after it has
completely stopped playing, then everything works fine.
It looks pretty much like a synchronization issue to me.
This method is not synchronized at the moment.
Since most of the MediaPlayer code is native I'm not sure what should
be synchronized.
Post by Marco Nelissen
Looks like you're calling MediaPlayer.setDataSource() on a MediaPlayer
that was already initialized, without first calling
MediaPlayer.reset()
Post by ATrubka
Hi, guys.
I'm using MediaPlayer and sometimes when first audio is about to end
and I click to the next audio I get the exception below. Looks like
the MediaPlayer is in some weird state of stopping playing and cannot
accept audio at the moment.
The exception goes to the native code which is greeks to me.
I couldn't find anything about this error on the internet either.
Is anyone here familiar with the problem?
Thank you in advance!
04-07 20:19:35.855: ERROR/MediaPlayer(1066): setDataSource called in
state 128
04-07 20:19:35.855: ERROR/AudioPlayerService(1066): Unable to play
chapter audio
java.lang.IllegalStateException
04-07 20:19:35.855: ERROR/AudioPlayerService(1066):     at
android.media.MediaPlayer.setDataSource(Native Method)
04-07 20:19:35.855: ERROR/AudioPlayerService(1066):     at
com.tourizo.android.services.AudioPlayerService.playResource
(AudioPlayerService.java:291)
04-07 20:19:35.855: ERROR/AudioPlayerService(1066):     at
com.tourizo.android.services.AudioPlayerService.access$3
(AudioPlayerService.java:287)
04-07 20:19:35.855: ERROR/AudioPlayerService(1066):     at
com.tourizo.android.services.AudioPlayerService$1.playCurrentChapter
(AudioPlayerService.java:89)
04-07 20:19:35.855: ERROR/AudioPlayerService(1066):     at
com.tourizo.android.services.AudioPlayerRemoteInterface$Stub.onTransact
(AudioPlayerRemoteInterface.java:99)
04-07 20:19:35.855: ERROR/AudioPlayerService(1066):     at
android.os.Binder.execTransact(Binder.java:276)
04-07 20:19:35.855: ERROR/AudioPlayerService(1066):     at
dalvik.system.NativeStart.run(Native Method)
Loading...