Skip to content

Commit 84569cc

Browse files
committed
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
1 parent f6b8f7b commit 84569cc

File tree

7 files changed

+28
-27
lines changed

7 files changed

+28
-27
lines changed

include/media/AudioRecord.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,6 @@ class AudioRecord
354354
audio_format_t format,
355355
uint32_t channelMask,
356356
int frameCount,
357-
uint32_t flags,
358357
audio_io_handle_t input);
359358
audio_io_handle_t getInput_l();
360359
status_t restoreRecord_l(audio_track_cblk_t*& cblk);

include/media/IAudioFlinger.h

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,13 @@ class IAudioFlinger : public IInterface
4343
public:
4444
DECLARE_META_INTERFACE(AudioFlinger);
4545

46+
// or-able bits shared by createTrack and openRecord, but not all combinations make sense
47+
enum {
48+
TRACK_DEFAULT = 0,
49+
TRACK_TIMED = 1,
50+
};
51+
typedef uint32_t track_flags_t;
52+
4653
/* create an audio track and registers it with AudioFlinger.
4754
* return null if the track cannot be created.
4855
*/
@@ -53,10 +60,9 @@ class IAudioFlinger : public IInterface
5360
audio_format_t format,
5461
uint32_t channelMask,
5562
int frameCount,
56-
uint32_t flags,
63+
track_flags_t flags,
5764
const sp<IMemory>& sharedBuffer,
5865
audio_io_handle_t output,
59-
bool isTimed,
6066
int *sessionId,
6167
status_t *status) = 0;
6268

@@ -67,7 +73,7 @@ class IAudioFlinger : public IInterface
6773
audio_format_t format,
6874
uint32_t channelMask,
6975
int frameCount,
70-
uint32_t flags,
76+
track_flags_t flags,
7177
int *sessionId,
7278
status_t *status) = 0;
7379

media/libmedia/AudioRecord.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ status_t AudioRecord::set(
201201

202202
// create the IAudioRecord
203203
status = openRecord_l(sampleRate, format, channelMask,
204-
frameCount, flags, input);
204+
frameCount, input);
205205
if (status != NO_ERROR) {
206206
return status;
207207
}
@@ -458,7 +458,6 @@ status_t AudioRecord::openRecord_l(
458458
audio_format_t format,
459459
uint32_t channelMask,
460460
int frameCount,
461-
uint32_t flags,
462461
audio_io_handle_t input)
463462
{
464463
status_t status;
@@ -471,7 +470,7 @@ status_t AudioRecord::openRecord_l(
471470
sampleRate, format,
472471
channelMask,
473472
frameCount,
474-
((uint16_t)flags) << 16,
473+
IAudioFlinger::TRACK_DEFAULT,
475474
&mSessionId,
476475
&status);
477476

@@ -778,7 +777,7 @@ status_t AudioRecord::restoreRecord_l(audio_track_cblk_t*& cblk)
778777
// following member variables: mAudioRecord, mCblkMemory and mCblk.
779778
// It will also delete the strong references on previous IAudioRecord and IMemory
780779
result = openRecord_l(cblk->sampleRate, mFormat, mChannelMask,
781-
mFrameCount, mFlags, getInput_l());
780+
mFrameCount, getInput_l());
782781
if (result == NO_ERROR) {
783782
result = mAudioRecord->start(0); // callback thread hasn't changed
784783
}

media/libmedia/AudioTrack.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -800,16 +800,19 @@ status_t AudioTrack::createTrack_l(
800800
}
801801
}
802802

803+
IAudioFlinger::track_flags_t trackFlags = IAudioFlinger::TRACK_DEFAULT;
804+
if (mIsTimed) {
805+
trackFlags |= IAudioFlinger::TRACK_TIMED;
806+
}
803807
sp<IAudioTrack> track = audioFlinger->createTrack(getpid(),
804808
streamType,
805809
sampleRate,
806810
format,
807811
channelMask,
808812
frameCount,
809-
((uint16_t)flags) << 16,
813+
trackFlags,
810814
sharedBuffer,
811815
output,
812-
mIsTimed,
813816
&mSessionId,
814817
&status);
815818

