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
diff --git a/include/media/AudioRecord.h b/include/media/AudioRecord.h
index 7df6668..5bfb65b 100644
--- a/include/media/AudioRecord.h
+++ b/include/media/AudioRecord.h
@@ -354,7 +354,6 @@
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);
diff --git a/include/media/IAudioFlinger.h b/include/media/IAudioFlinger.h
index 0f39cf3..2bae08e 100644
--- a/include/media/IAudioFlinger.h
+++ b/include/media/IAudioFlinger.h
@@ -43,6 +43,13 @@
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 @@
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 @@
audio_format_t format,
uint32_t channelMask,
int frameCount,
- uint32_t flags,
+ track_flags_t flags,
int *sessionId,
status_t *status) = 0;
diff --git a/media/libmedia/AudioRecord.cpp b/media/libmedia/AudioRecord.cpp
index 05ade75..70ec593 100644
--- a/media/libmedia/AudioRecord.cpp
+++ b/media/libmedia/AudioRecord.cpp
@@ -201,7 +201,7 @@
// create the IAudioRecord
status = openRecord_l(sampleRate, format, channelMask,
- frameCount, flags, input);
+ frameCount, input);
if (status != NO_ERROR) {
return status;
}
@@ -458,7 +458,6 @@
audio_format_t format,
uint32_t channelMask,
int frameCount,
- uint32_t flags,
audio_io_handle_t input)
{
status_t status;
@@ -471,7 +470,7 @@
sampleRate, format,
channelMask,
frameCount,
- ((uint16_t)flags) << 16,
+ IAudioFlinger::TRACK_DEFAULT,
&mSessionId,
&status);
@@ -778,7 +777,7 @@
// 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
}
diff --git a/media/libmedia/AudioTrack.cpp b/media/libmedia/AudioTrack.cpp
index 048be1d..a73f035 100644
--- a/media/libmedia/AudioTrack.cpp
+++ b/media/libmedia/AudioTrack.cpp
@@ -800,16 +800,19 @@
}
}
+ 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);
diff --git a/media/libmedia/IAudioFlinger.cpp b/media/libmedia/IAudioFlinger.cpp
index 07b12e4..ce10c8e 100644
--- a/media/libmedia/IAudioFlinger.cpp
+++ b/media/libmedia/IAudioFlinger.cpp
@@ -87,10 +87,9 @@
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 @@
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 @@
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 @@
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 @@
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,
diff --git a/services/audioflinger/AudioFlinger.cpp b/services/audioflinger/AudioFlinger.cpp
index d83d19a..993192c 100644
--- a/services/audioflinger/AudioFlinger.cpp
+++ b/services/audioflinger/AudioFlinger.cpp
@@ -442,11 +442,9 @@
audio_format_t format,
uint32_t channelMask,
int frameCount,
- // FIXME dead, remove from IAudioFlinger
- uint32_t flags,
+ IAudioFlinger::track_flags_t flags,
const sp<IMemory>& sharedBuffer,
audio_io_handle_t output,
- bool isTimed,
int *sessionId,
status_t *status)
{
@@ -504,6 +502,7 @@
}
ALOGV("createTrack() lSessionId: %d", lSessionId);
+ bool isTimed = (flags & IAudioFlinger::TRACK_TIMED) != 0;
track = thread->createTrack_l(client, streamType, sampleRate, format,
channelMask, frameCount, sharedBuffer, lSessionId, isTimed, &lStatus);
@@ -4677,8 +4676,7 @@
audio_format_t format,
uint32_t channelMask,
int frameCount,
- // FIXME dead, remove from IAudioFlinger
- uint32_t flags,
+ IAudioFlinger::track_flags_t flags,
int *sessionId,
status_t *status)
{
diff --git a/services/audioflinger/AudioFlinger.h b/services/audioflinger/AudioFlinger.h
index 0e4b24aa..a9afcb3 100644
--- a/services/audioflinger/AudioFlinger.h
+++ b/services/audioflinger/AudioFlinger.h
@@ -87,10 +87,9 @@
audio_format_t format,
uint32_t channelMask,
int frameCount,
- uint32_t flags,
+ IAudioFlinger::track_flags_t flags,
const sp<IMemory>& sharedBuffer,
audio_io_handle_t output,
- bool isTimed,
int *sessionId,
status_t *status);
@@ -101,7 +100,7 @@
audio_format_t format,
uint32_t channelMask,
int frameCount,
- uint32_t flags,
+ IAudioFlinger::track_flags_t flags,
int *sessionId,
status_t *status);