Update stream usage notification value

Signed-off-by: Sulav Mulmi <sulav.mulmi@huawei.com>
This commit is contained in:
Sulav Mulmi 2022-03-12 12:57:44 +05:30
parent 691501f43d
commit 83df743634
5 changed files with 57 additions and 13 deletions

View File

@ -44,7 +44,7 @@ std::unique_ptr<AudioRenderer> AudioRenderer::Create(const AudioRendererOptions
"Invalid content type");
StreamUsage streamUsage = rendererOptions.rendererInfo.streamUsage;
CHECK_AND_RETURN_RET_LOG(streamUsage >= STREAM_USAGE_UNKNOWN && streamUsage <= STREAM_USAGE_VOICE_ASSISTANT,
CHECK_AND_RETURN_RET_LOG(streamUsage >= STREAM_USAGE_UNKNOWN && streamUsage <= STREAM_USAGE_NOTIFICATION_RINGTONE,
nullptr, "Invalid stream usage");
AudioStreamType audioStreamType = AudioStream::GetStreamType(contentType, streamUsage);

View File

@ -90,14 +90,8 @@ private:
bool isReadyToWrite_;
void WriteBuffers();
static constexpr AudioStreamType streamTypeMap_[CONTENT_TYPE_RINGTONE + 1][STREAM_USAGE_VOICE_ASSISTANT + 1] = {
{STREAM_MUSIC, STREAM_MUSIC, STREAM_MUSIC, STREAM_MUSIC, STREAM_MUSIC},
{STREAM_MUSIC, STREAM_VOICE_ASSISTANT, STREAM_VOICE_CALL, STREAM_MUSIC, STREAM_VOICE_ASSISTANT},
{STREAM_MUSIC, STREAM_MUSIC, STREAM_MUSIC, STREAM_RING, STREAM_VOICE_ASSISTANT},
{STREAM_MEDIA, STREAM_MEDIA, STREAM_MUSIC, STREAM_MUSIC, STREAM_MUSIC},
{STREAM_NOTIFICATION, STREAM_NOTIFICATION, STREAM_MUSIC, STREAM_MUSIC, STREAM_MUSIC},
{STREAM_RING, STREAM_RING, STREAM_MUSIC, STREAM_RING, STREAM_MUSIC}
};
static const std::map<std::pair<ContentType, StreamUsage>, AudioStreamType> streamTypeMap_;
static std::map<std::pair<ContentType, StreamUsage>, AudioStreamType> CreateStreamMap();
};
} // namespace AudioStandard
} // namespace OHOS

View File

