Loading include/media/AudioTrack.h +7 −3 Original line number Diff line number Diff line Loading @@ -187,7 +187,8 @@ public: int notificationFrames = 0, int sessionId = 0, transfer_type transferType = TRANSFER_DEFAULT, const audio_offload_info_t *offloadInfo = NULL); const audio_offload_info_t *offloadInfo = NULL, int uid = -1); /* Creates an audio track and registers it with AudioFlinger. * With this constructor, the track is configured for static buffer mode. Loading @@ -211,7 +212,8 @@ public: int notificationFrames = 0, int sessionId = 0, transfer_type transferType = TRANSFER_DEFAULT, const audio_offload_info_t *offloadInfo = NULL); const audio_offload_info_t *offloadInfo = NULL, int uid = -1); /* Terminates the AudioTrack and unregisters it from AudioFlinger. * Also destroys all resources associated with the AudioTrack. Loading Loading @@ -248,7 +250,8 @@ public: bool threadCanCallJava = false, int sessionId = 0, transfer_type transferType = TRANSFER_DEFAULT, const audio_offload_info_t *offloadInfo = NULL); const audio_offload_info_t *offloadInfo = NULL, int uid = -1); /* Result of constructing the AudioTrack. This must be checked for successful initialization * before using any AudioTrack API (except for set()), because using Loading Loading @@ -751,6 +754,7 @@ private: sp<DeathNotifier> mDeathNotifier; uint32_t mSequence; // incremented for each new IAudioTrack attempt audio_io_handle_t mOutput; // cached output io handle int mClientUid; }; class TimedAudioTrack : public AudioTrack Loading include/media/IAudioFlinger.h +1 −0 Original line number Diff line number Diff line Loading @@ -74,6 +74,7 @@ public: // output: server's description of IAudioTrack for display in logs. // Don't attempt to parse, as the format could change. String8& name, int clientUid, status_t *status) = 0; virtual sp<IAudioRecord> openRecord( Loading media/libmedia/AudioTrack.cpp +15 −5 Original line number Diff line number Diff line Loading @@ -101,7 +101,8 @@ AudioTrack::AudioTrack( int notificationFrames, int sessionId, transfer_type transferType, const audio_offload_info_t *offloadInfo) const audio_offload_info_t *offloadInfo, int uid) : mStatus(NO_INIT), mIsTimed(false), mPreviousPriority(ANDROID_PRIORITY_NORMAL), Loading @@ -109,7 +110,8 @@ AudioTrack::AudioTrack( { mStatus = set(streamType, sampleRate, format, channelMask, frameCount, flags, cbf, user, notificationFrames, 0 /*sharedBuffer*/, false /*threadCanCallJava*/, sessionId, transferType, offloadInfo); 0 /*sharedBuffer*/, false /*threadCanCallJava*/, sessionId, transferType, offloadInfo, uid); } AudioTrack::AudioTrack( Loading @@ -124,7 +126,8 @@ AudioTrack::AudioTrack( int notificationFrames, int sessionId, transfer_type transferType, const audio_offload_info_t *offloadInfo) const audio_offload_info_t *offloadInfo, int uid) : mStatus(NO_INIT), mIsTimed(false), mPreviousPriority(ANDROID_PRIORITY_NORMAL), Loading @@ -132,7 +135,7 @@ AudioTrack::AudioTrack( { mStatus = set(streamType, sampleRate, format, channelMask, 0 /*frameCount*/, flags, cbf, user, notificationFrames, sharedBuffer, false /*threadCanCallJava*/, sessionId, transferType, offloadInfo); sharedBuffer, false /*threadCanCallJava*/, sessionId, transferType, offloadInfo, uid); } AudioTrack::~AudioTrack() Loading Loading @@ -169,7 +172,8 @@ status_t AudioTrack::set( bool threadCanCallJava, int sessionId, transfer_type transferType, const audio_offload_info_t *offloadInfo) const audio_offload_info_t *offloadInfo, int uid) { switch (transferType) { case TRANSFER_DEFAULT: Loading Loading @@ -313,6 +317,11 @@ status_t AudioTrack::set( mNotificationFramesReq = notificationFrames; mNotificationFramesAct = 0; mSessionId = sessionId; if (uid == -1 || (IPCThreadState::self()->getCallingPid() != getpid())) { mClientUid = IPCThreadState::self()->getCallingUid(); } else { mClientUid = uid; } mAuxEffectId = 0; mFlags = flags; mCbf = cbf; Loading Loading @@ -962,6 +971,7 @@ status_t AudioTrack::createTrack_l( tid, &mSessionId, mName, mClientUid, &status); if (track == 0) { Loading media/libmedia/IAudioFlinger.cpp +4 −1 Original line number Diff line number Diff line Loading @@ -96,6 +96,7 @@ public: pid_t tid, int *sessionId, String8& name, int clientUid, status_t *status) { Parcel data, reply; Loading @@ -121,6 +122,7 @@ public: lSessionId = *sessionId; } data.writeInt32(lSessionId); data.writeInt32(clientUid); status_t lStatus = remote()->transact(CREATE_TRACK, data, &reply); if (lStatus != NO_ERROR) { ALOGE("createTrack error: %s", strerror(-lStatus)); Loading Loading @@ -762,6 +764,7 @@ status_t BnAudioFlinger::onTransact( audio_io_handle_t output = (audio_io_handle_t) data.readInt32(); pid_t tid = (pid_t) data.readInt32(); int sessionId = data.readInt32(); int clientUid = data.readInt32(); String8 name; status_t status; sp<IAudioTrack> track; Loading @@ -773,7 +776,7 @@ status_t BnAudioFlinger::onTransact( track = createTrack( (audio_stream_type_t) streamType, sampleRate, format, channelMask, frameCount, &flags, buffer, output, tid, &sessionId, name, &status); &sessionId, name, clientUid, &status); } reply->writeInt32(flags); reply->writeInt32(sessionId); Loading media/libmediaplayerservice/MediaPlayerService.cpp +12 −7 Original line number Diff line number Diff line Loading @@ -590,7 +590,7 @@ sp<MediaPlayerBase> MediaPlayerService::Client::setDataSource_pre( } if (!p->hardwareOutput()) { mAudioOutput = new AudioOutput(mAudioSessionId); mAudioOutput = new AudioOutput(mAudioSessionId, IPCThreadState::self()->getCallingUid()); static_cast<MediaPlayerInterface*>(p.get())->setAudioSink(mAudioOutput); } Loading Loading @@ -1296,12 +1296,13 @@ Exit: #undef LOG_TAG #define LOG_TAG "AudioSink" MediaPlayerService::AudioOutput::AudioOutput(int sessionId) MediaPlayerService::AudioOutput::AudioOutput(int sessionId, int uid) : mCallback(NULL), mCallbackCookie(NULL), mCallbackData(NULL), mBytesWritten(0), mSessionId(sessionId), mUid(uid), mFlags(AUDIO_OUTPUT_FLAG_NONE) { ALOGV("AudioOutput(%d)", sessionId); mStreamType = AUDIO_STREAM_MUSIC; Loading Loading @@ -1549,7 +1550,8 @@ status_t MediaPlayerService::AudioOutput::open( 0, // notification frames mSessionId, AudioTrack::TRANSFER_CALLBACK, offloadInfo); offloadInfo, mUid); } else { t = new AudioTrack( mStreamType, Loading @@ -1558,10 +1560,13 @@ status_t MediaPlayerService::AudioOutput::open( channelMask, frameCount, flags, NULL, NULL, 0, mSessionId); NULL, // callback NULL, // user data 0, // notification frames mSessionId, AudioTrack::TRANSFER_DEFAULT, NULL, // offload info mUid); } if ((t == 0) || (t->initCheck() != NO_ERROR)) { Loading Loading
include/media/AudioTrack.h +7 −3 Original line number Diff line number Diff line Loading @@ -187,7 +187,8 @@ public: int notificationFrames = 0, int sessionId = 0, transfer_type transferType = TRANSFER_DEFAULT, const audio_offload_info_t *offloadInfo = NULL); const audio_offload_info_t *offloadInfo = NULL, int uid = -1); /* Creates an audio track and registers it with AudioFlinger. * With this constructor, the track is configured for static buffer mode. Loading @@ -211,7 +212,8 @@ public: int notificationFrames = 0, int sessionId = 0, transfer_type transferType = TRANSFER_DEFAULT, const audio_offload_info_t *offloadInfo = NULL); const audio_offload_info_t *offloadInfo = NULL, int uid = -1); /* Terminates the AudioTrack and unregisters it from AudioFlinger. * Also destroys all resources associated with the AudioTrack. Loading Loading @@ -248,7 +250,8 @@ public: bool threadCanCallJava = false, int sessionId = 0, transfer_type transferType = TRANSFER_DEFAULT, const audio_offload_info_t *offloadInfo = NULL); const audio_offload_info_t *offloadInfo = NULL, int uid = -1); /* Result of constructing the AudioTrack. This must be checked for successful initialization * before using any AudioTrack API (except for set()), because using Loading Loading @@ -751,6 +754,7 @@ private: sp<DeathNotifier> mDeathNotifier; uint32_t mSequence; // incremented for each new IAudioTrack attempt audio_io_handle_t mOutput; // cached output io handle int mClientUid; }; class TimedAudioTrack : public AudioTrack Loading
include/media/IAudioFlinger.h +1 −0 Original line number Diff line number Diff line Loading @@ -74,6 +74,7 @@ public: // output: server's description of IAudioTrack for display in logs. // Don't attempt to parse, as the format could change. String8& name, int clientUid, status_t *status) = 0; virtual sp<IAudioRecord> openRecord( Loading
media/libmedia/AudioTrack.cpp +15 −5 Original line number Diff line number Diff line Loading @@ -101,7 +101,8 @@ AudioTrack::AudioTrack( int notificationFrames, int sessionId, transfer_type transferType, const audio_offload_info_t *offloadInfo) const audio_offload_info_t *offloadInfo, int uid) : mStatus(NO_INIT), mIsTimed(false), mPreviousPriority(ANDROID_PRIORITY_NORMAL), Loading @@ -109,7 +110,8 @@ AudioTrack::AudioTrack( { mStatus = set(streamType, sampleRate, format, channelMask, frameCount, flags, cbf, user, notificationFrames, 0 /*sharedBuffer*/, false /*threadCanCallJava*/, sessionId, transferType, offloadInfo); 0 /*sharedBuffer*/, false /*threadCanCallJava*/, sessionId, transferType, offloadInfo, uid); } AudioTrack::AudioTrack( Loading @@ -124,7 +126,8 @@ AudioTrack::AudioTrack( int notificationFrames, int sessionId, transfer_type transferType, const audio_offload_info_t *offloadInfo) const audio_offload_info_t *offloadInfo, int uid) : mStatus(NO_INIT), mIsTimed(false), mPreviousPriority(ANDROID_PRIORITY_NORMAL), Loading @@ -132,7 +135,7 @@ AudioTrack::AudioTrack( { mStatus = set(streamType, sampleRate, format, channelMask, 0 /*frameCount*/, flags, cbf, user, notificationFrames, sharedBuffer, false /*threadCanCallJava*/, sessionId, transferType, offloadInfo); sharedBuffer, false /*threadCanCallJava*/, sessionId, transferType, offloadInfo, uid); } AudioTrack::~AudioTrack() Loading Loading @@ -169,7 +172,8 @@ status_t AudioTrack::set( bool threadCanCallJava, int sessionId, transfer_type transferType, const audio_offload_info_t *offloadInfo) const audio_offload_info_t *offloadInfo, int uid) { switch (transferType) { case TRANSFER_DEFAULT: Loading Loading @@ -313,6 +317,11 @@ status_t AudioTrack::set( mNotificationFramesReq = notificationFrames; mNotificationFramesAct = 0; mSessionId = sessionId; if (uid == -1 || (IPCThreadState::self()->getCallingPid() != getpid())) { mClientUid = IPCThreadState::self()->getCallingUid(); } else { mClientUid = uid; } mAuxEffectId = 0; mFlags = flags; mCbf = cbf; Loading Loading @@ -962,6 +971,7 @@ status_t AudioTrack::createTrack_l( tid, &mSessionId, mName, mClientUid, &status); if (track == 0) { Loading
media/libmedia/IAudioFlinger.cpp +4 −1 Original line number Diff line number Diff line Loading @@ -96,6 +96,7 @@ public: pid_t tid, int *sessionId, String8& name, int clientUid, status_t *status) { Parcel data, reply; Loading @@ -121,6 +122,7 @@ public: lSessionId = *sessionId; } data.writeInt32(lSessionId); data.writeInt32(clientUid); status_t lStatus = remote()->transact(CREATE_TRACK, data, &reply); if (lStatus != NO_ERROR) { ALOGE("createTrack error: %s", strerror(-lStatus)); Loading Loading @@ -762,6 +764,7 @@ status_t BnAudioFlinger::onTransact( audio_io_handle_t output = (audio_io_handle_t) data.readInt32(); pid_t tid = (pid_t) data.readInt32(); int sessionId = data.readInt32(); int clientUid = data.readInt32(); String8 name; status_t status; sp<IAudioTrack> track; Loading @@ -773,7 +776,7 @@ status_t BnAudioFlinger::onTransact( track = createTrack( (audio_stream_type_t) streamType, sampleRate, format, channelMask, frameCount, &flags, buffer, output, tid, &sessionId, name, &status); &sessionId, name, clientUid, &status); } reply->writeInt32(flags); reply->writeInt32(sessionId); Loading
media/libmediaplayerservice/MediaPlayerService.cpp +12 −7 Original line number Diff line number Diff line Loading @@ -590,7 +590,7 @@ sp<MediaPlayerBase> MediaPlayerService::Client::setDataSource_pre( } if (!p->hardwareOutput()) { mAudioOutput = new AudioOutput(mAudioSessionId); mAudioOutput = new AudioOutput(mAudioSessionId, IPCThreadState::self()->getCallingUid()); static_cast<MediaPlayerInterface*>(p.get())->setAudioSink(mAudioOutput); } Loading Loading @@ -1296,12 +1296,13 @@ Exit: #undef LOG_TAG #define LOG_TAG "AudioSink" MediaPlayerService::AudioOutput::AudioOutput(int sessionId) MediaPlayerService::AudioOutput::AudioOutput(int sessionId, int uid) : mCallback(NULL), mCallbackCookie(NULL), mCallbackData(NULL), mBytesWritten(0), mSessionId(sessionId), mUid(uid), mFlags(AUDIO_OUTPUT_FLAG_NONE) { ALOGV("AudioOutput(%d)", sessionId); mStreamType = AUDIO_STREAM_MUSIC; Loading Loading @@ -1549,7 +1550,8 @@ status_t MediaPlayerService::AudioOutput::open( 0, // notification frames mSessionId, AudioTrack::TRANSFER_CALLBACK, offloadInfo); offloadInfo, mUid); } else { t = new AudioTrack( mStreamType, Loading @@ -1558,10 +1560,13 @@ status_t MediaPlayerService::AudioOutput::open( channelMask, frameCount, flags, NULL, NULL, 0, mSessionId); NULL, // callback NULL, // user data 0, // notification frames mSessionId, AudioTrack::TRANSFER_DEFAULT, NULL, // offload info mUid); } if ((t == 0) || (t->initCheck() != NO_ERROR)) { Loading