summaryrefslogtreecommitdiffstats
path: root/media/libstagefright/AMRWriter.cpp
diff options
context:
space:
mode:
authorJames Dong <jdong@google.com>2010-05-14 11:48:00 -0700
committerJames Dong <jdong@google.com>2010-05-14 11:48:00 -0700
commitf0ce2fb0c7bf3a414279e5aba61105f3d9025c0e (patch)
tree4fea53e0f6cd8068d0342828c267fe734925f2f8 /media/libstagefright/AMRWriter.cpp
parent3c0131f02b6f008321608044c53bccce2ac5f6dd (diff)
downloadframeworks_av-f0ce2fb0c7bf3a414279e5aba61105f3d9025c0e.zip
frameworks_av-f0ce2fb0c7bf3a414279e5aba61105f3d9025c0e.tar.gz
frameworks_av-f0ce2fb0c7bf3a414279e5aba61105f3d9025c0e.tar.bz2
Detect and handle premature termination of a recording session
Change-Id: Ifb83b19f3e68580345b23efed5d5956fb81baeb8
Diffstat (limited to 'media/libstagefright/AMRWriter.cpp')
-rw-r--r--media/libstagefright/AMRWriter.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/media/libstagefright/AMRWriter.cpp b/media/libstagefright/AMRWriter.cpp
index 0d54235..aec7394 100644
--- a/media/libstagefright/AMRWriter.cpp
+++ b/media/libstagefright/AMRWriter.cpp
@@ -162,6 +162,7 @@ void *AMRWriter::ThreadWrapper(void *me) {
void AMRWriter::threadFunc() {
mEstimatedDurationUs = 0;
mEstimatedSizeBytes = 0;
+ bool stoppedPrematurely = true;
while (!mDone) {
MediaBuffer *buffer;
status_t err = mSource->read(&buffer);
@@ -202,10 +203,22 @@ void AMRWriter::threadFunc() {
break;
}
+ // XXX: How to tell it is stopped prematurely?
+ if (stoppedPrematurely) {
+ stoppedPrematurely = false;
+ }
+
buffer->release();
buffer = NULL;
}
+ if (stoppedPrematurely) {
+ notify(MEDIA_RECORDER_EVENT_INFO, MEDIA_RECORDER_INFO_STOP_PREMATURELY, 0);
+ }
+
+ fflush(mFile);
+ fclose(mFile);
+ mFile = NULL;
mReachedEOS = true;
}