OSDN Git Service

MediaCodecSource: stop puller from caller's thread instead of looper
authorChong Zhang <chz@google.com>
Fri, 1 Aug 2014 17:30:26 +0000 (10:30 -0700)
committerChong Zhang <chz@google.com>
Mon, 4 Aug 2014 18:59:05 +0000 (11:59 -0700)
commit16e79115e497386eaf010af388627f94314a55a3
tree600138fd3483f527278304fbf866be53f40e6ea1
parent44622db93a24219123facbbe14259000f90de728
MediaCodecSource: stop puller from caller's thread instead of looper

Currently CameraSource/AudioSource's stop() and read() are both called
from the puller's looper. This works if source operates normally (i.e.
read() returns regularly before source is stopped), as the stop() will
eventually be handled by the looper. However, if for some reason the
source hang, it will get stuck in read(), and the stop() will never
be processed, which could lead to ANR (in addition to the source hang).

We need to move the source's stop out of the puller's looper. It also
can't be on MediaCodecSource's looper, because the source's stop
synchrounously waits for all outstanding buffers to return, these
are only returned when MediaCodecSource's looper processes the buffer.

This change moves the stop to MediaCodecSource::stop, after encoder
is shutdown.

Bug: 16522726
Change-Id: Ie91f563c5d8a98ab091bf1945af4e51f662b9403
include/media/stagefright/MediaCodecSource.h
media/libstagefright/AudioSource.cpp
media/libstagefright/MediaCodecSource.cpp