mirror of
https://github.com/mozilla/cubeb
synced 2024-11-21 06:26:10 -07:00
Allocate and share session ID for input voice streams
A session ID is required for audiofx, even through presets. The latter is not clear in the documentation, but see https://android.googlesource.com/platform/frameworks/av/+/master/services/audioflinger/AudioFlinger.cpp#1035
This commit is contained in:
parent
76ffc3e9e1
commit
d896f3af2a
1 changed files with 19 additions and 7 deletions
|
@ -48,6 +48,7 @@ using namespace std;
|
|||
X(AAudioStreamBuilder_delete) \
|
||||
X(AAudioStreamBuilder_setDataCallback) \
|
||||
X(AAudioStreamBuilder_setErrorCallback) \
|
||||
X(AAudioStreamBuilder_setSessionId) \
|
||||
X(AAudioStream_close) \
|
||||
X(AAudioStream_read) \
|
||||
X(AAudioStream_requestStart) \
|
||||
|
@ -67,6 +68,7 @@ using namespace std;
|
|||
X(AAudioStream_getFramesWritten) \
|
||||
X(AAudioStream_getFramesPerBurst) \
|
||||
X(AAudioStream_getInputPreset) \
|
||||
X(AAudioStream_getSessionId) \
|
||||
X(AAudioStreamBuilder_setInputPreset) \
|
||||
X(AAudioStreamBuilder_setUsage) \
|
||||
X(AAudioStreamBuilder_setFramesPerDataCallback)
|
||||
|
@ -82,10 +84,8 @@ using namespace std;
|
|||
// X(AAudioStream_getXRunCount) \
|
||||
// X(AAudioStream_isMMapUsed) \
|
||||
// X(AAudioStreamBuilder_setContentType) \
|
||||
// X(AAudioStreamBuilder_setSessionId) \
|
||||
// X(AAudioStream_getUsage) \
|
||||
// X(AAudioStream_getContentType) \
|
||||
// X(AAudioStream_getSessionId) \
|
||||
// END: not needed or added later on
|
||||
|
||||
#define MAKE_TYPEDEF(x) static decltype(x) * cubeb_##x;
|
||||
|
@ -179,6 +179,7 @@ struct cubeb_stream {
|
|||
bool voice_input{};
|
||||
bool voice_output{};
|
||||
cubeb_input_processing_params input_processing_params{};
|
||||
aaudio_session_id_t input_session_id{AAUDIO_SESSION_ID_NONE};
|
||||
uint64_t previous_clock{};
|
||||
};
|
||||
|
||||
|
@ -1225,11 +1226,19 @@ aaudio_stream_init_impl(cubeb_stream * stm, lock_guard<mutex> & lock)
|
|||
// input
|
||||
cubeb_stream_params in_params;
|
||||
if (stm->input_stream_params) {
|
||||
aaudio_input_preset_t preset =
|
||||
stm->voice_input ? *input_processing_params_to_input_preset(
|
||||
stm->input_processing_params)
|
||||
: AAUDIO_INPUT_PRESET_CAMCORDER;
|
||||
WRAP(AAudioStreamBuilder_setInputPreset)(sb, preset);
|
||||
if (stm->voice_input) {
|
||||
const aaudio_session_id_t session_id =
|
||||
stm->input_session_id == AAUDIO_SESSION_ID_NONE
|
||||
? AAUDIO_SESSION_ID_ALLOCATE
|
||||
: stm->input_session_id;
|
||||
WRAP(AAudioStreamBuilder_setSessionId)(sb, session_id);
|
||||
const auto preset = *input_processing_params_to_input_preset(
|
||||
stm->input_processing_params);
|
||||
WRAP(AAudioStreamBuilder_setInputPreset)(sb, preset);
|
||||
} else {
|
||||
WRAP(AAudioStreamBuilder_setInputPreset)
|
||||
(sb, AAUDIO_INPUT_PRESET_CAMCORDER);
|
||||
}
|
||||
WRAP(AAudioStreamBuilder_setDirection)(sb, AAUDIO_DIRECTION_INPUT);
|
||||
WRAP(AAudioStreamBuilder_setDataCallback)(sb, in_data_callback, stm);
|
||||
assert(stm->latency_frames < std::numeric_limits<int32_t>::max());
|
||||
|
@ -1242,6 +1251,9 @@ aaudio_stream_init_impl(cubeb_stream * stm, lock_guard<mutex> & lock)
|
|||
return res_err;
|
||||
}
|
||||
|
||||
if (stm->voice_input) {
|
||||
stm->input_session_id = WRAP(AAudioStream_getSessionId)(stm->istream);
|
||||
}
|
||||
int32_t input_burst_size =
|
||||
WRAP(AAudioStream_getFramesPerBurst)(stm->istream);
|
||||
LOG("AAudio input burst size: %d", input_burst_size);
|
||||
|
|
Loading…
Reference in a new issue