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

Commit a075db4f authored by Glenn Kasten's avatar Glenn Kasten
Browse files

IAudioFlinger::createTrack and openRecord flags

createTrack and openRecord don't need the "old" flags parameter,
which was either audio_policy_output_t or audio_in_acoustics_t
shifted left by 16 bits.  But they do need "new" flags, which
are defined by the application use case.  Initially, the only
application use case flag is timed output, but others are planned.

For output, the audio_policy_output_t flags are passed to
AudioSystem::getOutput, which returns an audio_io_handle_t, and that
handle is then passed to createTrack. So createTrack doesn't need the
old flags parameter.

For input, the audio_in_acoustics_t flags are passed to
AudioSystem::getInput, which returns an audio_io_handle_t, and that
handle is then passed to openRecord. So openRecord doesn't need the
old flags parameter.

Change-Id: I18a9870911846cca69d420c19fe6a9face2fe8c4
parent 1746929d
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -354,7 +354,6 @@ private:
                                audio_format_t format,
                                uint32_t channelMask,
                                int frameCount,
                                uint32_t flags,
                                audio_io_handle_t input);
            audio_io_handle_t getInput_l();
            status_t restoreRecord_l(audio_track_cblk_t*& cblk);
+9 −3
Original line number Diff line number Diff line
@@ -43,6 +43,13 @@ class IAudioFlinger : public IInterface
public:
    DECLARE_META_INTERFACE(AudioFlinger);

    // or-able bits shared by createTrack and openRecord, but not all combinations make sense
    enum {
        TRACK_DEFAULT = 0,
        TRACK_TIMED   = 1,
    };
    typedef uint32_t track_flags_t;

    /* create an audio track and registers it with AudioFlinger.
     * return null if the track cannot be created.
     */
@@ -53,10 +60,9 @@ public:
                                audio_format_t format,
                                uint32_t channelMask,
                                int frameCount,
                                uint32_t flags,
                                track_flags_t flags,
                                const sp<IMemory>& sharedBuffer,
                                audio_io_handle_t output,
                                bool isTimed,
                                int *sessionId,
                                status_t *status) = 0;

@@ -67,7 +73,7 @@ public:
                                audio_format_t format,
                                uint32_t channelMask,
                                int frameCount,
                                uint32_t flags,
                                track_flags_t flags,
                                int *sessionId,
                                status_t *status) = 0;

+3 −4
Original line number Diff line number Diff line
@@ -201,7 +201,7 @@ status_t AudioRecord::set(

    // create the IAudioRecord
    status = openRecord_l(sampleRate, format, channelMask,
                        frameCount, flags, input);
                        frameCount, input);
    if (status != NO_ERROR) {
        return status;
    }
@@ -458,7 +458,6 @@ status_t AudioRecord::openRecord_l(
        audio_format_t format,
        uint32_t channelMask,
        int frameCount,
        uint32_t flags,
        audio_io_handle_t input)
{
    status_t status;
@@ -471,7 +470,7 @@ status_t AudioRecord::openRecord_l(
                                                       sampleRate, format,
                                                       channelMask,
                                                       frameCount,
                                                       ((uint16_t)flags) << 16,
                                                       IAudioFlinger::TRACK_DEFAULT,
                                                       &mSessionId,
                                                       &status);

@@ -778,7 +777,7 @@ status_t AudioRecord::restoreRecord_l(audio_track_cblk_t*& cblk)
        // following member variables: mAudioRecord, mCblkMemory and mCblk.
        // It will also delete the strong references on previous IAudioRecord and IMemory
        result = openRecord_l(cblk->sampleRate, mFormat, mChannelMask,
                mFrameCount, mFlags, getInput_l());
                mFrameCount, getInput_l());
        if (result == NO_ERROR) {
            result = mAudioRecord->start(0);    // callback thread hasn't changed
        }
+5 −2
Original line number Diff line number Diff line
@@ -800,16 +800,19 @@ status_t AudioTrack::createTrack_l(
        }
    }

    IAudioFlinger::track_flags_t trackFlags = IAudioFlinger::TRACK_DEFAULT;
    if (mIsTimed) {
        trackFlags |= IAudioFlinger::TRACK_TIMED;
    }
    sp<IAudioTrack> track = audioFlinger->createTrack(getpid(),
                                                      streamType,
                                                      sampleRate,
                                                      format,
                                                      channelMask,
                                                      frameCount,
                                                      ((uint16_t)flags) << 16,
                                                      trackFlags,
                                                      sharedBuffer,
                                                      output,
                                                      mIsTimed,
                                                      &mSessionId,
                                                      &status);

+6 −9
Original line number Diff line number Diff line
@@ -87,10 +87,9 @@ public:
                                audio_format_t format,
                                uint32_t channelMask,
                                int frameCount,
                                uint32_t flags,
                                track_flags_t flags,
                                const sp<IMemory>& sharedBuffer,
                                audio_io_handle_t output,
                                bool isTimed,
                                int *sessionId,
                                status_t *status)
    {
@@ -103,10 +102,9 @@ public:
        data.writeInt32(format);
        data.writeInt32(channelMask);
        data.writeInt32(frameCount);
        data.writeInt32(flags);
        data.writeInt32((int32_t) flags);
        data.writeStrongBinder(sharedBuffer->asBinder());
        data.writeInt32((int32_t) output);
        data.writeInt32(isTimed);
        int lSessionId = 0;
        if (sessionId != NULL) {
            lSessionId = *sessionId;
@@ -136,7 +134,7 @@ public:
                                audio_format_t format,
                                uint32_t channelMask,
                                int frameCount,
                                uint32_t flags,
                                track_flags_t flags,
                                int *sessionId,
                                status_t *status)
    {
@@ -688,15 +686,14 @@ status_t BnAudioFlinger::onTransact(
            audio_format_t format = (audio_format_t) data.readInt32();
            int channelCount = data.readInt32();
            size_t bufferCount = data.readInt32();
            uint32_t flags = data.readInt32();
            track_flags_t flags = (track_flags_t) data.readInt32();
            sp<IMemory> buffer = interface_cast<IMemory>(data.readStrongBinder());
            audio_io_handle_t output = (audio_io_handle_t) data.readInt32();
            bool isTimed = data.readInt32();
            int sessionId = data.readInt32();
            status_t status;
            sp<IAudioTrack> track = createTrack(pid,
                    (audio_stream_type_t) streamType, sampleRate, format,
                    channelCount, bufferCount, flags, buffer, output, isTimed, &sessionId, &status);
                    channelCount, bufferCount, flags, buffer, output, &sessionId, &status);
            reply->writeInt32(sessionId);
            reply->writeInt32(status);
            reply->writeStrongBinder(track->asBinder());
@@ -710,7 +707,7 @@ status_t BnAudioFlinger::onTransact(
            audio_format_t format = (audio_format_t) data.readInt32();
            int channelCount = data.readInt32();
            size_t bufferCount = data.readInt32();
            uint32_t flags = data.readInt32();
            track_flags_t flags = (track_flags_t) data.readInt32();
            int sessionId = data.readInt32();
            status_t status;
            sp<IAudioRecord> record = openRecord(pid, input,
Loading