Skip to content

Commit 116072a

Browse files
committed
some cleaning stuff
1 parent ce60158 commit 116072a

File tree

3 files changed

+5
-99
lines changed

3 files changed

+5
-99
lines changed

jni/libmediaplayer/decoder_audio.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ bool DecoderAudio::process(AVPacket *packet)
2626
int size = mSamplesSize;
2727
int len = avcodec_decode_audio3(mStream->codec, mSamples, &size, packet);
2828

29+
//call handler for posting buffer to os audio driver
2930
onDecode(mSamples, size);
3031

3132
return true;

jni/libmediaplayer/decoder_video.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,6 @@ bool DecoderVideo::decode(void* ptr)
156156

157157
__android_log_print(ANDROID_LOG_INFO, TAG, "decoding video ended");
158158

159-
Output::VideoDriver_unregister();
160-
161159
// Free the RGB image
162160
av_free(mFrame);
163161
// Free the RGB image

jni/libmediaplayer/mediaplayer.cpp

Lines changed: 4 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -186,16 +186,18 @@ status_t MediaPlayer::suspend() {
186186
__android_log_print(ANDROID_LOG_ERROR, TAG, "Couldn't cancel player thread");
187187
}
188188

189-
__android_log_print(ANDROID_LOG_ERROR, TAG, "suspended");
190-
191189
// Close the codec
192190
free(mDecoderAudio);
193191
free(mDecoderVideo);
194192

195193
// Close the video file
196194
av_close_input_file(mMovieFile);
197195

196+
//close OS drivers
198197
Output::AudioDriver_unregister();
198+
Output::VideoDriver_unregister();
199+
200+
__android_log_print(ANDROID_LOG_ERROR, TAG, "suspended");
199201

200202
return NO_ERROR;
201203
}
@@ -483,99 +485,4 @@ void MediaPlayer::notify(int msg, int ext1, int ext2)
483485
mListener->notify(msg, ext1, ext2);
484486
__android_log_print(ANDROID_LOG_INFO, TAG, "back from callback");
485487
}
486-
/*
487-
// TODO: In the future, we might be on the same thread if the app is
488-
// running in the same process as the media server. In that case,
489-
// this will deadlock.
490-
//
491-
// The threadId hack below works around this for the care of prepare
492-
// and seekTo within the same process.
493-
// FIXME: Remember, this is a hack, it's not even a hack that is applied
494-
// consistently for all use-cases, this needs to be revisited.
495-
if (mLockThreadId != getThreadId()) {
496-
mLock.lock();
497-
locked = true;
498-
}
499-
500-
if (mPlayer == 0) {
501-
__android_log_print(ANDROID_LOG_INFO, TAG, "notify(%d, %d, %d) callback on disconnected mediaplayer", msg, ext1, ext2);
502-
if (locked) mLock.unlock(); // release the lock when done.
503-
return;
504-
}
505-
506-
switch (msg) {
507-
case MEDIA_NOP: // interface test message
508-
break;
509-
case MEDIA_PREPARED:
510-
__android_log_print(ANDROID_LOG_INFO, TAG, "prepared");
511-
mCurrentState = MEDIA_PLAYER_PREPARED;
512-
if (mPrepareSync) {
513-
__android_log_print(ANDROID_LOG_INFO, TAG, "signal application thread");
514-
mPrepareSync = false;
515-
mPrepareStatus = NO_ERROR;
516-
mSignal.signal();
517-
}
518-
break;
519-
case MEDIA_PLAYBACK_COMPLETE:
520-
__android_log_print(ANDROID_LOG_INFO, TAG, "playback complete");
521-
if (!mLoop) {
522-
mCurrentState = MEDIA_PLAYER_PLAYBACK_COMPLETE;
523-
}
524-
break;
525-
case MEDIA_ERROR:
526-
// Always log errors.
527-
// ext1: Media framework error code.
528-
// ext2: Implementation dependant error code.
529-
LOGE("error (%d, %d)", ext1, ext2);
530-
mCurrentState = MEDIA_PLAYER_STATE_ERROR;
531-
if (mPrepareSync)
532-
{
533-
__android_log_print(ANDROID_LOG_INFO, TAG, "signal application thread");
534-
mPrepareSync = false;
535-
mPrepareStatus = ext1;
536-
mSignal.signal();
537-
send = false;
538-
}
539-
break;
540-
case MEDIA_INFO:
541-
// ext1: Media framework error code.
542-
// ext2: Implementation dependant error code.
543-
LOGW("info/warning (%d, %d)", ext1, ext2);
544-
break;
545-
case MEDIA_SEEK_COMPLETE:
546-
__android_log_print(ANDROID_LOG_INFO, TAG, "Received seek complete");
547-
if (mSeekPosition != mCurrentPosition) {
548-
__android_log_print(ANDROID_LOG_INFO, TAG, "Executing queued seekTo(%d)", mSeekPosition);
549-
mSeekPosition = -1;
550-
seekTo_l(mCurrentPosition);
551-
}
552-
else {
553-
__android_log_print(ANDROID_LOG_INFO, TAG, "All seeks complete - return to regularly scheduled program");
554-
mCurrentPosition = mSeekPosition = -1;
555-
}
556-
break;
557-
case MEDIA_BUFFERING_UPDATE:
558-
__android_log_print(ANDROID_LOG_INFO, TAG, "buffering %d", ext1);
559-
break;
560-
case MEDIA_SET_VIDEO_SIZE:
561-
__android_log_print(ANDROID_LOG_INFO, TAG, "New video size %d x %d", ext1, ext2);
562-
mVideoWidth = ext1;
563-
mVideoHeight = ext2;
564-
break;
565-
default:
566-
__android_log_print(ANDROID_LOG_INFO, TAG, "unrecognized message: (%d, %d, %d)", msg, ext1, ext2);
567-
break;
568-
}
569-
570-
sp<MediaPlayerListener> listener = mListener;
571-
if (locked) mLock.unlock();
572-
573-
// this prevents re-entrant calls into client code
574-
if ((listener != 0) && send) {
575-
Mutex::Autolock _l(mNotifyLock);
576-
__android_log_print(ANDROID_LOG_INFO, TAG, "callback application");
577-
listener->notify(msg, ext1, ext2);
578-
__android_log_print(ANDROID_LOG_INFO, TAG, "back from callback");
579-
}
580-
*/
581488
}

0 commit comments

Comments
 (0)