I removed the #if(0) code per Rajesh and Greg's comments.
I also added a HAL check for the device UID so we only do the pause reset logic on the 6630. Other OMAP-based devices probably do the same behavior, but since the 3650 is not OMAP-based it should behave the same way as the emulator (i.e., as the original code). If you search for "m_deviceResetsOnPause" you'll see thse additional changes.
The core needs to link with hal.lib for this.
I tested on the 6630 and emulator so ensure the UID is detected properly and it is.
Liam
Index: clntcoredll_symbian.pcf =================================================================== RCS file: /cvsroot/client/core/clntcoredll_symbian.pcf,v retrieving revision 1.9 diff -u -w -r1.9 clntcoredll_symbian.pcf --- clntcoredll_symbian.pcf 4 Apr 2005 18:19:11 -0000 1.9 +++ clntcoredll_symbian.pcf 13 Apr 2005 19:15:38 -0000 @@ -60,5 +60,6 @@ project.AddIncludes('.', 'pub/platform/symbian')
-if(project.IsDefined('_SYMBIAN_70_') or project.IsDefined('_SYMBIAN_81_') or project.IsDefined('_SYMBIAN_80_')):
+if(project.IsDefined('HELIX_CONFIG_DEVSOUND')):
project.AddSystemLibraries('MMFDevSound.lib')
+ project.AddSystemLibraries('hal.lib')
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 19:15:21 -0000
@@ -51,6 +51,7 @@
#include <calypso/audiopreference.h>
#endif
+#include <hal.h> // device id #include "hxcom.h" #include "hxslist.h" #include "hxausvc.h" @@ -62,13 +63,6 @@ #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,30 +159,6 @@
const char * StringifyKErr(TInt err) { return 0; }
#endif
-static TInt FlagToNumber(TMMFSampleRate flag)
-{
- switch( flag )
- {
- case EMMFSampleRate8000Hz:
- return 8000;
- case EMMFSampleRate11025Hz:
- return 11025;
- case EMMFSampleRate16000Hz:
- return 16000;
- case EMMFSampleRate22050Hz:
- return 22050;
- case EMMFSampleRate32000Hz:
- return 32000;
- case EMMFSampleRate44100Hz:
- return 44100;
- case EMMFSampleRate48000Hz:
- return 48000;
- default:
- break;
- }
- HX_ASSERT(false);
- return 0;
-} static TMMFSampleRate NumberToFlag(TInt num)
{
@@ -211,7 +181,7 @@
default:
break;
}
- HX_ASSERT(false);
+ HX_ASSERT(FALSE);
return EMMFSampleRate16000Hz;
}@@ -219,7 +189,7 @@
HXSymbianAudioServer* pServer)
: CSession(client),
m_pServer(pServer),
- m_wantsNotify(false),
+ m_wantsNotify(FALSE),
m_lastPlayError(KErrNone),
m_pStream(NULL),
m_sampleRate(0),
@@ -227,19 +197,35 @@
m_cbBlock(0),
m_cbBufferList(0),
m_state(CLOSED),
+ m_deviceResetsOnPause(FALSE),
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);
m_pServer->AddSession();
memset(&m_Settings, 0, sizeof( m_Settings) );
+
+ // Do run-time check for devices (6630) that are known to do a device
+ // reset after a pause. Other devices (OMAP-based in particular) may+ // need to be added here.
+ const TInt DEVICE_UID_6630 = 0x101fbb55; // emulator = 0x10005f62
+
+ TInt uid = 0;
+ TInt res = HAL::Get(HALData::EMachineUid, uid);
+ if (KErrNone == res)
+ {
+ if (DEVICE_UID_6630 == uid)
+ {
+ m_deviceResetsOnPause = TRUE;
+ }
+ HXLOGL3(HXLOG_ADEV, "HXSymbianAudioSession::HXSymbianAudioSession(): symbian device uid = 0x%08x", uid);
+ }
}
//
@@ -368,7 +354,7 @@
}
break;
default:
- HX_ASSERT(false);
+ HX_ASSERT(FALSE);
Message().Complete(KErrGeneral);
break;
}
@@ -385,12 +371,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 +392,7 @@
break;
default:
// unexpected
- HX_ASSERT(false);
+ HX_ASSERT(FALSE);
err = KErrGeneral;
break;
}
@@ -416,19 +410,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 +438,26 @@
{
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));
+ 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 +482,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 +509,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 +528,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 +597,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; total = %lu ms",
+ 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 +667,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 +738,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 +764,7 @@
HXSymbianAudioSession::RequestDeviceTakenNotification()
{
HXLOGL3(HXLOG_ADEV, "HXSymbianAudioSession::RequestDeviceTakenNotification()");
- m_wantsNotify = true;
+ m_wantsNotify = TRUE;
m_notifyRequest = Message();
}
@@ -761,7 +774,7 @@
if (m_wantsNotify)
{
m_notifyRequest.Complete(KErrCancel);
- m_wantsNotify = false;
+ m_wantsNotify = FALSE;
}
}@@ -777,7 +790,7 @@
{
HXLOGL3(HXLOG_ADEV, "HXSymbianAudioSession::NotifyDeviceTaken(): doing notify...");
m_notifyRequest.Complete(m_lastPlayError);
- m_wantsNotify = false;
+ m_wantsNotify = FALSE;
}
}
@@ -812,43 +825,51 @@
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()
+void HXSymbianAudioSession::InitPausedState()
{
- while (!m_bufferList.IsEmpty())
+ if (m_deviceResetsOnPause)
{
- IHXBuffer* pBuf = (IHXBuffer*)m_bufferList.RemoveHead();
- HX_RELEASE(pBuf);
+ // on some devices the sample count will reset after we call Pause/Resume
+ PrepareForDeviceReset();
}
- m_cbBufferList = 0;
- m_cbFrontBufferWritten = 0;
+
+}
+
+void HXSymbianAudioSession::InitStoppedState()
+{
+ PrepareForDeviceReset();
}
void HXSymbianAudioSession::InitClosedState()
{
- HX_ASSERT(CLOSED == m_state);
FreePendingBuffers(); if (m_wantsNotify)
@@ -859,22 +880,39 @@
HX_DELETE(m_pStream);
}-void HXSymbianAudioSession::DoPlayInit()
+void HXSymbianAudioSession::FreePendingBuffers()
{
- HXLOGL3(HXLOG_ADEV, "HXSymbianAudioSession::DoPlayInit(): setting priority and calling PlayInitL");
+ while (!m_bufferList.IsEmpty())
+ {
+ 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 +940,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 +981,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 +1010,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 +1027,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 +1040,6 @@
HX_ASSERT(aError != KErrNone); // possible?
if (aError != KErrNone)
{
- UpdateTimeSampleStats();
-
// stream is implicitly stopped when an error occurs
switch(aError)
{
@@ -1003,29 +1047,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 19:15:21 -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;
@@ -139,6 +141,7 @@
TUint m_cbBlock;
TUint m_cbBufferList;
State m_state;
+ HXBOOL m_deviceResetsOnPause; // write related
CHXSimpleList m_bufferList;
@@ -148,11 +151,12 @@
// 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_
At 10:18 AM 4/13/2005, Greg Wright wrote:
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.
Does this mean this code will not run on phones like the 3650? We still need to support older Series60 devices on the 150Cay branch.
+#if (0) static TInt FlagToNumber(TMMFSampleRate flag) { switch( flag ) @@ -186,9 +179,10 @@ default: break; } - HX_ASSERT(false); + HX_ASSERT(FALSE); return 0; } +#endif
Are we going to use this #if 0 code later?
+ 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); + }
What is priority 69 and is this changing from the old one?
rest looks good.
--greg.
_______________________________________________ Audio-dev mailing list [email protected] http://lists.helixcommunity.org/mailman/listinfo/audio-dev
