blob: 36d8eef543f93e48a4a685a311240121f44b672b [file] [log] [blame]
Glenn Kasten97b5d0d2012-03-23 18:54:19 -07001/*
2 * Copyright (C) 2012 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
Glenn Kasten60fd12a2017-02-21 13:06:16 -080017#define LOG_TAG "FastMixerState"
18//#define LOG_NDEBUG 0
19
Glenn Kastendc2c50b2016-04-21 08:13:14 -070020#include <cutils/properties.h>
Glenn Kasten97b5d0d2012-03-23 18:54:19 -070021#include "FastMixerState.h"
22
23namespace android {
24
25FastTrack::FastTrack() :
Martin Storsjo3ce28aa2014-02-05 19:49:05 +020026 mBufferProvider(NULL), mVolumeProvider(NULL),
Andy Hunge8a1ced2014-05-09 15:02:21 -070027 mChannelMask(AUDIO_CHANNEL_OUT_STEREO), mFormat(AUDIO_FORMAT_INVALID), mGeneration(0)
Glenn Kasten97b5d0d2012-03-23 18:54:19 -070028{
29}
30
31FastTrack::~FastTrack()
32{
33}
34
Glenn Kastenf7160b52014-03-18 17:01:15 -070035FastMixerState::FastMixerState() : FastThreadState(),
Glenn Kasten22340022014-04-07 12:04:41 -070036 // mFastTracks
Glenn Kasten97b5d0d2012-03-23 18:54:19 -070037 mFastTracksGen(0), mTrackMask(0), mOutputSink(NULL), mOutputSinkGen(0),
Glenn Kasten22340022014-04-07 12:04:41 -070038 mFrameCount(0), mTeeSink(NULL)
Glenn Kasten97b5d0d2012-03-23 18:54:19 -070039{
Glenn Kastendc2c50b2016-04-21 08:13:14 -070040 int ok = pthread_once(&sMaxFastTracksOnce, sMaxFastTracksInit);
41 if (ok != 0) {
42 ALOGE("%s pthread_once failed: %d", __func__, ok);
43 }
Glenn Kasten97b5d0d2012-03-23 18:54:19 -070044}
45
46FastMixerState::~FastMixerState()
47{
48}
49
Glenn Kastend702a562015-03-02 15:51:38 -080050// static
Glenn Kastendc2c50b2016-04-21 08:13:14 -070051unsigned FastMixerState::sMaxFastTracks = kDefaultFastTracks;
52
53// static
54pthread_once_t FastMixerState::sMaxFastTracksOnce = PTHREAD_ONCE_INIT;
55
56// static
Glenn Kastend702a562015-03-02 15:51:38 -080057const char *FastMixerState::commandToString(Command command)
58{
59 const char *str = FastThreadState::commandToString(command);
60 if (str != NULL) {
61 return str;
62 }
63 switch (command) {
64 case FastMixerState::MIX: return "MIX";
65 case FastMixerState::WRITE: return "WRITE";
66 case FastMixerState::MIX_WRITE: return "MIX_WRITE";
67 }
68 LOG_ALWAYS_FATAL("%s", __func__);
69}
70
Glenn Kastendc2c50b2016-04-21 08:13:14 -070071// static
72void FastMixerState::sMaxFastTracksInit()
73{
74 char value[PROPERTY_VALUE_MAX];
75 if (property_get("ro.audio.max_fast_tracks", value, NULL) > 0) {
76 char *endptr;
77 unsigned long ul = strtoul(value, &endptr, 0);
78 if (*endptr == '\0' && kMinFastTracks <= ul && ul <= kMaxFastTracks) {
79 sMaxFastTracks = (unsigned) ul;
80 }
81 }
82 ALOGI("sMaxFastTracks = %u", sMaxFastTracks);
83}
84
Glenn Kasten97b5d0d2012-03-23 18:54:19 -070085} // namespace android