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

Commit 7b874326 authored by The Android Open Source Project's avatar The Android Open Source Project
Browse files

Merge commit 'korg/cupcake'

parents 1503b07c 15c7247e
Loading
Loading
Loading
Loading
+17 −16
Original line number Diff line number Diff line
@@ -259,12 +259,11 @@ status_t AudioSystem::getOutputSamplingRate(int* samplingRate, int streamType)
{
    int output = getOutput(streamType);
    
    if (gOutSamplingRate[output] == 0) {
        const sp<IAudioFlinger>& af = AudioSystem::get_audio_flinger();
        if (af == 0) return PERMISSION_DENIED;
        // gOutSamplingRate is updated by get_audio_flinger()
    }
    if (output == NUM_AUDIO_OUTPUT_TYPES) return PERMISSION_DENIED;

    // gOutSamplingRate[] is updated by getOutput() which calls get_audio_flinger()
    LOGV("getOutputSamplingRate() streamType %d, output %d, sampling rate %d", streamType, output, gOutSamplingRate[output]);
    
    *samplingRate = gOutSamplingRate[output];
    
    return NO_ERROR;
@@ -274,14 +273,13 @@ status_t AudioSystem::getOutputFrameCount(int* frameCount, int streamType)
{
    int output = getOutput(streamType);

    if (gOutFrameCount[output] == 0) {
        const sp<IAudioFlinger>& af = AudioSystem::get_audio_flinger();
        if (af == 0) return PERMISSION_DENIED;
        // gOutFrameCount is updated by get_audio_flinger()
    }
    if (output == NUM_AUDIO_OUTPUT_TYPES) return PERMISSION_DENIED;

    // gOutFrameCount[] is updated by getOutput() which calls get_audio_flinger()
    LOGV("getOutputFrameCount() streamType %d, output %d, frame count %d", streamType, output, gOutFrameCount[output]);

    *frameCount = gOutFrameCount[output];
    
    return NO_ERROR;
}

@@ -289,11 +287,9 @@ status_t AudioSystem::getOutputLatency(uint32_t* latency, int streamType)
{
    int output = getOutput(streamType);

    if (gOutLatency[output] == 0) {
        const sp<IAudioFlinger>& af = AudioSystem::get_audio_flinger();
        if (af == 0) return PERMISSION_DENIED;
        // gOutLatency is updated by get_audio_flinger()
    }
    if (output == NUM_AUDIO_OUTPUT_TYPES) return PERMISSION_DENIED;

    // gOutLatency[] is updated by getOutput() which calls get_audio_flinger()
    LOGV("getOutputLatency() streamType %d, output %d, latency %d", streamType, output, gOutLatency[output]);

    *latency = gOutLatency[output];
@@ -355,6 +351,11 @@ void AudioSystem::setErrorCallback(audio_error_callback cb) {

int AudioSystem::getOutput(int streamType)
{   
    // make sure that gA2dpEnabled is valid by calling get_audio_flinger() which in turn 
    // will call gAudioFlinger->isA2dpEnabled()
    const sp<IAudioFlinger>& af = AudioSystem::get_audio_flinger();
    if (af == 0) return NUM_AUDIO_OUTPUT_TYPES;

    if (streamType == DEFAULT) {
        streamType = MUSIC;
    }
+16 −0
Original line number Diff line number Diff line
@@ -30,11 +30,24 @@
#include <utils/MemoryHeapBase.h>
#include <utils/MemoryBase.h>
#include <media/PVMediaRecorder.h>
#include <utils/String16.h>

#include "MediaRecorderClient.h"

namespace android {

const char* cameraPermission = "android.permission.CAMERA";

static bool checkPermission(const char* permissionString) {
#ifndef HAVE_ANDROID_OS
    return true;
#endif
    if (getpid() == IPCThreadState::self()->getCallingPid()) return true;
    bool ok = checkCallingPermission(String16(permissionString));
    if (!ok) LOGE("Request requires %s", permissionString);
    return ok;
}

status_t MediaRecorderClient::setCamera(const sp<ICamera>& camera)
{
    LOGV("setCamera");
@@ -60,6 +73,9 @@ status_t MediaRecorderClient::setPreviewSurface(const sp<ISurface>& surface)
status_t MediaRecorderClient::setVideoSource(int vs)
{
    LOGV("setVideoSource(%d)", vs);
    if (!checkPermission(cameraPermission)) {
        return PERMISSION_DENIED;
    }
    Mutex::Autolock lock(mLock);
    if (mRecorder == NULL)	{
        LOGE("recorder is not initialized");