media/libmedia/IAudioFlinger.cpp

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,9 @@ class BpAudioFlinger : public BpInterface<IAudioFlinger>
8787
audio_format_t format,
8888
uint32_t channelMask,
8989
int frameCount,
90-
uint32_t flags,
90+
track_flags_t flags,
9191
const sp<IMemory>& sharedBuffer,
9292
audio_io_handle_t output,
93-
bool isTimed,
9493
int *sessionId,
9594
status_t *status)
9695
{
@@ -103,10 +102,9 @@ class BpAudioFlinger : public BpInterface<IAudioFlinger>
103102
data.writeInt32(format);
104103
data.writeInt32(channelMask);
105104
data.writeInt32(frameCount);
106-
data.writeInt32(flags);
105+
data.writeInt32((int32_t) flags);
107106
data.writeStrongBinder(sharedBuffer->asBinder());
108107
data.writeInt32((int32_t) output);
109-
data.writeInt32(isTimed);
110108
int lSessionId = 0;
111109
if (sessionId != NULL) {
112110
lSessionId = *sessionId;
@@ -136,7 +134,7 @@ class BpAudioFlinger : public BpInterface<IAudioFlinger>
136134
audio_format_t format,
137135
uint32_t channelMask,
138136
int frameCount,
139-
uint32_t flags,
137+
track_flags_t flags,
140138
int *sessionId,
141139
status_t *status)
142140
{
@@ -688,15 +686,14 @@ status_t BnAudioFlinger::onTransact(
688686
audio_format_t format = (audio_format_t) data.readInt32();
689687
int channelCount = data.readInt32();
690688
size_t bufferCount = data.readInt32();
691-
uint32_t flags = data.readInt32();
689+
track_flags_t flags = (track_flags_t) data.readInt32();
692690
sp<IMemory> buffer = interface_cast<IMemory>(data.readStrongBinder());
693691
audio_io_handle_t output = (audio_io_handle_t) data.readInt32();
694-
bool isTimed = data.readInt32();
695692
int sessionId = data.readInt32();
696693
status_t status;
697694
sp<IAudioTrack> track = createTrack(pid,
698695
(audio_stream_type_t) streamType, sampleRate, format,
699-
channelCount, bufferCount, flags, buffer, output, isTimed, &sessionId, &status);
696+
channelCount, bufferCount, flags, buffer, output, &sessionId, &status);
700697
reply->writeInt32(sessionId);
701698
reply->writeInt32(status);
702699
reply->writeStrongBinder(track->asBinder());
@@ -710,7 +707,7 @@ status_t BnAudioFlinger::onTransact(
710707
audio_format_t format = (audio_format_t) data.readInt32();
711708
int channelCount = data.readInt32();
712709
size_t bufferCount = data.readInt32();
713-
uint32_t flags = data.readInt32();
710+
track_flags_t flags = (track_flags_t) data.readInt32();
714711
int sessionId = data.readInt32();
715712
status_t status;
716713
sp<IAudioRecord> record = openRecord(pid, input,

services/audioflinger/AudioFlinger.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -442,11 +442,9 @@ sp<IAudioTrack> AudioFlinger::createTrack(
442442
audio_format_t format,
443443
uint32_t channelMask,
444444
int frameCount,
445-
// FIXME dead, remove from IAudioFlinger
446-
uint32_t flags,
445+
IAudioFlinger::track_flags_t flags,
447446
const sp<IMemory>& sharedBuffer,
448447
audio_io_handle_t output,
449-
bool isTimed,
450448
int *sessionId,
451449
status_t *status)
452450
{
@@ -504,6 +502,7 @@ sp<IAudioTrack> AudioFlinger::createTrack(
504502
}
505503
ALOGV("createTrack() lSessionId: %d", lSessionId);
506504

505+
bool isTimed = (flags & IAudioFlinger::TRACK_TIMED) != 0;
507506
track = thread->createTrack_l(client, streamType, sampleRate, format,
508507
channelMask, frameCount, sharedBuffer, lSessionId, isTimed, &lStatus);
509508

@@ -4677,8 +4676,7 @@ sp<IAudioRecord> AudioFlinger::openRecord(
46774676
audio_format_t format,
46784677
uint32_t channelMask,
46794678
int frameCount,
4680-
// FIXME dead, remove from IAudioFlinger
4681-
uint32_t flags,
4679+
IAudioFlinger::track_flags_t flags,
46824680
int *sessionId,
46834681
status_t *status)
46844682
{

services/audioflinger/AudioFlinger.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,9 @@ class AudioFlinger :
8787
audio_format_t format,
8888
uint32_t channelMask,
8989
int frameCount,
90-
uint32_t flags,
90+
IAudioFlinger::track_flags_t flags,
9191
const sp<IMemory>& sharedBuffer,
9292
audio_io_handle_t output,
93-
bool isTimed,
9493
int *sessionId,
9594
status_t *status);
9695

@@ -101,7 +100,7 @@ class AudioFlinger :
101100
audio_format_t format,
102101
uint32_t channelMask,
103102
int frameCount,
104-
uint32_t flags,
103+
IAudioFlinger::track_flags_t flags,
105104
int *sessionId,
106105
status_t *status);
107106

0 commit comments

Comments
 (0)