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

Commit 838177b7 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Use String8/16 c_str [audio]" into main

parents cf3bb9e4 8f36f6ea
Loading
Loading
Loading
Loading
+6 −6
Original line number Diff line number Diff line
@@ -33,12 +33,12 @@ FileInput::~FileInput() {

status_t FileInput::open() {
    if (mOpen) {
        ALOGW("%s: Open called when file %s already open.", __FUNCTION__, mPath.string());
        ALOGW("%s: Open called when file %s already open.", __FUNCTION__, mPath.c_str());
        return OK;
    }
    mFp = ::fopen(mPath, "rb");
    if (!mFp) {
        ALOGE("%s: Could not open file %s", __FUNCTION__, mPath.string());
        ALOGE("%s: Could not open file %s", __FUNCTION__, mPath.c_str());
        return BAD_VALUE;
    }
    mOpen = true;
@@ -47,14 +47,14 @@ status_t FileInput::open() {

ssize_t FileInput::read(uint8_t* buf, size_t offset, size_t count) {
    if (!mOpen) {
        ALOGE("%s: Could not read file %s, file not open.", __FUNCTION__, mPath.string());
        ALOGE("%s: Could not read file %s, file not open.", __FUNCTION__, mPath.c_str());
        return BAD_VALUE;
    }

    size_t bytesRead = ::fread(buf + offset, sizeof(uint8_t), count, mFp);
    int error = ::ferror(mFp);
    if (error != 0) {
        ALOGE("%s: Error %d occurred while reading file %s.", __FUNCTION__, error, mPath.string());
        ALOGE("%s: Error %d occurred while reading file %s.", __FUNCTION__, error, mPath.c_str());
        return BAD_VALUE;
    }

@@ -68,13 +68,13 @@ ssize_t FileInput::read(uint8_t* buf, size_t offset, size_t count) {

status_t FileInput::close() {
    if(!mOpen) {
        ALOGW("%s: Close called when file %s already close.", __FUNCTION__, mPath.string());
        ALOGW("%s: Close called when file %s already close.", __FUNCTION__, mPath.c_str());
        return OK;
    }

    status_t ret = OK;
    if(::fclose(mFp) != 0) {
        ALOGE("%s: Failed to close file %s.", __FUNCTION__, mPath.string());
        ALOGE("%s: Failed to close file %s.", __FUNCTION__, mPath.c_str());
        ret = BAD_VALUE;
    }
    mOpen = false;
+7 −7
Original line number Diff line number Diff line
@@ -25,19 +25,19 @@ FileOutput::FileOutput(String8 path) : mFp(NULL), mPath(path), mOpen(false) {}

FileOutput::~FileOutput() {
    if (mOpen) {
        ALOGW("%s: Destructor called with %s still open.", __FUNCTION__, mPath.string());
        ALOGW("%s: Destructor called with %s still open.", __FUNCTION__, mPath.c_str());
        close();
    }
}

status_t FileOutput::open() {
    if (mOpen) {
        ALOGW("%s: Open called when file %s already open.", __FUNCTION__, mPath.string());
        ALOGW("%s: Open called when file %s already open.", __FUNCTION__, mPath.c_str());
        return OK;
    }
    mFp = ::fopen(mPath, "wb");
    if (!mFp) {
        ALOGE("%s: Could not open file %s", __FUNCTION__, mPath.string());
        ALOGE("%s: Could not open file %s", __FUNCTION__, mPath.c_str());
        return BAD_VALUE;
    }
    mOpen = true;
@@ -46,7 +46,7 @@ status_t FileOutput::open() {

status_t FileOutput::write(const uint8_t* buf, size_t offset, size_t count) {
    if (!mOpen) {
        ALOGE("%s: Could not write file %s, file not open.", __FUNCTION__, mPath.string());
        ALOGE("%s: Could not write file %s, file not open.", __FUNCTION__, mPath.c_str());
        return BAD_VALUE;
    }

@@ -54,7 +54,7 @@ status_t FileOutput::write(const uint8_t* buf, size_t offset, size_t count) {

    int error = ::ferror(mFp);
    if (error != 0) {
        ALOGE("%s: Error %d occurred while writing file %s.", __FUNCTION__, error, mPath.string());
        ALOGE("%s: Error %d occurred while writing file %s.", __FUNCTION__, error, mPath.c_str());
        return BAD_VALUE;
    }
    return OK;
@@ -62,13 +62,13 @@ status_t FileOutput::write(const uint8_t* buf, size_t offset, size_t count) {

status_t FileOutput::close() {
    if(!mOpen) {
        ALOGW("%s: Close called when file %s already close.", __FUNCTION__, mPath.string());
        ALOGW("%s: Close called when file %s already close.", __FUNCTION__, mPath.c_str());
        return OK;
    }

    status_t ret = OK;
    if(::fclose(mFp) != 0) {
        ALOGE("%s: Failed to close file %s.", __FUNCTION__, mPath.string());
        ALOGE("%s: Failed to close file %s.", __FUNCTION__, mPath.c_str());
        ret = BAD_VALUE;
    }
    mOpen = false;
+1 −1
Original line number Diff line number Diff line
@@ -377,7 +377,7 @@ void TiffIfd::log() const {
    size_t s = mEntries.size();
    ALOGI("[ifd: %x, num_entries: %zu, entries:\n", getId(), s);
    for(size_t i = 0; i < s; ++i) {
        ALOGI("\t%s", mEntries[i]->toString().string());
        ALOGI("\t%s", mEntries[i]->toString().c_str());
    }
    ALOGI(", next_ifd: %x]", ((mNextIfd != NULL) ? mNextIfd->getId() : 0));
}
+1 −1
Original line number Diff line number Diff line
@@ -745,7 +745,7 @@ status_t AudioRecord::dump(int fd, const Vector<String16>& args __unused) const
                        mInput, mLatency, mSelectedDeviceId, mRoutedDeviceId);
    result.appendFormat("  mic direction(%d) mic field dimension(%f)",
                        mSelectedMicDirection, mSelectedMicFieldDimension);
    ::write(fd, result.string(), result.size());
    ::write(fd, result.c_str(), result.size());
    return NO_ERROR;
}

+1 −1
Original line number Diff line number Diff line
@@ -86,7 +86,7 @@ static sp<IBinder> gAudioFlingerBinder = nullptr;
void AudioSystem::setAudioFlingerBinder(const sp<IBinder>& audioFlinger) {
    if (audioFlinger->getInterfaceDescriptor() != media::IAudioFlingerService::descriptor) {
        ALOGE("setAudioFlingerBinder: received a binder of type %s",
              String8(audioFlinger->getInterfaceDescriptor()).string());
              String8(audioFlinger->getInterfaceDescriptor()).c_str());
        return;
    }
    Mutex::Autolock _l(gLock);
Loading