@ -283,8 +283,8 @@ enum StreamUsage {
STREAM_USAGE_UNKNOWN = 0,
STREAM_USAGE_MEDIA = 1,
STREAM_USAGE_VOICE_COMMUNICATION = 2,
STREAM_USAGE_NOTIFICATION_RINGTONE = 3,
STREAM_USAGE_VOICE_ASSISTANT = 4
STREAM_USAGE_VOICE_ASSISTANT = 4,
STREAM_USAGE_NOTIFICATION_RINGTONE = 6
};
/**

View File

@ -371,7 +371,7 @@ declare namespace audio {
* Notification or ringtone usage.
* @since 7
*/
STREAM_USAGE_NOTIFICATION_RINGTONE = 3
STREAM_USAGE_NOTIFICATION_RINGTONE = 6
}
/**

View File

@ -34,6 +34,51 @@ constexpr int32_t WRITE_RETRY_DELAY_IN_US = 500;
constexpr int32_t READ_WRITE_WAIT_TIME_IN_US = 500;
constexpr int32_t CB_WRITE_BUFFERS_WAIT_IN_US = 500;
const map<pair<ContentType, StreamUsage>, AudioStreamType> AudioStream::streamTypeMap_ = AudioStream::CreateStreamMap();
map<pair<ContentType, StreamUsage>, AudioStreamType> AudioStream::CreateStreamMap()
{
map<pair<ContentType, StreamUsage>, AudioStreamType> streamMap;
streamMap[make_pair(CONTENT_TYPE_UNKNOWN, STREAM_USAGE_UNKNOWN)] = STREAM_MUSIC;
streamMap[make_pair(CONTENT_TYPE_UNKNOWN, STREAM_USAGE_MEDIA)] = STREAM_MUSIC;
streamMap[make_pair(CONTENT_TYPE_UNKNOWN, STREAM_USAGE_VOICE_COMMUNICATION)] = STREAM_MUSIC;
streamMap[make_pair(CONTENT_TYPE_UNKNOWN, STREAM_USAGE_VOICE_ASSISTANT)] = STREAM_MUSIC;
streamMap[make_pair(CONTENT_TYPE_UNKNOWN, STREAM_USAGE_NOTIFICATION_RINGTONE)] = STREAM_MUSIC;
streamMap[make_pair(CONTENT_TYPE_SPEECH, STREAM_USAGE_UNKNOWN)] = STREAM_MUSIC;
streamMap[make_pair(CONTENT_TYPE_SPEECH, STREAM_USAGE_MEDIA)] = STREAM_VOICE_ASSISTANT;
streamMap[make_pair(CONTENT_TYPE_SPEECH, STREAM_USAGE_VOICE_COMMUNICATION)] = STREAM_VOICE_CALL;
streamMap[make_pair(CONTENT_TYPE_SPEECH, STREAM_USAGE_VOICE_ASSISTANT)] = STREAM_VOICE_ASSISTANT;
streamMap[make_pair(CONTENT_TYPE_SPEECH, STREAM_USAGE_NOTIFICATION_RINGTONE)] = STREAM_MUSIC;
streamMap[make_pair(CONTENT_TYPE_MUSIC, STREAM_USAGE_UNKNOWN)] = STREAM_MUSIC;
streamMap[make_pair(CONTENT_TYPE_MUSIC, STREAM_USAGE_MEDIA)] = STREAM_MUSIC;
streamMap[make_pair(CONTENT_TYPE_MUSIC, STREAM_USAGE_VOICE_COMMUNICATION)] = STREAM_MUSIC;
streamMap[make_pair(CONTENT_TYPE_MUSIC, STREAM_USAGE_VOICE_ASSISTANT)] = STREAM_VOICE_ASSISTANT;
streamMap[make_pair(CONTENT_TYPE_MUSIC, STREAM_USAGE_NOTIFICATION_RINGTONE)] = STREAM_RING;
streamMap[make_pair(CONTENT_TYPE_MOVIE, STREAM_USAGE_UNKNOWN)] = STREAM_MEDIA;
streamMap[make_pair(CONTENT_TYPE_MOVIE, STREAM_USAGE_MEDIA)] = STREAM_MEDIA;
streamMap[make_pair(CONTENT_TYPE_MOVIE, STREAM_USAGE_VOICE_COMMUNICATION)] = STREAM_MUSIC;
streamMap[make_pair(CONTENT_TYPE_MOVIE, STREAM_USAGE_VOICE_ASSISTANT)] = STREAM_MUSIC;
streamMap[make_pair(CONTENT_TYPE_MOVIE, STREAM_USAGE_NOTIFICATION_RINGTONE)] = STREAM_MUSIC;
streamMap[make_pair(CONTENT_TYPE_SONIFICATION, STREAM_USAGE_UNKNOWN)] = STREAM_NOTIFICATION;
streamMap[make_pair(CONTENT_TYPE_SONIFICATION, STREAM_USAGE_MEDIA)] = STREAM_NOTIFICATION;
streamMap[make_pair(CONTENT_TYPE_SONIFICATION, STREAM_USAGE_VOICE_COMMUNICATION)] = STREAM_MUSIC;
streamMap[make_pair(CONTENT_TYPE_SONIFICATION, STREAM_USAGE_VOICE_ASSISTANT)] = STREAM_MUSIC;
streamMap[make_pair(CONTENT_TYPE_SONIFICATION, STREAM_USAGE_NOTIFICATION_RINGTONE)] = STREAM_MUSIC;
streamMap[make_pair(CONTENT_TYPE_RINGTONE, STREAM_USAGE_UNKNOWN)] = STREAM_RING;
streamMap[make_pair(CONTENT_TYPE_RINGTONE, STREAM_USAGE_MEDIA)] = STREAM_RING;
streamMap[make_pair(CONTENT_TYPE_RINGTONE, STREAM_USAGE_VOICE_COMMUNICATION)] = STREAM_MUSIC;
streamMap[make_pair(CONTENT_TYPE_RINGTONE, STREAM_USAGE_VOICE_ASSISTANT)] = STREAM_MUSIC;
streamMap[make_pair(CONTENT_TYPE_RINGTONE, STREAM_USAGE_NOTIFICATION_RINGTONE)] = STREAM_RING;
return streamMap;
}
AudioStream::AudioStream(AudioStreamType eStreamType, AudioMode eMode) : eStreamType_(eStreamType),
eMode_(eMode),
state_(NEW),
@ -453,7 +498,12 @@ bool AudioStream::ReleaseAudioStream()
AudioStreamType AudioStream::GetStreamType(ContentType contentType, StreamUsage streamUsage)
{
AudioStreamType streamType = streamTypeMap_[contentType][streamUsage];
AudioStreamType streamType = STREAM_MUSIC;
auto pos = streamTypeMap_.find(make_pair(contentType, streamUsage));
if (pos != streamTypeMap_.end()) {
streamType = pos->second;
}
if (streamType == STREAM_MEDIA) {
streamType = STREAM_MUSIC;
}