Loading media/libmediaplayerservice/nuplayer/NuPlayerRenderer.cpp +29 −0 Original line number Diff line number Diff line Loading @@ -38,6 +38,15 @@ namespace android { // is closed to allow the audio DSP to power down. static const int64_t kOffloadPauseMaxUs = 10000000ll; // static const NuPlayer::Renderer::PcmInfo NuPlayer::Renderer::AUDIO_PCMINFO_INITIALIZER = { AUDIO_CHANNEL_NONE, AUDIO_OUTPUT_FLAG_NONE, AUDIO_FORMAT_INVALID, 0, // mNumChannels 0 // mSampleRate }; // static const int64_t NuPlayer::Renderer::kMinPositionUpdateDelayUs = 100000ll; Loading Loading @@ -76,6 +85,7 @@ NuPlayer::Renderer::Renderer( mAudioOffloadPauseTimeoutGeneration(0), mAudioOffloadTornDown(false), mCurrentOffloadInfo(AUDIO_INFO_INITIALIZER), mCurrentPcmInfo(AUDIO_PCMINFO_INITIALIZER), mTotalBuffersQueued(0), mLastAudioBufferDrained(0) { } Loading Loading @@ -1442,6 +1452,8 @@ status_t NuPlayer::Renderer::onOpenAudioSink( // no change from previous configuration, everything ok. return OK; } mCurrentPcmInfo = AUDIO_PCMINFO_INITIALIZER; ALOGV("openAudioSink: try to open AudioSink in offload mode"); uint32_t offloadFlags = flags; offloadFlags |= AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD; Loading Loading @@ -1483,6 +1495,20 @@ status_t NuPlayer::Renderer::onOpenAudioSink( ALOGV("openAudioSink: open AudioSink in NON-offload mode"); uint32_t pcmFlags = flags; pcmFlags &= ~AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD; const PcmInfo info = { (audio_channel_mask_t)channelMask, (audio_output_flags_t)pcmFlags, AUDIO_FORMAT_PCM_16_BIT, // TODO: change to audioFormat numChannels, sampleRate }; if (memcmp(&mCurrentPcmInfo, &info, sizeof(info)) == 0) { ALOGV("openAudioSink: no change in pcm mode"); // no change from previous configuration, everything ok. return OK; } audioSinkChanged = true; mAudioSink->close(); mCurrentOffloadInfo = AUDIO_INFO_INITIALIZER; Loading @@ -1497,8 +1523,10 @@ status_t NuPlayer::Renderer::onOpenAudioSink( (audio_output_flags_t)pcmFlags); if (err != OK) { ALOGW("openAudioSink: non offloaded open failed status: %d", err); mCurrentPcmInfo = AUDIO_PCMINFO_INITIALIZER; return err; } mCurrentPcmInfo = info; mAudioSink->start(); } if (audioSinkChanged) { Loading @@ -1513,6 +1541,7 @@ status_t NuPlayer::Renderer::onOpenAudioSink( void NuPlayer::Renderer::onCloseAudioSink() { mAudioSink->close(); mCurrentOffloadInfo = AUDIO_INFO_INITIALIZER; mCurrentPcmInfo = AUDIO_PCMINFO_INITIALIZER; } } // namespace android Loading media/libmediaplayerservice/nuplayer/NuPlayerRenderer.h +10 −0 Original line number Diff line number Diff line Loading @@ -181,6 +181,16 @@ private: bool mAudioOffloadTornDown; audio_offload_info_t mCurrentOffloadInfo; struct PcmInfo { audio_channel_mask_t mChannelMask; audio_output_flags_t mFlags; audio_format_t mFormat; int32_t mNumChannels; int32_t mSampleRate; }; PcmInfo mCurrentPcmInfo; static const PcmInfo AUDIO_PCMINFO_INITIALIZER; int32_t mTotalBuffersQueued; int32_t mLastAudioBufferDrained; Loading Loading
media/libmediaplayerservice/nuplayer/NuPlayerRenderer.cpp +29 −0 Original line number Diff line number Diff line Loading @@ -38,6 +38,15 @@ namespace android { // is closed to allow the audio DSP to power down. static const int64_t kOffloadPauseMaxUs = 10000000ll; // static const NuPlayer::Renderer::PcmInfo NuPlayer::Renderer::AUDIO_PCMINFO_INITIALIZER = { AUDIO_CHANNEL_NONE, AUDIO_OUTPUT_FLAG_NONE, AUDIO_FORMAT_INVALID, 0, // mNumChannels 0 // mSampleRate }; // static const int64_t NuPlayer::Renderer::kMinPositionUpdateDelayUs = 100000ll; Loading Loading @@ -76,6 +85,7 @@ NuPlayer::Renderer::Renderer( mAudioOffloadPauseTimeoutGeneration(0), mAudioOffloadTornDown(false), mCurrentOffloadInfo(AUDIO_INFO_INITIALIZER), mCurrentPcmInfo(AUDIO_PCMINFO_INITIALIZER), mTotalBuffersQueued(0), mLastAudioBufferDrained(0) { } Loading Loading @@ -1442,6 +1452,8 @@ status_t NuPlayer::Renderer::onOpenAudioSink( // no change from previous configuration, everything ok. return OK; } mCurrentPcmInfo = AUDIO_PCMINFO_INITIALIZER; ALOGV("openAudioSink: try to open AudioSink in offload mode"); uint32_t offloadFlags = flags; offloadFlags |= AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD; Loading Loading @@ -1483,6 +1495,20 @@ status_t NuPlayer::Renderer::onOpenAudioSink( ALOGV("openAudioSink: open AudioSink in NON-offload mode"); uint32_t pcmFlags = flags; pcmFlags &= ~AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD; const PcmInfo info = { (audio_channel_mask_t)channelMask, (audio_output_flags_t)pcmFlags, AUDIO_FORMAT_PCM_16_BIT, // TODO: change to audioFormat numChannels, sampleRate }; if (memcmp(&mCurrentPcmInfo, &info, sizeof(info)) == 0) { ALOGV("openAudioSink: no change in pcm mode"); // no change from previous configuration, everything ok. return OK; } audioSinkChanged = true; mAudioSink->close(); mCurrentOffloadInfo = AUDIO_INFO_INITIALIZER; Loading @@ -1497,8 +1523,10 @@ status_t NuPlayer::Renderer::onOpenAudioSink( (audio_output_flags_t)pcmFlags); if (err != OK) { ALOGW("openAudioSink: non offloaded open failed status: %d", err); mCurrentPcmInfo = AUDIO_PCMINFO_INITIALIZER; return err; } mCurrentPcmInfo = info; mAudioSink->start(); } if (audioSinkChanged) { Loading @@ -1513,6 +1541,7 @@ status_t NuPlayer::Renderer::onOpenAudioSink( void NuPlayer::Renderer::onCloseAudioSink() { mAudioSink->close(); mCurrentOffloadInfo = AUDIO_INFO_INITIALIZER; mCurrentPcmInfo = AUDIO_PCMINFO_INITIALIZER; } } // namespace android Loading
media/libmediaplayerservice/nuplayer/NuPlayerRenderer.h +10 −0 Original line number Diff line number Diff line Loading @@ -181,6 +181,16 @@ private: bool mAudioOffloadTornDown; audio_offload_info_t mCurrentOffloadInfo; struct PcmInfo { audio_channel_mask_t mChannelMask; audio_output_flags_t mFlags; audio_format_t mFormat; int32_t mNumChannels; int32_t mSampleRate; }; PcmInfo mCurrentPcmInfo; static const PcmInfo AUDIO_PCMINFO_INITIALIZER; int32_t mTotalBuffersQueued; int32_t mLastAudioBufferDrained; Loading