// Reset should be OK in any state status_t MediaRecorder::reset() { LOGV("reset"); if (mMediaRecorder == NULL) { LOGE("media recorder is not initialized yet"); return INVALID_OPERATION; } doCleanUp(); status_t ret = UNKNOWN_ERROR; switch(mCurrentState) { case MEDIA_RECORDER_IDLE: ret = OK; break; case MEDIA_RECORDER_RECORDING: case MEDIA_RECORDER_DATASOURCE_CONFIGURED: case MEDIA_RECORDER_PREPARED: case MEDIA_RECORDER_ERROR: { ret = doReset(); if (OK != ret) { return ret; // No need to continue } } // Intentional fall through case MEDIA_RECORDER_INITIALIZED: ret = close(); break; default: { LOGE("Unexpected non-existing state: %d", mCurrentState); break; } } return ret; }
status_t MediaRecorder::stop() { LOGV("stop"); if (mMediaRecorder == NULL) { LOGE("media recorder is not initialized yet"); return INVALID_OPERATION; } if (!(mCurrentState & MEDIA_RECORDER_RECORDING)) { LOGE("stop called in an invalid state: %d", mCurrentState); return INVALID_OPERATION; } status_t ret = mMediaRecorder->stop(); if (OK != ret) { LOGE("stop failed: %d", ret); mCurrentState = MEDIA_RECORDER_ERROR; return ret; } // FIXME: // stop and reset are semantically different. // We treat them the same for now, and will change this in the future. doCleanUp(); mCurrentState = MEDIA_RECORDER_IDLE; return ret; }
MediaRecorder::MediaRecorder() { LOGV("constructor"); sp<IServiceManager> sm = defaultServiceManager(); sp<IBinder> binder; do { binder = sm->getService(String16("media.player")); if (binder != NULL) { break; } LOGW("MediaPlayerService not published, waiting..."); usleep(500000); // 0.5 s } while(true); sp<IMediaPlayerService> service = interface_cast<IMediaPlayerService>(binder); if (service != NULL) { mMediaRecorder = service->createMediaRecorder(getpid()); } mMediaRecorder = service->createMediaRecorder(getpid()); if (mMediaRecorder != NULL) { mCurrentState = MEDIA_RECORDER_IDLE; } doCleanUp(); }
//---------------------------------------------------------------------- // Name : sortEnd // // Parameters : none // // Description : Does any de-init tasks // // Return Value : // SORT_SUCCESS if everything goes on well. // SORT_FAILURE if any error encounterd. // //---------------------------------------------------------------------- NABoolean SortUtil::sortEnd(void) { state_ = SORT_END; doCleanUp(); //Yield any excess quota before exiting this operator. Note that //yield retains the original quota for next round if this operator //gets used. returnExcessMemoryQuota(overheadPerRecord_); // SQLMXLoggingArea::logExecRtInfo(NULL,0,"Sort operation has ended", explainNodeId_); return SORT_SUCCESS; }
MediaRecorder::MediaRecorder() { LOGV("constructor"); const sp<IMediaPlayerService>& service(getMediaPlayerService()); if (service != NULL) { mMediaRecorder = service->createMediaRecorder(getpid()); } if (mMediaRecorder != NULL) { mCurrentState = MEDIA_RECORDER_IDLE; } doCleanUp(); }
MediaRecorder::MediaRecorder() : mSurfaceMediaSource(NULL) { const sp<IMediaPlayerService>& service(getMediaPlayerService()); if (service != NULL) { mMediaRecorder = service->createMediaRecorder(); } if (mMediaRecorder != NULL) { mCurrentState = MEDIA_RECORDER_IDLE; } doCleanUp(); }
MediaRecorder::MediaRecorder(const String16& opPackageName) : mSurfaceMediaSource(NULL) { ALOGV("constructor"); const sp<IMediaPlayerService> service(getMediaPlayerService()); if (service != NULL) { mMediaRecorder = service->createMediaRecorder(opPackageName); } if (mMediaRecorder != NULL) { mCurrentState = MEDIA_RECORDER_IDLE; } doCleanUp(); }
//---------------------------------------------------------------------- // Name : sortInitialize // // Parameters : ... // // Description : // // Return Value : // SORT_SUCCESS if everything goes on well. // SORT_FAILURE if any error encounterd. // //---------------------------------------------------------------------- NABoolean SortUtil::sortInitialize(SortUtilConfig& config) { //--------------------------------------------------------------- // Do some cleanup since we may be re-initializing SortUtil. // Basically we delete any memory that was allocated dynamically // but was not yet released. Also, the sortError is reset. //--------------------------------------------------------------- doCleanUp(); sortAlgo_ = new (config.heapAddr_) Qsort(config.runSize_, config.maxMem_, config.recSize_, config.sortType_.doNotAllocRec_, config.keySize_, scratch_, TRUE, config.heapAddr_, &sortError_, explainNodeId_, this); if (sortAlgo_ == NULL) { sortError_.setErrorInfo( EScrNoMemory //sort error ,NULL //syserr: the actual FS error ,NULL //syserrdetail ,"SortUtil::sortInitialize" //methodname ); return SORT_FAILURE; } //The maximum memory that sort can consume is governed by three parameters. //(config.maxNumBuffers_ * sorttdb.maxbufferSize) + config..maxMem_. //yield any excess quota to other operators. overheadPerRecord_ = sortAlgo_->getOverheadPerRecord(); returnExcessMemoryQuota(overheadPerRecord_); //-------------------------------------------------------------------- // The Class SortAlgo by default assumes internal sorting. If we are // using external sort we should indicate it to SortAlgo. //-------------------------------------------------------------------- state_ = SORT_SEND; return SORT_SUCCESS; }
void CEngine::Start() { doAditionalInit(); run(); doCleanUp(); }