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

Commit 1c5a89d4 authored by Glenn Kasten's avatar Glenn Kasten
Browse files

Use audio_format_t consistently

Was int, uint32_t, uint16_t, and uint8_t with 2-bit bitfield.
Also replace 0 by AUDIO_FORMAT_DEFAULT and replace 1 by
AUDIO_FORMAT_PCM_16_BIT.

Change-Id: Ia8804f53f1725669e368857d5bb2044917e17975
parent a8719ad9
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -240,7 +240,7 @@ android_media_AudioTrack_native_setup(JNIEnv *env, jobject thiz, jobject weak_th

    // compute the frame count
    int bytesPerSample = audioFormat == javaAudioTrackFields.PCM16 ? 2 : 1;
    int format = audioFormat == javaAudioTrackFields.PCM16 ? 
    audio_format_t format = audioFormat == javaAudioTrackFields.PCM16 ?
            AUDIO_FORMAT_PCM_16_BIT : AUDIO_FORMAT_PCM_8_BIT;
    int frameCount = buffSizeInBytes / (nbChannels * bytesPerSample);
    
+8 −7
Original line number Diff line number Diff line
@@ -69,7 +69,8 @@ public:
            MUTE    = 0x00000001
        };
        uint32_t    flags;
        int         format;
        audio_format_t format; // but AUDIO_FORMAT_PCM_8_BIT -> AUDIO_FORMAT_PCM_16_BIT
        // accessed directly by WebKit ANP callback
        int         channelCount; // will be removed in the future, do not use
        size_t      frameCount;
        size_t      size;
@@ -143,7 +144,7 @@ public:

                        AudioTrack( int streamType,
                                    uint32_t sampleRate  = 0,
                                    int format           = 0,
                                    audio_format_t format = AUDIO_FORMAT_DEFAULT,
                                    int channelMask      = 0,
                                    int frameCount       = 0,
                                    uint32_t flags       = 0,
@@ -163,7 +164,7 @@ public:

                        AudioTrack( int streamType,
                                    uint32_t sampleRate = 0,
                                    int format          = 0,
                                    audio_format_t format = AUDIO_FORMAT_DEFAULT,
                                    int channelMask     = 0,
                                    const sp<IMemory>& sharedBuffer = 0,
                                    uint32_t flags      = 0,
@@ -187,7 +188,7 @@ public:
     * */
            status_t    set(int streamType      =-1,
                            uint32_t sampleRate = 0,
                            int format          = 0,
                            audio_format_t format = AUDIO_FORMAT_DEFAULT,
                            int channelMask     = 0,
                            int frameCount      = 0,
                            uint32_t flags      = 0,
@@ -215,7 +216,7 @@ public:
    /* getters, see constructor */

            int         streamType() const;
            int         format() const;
            audio_format_t format() const;
            int         channelCount() const;
            uint32_t    frameCount() const;
            int         frameSize() const;
@@ -434,7 +435,7 @@ private:
            bool processAudioBuffer(const sp<AudioTrackThread>& thread);
            status_t createTrack_l(int streamType,
                                 uint32_t sampleRate,
                                 uint32_t format,
                                 audio_format_t format,
                                 uint32_t channelMask,
                                 int frameCount,
                                 uint32_t flags,
@@ -455,7 +456,7 @@ private:
    uint32_t                mFrameCount;

    audio_track_cblk_t*     mCblk;
    uint32_t                mFormat;
    audio_format_t          mFormat;
    uint8_t                 mStreamType;
    uint8_t                 mChannelCount;
    uint8_t                 mMuted;
+3 −2
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@
#include <utils/String8.h>
#include <binder/IInterface.h>
#include <binder/Parcel.h>
#include <system/audio.h>

#include <media/IMediaPlayerClient.h>
#include <media/IMediaPlayer.h>
@@ -43,8 +44,8 @@ public:
    virtual sp<IMediaMetadataRetriever> createMetadataRetriever(pid_t pid) = 0;
    virtual sp<IMediaPlayer> create(pid_t pid, const sp<IMediaPlayerClient>& client, int audioSessionId = 0) = 0;

    virtual sp<IMemory>         decode(const char* url, uint32_t *pSampleRate, int* pNumChannels, int* pFormat) = 0;
    virtual sp<IMemory>         decode(int fd, int64_t offset, int64_t length, uint32_t *pSampleRate, int* pNumChannels, int* pFormat) = 0;
    virtual sp<IMemory>         decode(const char* url, uint32_t *pSampleRate, int* pNumChannels, audio_format_t* pFormat) = 0;
    virtual sp<IMemory>         decode(int fd, int64_t offset, int64_t length, uint32_t *pSampleRate, int* pNumChannels, audio_format_t* pFormat) = 0;
    virtual sp<IOMX>            getOMX() = 0;

    // codecs and audio devices usage tracking for the battery app
+1 −1
Original line number Diff line number Diff line
@@ -85,7 +85,7 @@ public:
        // audio data.
        virtual status_t    open(
                uint32_t sampleRate, int channelCount,
                int format=AUDIO_FORMAT_PCM_16_BIT,
                audio_format_t format=AUDIO_FORMAT_PCM_16_BIT,
                int bufferCount=DEFAULT_AUDIOSINK_BUFFERCOUNT,
                AudioCallback cb = NULL,
                void *cookie = NULL) = 0;
+2 −2
Original line number Diff line number Diff line
@@ -190,8 +190,8 @@ public:
            bool            isLooping();
            status_t        setVolume(float leftVolume, float rightVolume);
            void            notify(int msg, int ext1, int ext2, const Parcel *obj = NULL);
    static  sp<IMemory>     decode(const char* url, uint32_t *pSampleRate, int* pNumChannels, int* pFormat);
    static  sp<IMemory>     decode(int fd, int64_t offset, int64_t length, uint32_t *pSampleRate, int* pNumChannels, int* pFormat);
    static  sp<IMemory>     decode(const char* url, uint32_t *pSampleRate, int* pNumChannels, audio_format_t* pFormat);
    static  sp<IMemory>     decode(int fd, int64_t offset, int64_t length, uint32_t *pSampleRate, int* pNumChannels, audio_format_t* pFormat);
            status_t        invoke(const Parcel& request, Parcel *reply);
            status_t        setMetadataFilter(const Parcel& filter);
            status_t        getMetadata(bool update_only, bool apply_filter, Parcel *metadata);
Loading