Use audio_stream_type_t consistently
At native level it was a mixture of audio_stream_type_t, int, uint32_t,
and uint8_t. Java is still int. Also fixed a couple of hard-coded -1
instead of AUDIO_STREAM_DEFAULT, and in startToneCommand a hard-coded 0
instead of AUDIO_STREAM_VOICE_CALL.
Change-Id: Ia33bfd70edca8c2daec9052984b369cd8eee2a83
diff --git a/media/jni/android_media_MediaPlayer.cpp b/media/jni/android_media_MediaPlayer.cpp
index 39fd9a9..8ff9dd3 100644
--- a/media/jni/android_media_MediaPlayer.cpp
+++ b/media/jni/android_media_MediaPlayer.cpp
@@ -479,7 +479,7 @@
jniThrowException(env, "java/lang/IllegalStateException", NULL);
return;
}
- process_media_player_call( env, thiz, mp->setAudioStreamType(streamtype) , NULL, NULL );
+ process_media_player_call( env, thiz, mp->setAudioStreamType((audio_stream_type_t) streamtype) , NULL, NULL );
}
static void
diff --git a/media/jni/soundpool/SoundPool.cpp b/media/jni/soundpool/SoundPool.cpp
index b5303ef..0d51def 100644
--- a/media/jni/soundpool/SoundPool.cpp
+++ b/media/jni/soundpool/SoundPool.cpp
@@ -39,7 +39,7 @@
uint32_t kDefaultSampleRate = 44100;
uint32_t kDefaultFrameCount = 1200;
-SoundPool::SoundPool(int maxChannels, int streamType, int srcQuality)
+SoundPool::SoundPool(int maxChannels, audio_stream_type_t streamType, int srcQuality)
{
ALOGV("SoundPool constructor: maxChannels=%d, streamType=%d, srcQuality=%d",
maxChannels, streamType, srcQuality);
@@ -570,7 +570,7 @@
// initialize track
int afFrameCount;
int afSampleRate;
- int streamType = mSoundPool->streamType();
+ audio_stream_type_t streamType = mSoundPool->streamType();
if (AudioSystem::getOutputFrameCount(&afFrameCount, streamType) != NO_ERROR) {
afFrameCount = kDefaultFrameCount;
}
diff --git a/media/jni/soundpool/SoundPool.h b/media/jni/soundpool/SoundPool.h
index 1b91b3b..6b11c28 100644
--- a/media/jni/soundpool/SoundPool.h
+++ b/media/jni/soundpool/SoundPool.h
@@ -162,7 +162,7 @@
friend class SoundPoolThread;
friend class SoundChannel;
public:
- SoundPool(int maxChannels, int streamType, int srcQuality);
+ SoundPool(int maxChannels, audio_stream_type_t streamType, int srcQuality);
~SoundPool();
int load(const char* url, int priority);
int load(int fd, int64_t offset, int64_t length, int priority);
@@ -178,7 +178,7 @@
void setPriority(int channelID, int priority);
void setLoop(int channelID, int loop);
void setRate(int channelID, float rate);
- int streamType() const { return mStreamType; }
+ audio_stream_type_t streamType() const { return mStreamType; }
int srcQuality() const { return mSrcQuality; }
// called from SoundPoolThread
@@ -220,7 +220,7 @@
List<SoundChannel*> mStop;
DefaultKeyedVector< int, sp<Sample> > mSamples;
int mMaxChannels;
- int mStreamType;
+ audio_stream_type_t mStreamType;
int mSrcQuality;
int mAllocated;
int mNextSampleID;
diff --git a/media/jni/soundpool/android_media_SoundPool.cpp b/media/jni/soundpool/android_media_SoundPool.cpp
index fe1c20a..da3af9d 100644
--- a/media/jni/soundpool/android_media_SoundPool.cpp
+++ b/media/jni/soundpool/android_media_SoundPool.cpp
@@ -179,7 +179,7 @@
android_media_SoundPool_native_setup(JNIEnv *env, jobject thiz, jobject weakRef, jint maxChannels, jint streamType, jint srcQuality)
{
ALOGV("android_media_SoundPool_native_setup");
- SoundPool *ap = new SoundPool(maxChannels, streamType, srcQuality);
+ SoundPool *ap = new SoundPool(maxChannels, (audio_stream_type_t) streamType, srcQuality);
if (ap == NULL) {
return -1;
}
diff --git a/media/libmedia/AudioSystem.cpp b/media/libmedia/AudioSystem.cpp
index 9d4137e..5193848 100644
--- a/media/libmedia/AudioSystem.cpp
+++ b/media/libmedia/AudioSystem.cpp
@@ -120,7 +120,7 @@
return NO_ERROR;
}
-status_t AudioSystem::setStreamVolume(int stream, float value, int output)
+status_t AudioSystem::setStreamVolume(audio_stream_type_t stream, float value, int output)
{
if (uint32_t(stream) >= AUDIO_STREAM_CNT) return BAD_VALUE;
const sp<IAudioFlinger>& af = AudioSystem::get_audio_flinger();
@@ -129,7 +129,7 @@
return NO_ERROR;
}
-status_t AudioSystem::setStreamMute(int stream, bool mute)
+status_t AudioSystem::setStreamMute(audio_stream_type_t stream, bool mute)
{
if (uint32_t(stream) >= AUDIO_STREAM_CNT) return BAD_VALUE;
const sp<IAudioFlinger>& af = AudioSystem::get_audio_flinger();
@@ -138,7 +138,7 @@
return NO_ERROR;
}
-status_t AudioSystem::getStreamVolume(int stream, float* volume, int output)
+status_t AudioSystem::getStreamVolume(audio_stream_type_t stream, float* volume, int output)
{
if (uint32_t(stream) >= AUDIO_STREAM_CNT) return BAD_VALUE;
const sp<IAudioFlinger>& af = AudioSystem::get_audio_flinger();
@@ -147,7 +147,7 @@
return NO_ERROR;
}
-status_t AudioSystem::getStreamMute(int stream, bool* mute)
+status_t AudioSystem::getStreamMute(audio_stream_type_t stream, bool* mute)
{
if (uint32_t(stream) >= AUDIO_STREAM_CNT) return BAD_VALUE;
const sp<IAudioFlinger>& af = AudioSystem::get_audio_flinger();
@@ -203,7 +203,7 @@
return volume ? 100 - int(dBConvertInverse * log(volume) + 0.5) : 0;
}
-status_t AudioSystem::getOutputSamplingRate(int* samplingRate, int streamType)
+status_t AudioSystem::getOutputSamplingRate(int* samplingRate, audio_stream_type_t streamType)
{
OutputDescriptor *outputDesc;
audio_io_handle_t output;
@@ -212,7 +212,7 @@
streamType = AUDIO_STREAM_MUSIC;
}
- output = getOutput((audio_stream_type_t)streamType);
+ output = getOutput(streamType);
if (output == 0) {
return PERMISSION_DENIED;
}
@@ -236,7 +236,7 @@
return NO_ERROR;
}
-status_t AudioSystem::getOutputFrameCount(int* frameCount, int streamType)
+status_t AudioSystem::getOutputFrameCount(int* frameCount, audio_stream_type_t streamType)
{
OutputDescriptor *outputDesc;
audio_io_handle_t output;
@@ -245,7 +245,7 @@
streamType = AUDIO_STREAM_MUSIC;
}
- output = getOutput((audio_stream_type_t)streamType);
+ output = getOutput(streamType);
if (output == 0) {
return PERMISSION_DENIED;
}
@@ -267,7 +267,7 @@
return NO_ERROR;
}
-status_t AudioSystem::getOutputLatency(uint32_t* latency, int streamType)
+status_t AudioSystem::getOutputLatency(uint32_t* latency, audio_stream_type_t streamType)
{
OutputDescriptor *outputDesc;
audio_io_handle_t output;
@@ -276,7 +276,7 @@
streamType = AUDIO_STREAM_MUSIC;
}
- output = getOutput((audio_stream_type_t)streamType);
+ output = getOutput(streamType);
if (output == 0) {
return PERMISSION_DENIED;
}
@@ -333,7 +333,7 @@
return af->setVoiceVolume(value);
}
-status_t AudioSystem::getRenderPosition(uint32_t *halFrames, uint32_t *dspFrames, int stream)
+status_t AudioSystem::getRenderPosition(uint32_t *halFrames, uint32_t *dspFrames, audio_stream_type_t stream)
{
const sp<IAudioFlinger>& af = AudioSystem::get_audio_flinger();
if (af == 0) return PERMISSION_DENIED;
@@ -342,7 +342,7 @@
stream = AUDIO_STREAM_MUSIC;
}
- return af->getRenderPosition(halFrames, dspFrames, getOutput((audio_stream_type_t)stream));
+ return af->getRenderPosition(halFrames, dspFrames, getOutput(stream));
}
unsigned int AudioSystem::getInputFramesLost(audio_io_handle_t ioHandle) {
@@ -467,7 +467,7 @@
gAudioErrorCallback = cb;
}
-bool AudioSystem::routedToA2dpOutput(int streamType) {
+bool AudioSystem::routedToA2dpOutput(audio_stream_type_t streamType) {
switch(streamType) {
case AUDIO_STREAM_MUSIC:
case AUDIO_STREAM_VOICE_CALL:
@@ -728,7 +728,7 @@
return aps->setEffectEnabled(id, enabled);
}
-status_t AudioSystem::isStreamActive(int stream, bool* state, uint32_t inPastMs)
+status_t AudioSystem::isStreamActive(audio_stream_type_t stream, bool* state, uint32_t inPastMs)
{
const sp<IAudioPolicyService>& aps = AudioSystem::get_audio_policy_service();
if (aps == 0) return PERMISSION_DENIED;
diff --git a/media/libmedia/AudioTrack.cpp b/media/libmedia/AudioTrack.cpp
index 9c650ad..98fec83 100644
--- a/media/libmedia/AudioTrack.cpp
+++ b/media/libmedia/AudioTrack.cpp
@@ -49,7 +49,7 @@
// static
status_t AudioTrack::getMinFrameCount(
int* frameCount,
- int streamType,
+ audio_stream_type_t streamType,
uint32_t sampleRate)
{
int afSampleRate;
@@ -83,7 +83,7 @@
}
AudioTrack::AudioTrack(
- int streamType,
+ audio_stream_type_t streamType,
uint32_t sampleRate,
audio_format_t format,
int channelMask,
@@ -102,7 +102,7 @@
}
AudioTrack::AudioTrack(
- int streamType,
+ audio_stream_type_t streamType,
uint32_t sampleRate,
audio_format_t format,
int channelMask,
@@ -140,7 +140,7 @@
}
status_t AudioTrack::set(
- int streamType,
+ audio_stream_type_t streamType,
uint32_t sampleRate,
audio_format_t format,
int channelMask,
@@ -204,7 +204,7 @@
uint32_t channelCount = popcount(channelMask);
audio_io_handle_t output = AudioSystem::getOutput(
- (audio_stream_type_t)streamType,
+ streamType,
sampleRate, format, channelMask,
(audio_policy_output_flags_t)flags);
@@ -275,7 +275,7 @@
return mLatency;
}
-int AudioTrack::streamType() const
+audio_stream_type_t AudioTrack::streamType() const
{
return mStreamType;
}
@@ -688,7 +688,7 @@
// must be called with mLock held
audio_io_handle_t AudioTrack::getOutput_l()
{
- return AudioSystem::getOutput((audio_stream_type_t)mStreamType,
+ return AudioSystem::getOutput(mStreamType,
mCblk->sampleRate, mFormat, mChannelMask, (audio_policy_output_flags_t)mFlags);
}
@@ -711,7 +711,7 @@
// must be called with mLock held
status_t AudioTrack::createTrack_l(
- int streamType,
+ audio_stream_type_t streamType,
uint32_t sampleRate,
audio_format_t format,
uint32_t channelMask,
diff --git a/media/libmedia/IAudioFlinger.cpp b/media/libmedia/IAudioFlinger.cpp
index abd491f..9ed1a2a 100644
--- a/media/libmedia/IAudioFlinger.cpp
+++ b/media/libmedia/IAudioFlinger.cpp
@@ -82,7 +82,7 @@
virtual sp<IAudioTrack> createTrack(
pid_t pid,
- int streamType,
+ audio_stream_type_t streamType,
uint32_t sampleRate,
uint32_t format,
uint32_t channelMask,
@@ -97,7 +97,7 @@
sp<IAudioTrack> track;
data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
data.writeInt32(pid);
- data.writeInt32(streamType);
+ data.writeInt32((int32_t) streamType);
data.writeInt32(sampleRate);
data.writeInt32(format);
data.writeInt32(channelMask);
@@ -249,42 +249,42 @@
return reply.readInt32();
}
- virtual status_t setStreamVolume(int stream, float value, int output)
+ virtual status_t setStreamVolume(audio_stream_type_t stream, float value, int output)
{
Parcel data, reply;
data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
- data.writeInt32(stream);
+ data.writeInt32((int32_t) stream);
data.writeFloat(value);
data.writeInt32(output);
remote()->transact(SET_STREAM_VOLUME, data, &reply);
return reply.readInt32();
}
- virtual status_t setStreamMute(int stream, bool muted)
+ virtual status_t setStreamMute(audio_stream_type_t stream, bool muted)
{
Parcel data, reply;
data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
- data.writeInt32(stream);
+ data.writeInt32((int32_t) stream);
data.writeInt32(muted);
remote()->transact(SET_STREAM_MUTE, data, &reply);
return reply.readInt32();
}
- virtual float streamVolume(int stream, int output) const
+ virtual float streamVolume(audio_stream_type_t stream, int output) const
{
Parcel data, reply;
data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
- data.writeInt32(stream);
+ data.writeInt32((int32_t) stream);
data.writeInt32(output);
remote()->transact(STREAM_VOLUME, data, &reply);
return reply.readFloat();
}
- virtual bool streamMute(int stream) const
+ virtual bool streamMute(audio_stream_type_t stream) const
{
Parcel data, reply;
data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
- data.writeInt32(stream);
+ data.writeInt32((int32_t) stream);
remote()->transact(STREAM_MUTE, data, &reply);
return reply.readInt32();
}
@@ -468,11 +468,11 @@
return reply.readInt32();
}
- virtual status_t setStreamOutput(uint32_t stream, int output)
+ virtual status_t setStreamOutput(audio_stream_type_t stream, int output)
{
Parcel data, reply;
data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
- data.writeInt32(stream);
+ data.writeInt32((int32_t) stream);
data.writeInt32(output);
remote()->transact(SET_STREAM_OUTPUT, data, &reply);
return reply.readInt32();
@@ -687,7 +687,7 @@
int sessionId = data.readInt32();
status_t status;
sp<IAudioTrack> track = createTrack(pid,
- streamType, sampleRate, format,
+ (audio_stream_type_t) streamType, sampleRate, format,
channelCount, bufferCount, flags, buffer, output, &sessionId, &status);
reply->writeInt32(sessionId);
reply->writeInt32(status);
@@ -762,26 +762,26 @@
int stream = data.readInt32();
float volume = data.readFloat();
int output = data.readInt32();
- reply->writeInt32( setStreamVolume(stream, volume, output) );
+ reply->writeInt32( setStreamVolume((audio_stream_type_t) stream, volume, output) );
return NO_ERROR;
} break;
case SET_STREAM_MUTE: {
CHECK_INTERFACE(IAudioFlinger, data, reply);
int stream = data.readInt32();
- reply->writeInt32( setStreamMute(stream, data.readInt32()) );
+ reply->writeInt32( setStreamMute((audio_stream_type_t) stream, data.readInt32()) );
return NO_ERROR;
} break;
case STREAM_VOLUME: {
CHECK_INTERFACE(IAudioFlinger, data, reply);
int stream = data.readInt32();
int output = data.readInt32();
- reply->writeFloat( streamVolume(stream, output) );
+ reply->writeFloat( streamVolume((audio_stream_type_t) stream, output) );
return NO_ERROR;
} break;
case STREAM_MUTE: {
CHECK_INTERFACE(IAudioFlinger, data, reply);
int stream = data.readInt32();
- reply->writeInt32( streamMute(stream) );
+ reply->writeInt32( streamMute((audio_stream_type_t) stream) );
return NO_ERROR;
} break;
case SET_MODE: {
@@ -904,7 +904,7 @@
CHECK_INTERFACE(IAudioFlinger, data, reply);
uint32_t stream = data.readInt32();
int output = data.readInt32();
- reply->writeInt32(setStreamOutput(stream, output));
+ reply->writeInt32(setStreamOutput((audio_stream_type_t) stream, output));
return NO_ERROR;
} break;
case SET_VOICE_VOLUME: {
diff --git a/media/libmedia/IAudioPolicyService.cpp b/media/libmedia/IAudioPolicyService.cpp
index 50b4855..67d9c45 100644
--- a/media/libmedia/IAudioPolicyService.cpp
+++ b/media/libmedia/IAudioPolicyService.cpp
@@ -154,7 +154,7 @@
Parcel data, reply;
data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
data.writeInt32(output);
- data.writeInt32(stream);
+ data.writeInt32((int32_t) stream);
data.writeInt32(session);
remote()->transact(START_OUTPUT, data, &reply);
return static_cast <status_t> (reply.readInt32());
@@ -167,7 +167,7 @@
Parcel data, reply;
data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
data.writeInt32(output);
- data.writeInt32(stream);
+ data.writeInt32((int32_t) stream);
data.writeInt32(session);
remote()->transact(STOP_OUTPUT, data, &reply);
return static_cast <status_t> (reply.readInt32());
@@ -324,11 +324,11 @@
return static_cast <status_t> (reply.readInt32());
}
- virtual bool isStreamActive(int stream, uint32_t inPastMs) const
+ virtual bool isStreamActive(audio_stream_type_t stream, uint32_t inPastMs) const
{
Parcel data, reply;
data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
- data.writeInt32(stream);
+ data.writeInt32((int32_t) stream);
data.writeInt32(inPastMs);
remote()->transact(IS_STREAM_ACTIVE, data, &reply);
return reply.readInt32();
@@ -598,9 +598,9 @@
case IS_STREAM_ACTIVE: {
CHECK_INTERFACE(IAudioPolicyService, data, reply);
- int stream = data.readInt32();
+ audio_stream_type_t stream = (audio_stream_type_t) data.readInt32();
uint32_t inPastMs = (uint32_t)data.readInt32();
- reply->writeInt32( isStreamActive(stream, inPastMs) );
+ reply->writeInt32( isStreamActive((audio_stream_type_t) stream, inPastMs) );
return NO_ERROR;
} break;
diff --git a/media/libmedia/IMediaPlayer.cpp b/media/libmedia/IMediaPlayer.cpp
index 9c1e6b7..64cc919 100644
--- a/media/libmedia/IMediaPlayer.cpp
+++ b/media/libmedia/IMediaPlayer.cpp
@@ -198,11 +198,11 @@
return reply.readInt32();
}
- status_t setAudioStreamType(int type)
+ status_t setAudioStreamType(audio_stream_type_t stream)
{
Parcel data, reply;
data.writeInterfaceToken(IMediaPlayer::getInterfaceDescriptor());
- data.writeInt32(type);
+ data.writeInt32((int32_t) stream);
remote()->transact(SET_AUDIO_STREAM_TYPE, data, &reply);
return reply.readInt32();
}
@@ -397,7 +397,7 @@
} break;
case SET_AUDIO_STREAM_TYPE: {
CHECK_INTERFACE(IMediaPlayer, data, reply);
- reply->writeInt32(setAudioStreamType(data.readInt32()));
+ reply->writeInt32(setAudioStreamType((audio_stream_type_t) data.readInt32()));
return NO_ERROR;
} break;
case SET_LOOPING: {
diff --git a/media/libmedia/ToneGenerator.cpp b/media/libmedia/ToneGenerator.cpp
index 9d32460..5ceb912 100644
--- a/media/libmedia/ToneGenerator.cpp
+++ b/media/libmedia/ToneGenerator.cpp
@@ -798,7 +798,7 @@
// none
//
////////////////////////////////////////////////////////////////////////////////
-ToneGenerator::ToneGenerator(int streamType, float volume, bool threadCanCallJava) {
+ToneGenerator::ToneGenerator(audio_stream_type_t streamType, float volume, bool threadCanCallJava) {
ALOGV("ToneGenerator constructor: streamType=%d, volume=%f\n", streamType, volume);
diff --git a/media/libmedia/mediaplayer.cpp b/media/libmedia/mediaplayer.cpp
index 4be960c..acf97a6 100644
--- a/media/libmedia/mediaplayer.cpp
+++ b/media/libmedia/mediaplayer.cpp
@@ -478,7 +478,7 @@
return reset_l();
}
-status_t MediaPlayer::setAudioStreamType(int type)
+status_t MediaPlayer::setAudioStreamType(audio_stream_type_t type)
{
ALOGV("MediaPlayer::setAudioStreamType");
Mutex::Autolock _l(mLock);
diff --git a/media/libmediaplayerservice/MediaPlayerService.cpp b/media/libmediaplayerservice/MediaPlayerService.cpp
index af58cac..a0c20ae 100644
--- a/media/libmediaplayerservice/MediaPlayerService.cpp
+++ b/media/libmediaplayerservice/MediaPlayerService.cpp
@@ -1010,7 +1010,7 @@
return p->reset();
}
-status_t MediaPlayerService::Client::setAudioStreamType(int type)
+status_t MediaPlayerService::Client::setAudioStreamType(audio_stream_type_t type)
{
ALOGV("[%d] setAudioStreamType(%d)", mConnId, type);
// TODO: for hardware output, call player instead
diff --git a/media/libmediaplayerservice/MediaPlayerService.h b/media/libmediaplayerservice/MediaPlayerService.h
index 66f245d..6b68b87 100644
--- a/media/libmediaplayerservice/MediaPlayerService.h
+++ b/media/libmediaplayerservice/MediaPlayerService.h
@@ -92,7 +92,7 @@
virtual void flush();
virtual void pause();
virtual void close();
- void setAudioStreamType(int streamType) { mStreamType = streamType; }
+ void setAudioStreamType(audio_stream_type_t streamType) { mStreamType = streamType; }
void setVolume(float left, float right);
status_t setAuxEffectSendLevel(float level);
status_t attachAuxEffect(int effectId);
@@ -108,7 +108,7 @@
AudioTrack* mTrack;
AudioCallback mCallback;
void * mCallbackCookie;
- int mStreamType;
+ audio_stream_type_t mStreamType;
float mLeftVolume;
float mRightVolume;
float mMsecsPerFrame;
@@ -149,7 +149,7 @@
virtual void flush() {}
virtual void pause() {}
virtual void close() {}
- void setAudioStreamType(int streamType) {}
+ void setAudioStreamType(audio_stream_type_t streamType) {}
void setVolume(float left, float right) {}
uint32_t sampleRate() const { return mSampleRate; }
audio_format_t format() const { return mFormat; }
@@ -259,7 +259,7 @@
virtual status_t getCurrentPosition(int* msec);
virtual status_t getDuration(int* msec);
virtual status_t reset();
- virtual status_t setAudioStreamType(int type);
+ virtual status_t setAudioStreamType(audio_stream_type_t type);
virtual status_t setLooping(int loop);
virtual status_t setVolume(float leftVolume, float rightVolume);
virtual status_t invoke(const Parcel& request, Parcel *reply);
diff --git a/media/libmediaplayerservice/MidiFile.h b/media/libmediaplayerservice/MidiFile.h
index 2a0dcf9..dfe4318 100644
--- a/media/libmediaplayerservice/MidiFile.h
+++ b/media/libmediaplayerservice/MidiFile.h
@@ -78,7 +78,7 @@
EAS_I32 mDuration;
EAS_STATE mState;
EAS_FILE mFileLocator;
- int mStreamType;
+ audio_stream_type_t mStreamType;
bool mLoop;
volatile bool mExit;
bool mPaused;