Hi Liam,
Here are my comments.
* Is the dead code (#if 0 code) needs to be checked in. Since the versioning is
maintained by CVS, maybe the dead code be removed.
* checkPendingFillBuffer = FALSE; statement not required in API void
HXSymbianAudioSession::Write(). It is already set to FALSE while variable
initialization. Saving one executable statement. :-)
* Is this code not redundant in Write() API ?
if (KErrNone == err && checkPendingFillBuffer && m_pPendingFillBuffer)
{
HXLOGL3(HXLOG_ADEV, "HXSymbianAudioSession::Write(): calling
BufferToBeFilled()");
BufferToBeFilled(m_pPendingFillBuffer);
HX_ASSERT(!m_pPendingFillBuffer);
}
When Play is Issued in Pause state, the same flow of code is executed from
Play() API. So do we need this in Write Call ?
Otherwise things look good.
Thanks,
Rajesh.
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of ext Liam
Murray
Sent: Tuesday, April 12, 2005 8:23 PM
To: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Subject: Re: [Audio-dev] CR: pause fix for symbian
Complete files attached.
At 06:16 PM 4/12/2005, Liam Murray wrote:
>Summary
>========
>
>Pause fix for Nokia 6630 device
>
>Overview
>========
>
>These changes fix pause so we handle the sample count reset that occurs
>after a pause/resume sequence on 6630. On the 6630 the device resets after
>a pause is issued to dev sound. At some point after we resume (via
>PlayData) the sample played count returned from the device resets. That
>point appears to be after the data in the audio device at the time we
>issued the pause plays out. This behavior is almost identical to an
>underflow so the handling is the same. (Also note: any dev sound buffer we
>may be holding because we couldn't fill it earlier we discard when we pause.)
>
>For now the code assumes a 6630 but in order to support other devices we
>will probably need to add a run-time check on the device id so this works
>on non-OMAP based devices.
>
>The emulator logic is the same as before.
>
>Thanks again to Rajesh for his valuable help.
>
>Testing
>=======
>Tried with a variety of clips, mostly rm, amr, 3gp. Local playback looks
>quite good and is significantly better. Rapid pause/resume and seeking
>looks good and a/v sync is maintained. I only see the buffering issue
>during streaming. Streaming playback still has excessive buffering and I
>think that is a separte issue.
>
>Builds tested/verified
>==================
>Wins, Device
>
>Files modified
>=============
>platform/symbian/audiosvr/mmf/audio_session-mmf.cpp
>platform/symbian/audiosvr/mmf/audio_session-mmf.
>
>
>
>Index: platform/symbian/audiosvr/mmf/audio_session-mmf.cpp
>===================================================================
>RCS file:
>/cvsroot/audio/device/platform/symbian/audiosvr/mmf/audio_session-mmf.cpp,v
>retrieving revision 1.7
>diff -u -w -r1.7 audio_session-mmf.cpp
>--- platform/symbian/audiosvr/mmf/audio_session-mmf.cpp 12 Apr 2005
>21:28:04 -0000 1.7
>+++ platform/symbian/audiosvr/mmf/audio_session-mmf.cpp 13 Apr 2005
>00:55:46 -0000
>@@ -61,14 +61,6 @@
> #include "hxtlogutil.h"
> #include <e32std.h>
>
>-
>-static const TInt KClientPriority = 69;
>-#if defined(HELIX_CONFIG_CALYPSO_AUDIO_PREF)
>-static const TMdaPriorityPreference KPriorityPref =
>(TMdaPriorityPreference)KAudioPrefComposer;
>-#else
>-static const TMdaPriorityPreference KPriorityPref =
>(TMdaPriorityPreference)80; //EMdaPriorityPreferenceTime;
>-#endif // SERIES60_PLAYER
>-
> inline
> TUint SamplesToMS(TUint count, TUint rate)
> {
>@@ -165,6 +157,7 @@
> const char * StringifyKErr(TInt err) { return 0; }
> #endif
>
>+#if (0)
> static TInt FlagToNumber(TMMFSampleRate flag)
> {
> switch( flag )
>@@ -186,9 +179,10 @@
> default:
> break;
> }
>- HX_ASSERT(false);
>+ HX_ASSERT(FALSE);
> return 0;
> }
>+#endif
>
> static TMMFSampleRate NumberToFlag(TInt num)
> {
>@@ -211,7 +205,7 @@
> default:
> break;
> }
>- HX_ASSERT(false);
>+ HX_ASSERT(FALSE);
> return EMMFSampleRate16000Hz;
> }
>
>@@ -219,7 +213,7 @@
> HXSymbianAudioServer* pServer)
> : CSession(client),
> m_pServer(pServer),
>- m_wantsNotify(false),
>+ m_wantsNotify(FALSE),
> m_lastPlayError(KErrNone),
> m_pStream(NULL),
> m_sampleRate(0),
>@@ -230,11 +224,10 @@
> m_pPendingFillBuffer(NULL),
> m_cbFrontBufferWritten(0),
> m_samplesWritten(0),
>- m_baseSampleCount(0),
>+ m_lastSampleCount(0),
> m_unplayedSampleCount(0),
> m_msTimePlayed(0),
>- m_msReInitTimePlayed(0),
>- m_sampleCountResetPending(false)
>+ m_sampleCountResetPending(FALSE)
> {
> // add the session to the server
> HX_ASSERT(m_pServer);
>@@ -368,7 +361,7 @@
> }
> break;
> default:
>- HX_ASSERT(false);
>+ HX_ASSERT(FALSE);
> Message().Complete(KErrGeneral);
> break;
> }
>@@ -385,12 +378,20 @@
> switch (m_state)
> {
> case STOPPED:
>- DoPlayInit();
>+ DoPlayInit(TRUE);
> break;
> case PAUSED:
>- HX_ASSERT(m_pStream);
>- Trans(PLAYING);
>+ Trans(PLAYINIT_PENDING);
>+ if (m_pPendingFillBuffer)
>+ {
>+ HXLOGL3(HXLOG_ADEV, "HXSymbianAudioSession::Play(): calling
>BufferToBeFilled()");
>+ BufferToBeFilled(m_pPendingFillBuffer);
>+ HX_ASSERT(!m_pPendingFillBuffer); // write list empty?
>+ }
>+ else
>+ {
> m_pStream->PlayData();
>+ }
> break;
> case PLAYINIT_PENDING:
> case PLAYING:
>@@ -398,7 +399,7 @@
> break;
> default:
> // unexpected
>- HX_ASSERT(false);
>+ HX_ASSERT(FALSE);
> err = KErrGeneral;
> break;
> }
>@@ -416,19 +417,19 @@
>
> switch (m_state)
> {
>- case PLAYINIT_PENDING:
> case PLAYING:
>+ case PLAYINIT_PENDING:
> Trans(PAUSED);
>- HX_ASSERT(m_pStream);
> m_pStream->Pause();
> break;
> case STOPPED:
>- // note: pause called immediately after init by higher level code
>(fall through)
>+ // note: pause called immediately after init by higher level code
>+ break;
> case PAUSED:
> // do nothing
> break;
> default:
>- HX_ASSERT(false);
>+ HX_ASSERT(FALSE);
> err = KErrGeneral;
> break;
> }
>@@ -444,20 +445,28 @@
> {
> TInt err = KErrNone;
>
>+ HXBOOL checkPendingFillBuffer = FALSE;
>+
> switch (m_state)
> {
> case STOPPED:
>- HXLOGL3(HXLOG_ADEV, "HXSymbianAudioSession::Write(): STOPPED;
>last err = %s", StringifyKErr(m_lastPlayError));
>- if (m_lastPlayError != KErrNone)
>- {
>- // we are stopped because of we got a call to PlayError
>- err = m_lastPlayError;
>- break;
>- }
>- // fall through if no error
>+ case PAUSED:
> case PLAYINIT_PENDING:
>+ HXLOGL3(HXLOG_ADEV, "HXSymbianAudioSession::Write(): state = %s",
>StringifyState(m_state));
>+ // add buffer to the list and wait
>+ checkPendingFillBuffer = FALSE;
>+ break;
> case PLAYING:
>- case PAUSED:
>+ checkPendingFillBuffer = TRUE;
>+ break;
>+ default:
>+ HXLOGL3(HXLOG_ADEV, "HXSymbianAudioSession::Write(): called in
>unexpected state %s ", StringifyState(m_state));
>+ HX_ASSERT(FALSE);
>+ err = KErrGeneral;
>+ break;
>+ }
>+
>+ if (KErrNone == err)
> {
> IHXBuffer* pAudioBuf = (IHXBuffer*)Message().Ptr0();
> if (pAudioBuf)
>@@ -482,20 +491,13 @@
> {
> err = KErrArgument;
> }
>- break;
>- }
>- default:
>- HXLOGL3(HXLOG_ADEV, "HXSymbianAudioSession::Write(): called in
>unexpected state %s ", StringifyState(m_state));
>- HX_ASSERT(false);
>- err = KErrGeneral;
>- break;
> }
>
> Message().Complete(err);
>
>- if( KErrNone == err && m_pPendingFillBuffer )
>+ if (KErrNone == err && checkPendingFillBuffer && m_pPendingFillBuffer)
> {
>- HXLOGL3(HXLOG_ADEV, "HXSymbianAudioSession::Write(): calling
>BufferToBeFilled");
>+ HXLOGL3(HXLOG_ADEV, "HXSymbianAudioSession::Write(): calling
>BufferToBeFilled()");
> BufferToBeFilled(m_pPendingFillBuffer);
> HX_ASSERT(!m_pPendingFillBuffer);
> }
>@@ -516,12 +518,10 @@
>
> void HXSymbianAudioSession::OnResetSampleCount()
> {
>- m_sampleCountResetPending = false;
>- m_baseSampleCount = 0;
>+ HXLOGL3(HXLOG_ADEV, "HXSymbianAudioSession::OnResetSampleCount()");
>+ m_sampleCountResetPending = FALSE;
>+ m_lastSampleCount = 0;
> m_unplayedSampleCount = 0;
>- // restore time in case this was auto re-init after underflow or similar
>- m_msTimePlayed = m_msReInitTimePlayed;
>- m_msReInitTimePlayed = 0;
> }
>
> void HXSymbianAudioSession::CheckSampleCountReset(TUint sampleCount)
>@@ -537,36 +537,58 @@
>
> if (m_sampleCountResetPending)
> {
>- HXLOGL3(HXLOG_ADEV,
>"HXSymbianAudioSession::HandleSampleCountReset(): checking for reset (old
>base = %lu; samps played = %lu; samps written = %lu)", m_baseSampleCount,
>sampleCount, m_samplesWritten);
>- if ( sampleCount < m_baseSampleCount || 0 == m_baseSampleCount
>/*0 = first play*/)
>+ HXLOGL3(HXLOG_ADEV,
>"HXSymbianAudioSession::HandleSampleCountReset(): checking for reset (last
>count = %lu; new count = %lu; samps written = %lu)", m_lastSampleCount,
>sampleCount, m_samplesWritten);
>+ if ( sampleCount < m_lastSampleCount || 0 == m_lastSampleCount)
> {
>- HXLOGL3(HXLOG_ADEV,
>"HXSymbianAudioSession::HandleSampleCountReset(): resetting base sample
>count");
> OnResetSampleCount();
> }
> else
> {
>- if (m_unplayedSampleCount > 0 && sampleCount -
>m_baseSampleCount > m_unplayedSampleCount)
>+ if (m_unplayedSampleCount > 0 && sampleCount -
>m_lastSampleCount > m_unplayedSampleCount)
> {
> // Special case:
> //
>- // If the base value at the time of the re-init is small,
>there is a risk that
>- // the counter is reset but by the time we see the
>(post-reset) value it has
>- // exceeded the base value. That breaks the logic above.
>We deal with this by
>- // comparing the samples played with the number of
>unwritten samples at the time
>- // of the underflow/stop. If the value is greater it must
>be from newly written
>- // samples.
>- HXLOGL3(HXLOG_ADEV,
>"HXSymbianAudioSession::HandleSampleCountReset(): resetting base sample
>count (special case %lu > %lu)", sampleCount - m_baseSampleCount,
>m_unplayedSampleCount);
>+ // If the sample played count at the time of the
>underflow/pause is small, there is a risk
>+ // that the counter is reset but by the time we see the
>(post-reset) value it has exceeded the
>+ // last value we saw. That breaks the logic above. We
>deal with this by comparing the
>+ // samples played with the number of unwritten samples at
>the time of the underflow/pause.
>+ // If the value is greater it must be from newly written
>samples.
>+ //
>+ HXLOGL3(HXLOG_ADEV,
>"HXSymbianAudioSession::HandleSampleCountReset(): special case additional
>played %lu > unplayed %lu; doing sample count reset", sampleCount -
>m_lastSampleCount, m_unplayedSampleCount);
> OnResetSampleCount();
> }
> }
> }
> }
>
>+void HXSymbianAudioSession::UpdateUnplayedSampleCount()
>+{
>+ // keep track of samples that we wrote but haven't been played yet
>+ if (!m_sampleCountResetPending)
>+ {
>+ HX_ASSERT(m_samplesWritten >= m_lastSampleCount);
>+ m_unplayedSampleCount = m_samplesWritten - m_lastSampleCount;
>+ }
>+
>+ HXLOGL4(HXLOG_ADEV,
>"HXSymbianAudioSession::UpdateUnplayedSampleCount(): unplayed samps = %lu
>(%lu ms)", m_unplayedSampleCount, SamplesToMS(m_unplayedSampleCount,
>m_sampleRate));
>+}
>+
>
> void HXSymbianAudioSession::UpdateTimeSampleStats()
> {
>+ if (PLAYING != m_state)
>+ {
>+ // samples written count may have increased
>+ UpdateUnplayedSampleCount();
>+
>+ // sample count is only reliable in PLAYING state
>+ HXLOGL4(HXLOG_ADEV,
>"HXSymbianAudioSession::UpdateUnplayedSampleCount(): state = %s (no
>update)", StringifyState(m_state));
>+ return;
>+ }
>+
> // We use some heuristics here because of the following observed
> behavior of values returned
>- // from CMMFDevSound::SamplesPlayed() around and after the time of an
>underflow.
>+ // from CMMFDevSound::SamplesPlayed() around and after the time of an
>underflow (or pause on
>+ // some devices). On OMAP-based devices (6630) a pause results in
>identical reset behavior.
> //
> // 1) Underflow occurs. At that time SamplesPlayed() is sometimes <
> samples written. Those appear
> // to play out (they are not droppped). There probably is a low
> threshold value at which point
>@@ -584,48 +606,47 @@
> // at time of the reset. Once those are played out the sample
> count is reset again.
> //
>
>+ //
>
> // determine how much time has elapsed since last time computation
>- TUint sampleCount = m_pStream->SamplesPlayed();
>+ TUint sampleCount = m_pStream->SamplesPlayed(); //returns TInt (max
>~13.5 hours for 44Khz)
>
> CheckSampleCountReset(sampleCount);
> if (m_sampleCountResetPending)
> {
>- // don't update time; we only want to add time for samples played
>since stop
>+ // don't update time; we only want to add time for samples played
>since sample count reset
> return;
> }
>
>-#if (0)
>- // assert likely indicates error; wrap-around is rare case (occurs
>after ~27 hours for 44Khz)
>- HX_ASSERT(m_baseSampleCount <= sampleCount);
>- TUint samplesElapsed = WrapDiff(m_baseSampleCount, sampleCount);
>-#else
>- if (sampleCount < m_baseSampleCount )
>+ if (sampleCount < m_lastSampleCount)
> {
>- // assume this is not a wrap-around (~27 hours for 44Khz)
>+ // Assume this is case where we see two resets, not the
>relatively rare wrap-arround case. The
>+ // first reset is apparantly for for unplayed samples at time of
>underflow. See (3) above
>
>- // assume this is case where we see two resets, the first
>apparantly for
>- // for unplayed samples at time of underflow; see (3) above
>- HXLOGL3(HXLOG_ADEV,
>"HXSymbianAudioSession::UpdateTimeSampleStats(): oops: base =
>%lu > played = %lu; (unplayed = %lu)", m_baseSampleCount, sampleCount,
>m_unplayedSampleCount);
>+ HXLOGL3(HXLOG_ADEV,
>"HXSymbianAudioSession::UpdateTimeSampleStats(): oops (unexpected reset):
>%lu (last) > %lu (current); unplayed = %lu", m_lastSampleCount,
>sampleCount, m_unplayedSampleCount);
> return;
> }
>- TUint samplesElapsed = sampleCount - m_baseSampleCount;
>-#endif
>+
>+ // assert likely indicates error; wrap-around is rare case
>+ HX_ASSERT(m_lastSampleCount <= sampleCount);
>+
>+ // calculate additional samples played since last update
>+ TUint samplesElapsed = WrapDiff(m_lastSampleCount, sampleCount);
>+
> // convert samples-played to time-played
> TUint msElapsed = SamplesToMS(samplesElapsed, m_sampleRate);
>
>- // update time
>+ // update current play time
> m_msTimePlayed += msElapsed;
>
>- // keep track of samples that we wrote but haven't been played yet
>- m_unplayedSampleCount = m_samplesWritten - sampleCount;
>-
>+ UpdateUnplayedSampleCount();
>
>- HXLOGL4(HXLOG_ADEV, "HXSymbianAudioSession::UpdateTimeSampleStats():
>base = %lu; played = %lu; unplayed = %lu (%lu ms)", m_baseSampleCount,
>sampleCount, m_unplayedSampleCount, SamplesToMS(m_unplayedSampleCount,
>m_sampleRate));
>- HXLOGL4(HXLOG_ADEV, "HXSymbianAudioSession::UpdateTimeSampleStats():
>adding %lu ms; total now %lu ms", msElapsed, m_msTimePlayed);
>+ HXLOGL4(HXLOG_ADEV,
>+ "HXSymbianAudioSession::UpdateTimeSampleStats(): last = %lu;
>current = %lu; added = %lu ms (%lu ms total)",
>+ m_lastSampleCount, sampleCount, msElapsed, m_msTimePlayed);
>
>- // update base sample count for next time
>- m_baseSampleCount = sampleCount;
>+ // update sample count for next time
>+ m_lastSampleCount = sampleCount;
> }
>
> //
>@@ -655,10 +676,10 @@
> HX_ASSERT(m_cbBufferList >= m_cbFrontBufferWritten);
> cbBuffered += m_cbBufferList - m_cbFrontBufferWritten;
>
>- // convert bytes to block count (rounded)
>+ // convert bytes to block count (rounded up)
> TUint32 blockCount = cbBuffered/m_cbBlock+1;
>
>- HXLOGL4(HXLOG_ADEV, "HXSymbianAudioSession::GetBlocksBuffered():
>block count = %lu (%lu bytes)", blockCount, cbBuffered);
>+ HXLOGL4(HXLOG_ADEV, "HXSymbianAudioSession::GetBlocksBuffered():
>block count = %lu (%lu bytes total; %lu in list)", blockCount, cbBuffered,
>m_cbBufferList);
>
> Message().Complete(blockCount);
>
>@@ -726,18 +747,19 @@
> //
> void HXSymbianAudioSession::Stop()
> {
>+ HXLOGL3(HXLOG_ADEV, "HXSymbianAudioSession::Stop(): state = %s",
>StringifyState(m_state));
> switch (m_state)
> {
>- case PLAYINIT_PENDING:
> case PLAYING:
>+ case PLAYINIT_PENDING:
> case PAUSED:
>- // important: update stats before stopping
>- UpdateTimeSampleStats();
>- HXLOGL3(HXLOG_ADEV, "HXSymbianAudioSession::Stop(): %lu ms
>unplayed in audio device", SamplesToMS(m_unplayedSampleCount, m_sampleRate));
>-
> Trans(STOPPED);
>- HX_ASSERT(m_pStream);
>+ HXLOGL3(HXLOG_ADEV, "HXSymbianAudioSession::Stop(): %lu ms
>unplayed in audio device", SamplesToMS(m_unplayedSampleCount, m_sampleRate));
> m_pStream->Stop();
>+
>+ // do additional stuff associated with user stop
>+ FreePendingBuffers();
>+ m_msTimePlayed = 0;
> break;
> default:
> // nothing
>@@ -751,7 +773,7 @@
> HXSymbianAudioSession::RequestDeviceTakenNotification()
> {
> HXLOGL3(HXLOG_ADEV,
> "HXSymbianAudioSession::RequestDeviceTakenNotification()");
>- m_wantsNotify = true;
>+ m_wantsNotify = TRUE;
> m_notifyRequest = Message();
> }
>
>@@ -761,7 +783,7 @@
> if (m_wantsNotify)
> {
> m_notifyRequest.Complete(KErrCancel);
>- m_wantsNotify = false;
>+ m_wantsNotify = FALSE;
> }
> }
>
>@@ -777,7 +799,7 @@
> {
> HXLOGL3(HXLOG_ADEV, "HXSymbianAudioSession::NotifyDeviceTaken():
> doing notify...");
> m_notifyRequest.Complete(m_lastPlayError);
>- m_wantsNotify = false;
>+ m_wantsNotify = FALSE;
> }
> }
>
>@@ -812,43 +834,50 @@
>
> void HXSymbianAudioSession::InitPlayInitPendingState()
> {
>- HX_ASSERT(PLAYINIT_PENDING == m_state);
> m_lastPlayError = KErrNone;
> }
>
>-void HXSymbianAudioSession::InitPausedState()
>+// Called when a stop or pause (omap-based device) is issued.
>+//
>+void HXSymbianAudioSession::PrepareForDeviceReset()
> {
>- HX_ASSERT(PAUSED == m_state);
>- m_pPendingFillBuffer = NULL;
>+ if (KErrNone == m_lastPlayError)
>+ {
>+ // Add unwritten samples to time played. Otherwise we can miss
>counting these
>+ // samples when the sample count resets. We don't know for sure
>when the count
>+ // will reset. This causes us to jump ahead in time until we
>catch up.
>+
>+ UpdateTimeSampleStats();
>+ TUint msPending = SamplesToMS(m_unplayedSampleCount, m_sampleRate);
>+ HXLOGL3(HXLOG_ADEV,
>"HXSymbianAudioSession::PrepareForDeviceReset(): unplayed = %lu (%lu ms)",
>m_unplayedSampleCount, msPending);
>+
>+ m_msTimePlayed += msPending;
> }
>
>-void HXSymbianAudioSession::InitStoppedState()
>-{
>- HX_ASSERT (STOPPED == m_state);
>- m_msTimePlayed = 0;
>- m_samplesWritten = 0;
>- m_pPendingFillBuffer = NULL;
>+ m_sampleCountResetPending = TRUE;
>
>- // we leave some time-associated values as is until sample count
>reset occurs
>- m_sampleCountResetPending = true;
>+ // samples written track samples written post device reset
>+ m_samplesWritten = 0;
>
>- FreePendingBuffers();
>+ m_pPendingFillBuffer = NULL;
> }
>
>-void HXSymbianAudioSession::FreePendingBuffers()
>-{
>- while (!m_bufferList.IsEmpty())
>+void HXSymbianAudioSession::InitPausedState()
> {
>- IHXBuffer* pBuf = (IHXBuffer*)m_bufferList.RemoveHead();
>- HX_RELEASE(pBuf);
>+ //XXXLCM fix me: use run-time check for devices (6630) that are known
>to do a reset after a pause
>+#if !defined(__WINS__)
>+ // on some devices the sample count will reset after we call Pause/Resume
>+ PrepareForDeviceReset();
>+#endif
> }
>- m_cbBufferList = 0;
>- m_cbFrontBufferWritten = 0;
>+
>+void HXSymbianAudioSession::InitStoppedState()
>+{
>+ PrepareForDeviceReset();
> }
>
> void HXSymbianAudioSession::InitClosedState()
> {
>- HX_ASSERT(CLOSED == m_state);
> FreePendingBuffers();
>
> if (m_wantsNotify)
>@@ -859,22 +888,39 @@
> HX_DELETE(m_pStream);
> }
>
>-void HXSymbianAudioSession::DoPlayInit()
>+void HXSymbianAudioSession::FreePendingBuffers()
>+{
>+ while (!m_bufferList.IsEmpty())
> {
>- HXLOGL3(HXLOG_ADEV, "HXSymbianAudioSession::DoPlayInit(): setting
>priority and calling PlayInitL");
>+ IHXBuffer* pBuf = (IHXBuffer*)m_bufferList.RemoveHead();
>+ HX_RELEASE(pBuf);
>+ }
>+ m_cbBufferList = 0;
>+ m_cbFrontBufferWritten = 0;
>+}
>+
>+
>+void HXSymbianAudioSession::DoPlayInit(HXBOOL setPriority)
>+{
>+ HXLOGL3(HXLOG_ADEV, "HXSymbianAudioSession::DoPlayInit(): state =
>%s", StringifyState(m_state));
>
>- HX_ASSERT(STOPPED == m_state);
> Trans(PLAYINIT_PENDING);
>
>+ if (setPriority)
>+ {
>+ HXLOGL3(HXLOG_ADEV, "HXSymbianAudioSession::DoPlayInit(): setting
>priority...");
>+ static const TInt KClientPriority = 69;
>+
> // set priority.
> TMMFPrioritySettings prioritySettings;
>- prioritySettings.iPref = KPriorityPref;
>+ prioritySettings.iPref = EMdaPriorityPreferenceTime;
> prioritySettings.iPriority = KClientPriority;
> prioritySettings.iState = EMMFStatePlaying;
> m_pStream->SetPrioritySettings(prioritySettings);
>+ }
>
> TRAPD(err, m_pStream->PlayInitL());
>- HXLOGL3(HXLOG_ADEV, "HXSymbianAudioSession::DoPlayInit(): PlayInitL()
>result: %s", StringifyKErr(err));
>+ HXLOGL3(HXLOG_ADEV, "HXSymbianAudioSession::DoPlayInit(): result =
>%s", StringifyKErr(err));
> if (err != KErrNone)
> {
> Trans(STOPPED);
>@@ -902,17 +948,17 @@
> {
> case PLAYINIT_PENDING:
> Trans(PLAYING);
>+ // fall through
>+ case PLAYING:
> break;
>- case PAUSED:
>- case STOPPED:
> default:
>+ HX_ASSERT(FALSE);
> HXLOGL3(HXLOG_ADEV, "HXSymbianAudioSession::BufferToBeFilled():
> unexpected state %s", StringifyState(m_state));
>- case PLAYING:
> break;
> }
>
>- if( aBuffer )
>- {
>+ HX_ASSERT(aBuffer);
>+
> TDes8& dataDesc = ((CMMFDataBuffer*)aBuffer)->Data();
> dataDesc = TPtrC8(NULL, 0 ); // ensure descriptor is reset/clear
> TUint cbDest = aBuffer->RequestSize();
>@@ -943,8 +989,11 @@
> cbToWrite = cbDest;
> }
>
>- // probably overkill: round write amount so we write only
>full sample (src buffers assumed to be frame-aligned)
>+ //buffers assumed to be frame-aligned
> HX_ASSERT(cbToWrite % m_cbSample == 0);
>+
>+ // probably overkill: round write amount so we write only full
>+ // sample (src buffers assumed to be frame-aligned)
> cbToWrite = (cbToWrite/m_cbSample) * m_cbSample;
> HX_ASSERT(cbToWrite != 0);
> HX_ASSERT(cbToWrite % m_cbSample == 0);
>@@ -969,9 +1018,11 @@
> }
> }
>
>+ //HXLOGL4(HXLOG_ADEV, "HXSymbianAudioSession::BufferToBeFilled():
>frame no = %lu; pos = %lu; last = %s; ts = %lu; status = %lu",
>aBuffer->FrameNumber(), aBuffer->Position(), aBuffer->LastBuffer() ?
>"true" : "false", aBuffer->TimeToPlay().Int64().Low(), aBuffer->Status() );
>+
> if (dataDesc.Length() > 0)
> {
>- HXLOGL4(HXLOG_ADEV,
>"HXSymbianAudioSession::BufferToBeFilled(): play buff = %ld bytes; samps
>written = %lu", dataDesc.Length(), m_samplesWritten);
>+ HXLOGL4(HXLOG_ADEV, "HXSymbianAudioSession::BufferToBeFilled():
>play buff = %ld bytes (%lu samps); samps written = %lu",
>dataDesc.Length(), dataDesc.Length()/m_cbSample, m_samplesWritten);
> if (PLAYING == m_state)
> {
> m_pStream->PlayData();
>@@ -984,8 +1035,11 @@
> // hold on to buffer; we'll fill it once we have more src data
> m_pPendingFillBuffer = aBuffer;
> }
>+
>+ UpdateTimeSampleStats();
> }
>-}
>+
>+
>
> // MDevSoundObserver
> void HXSymbianAudioSession::PlayError(TInt aError)
>@@ -994,8 +1048,6 @@
> HX_ASSERT(aError != KErrNone); // possible?
> if (aError != KErrNone)
> {
>- UpdateTimeSampleStats();
>-
> // stream is implicitly stopped when an error occurs
> switch(aError)
> {
>@@ -1003,29 +1055,22 @@
> {
> // either we just played out or (more likely) we were not
> // writing to the device fast enough
>- // add unwritten samples to time played (note: reported time
>- // will be slightly ahead until we catch up)
>- TUint msPending = SamplesToMS(m_unplayedSampleCount,
>m_sampleRate);
>- HXLOGL3(HXLOG_ADEV, "HXSymbianAudioSession::PlayError():
>underflow unplayed time = %lu (%lu samples)", msPending,
>m_unplayedSampleCount);
>- m_msTimePlayed += msPending;
>
>- // save current time so we preserve monotonically
>increasing time
>- m_msReInitTimePlayed = m_msTimePlayed;
>-
>- // re-init so we resume (continue) audio playback
>+ // do re-init so we continue audio playback
> Trans(STOPPED);
>- DoPlayInit();
>+ DoPlayInit(TRUE);
> }
> break;
> case KErrCancel:
>+ m_lastPlayError = aError;
> Trans(STOPPED);
> break;
> case KErrAccessDenied:
> case KErrInUse:
> case KErrDied: // incoming message notification on 6630
> generates this
> default:
>- Trans(STOPPED);
> m_lastPlayError = aError;
>+ Trans(STOPPED);
> NotifyDeviceTaken();
> break;
> }
>Index: platform/symbian/audiosvr/mmf/audio_session-mmf.h
>===================================================================
>RCS file:
>/cvsroot/audio/device/platform/symbian/audiosvr/mmf/audio_session-mmf.h,v
>retrieving revision 1.6
>diff -u -w -r1.6 audio_session-mmf.h
>--- platform/symbian/audiosvr/mmf/audio_session-mmf.h 4 Apr 2005
>23:08:45 -0000 1.6
>+++ platform/symbian/audiosvr/mmf/audio_session-mmf.h 13 Apr 2005
>00:55:46 -0000
>@@ -112,10 +112,12 @@
> void SendEventToClient(const TMMFEvent& aEvent);
>
> // helpers
>- void DoPlayInit();
>+ void DoPlayInit(HXBOOL setPriority = TRUE);
> void UpdateTimeSampleStats();
>+ void UpdateUnplayedSampleCount();
> void CheckSampleCountReset(TUint sampleCount);
> void OnResetSampleCount();
>+ void PrepareForDeviceReset();
>
> void FreePendingBuffers();
> void InitPlayInitPendingState();
>@@ -123,14 +125,14 @@
> void InitStoppedState();
> void InitClosedState();
> void Trans(State state);
>- friend const char *StringifyState(HXSymbianAudioSession::State state);
>+ //friend const char *StringifyState(HXSymbianAudioSession::State state);
>
> private:
>
> HXSymbianAudioServer* m_pServer;
> RMessage m_notifyRequest;
> RMessage m_InitMessage;
>- bool m_wantsNotify;
>+ HXBOOL m_wantsNotify;
> TInt m_lastPlayError;
> CMMFDevSound* m_pStream;
> TMMFCapabilities m_Settings;
>@@ -148,11 +150,10 @@
>
>
> // audio time related
>- TUint m_baseSampleCount;
>+ TUint m_lastSampleCount;
> TUint m_unplayedSampleCount;
> TUint m_msTimePlayed;
>- TUint m_msReInitTimePlayed;
>- bool m_sampleCountResetPending;
>+ HXBOOL m_sampleCountResetPending;
> };
>
> #endif // _AUDIO_SESSION_H_
>
>
>_______________________________________________
>Audio-dev mailing list
>[email protected]
>http://lists.helixcommunity.org/mailman/listinfo/audio-dev
_______________________________________________
Audio-dev mailing list
[email protected]
http://lists.helixcommunity.org/mailman/listinfo/audio-dev