summaryrefslogtreecommitdiffstats
path: root/cmds
diff options
context:
space:
mode:
Diffstat (limited to 'cmds')
-rw-r--r--cmds/screenrecord/screenrecord.cpp16
1 files changed, 6 insertions, 10 deletions
diff --git a/cmds/screenrecord/screenrecord.cpp b/cmds/screenrecord/screenrecord.cpp
index 923f781..3f8567c 100644
--- a/cmds/screenrecord/screenrecord.cpp
+++ b/cmds/screenrecord/screenrecord.cpp
@@ -144,6 +144,10 @@ static status_t prepareEncoder(float displayFps, sp<MediaCodec>* pCodec,
looper->start();
ALOGV("Creating codec");
sp<MediaCodec> codec = MediaCodec::CreateByType(looper, "video/avc", true);
+ if (codec == NULL) {
+ fprintf(stderr, "ERROR: unable to create video/avc codec instance\n");
+ return UNKNOWN_ERROR;
+ }
err = codec->configure(format, NULL, NULL,
MediaCodec::CONFIGURE_FLAG_ENCODE);
if (err != NO_ERROR) {
@@ -461,17 +465,9 @@ static status_t recordScreen(const char* fileName) {
printf("Stopping encoder and muxer\n");
}
- // Shut everything down.
- //
- // The virtual display will continue to produce frames until "dpy"
- // goes out of scope (and something causes the Binder traffic to transmit;
- // can be forced with IPCThreadState::self()->flushCommands()). This
- // could cause SurfaceFlinger to get stuck trying to feed us, so we want
- // to set a NULL Surface to make the virtual display "dormant".
+ // Shut everything down, starting with the producer side.
bufferProducer = NULL;
- SurfaceComposerClient::openGlobalTransaction();
- SurfaceComposerClient::setDisplaySurface(dpy, bufferProducer);
- SurfaceComposerClient::closeGlobalTransaction();
+ SurfaceComposerClient::destroyDisplay(dpy);
encoder->stop();
muxer->stop();