@@ -186,16 +186,18 @@ status_t MediaPlayer::suspend() {
186
186
__android_log_print (ANDROID_LOG_ERROR, TAG, " Couldn't cancel player thread" );
187
187
}
188
188
189
- __android_log_print (ANDROID_LOG_ERROR, TAG, " suspended" );
190
-
191
189
// Close the codec
192
190
free (mDecoderAudio );
193
191
free (mDecoderVideo );
194
192
195
193
// Close the video file
196
194
av_close_input_file (mMovieFile );
197
195
196
+ // close OS drivers
198
197
Output::AudioDriver_unregister ();
198
+ Output::VideoDriver_unregister ();
199
+
200
+ __android_log_print (ANDROID_LOG_ERROR, TAG, " suspended" );
199
201
200
202
return NO_ERROR;
201
203
}
@@ -483,99 +485,4 @@ void MediaPlayer::notify(int msg, int ext1, int ext2)
483
485
mListener ->notify (msg, ext1, ext2);
484
486
__android_log_print (ANDROID_LOG_INFO, TAG, " back from callback" );
485
487
}
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
- */
581
488
}
0 commit comments