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

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

Bug 4599730 Get audio channel count on MediaPlayer

Related changes:
 - Fix bug in get/setParameter* to recycle Parcels when done with them.

Change-Id: Iaff05e91bbd99a14fccb79d816dd873359b6ae65
parent 7fc25dd8
Loading
Loading
Loading
Loading
+13 −4
Original line number Diff line number Diff line
@@ -130,13 +130,22 @@ enum media_player_states {
    MEDIA_PLAYER_PLAYBACK_COMPLETE  = 1 << 7
};

enum media_set_parameter_keys {
    KEY_PARAMETER_TIMED_TEXT_TRACK_INDEX = 1000,
    KEY_PARAMETER_TIMED_TEXT_ADD_OUT_OF_BAND_SOURCE = 1001,
// Keep KEY_PARAMETER_* in sync with MediaPlayer.java.
// The same enum space is used for both set and get, in case there are future keys that
// can be both set and get.  But as of now, all parameters are either set only or get only.
enum media_parameter_keys {
    KEY_PARAMETER_TIMED_TEXT_TRACK_INDEX = 1000,                // set only
    KEY_PARAMETER_TIMED_TEXT_ADD_OUT_OF_BAND_SOURCE = 1001,     // set only

    // Streaming/buffering parameters
    KEY_PARAMETER_CACHE_STAT_COLLECT_FREQ_MS = 1100,
    KEY_PARAMETER_CACHE_STAT_COLLECT_FREQ_MS = 1100,            // set only

    // Return a Parcel containing a single int, which is the channel count of the
    // audio track, or zero for error (e.g. no audio track) or unknown.
    KEY_PARAMETER_AUDIO_CHANNEL_COUNT = 1200,                   // get only

};

// ----------------------------------------------------------------------------
// ref-counted object for callbacks
class MediaPlayerListener: virtual public RefBase
+16 −1
Original line number Diff line number Diff line
@@ -2238,7 +2238,22 @@ status_t AwesomePlayer::setCacheStatCollectFreq(const Parcel &request) {
}

status_t AwesomePlayer::getParameter(int key, Parcel *reply) {
    switch (key) {
    case KEY_PARAMETER_AUDIO_CHANNEL_COUNT:
        {
            int32_t channelCount;
            if (mAudioTrack == 0 ||
                    !mAudioTrack->getFormat()->findInt32(kKeyChannelCount, &channelCount)) {
                channelCount = 0;
            }
            reply->writeInt32(channelCount);
        }
        return OK;
    default:
        {
            return ERROR_UNSUPPORTED;
        }
    }
}

bool AwesomePlayer::isStreamingHTTP() const {