sl@0: // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of the License "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // e32\include\drivers\soundsc.h sl@0: // Kernel side definitions for the shared chunk sound driver. sl@0: // sl@0: // sl@0: sl@0: /** sl@0: @file sl@0: @internalTechnology sl@0: @prototype sl@0: */ sl@0: sl@0: #ifndef __SOUNDSC_H__ sl@0: #define __SOUNDSC_H__ sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: sl@0: /** The maximum number of client transfer requests which may be outstanding in a particular direction at any time. */ sl@0: const TInt KMaxSndScRequestsPending=8; sl@0: sl@0: /** sl@0: A bit-mask value for the sound configuration status variable DSoundScLdd::iSoundConfigFlags. This being set signifies sl@0: that the sound configuration has been set in hardware by the driver. sl@0: */ sl@0: const TUint KSndScSoundConfigIsSetup=0x00000001; sl@0: /** sl@0: A bit-mask value for the sound configuration status variable DSoundScLdd::iSoundConfigFlags. This being set signifies sl@0: that the record level / play volume has been set in hardware by the driver. sl@0: */ sl@0: const TUint KSndScVolumeIsSetup=0x00000002; sl@0: sl@0: // Bit-mask values used when testing the driver sl@0: const TUint KSoundScTest_StartTransferError=0x01; sl@0: const TUint KSoundScTest_TransferDataError=0x02; sl@0: const TUint KSoundScTest_TransferTimeout=0x04; sl@0: sl@0: // Forward declarations sl@0: class TAudioBuffer; sl@0: class DBufferManager; sl@0: class DSoundScLdd; sl@0: sl@0: /** sl@0: @publishedPartner sl@0: @prototype sl@0: */ sl@0: class TSoundSharedChunkBufConfig : public TSharedChunkBufConfigBase sl@0: { sl@0: public: sl@0: /** The first entry of the buffer offset list. This list holds the offset from the start of the chunk sl@0: for each buffer. This list is only valid if the flag KScFlagBufOffsetListInUse is set in sl@0: TSharedChunkBufConfigBase::iFlags. */ sl@0: TInt iBufferOffsetListStart; sl@0: }; sl@0: sl@0: /** sl@0: The sound driver power handler class. sl@0: */ sl@0: class DSoundScPowerHandler : public DPowerHandler sl@0: { sl@0: public: sl@0: DSoundScPowerHandler(DSoundScLdd* aChannel); sl@0: // Inherited from DPowerHandler sl@0: void PowerUp(); sl@0: void PowerDown(TPowerState aPowerState); sl@0: private: sl@0: DSoundScLdd* iChannel; sl@0: }; sl@0: sl@0: /** sl@0: An object encapsulating an audio data transfer - either record or playback. sl@0: */ sl@0: class TSndScTransfer sl@0: { sl@0: public: sl@0: enum TTfState sl@0: { sl@0: /** None of the data for this transfer has been queued on the device. */ sl@0: ETfNotStarted, sl@0: /** Some of the data for this transfer has been queued on the device - but there is more that needs queuing. */ sl@0: ETfPartlyStarted, sl@0: /** All the data for this transfer has been queued on the device - but transfer is not complete. */ sl@0: ETfFullyStarted, sl@0: /** All the data for this transfer has been transferred. */ sl@0: ETfDone sl@0: }; sl@0: public: sl@0: TSndScTransfer(); sl@0: void Init(TUint aId,TInt aChunkOffset,TInt aLength,TAudioBuffer* anAudioBuffer); sl@0: inline TInt GetNotStartedLen(); sl@0: inline TInt GetStartOffset(); sl@0: inline TInt GetLengthTransferred(); sl@0: void SetStarted(TInt aLength); sl@0: TBool SetCompleted(TInt aLength); sl@0: public: sl@0: /** A value which uniquely identifies a particular audio data transfer. */ sl@0: TUint iId; sl@0: /** The status of this transfer. */ sl@0: TTfState iTfState; sl@0: /** The audio buffer associated with this transfer. */ sl@0: TAudioBuffer* iAudioBuffer; sl@0: private: sl@0: /** An offset within the shared chunk indicating the progress of the transfer. Data between the initial offset sl@0: and this value has either been successfully been transferred or has been queued for transfer. */ sl@0: TUint iStartedOffset; sl@0: /** An offset within the shared chunk indicating the end of the data to be transferred. */ sl@0: TUint iEndOffset; sl@0: /** This holds the count of the number of bytes which have been successfully transferred. */ sl@0: TInt iLengthTransferred; sl@0: /** This holds the count of the number of transfer fragments which are currently in progress for this transfer. */ sl@0: TInt iTransfersInProgress; sl@0: }; sl@0: sl@0: /** sl@0: An object encapsulating an audio request from the client - either record or playback. sl@0: */ sl@0: class TSoundScRequest : public SDblQueLink sl@0: { sl@0: public: sl@0: inline TSoundScRequest(); sl@0: virtual ~TSoundScRequest(); sl@0: virtual TInt Construct(); sl@0: public: sl@0: /** The thread which issued the request and which supplied the request status. */ sl@0: DThread* iOwningThread; sl@0: /** The client request completion object sl@0: This is the base class and may be constructed as a derived type*/ sl@0: TClientRequest* iClientRequest; sl@0: }; sl@0: sl@0: /** sl@0: A play request object. sl@0: */ sl@0: class TSoundScPlayRequest : public TSoundScRequest sl@0: { sl@0: public: sl@0: TSoundScPlayRequest(); sl@0: inline void SetFail(TInt aCompletionReason); sl@0: inline void UpdateProgress(TInt aLength); sl@0: TInt Construct(); sl@0: public: sl@0: /** The transfer information associated with this play request. */ sl@0: TSndScTransfer iTf; sl@0: /** The play request flags which were supplied by the client for this request - see KSndFlagLastSample. */ sl@0: TUint iFlags; sl@0: /** The error value to be returned when completing the request. */ sl@0: TInt iCompletionReason; sl@0: }; sl@0: sl@0: /** sl@0: An object encapsulating a queue of audio requests from the client. sl@0: */ sl@0: class TSoundScRequestQueue sl@0: { sl@0: public: sl@0: TSoundScRequestQueue(DSoundScLdd* aLdd); sl@0: virtual ~TSoundScRequestQueue(); sl@0: virtual TInt Create(); sl@0: TSoundScRequest* NextFree(); sl@0: void Add(TSoundScRequest* aReq); sl@0: TSoundScRequest* Remove(); sl@0: TSoundScRequest* Remove(TSoundScRequest* aReq); sl@0: TSoundScRequest* Find(TRequestStatus* aStatus); sl@0: void Free(TSoundScRequest* aReq); sl@0: inline TBool IsEmpty(); sl@0: inline TBool IsAnchor(TSoundScRequest* aReq); sl@0: void CompleteAll(TInt aCompletionReason,NFastMutex* aMutex=NULL); sl@0: protected: sl@0: /** The queue of pending audio requests. */ sl@0: SDblQue iPendRequestQ; sl@0: /** The queue of unused audio requests. */ sl@0: SDblQue iUnusedRequestQ; sl@0: /** The actual array of request objects. */ sl@0: TSoundScRequest* iRequest[KMaxSndScRequestsPending]; sl@0: /** Mutex used to protect the unused queue from corruption */ sl@0: NFastMutex iUnusedRequestQLock; sl@0: private: sl@0: /** The owning LDD object. */ sl@0: DSoundScLdd* iLdd; sl@0: }; sl@0: sl@0: /** sl@0: An object encapsulating a queue of play requests from the client. sl@0: */ sl@0: class TSoundScPlayRequestQueue : public TSoundScRequestQueue sl@0: { sl@0: public: sl@0: TSoundScPlayRequestQueue(DSoundScLdd* aLdd); sl@0: virtual TInt Create(); sl@0: TSoundScPlayRequest* NextRequestForTransfer(); sl@0: TSoundScPlayRequest* Find(TUint aTransferID,TBool& aIsNextToComplete); sl@0: }; sl@0: sl@0: /** sl@0: The buffer manager base class. sl@0: */ sl@0: class DBufferManager : public DBase sl@0: { sl@0: public: sl@0: enum TFlushOp sl@0: { sl@0: /** Flush before a DMA write. */ sl@0: EFlushBeforeDmaWrite, sl@0: /** Flush before a DMA read. */ sl@0: EFlushBeforeDmaRead, sl@0: /** Flush after a DMA read. */ sl@0: EFlushAfterDmaRead sl@0: }; sl@0: public: sl@0: DBufferManager(DSoundScLdd* aLdd); sl@0: ~DBufferManager(); sl@0: TInt Create(TSoundSharedChunkBufConfig* aBufConfig); sl@0: TInt Create(TSoundSharedChunkBufConfig& aBufConfig,TInt aChunkHandle,DThread* anOwningThread); sl@0: void FlushData(TInt aChunkOffset,TInt aLength,TFlushOp aFlushOp); sl@0: protected: sl@0: TInt ValidateBufferOffsets(TInt* aBufferOffsetList,TInt aNumBuffers,TInt aBufferSizeInBytes); sl@0: TInt ValidateRegion(TUint aChunkOffset,TUint aLength,TAudioBuffer*& anAudioBuffer); sl@0: TInt CreateBufferLists(TInt aNumBuffers); sl@0: TInt CommitMemoryForBuffer(TInt aChunkOffset,TInt aSize,TBool& aIsContiguous); sl@0: void GetChunkCreateInfo(TChunkCreateInfo& aChunkCreateInfo); sl@0: protected: sl@0: /** The owning LDD object. */ sl@0: DSoundScLdd* iLdd; sl@0: /** The chunk which contains the buffers. */ sl@0: DChunk* iChunk; sl@0: /** The linear address in kernel process for the start of the chunk. */ sl@0: TLinAddr iChunkBase; sl@0: /** MMU mapping attributes that the chunk has actually been mapped with. */ sl@0: TUint32 iChunkMapAttr; sl@0: /** The number of buffers. */ sl@0: TInt iNumBuffers; sl@0: /** The actual array of buffer objects. */ sl@0: TAudioBuffer* iAudioBuffers; sl@0: /** The maximum transfer length that the owning audio channel can support in a single data transfer. */ sl@0: TInt iMaxTransferLen; sl@0: protected: sl@0: friend class DSoundScLdd; sl@0: friend class TAudioBuffer; sl@0: }; sl@0: sl@0: /** sl@0: The record buffer manager class. sl@0: */ sl@0: class DRecordBufferManager : public DBufferManager sl@0: { sl@0: public: sl@0: DRecordBufferManager(DSoundScLdd* aLdd); sl@0: void Reset(); sl@0: inline TAudioBuffer* GetCurrentRecordBuffer(); sl@0: inline TAudioBuffer* GetNextRecordBuffer(); sl@0: TAudioBuffer* GetBufferForClient(); sl@0: TAudioBuffer* SetBufferFilled(TInt aBytesAdded,TInt aTransferResult); sl@0: TAudioBuffer* ReleaseBuffer(TInt aChunkOffset); sl@0: protected: sl@0: /** The buffer currently being filled with record data. (Not in any list). */ sl@0: TAudioBuffer* iCurrentBuffer; sl@0: /** The next buffer to use to capture record data. (Not in any list). */ sl@0: TAudioBuffer* iNextBuffer; sl@0: /** A queue of those buffers which are currently free. */ sl@0: SDblQue iFreeBufferQ; sl@0: /** A queue of those buffers which currently contain record data (and which aren't being used by the client). */ sl@0: SDblQue iCompletedBufferQ; sl@0: /** A queue of those buffers which are currently being used by the client. */ sl@0: SDblQue iInUseBufferQ; sl@0: /** A flag set within SetBufferFilled() each time it is necessary to use a buffer from the completed list rather sl@0: than the free list as the next buffer for capture (i.e. 'iNextBuffer'). */ sl@0: TBool iBufOverflow; sl@0: private: sl@0: friend class DSoundScLdd; sl@0: }; sl@0: sl@0: /** sl@0: The class representing a single record/play buffer. sl@0: */ sl@0: class TAudioBuffer : public SDblQueLink sl@0: { sl@0: public: sl@0: TAudioBuffer(); sl@0: ~TAudioBuffer(); sl@0: TInt Create(DChunk* aChunk,TInt aChunkOffset,TInt aSize,TBool aIsContiguous,DBufferManager* aBufManager); sl@0: TInt GetFragmentLength(TInt aChunkOffset,TInt aLengthRemaining,TPhysAddr& aPhysAddr); sl@0: void Flush(DBufferManager::TFlushOp aFlushOp); sl@0: public: sl@0: /** The owning buffer manager. */ sl@0: DBufferManager* iBufManager; sl@0: /** The offset, in bytes, of the start of the buffer within the chunk. */ sl@0: TInt iChunkOffset; sl@0: /** The size of the buffer in bytes. */ sl@0: TInt iSize; sl@0: /** The physical address of the start of the buffer. KPhysAddrInvalid if the buffer is not physically contiguous. */ sl@0: TPhysAddr iPhysicalAddress; sl@0: /** A list of physical addresses for buffer pages. 0 if the buffer is physically contiguous. */ sl@0: TPhysAddr* iPhysicalPages; sl@0: /** Used for record only this is the number of bytes added into this buffer during recording. */ sl@0: TInt iBytesAdded; sl@0: /** Used for record only this is the result of the transfer into this buffer. */ sl@0: TInt iResult; sl@0: }; sl@0: sl@0: /** sl@0: The physical device driver (PDD) base class for the sound driver - for either playback or record. sl@0: @publishedPartner sl@0: @prototype sl@0: */ sl@0: class DSoundScPdd : public DBase sl@0: { sl@0: public: sl@0: /** sl@0: Return the DFC queue to be used by this device. sl@0: @param aUnit The record or playback unit for which to return the DFC queue. This is for use by sl@0: SMP optimised drivers to return different DFC queues for different units that can sl@0: then run on separate CPU cores. sl@0: @return The DFC queue to use. sl@0: */ sl@0: virtual TDfcQue* DfcQ(TInt aUnit)=0; sl@0: sl@0: /** sl@0: Return the shared chunk create information to be used by this device. sl@0: @param aChunkCreateInfo A chunk create info. object to be to be filled with the settings sl@0: required for this device. sl@0: */ sl@0: virtual void GetChunkCreateInfo(TChunkCreateInfo& aChunkCreateInfo)=0; sl@0: sl@0: /** sl@0: Return the capabilities of this audio device. sl@0: This includes information on the direction of the device (i.e. play or record), the number of audio channels sl@0: supported (mono, stereo etc), the encoding formats and sample rates supported and so on. sl@0: @param aCapsBuf A packaged TSoundFormatsSupportedV02 object to be filled with the capabilities sl@0: of this device. This descriptor is in kernel memory and can be accessed directly. sl@0: @see TSoundFormatsSupportedV02. sl@0: */ sl@0: virtual void Caps(TDes8& aCapsBuf) const=0; sl@0: sl@0: /** sl@0: Return the maximum transfer length in bytes that this device can support in a single data transfer. sl@0: (If the device is using the Symbian DMA framework to handle data transfers then the framework handles data sl@0: transfers which exceed the maximum transfer length for the platform. However, some PDD implementations sl@0: may not use the DMA framework). sl@0: @return The maximum transfer length in bytes. sl@0: */ sl@0: virtual TInt MaxTransferLen() const=0; sl@0: sl@0: /** sl@0: Configure or reconfigure the device using the configuration supplied. sl@0: @param aConfigBuf A packaged TCurrentSoundFormatV02 object which contains the new configuration settings. sl@0: This descriptor is in kernel memory and can be accessed directly. sl@0: @return KErrNone if successful, otherwise one of the other system wide error codes. sl@0: @see TCurrentSoundFormatV02. sl@0: */ sl@0: virtual TInt SetConfig(const TDesC8& aConfigBuf)=0; sl@0: sl@0: /** sl@0: Set the volume or record level. sl@0: @param aVolume The play volume or record level to be set - a value in the range 0 to 255. The value 255 sl@0: equates to the maximum volume and each value below this equates to a 0.5dB step below it. sl@0: @return KErrNone if successful, otherwise one of the other system wide error codes. sl@0: */ sl@0: virtual TInt SetVolume(TInt aVolume)=0; sl@0: sl@0: /** sl@0: Prepare the audio device for data transfer. sl@0: This may be preparing it either for record or playback - depending on the direction of the channel. sl@0: @return KErrNone if successful, otherwise one of the other system wide error codes. sl@0: */ sl@0: virtual TInt StartTransfer()=0; sl@0: sl@0: /** sl@0: Initiate the transfer of a portion of data from/to the audio device. sl@0: This may be to either record or playback the data - depending on the direction of the channel. When the transfer is sl@0: complete, the PDD should signal this event using the LDD function PlayCallback() or RecordCallback() as appropriate. sl@0: @param aTransferID A value assigned by the LDD to allow it to uniquely identify a particular transfer fragment. sl@0: @param aLinAddr A linear address within the shared chunk. For playback this is the address of the start of the data sl@0: to be transferred. For record, this is the start address for storing the recorded data. sl@0: @param aPhysAddr The physical address within the shared chunk that corresponds to the linear address: aLinAddr. sl@0: @param aNumBytes The number of bytes to be transferred. sl@0: @return KErrNone if the transfer has been initiated successfully; sl@0: KErrNotReady if the device is unable to accept the transfer for the moment; sl@0: otherwise one of the other system-wide error codes. sl@0: */ sl@0: virtual TInt TransferData(TUint aTransferID,TLinAddr aLinAddr,TPhysAddr aPhysAddr,TInt aNumBytes)=0; sl@0: sl@0: /** sl@0: Terminate the transfer of a data to/from the device and to release any resources necessary for transfer. sl@0: In the case of playback, this is called soon after the last pending play request from the client has been completed. sl@0: In the case of record, the LDD will leave the audio device capturing record data even when there are no record sl@0: requests pending from the client. Transfer will only be terminated when the client either issues sl@0: RSoundSc::CancelRecordData() or closes the channel. Once this function had been called, the LDD will not issue sl@0: any further TransferData() commands without first issueing a StartTransfer() command. sl@0: */ sl@0: virtual void StopTransfer()=0; sl@0: sl@0: /** sl@0: Halt the transfer of data to/from the sound device but don't release any resources necessary for transfer. sl@0: In the case of playback, if possible, any active transfer should be suspended in such a way that it can be sl@0: resumed later - starting from next sample following the one last played. sl@0: In the case of record, any active transfer should be aborted. When recording is halted the PDD should signal this event sl@0: with a single call of the LDD function RecordCallback() - reporting back any partial data already received. In this sl@0: case, if transfer is resumed later, the LDD will issue a new TransferData() request to re-commence data transfer. sl@0: @return KErrNone if successful, otherwise one of the other system wide error codes. sl@0: */ sl@0: virtual TInt PauseTransfer()=0; sl@0: sl@0: /** sl@0: Resume the transfer of data to/from the sound device following a request to halt the transfer. sl@0: In the case of playback, if possible, any transfer which was active when the device was halted should be resumed - sl@0: starting from next sample following the one last played. Once complete, it should be reported using PlayCallback() sl@0: as normal. sl@0: In the case of record, any active transfer would have been aborted when the device was halted so its just a case sl@0: of re-creating the same setup achieved following StartTransfer(). sl@0: @return KErrNone if successful, otherwise one of the other system wide error codes. sl@0: */ sl@0: virtual TInt ResumeTransfer()=0; sl@0: sl@0: /** sl@0: Power up the sound device. This is called when the channel is first opened and if ever the phone is brought out sl@0: of standby mode. sl@0: @return KErrNone if successful, otherwise one of the other system wide error codes. sl@0: */ sl@0: virtual TInt PowerUp()=0; sl@0: sl@0: /** sl@0: Power down the sound device. This is called when the channel is closed and just before the phone powers down when sl@0: being turned off or going into standby. sl@0: */ sl@0: virtual void PowerDown()=0; sl@0: sl@0: /** sl@0: Handle a custom configuration request. sl@0: @param aFunction A number identifying the request. sl@0: @param aParam A 32-bit value passed to the driver. Its meaning depends on the request. sl@0: @return KErrNone if successful, otherwise one of the other system wide error codes. sl@0: */ sl@0: virtual TInt CustomConfig(TInt aFunction,TAny* aParam)=0; sl@0: sl@0: /** sl@0: Calculates and returns the number of microseconds of data transferred since the start of transfer. sl@0: @param aTime A reference to a variable into which to place the number of microseconds played or recorded. sl@0: @param aState The current state of the transfer (from TSoundScLdd::TState). Included so that paused sl@0: and Active transfers can be treated differently. sl@0: @return KErrNone if successful, otherwise one of the other system wide error codes. sl@0: */ sl@0: virtual TInt TimeTransferred(TInt64& aTime, TInt aState); sl@0: protected: sl@0: inline DSoundScLdd* Ldd(); sl@0: private: sl@0: DSoundScLdd* iLdd; sl@0: friend class DSoundScLdd; sl@0: }; sl@0: sl@0: /** sl@0: The logical device (factory class) for the sound driver. sl@0: */ sl@0: class DSoundScLddFactory : public DLogicalDevice sl@0: { sl@0: public: sl@0: DSoundScLddFactory(); sl@0: virtual TInt Install(); sl@0: virtual void GetCaps(TDes8 &aDes) const; sl@0: virtual TInt Create(DLogicalChannelBase*& aChannel); sl@0: TBool IsUnitOpen(TInt aUnit); sl@0: TInt SetUnitOpen(TInt aUnit,TBool aIsOpenSetting); sl@0: private: sl@0: /** Mask to keep track of which units have a channel open on them. */ sl@0: TUint iUnitsOpenMask; sl@0: /** A mutex to protect access to the unit info. mask. */ sl@0: NFastMutex iUnitInfoMutex; sl@0: }; sl@0: sl@0: /** sl@0: The logical channel class for the sound driver. sl@0: */ sl@0: class DSoundScLdd : public DLogicalChannel sl@0: { sl@0: public: sl@0: enum TState sl@0: { sl@0: /** Channel is open - but not configured. */ sl@0: EOpen, sl@0: /** Channel is configured - but inactive. */ sl@0: EConfigured, sl@0: /** Channel is active - recording or playing data. */ sl@0: EActive, sl@0: /** Channel is paused - recording or playing has been suspended. */ sl@0: EPaused sl@0: }; sl@0: public: sl@0: DSoundScLdd(); sl@0: virtual ~DSoundScLdd(); sl@0: // Inherited from DLogicalChannel sl@0: virtual TInt DoCreate(TInt aUnit, const TDesC8* anInfo, const TVersion& aVer); sl@0: virtual TInt Request(TInt aReqNo, TAny* a1, TAny* a2); sl@0: virtual TInt SendMsg(TMessageBase* aMsg); sl@0: virtual void HandleMsg(TMessageBase* aMsg); sl@0: void Shutdown(); sl@0: // Functions used by the PDD sl@0: virtual void PlayCallback(TUint aTransferID,TInt aTransferResult,TInt aBytesPlayed); sl@0: virtual void RecordCallback(TUint aTransferID,TInt aTransferResult,TInt aBytesRecorded); sl@0: virtual void NotifyChangeOfHwConfigCallback(TBool aHeadsetPresent); sl@0: virtual TSoundSharedChunkBufConfig* BufConfig(); sl@0: virtual TLinAddr ChunkBase(); sl@0: private: sl@0: // Implementations for the different kinds of requests sl@0: TInt DoControl(TInt aFunction, TAny* a1, TAny* a2,DThread* aThread); sl@0: TInt DoRequest(TInt aFunction, TRequestStatus* aStatus, TAny* a1, TAny* a2,DThread* aThread); sl@0: TInt DoCancel(TUint aMask); sl@0: TInt SetBufferConfig(DThread* aThread); sl@0: TInt SetBufferConfig(TInt aChunkHandle,DThread* aThread); sl@0: TInt SetSoundConfig(); sl@0: TInt DoSetSoundConfig(const TCurrentSoundFormatV02& aSoundConfig); sl@0: TInt SetVolume(TInt aVolume); sl@0: TInt PlayData(TRequestStatus* aStatus,TSoundScPlayRequest* aRequest,DThread* aThread); sl@0: TInt RecordData(TRequestStatus* aStatus,TInt* aLengthPtr,DThread* aThread); sl@0: TInt StartRecord(); sl@0: TInt ReleaseBuffer(TInt aChunkOffset); sl@0: TInt CustomConfig(TInt aFunction,TAny* aParam); sl@0: TInt ValidateConfig(const TCurrentSoundFormatV02& aConfig); sl@0: TInt ReAllocBufferConfigInfo(TInt aNumBuffers); sl@0: void StartNextPlayTransfers(); sl@0: inline void CompletePlayRequest(TSoundScPlayRequest* aReq,TInt aResult); sl@0: void DoCompletePlayRequest(TSoundScPlayRequest* aReq); sl@0: void CompleteAllDonePlayRequests(TSoundScPlayRequest* aReq); sl@0: void HandleCurrentRecordBufferDone(TInt aTransferResult); sl@0: void CompleteRequest(DThread* aThread,TRequestStatus* aStatus,TInt aReason,TClientRequest* aClientRequest=NULL); sl@0: TInt StartNextRecordTransfers(); sl@0: void StartPlayEofTimer(); sl@0: void CancelPlayEofTimer(); sl@0: inline DSoundScPdd* Pdd(); sl@0: static void PlayEofTimerExpired(TAny* aChannel); sl@0: static void PlayEofTimerDfc(TAny* aChannel); sl@0: static void PowerUpDfc(TAny* aChannel); sl@0: static void PowerDownDfc(TAny* aChannel); sl@0: TInt PrePlay(TMessageBase* aMsg); sl@0: TInt PreSetBufferChunkCreateOrOpen(TMessageBase* aMsg); sl@0: TInt PreSetSoundConfig(TMessageBase* aMsg); sl@0: private: sl@0: /** The handle to the chunk that is returned to the user side code. */ sl@0: TInt iChunkHandle; sl@0: /** The handle of the thread that created the chunk referenced by iChunkHandle */ sl@0: DThread* iChunkHandleThread; sl@0: /** The unit number of this channel. */ sl@0: TInt iUnit; sl@0: /** The data transfer direction for this unit: play or record. */ sl@0: TSoundDirection iDirection; sl@0: /** The operating state of the channel. */ sl@0: TState iState; sl@0: /** Spare. */ sl@0: TInt iSpare; sl@0: /** The buffer manager - managing the shared chunk and the record/play buffers within this. */ sl@0: DBufferManager* iBufManager; sl@0: /** A mutex to protect access to the buffer lists and the pending request list. */ sl@0: NFastMutex iMutex; sl@0: /** The transfer status of the record buffer currently being filled. */ sl@0: TSndScTransfer iCurrentRecBufTf; sl@0: /** The transfer status of the record buffer which is next to be filled. */ sl@0: TSndScTransfer iNextRecBufTf; sl@0: /** The current buffer configuration in the play/record chunk. */ sl@0: TSoundSharedChunkBufConfig* iBufConfig; sl@0: /** The size in bytes of the play/record buffer configuration info. structure. */ sl@0: TInt iBufConfigSize; sl@0: /** The sound driver power handler. */ sl@0: DSoundScPowerHandler* iPowerHandler; sl@0: /** DFC used to handle power down requests from the power manager before a transition into system shutdown/standby. */ sl@0: TDfc iPowerDownDfc; sl@0: /** DFC used to handle power up requests from the power manager following a transition out of system standby. */ sl@0: TDfc iPowerUpDfc; sl@0: /** The capabilities of this device. */ sl@0: TSoundFormatsSupportedV02 iCaps; sl@0: /** The current audio configuration of the driver. */ sl@0: TCurrentSoundFormatV02 iSoundConfig; sl@0: /** The requested audio configuration of the driver before validation. */ sl@0: TCurrentSoundFormatV02 iTempSoundConfig; sl@0: /** A bitmask holding sound configuration status information. */ sl@0: TUint32 iSoundConfigFlags; sl@0: /** The current setting for the record level / play volume. */ sl@0: TInt iVolume; sl@0: /** The queue of pending play or record requests. */ sl@0: TSoundScRequestQueue* iReqQueue; sl@0: /** Used to complete the change of hardware notification. */ sl@0: TClientDataRequest* iNotifyChangeOfHwClientRequest; sl@0: /** The thread which has registered for the hardware configuration change notifier. */ sl@0: DThread* iChangeOfHwConfigThread; sl@0: /** A pointer to the headset present boolean variable in client memory which is updated on a notification. */ sl@0: TBool* iHeadsetPresentStatPtr; sl@0: /** To keep track of the number of bytes transferred. */ sl@0: TInt iBytesTransferred; sl@0: /** Count of the number of times the PDD completes a record transfer fragment just after being paused. */ sl@0: TInt iCompletesWhilePausedCount; sl@0: /** A timer used to delay exiting play transfer mode at EOF. */ sl@0: NTimer iEofTimer; sl@0: /** DFC used to delay exiting play transfer mode at EOF. */ sl@0: TDfc iPlayEofDfc; sl@0: /** Used for testing and debugging. */ sl@0: TUint iTestSettings; sl@0: /** A flag to indicate whether the play EOF timer is active. */ sl@0: TBool iPlayEofTimerActive; sl@0: /** Used in debug builds to track that all calls to DThread::Open() are balanced with a close before the driver closes. */ sl@0: TInt iThreadOpenCount; sl@0: /** Used to complete requests in the DFC thread. */ sl@0: TClientRequest** iClientRequests; sl@0: sl@0: friend class DBufferManager; sl@0: friend class DSoundScPowerHandler; sl@0: friend class TSoundScRequestQueue; sl@0: }; sl@0: sl@0: #include sl@0: #endif // __SOUNDSC_H__