internetradio2.0/mediaenginesrc/irtestingaudioplayer.cpp
changeset 0 09774dfdd46b
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/internetradio2.0/mediaenginesrc/irtestingaudioplayer.cpp	Mon Apr 19 14:01:53 2010 +0300
@@ -0,0 +1,113 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+#include "irtestingaudioplayer.h"
+#include "irmp3player.h"
+
+// Constants
+
+const TInt KTWOMILLION = 2000000 ;
+
+CIRTestingAudioPlayer::CIRTestingAudioPlayer(CIRMP3Player& aMP3Player):
+			 CActive(CActive::EPriorityStandard),iMP3Player(aMP3Player)
+{
+		iCounter=0;
+}
+
+CIRTestingAudioPlayer::~CIRTestingAudioPlayer()
+{
+	// Make sure we're cancelled
+	Cancel();
+	iTimer.Close();
+
+}
+
+CIRTestingAudioPlayer* CIRTestingAudioPlayer::NewL(CIRMP3Player& aMP3Player)
+{
+	CIRTestingAudioPlayer* self = new (ELeave) CIRTestingAudioPlayer(aMP3Player);
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop( self );
+	return self;
+}
+void CIRTestingAudioPlayer::ConstructL()
+{
+	iTimer.CreateLocal();
+}
+
+void CIRTestingAudioPlayer::IssueRequest()
+{
+
+	// Request another wait
+  	iStatus = KRequestPending;
+    iTimer.After( iStatus, KTWOMILLION );
+    //console->Printf(_L("\n Set Active called after iTimer()"))
+    SetActive();
+    //console->Printf(_L("\n Leaving Issue Request"))
+}
+
+void CIRTestingAudioPlayer::DoCancel()
+{
+	iTimer.Cancel(); // Close the ASP
+}
+
+void CIRTestingAudioPlayer::RunL()
+	{
+
+	switch(iAudioFuncType)
+		{
+		case EOpen:
+			{
+			iMP3Player.MaoscOpenComplete(0);
+			}
+		break;
+		case EWriteLBufferCopied:
+			{
+			TBuf8<2> dummy;
+			iMP3Player.MaoscBufferCopied(0,dummy);
+			}
+		break;
+		case EWriteLPlayComplete:
+			{
+			iMP3Player.MaoscOpenComplete(0);
+			}
+			break;
+		default:
+			{
+
+			}
+		}
+	}
+
+void CIRTestingAudioPlayer::Open()
+	{
+	iAudioFuncType = EOpen;
+	IssueRequest();
+	}
+void CIRTestingAudioPlayer::Write()
+	{
+	iAudioFuncType = EWriteLBufferCopied;
+	IssueRequest();
+	}
+void CIRTestingAudioPlayer::Stop()
+	{
+	iTimer.Cancel();
+	}
+void CIRTestingAudioPlayer::Close()
+	{
+	// do nothing
+	}