Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3cff3022 authored by Jason Sams's avatar Jason Sams Committed by The Android Open Source Project
Browse files

Automated import from //branches/master/...@141471,141471

parent 7a7af5c8
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -42,7 +42,8 @@ LOCAL_SRC_FILES:= \
LOCAL_SHARED_LIBRARIES:= \
    libui \
    libutils \
    libcutils
    libcutils \
    libmedia

LOCAL_MODULE:= libcameraservice

+30 −0
Original line number Diff line number Diff line
@@ -28,6 +28,8 @@
#include <utils/MemoryHeapBase.h>
#include <ui/ICameraService.h>

#include <media/mediaplayer.h>
#include <media/AudioSystem.h>
#include "CameraService.h"

namespace android {
@@ -151,6 +153,19 @@ void CameraService::removeClient(const sp<ICameraClient>& cameraClient)
    }
}

static sp<MediaPlayer> newMediaPlayer(const char *file) 
{
    sp<MediaPlayer> mp = new MediaPlayer();
    if (mp->setDataSource(file) == NO_ERROR) {
        mp->setAudioStreamType(AudioSystem::ALARM);
        mp->prepare();
    } else {
        mp.clear();
        LOGE("Failed to load CameraService sounds.");
    }
    return mp;
}

CameraService::Client::Client(const sp<CameraService>& cameraService,
        const sp<ICameraClient>& cameraClient, pid_t clientPid)
{
@@ -161,6 +176,9 @@ CameraService::Client::Client(const sp<CameraService>& cameraService,
    mHardware = openCameraHardware();
    mUseOverlay = mHardware->useOverlay();

    mMediaPlayerClick = newMediaPlayer("/system/media/audio/ui/camera_click.ogg");
    mMediaPlayerBeep = newMediaPlayer("/system/media/audio/ui/VideoRecord.ogg");

    // Callback is disabled by default
    mPreviewCallbackFlag = FRAME_CALLBACK_FLAG_NOOP;
    LOGD("Client X constructor");
@@ -265,6 +283,9 @@ CameraService::Client::~Client()
#endif
    }

    mMediaPlayerBeep.clear();
    mMediaPlayerClick.clear();

    // make sure we tear down the hardware
    mClientPid = IPCThreadState::self()->getCallingPid();
    disconnect();
@@ -464,6 +485,9 @@ status_t CameraService::Client::startPreview()

status_t CameraService::Client::startRecording()
{
    if (mMediaPlayerBeep.get() != NULL) {
        mMediaPlayerBeep->start();
    }
    return startCameraMode(CAMERA_RECORDING_MODE);
}

@@ -502,6 +526,9 @@ void CameraService::Client::stopRecording()
        return;
    }

    if (mMediaPlayerBeep.get() != NULL) {
        mMediaPlayerBeep->start();
    }
    mHardware->stopRecording();
    LOGV("stopRecording(), hardware stopped OK");
    mPreviewBuffer.clear();
@@ -684,6 +711,9 @@ status_t CameraService::Client::takePicture()
        return INVALID_OPERATION;
    }

    if (mMediaPlayerClick.get() != NULL) {
        mMediaPlayerClick->start();
    }
    return mHardware->takePicture(shutterCallback,
                                  yuvPictureCallback,
                                  jpegPictureCallback,
+5 −0
Original line number Diff line number Diff line
@@ -27,6 +27,8 @@ class android::MemoryHeapBase;

namespace android {

class MediaPlayer;

// ----------------------------------------------------------------------------

#define LIKELY( exp )       (__builtin_expect( (exp) != 0, true  ))
@@ -178,6 +180,9 @@ private:
                    sp<MemoryHeapBase>          mPreviewBuffer;
                    int                         mPreviewCallbackFlag;

                    sp<MediaPlayer>             mMediaPlayerClick;
                    sp<MediaPlayer>             mMediaPlayerBeep;

                    // these are immutable once the object is created,
                    // they don't need to be protected by a lock
                    sp<ICameraClient>           mCameraClient;