accessoryservices/accessoryserver/src/Server/AccSrvSubAudioControl.cpp
branchRCL_3
changeset 81 24127ea5a236
parent 56 1ddbe54d0645
equal deleted inserted replaced
71:fdcef27a50b8 81:24127ea5a236
   119 
   119 
   120     COM_TRACE_( "[AccFW:AccServer] CAccSrvSubAudioControl::~CAccSrvSubAudioControl - return void" );
   120     COM_TRACE_( "[AccFW:AccServer] CAccSrvSubAudioControl::~CAccSrvSubAudioControl - return void" );
   121     }
   121     }
   122 
   122 
   123 // -----------------------------------------------------------------------------
   123 // -----------------------------------------------------------------------------
   124 // CAccSrvSubAudioControl::NotifyAccessoryAudioLinkOpenedL
   124 // CAccSrvSubAudioControl::NotifyAccessoryAudioLinkOpened
   125 // -----------------------------------------------------------------------------
   125 // -----------------------------------------------------------------------------
   126 //
   126 //
   127 void CAccSrvSubAudioControl::NotifyAccessoryAudioLinkOpenedL( const RMessage2& aMessage )
   127 void CAccSrvSubAudioControl::NotifyAccessoryAudioLinkOpened( const RMessage2& aMessage )
   128     {
   128     {
   129     COM_TRACE_( "[AccFW:AccServer] CAccSrvSubAudioControl::NotifyAccessoryAudioLinkOpenedL()" );
   129     COM_TRACE_( "[AccFW:AccServer] CAccSrvSubAudioControl::NotifyAccessoryAudioLinkOpened()" );
   130 
   130 
   131     iConnectionController->NotificationQueue().RegisterControlMessage( EAccessoryAudioLinkOpened,
   131     iConnectionController->NotificationQueue().RegisterControlMessage( EAccessoryAudioLinkOpened,
   132                                                                        this );
   132                                                                        this );
   133 
   133 
   134     iNotifyAccessoryAudioLinkOpenedMsg = aMessage;//Store RMessage2 for future completion
   134     iNotifyAccessoryAudioLinkOpenedMsg = aMessage;//Store RMessage2 for future completion
   135 
   135 
   136     // If message is null, there is no pending request and no filtering needed
   136     // If message is null, there is no pending request and no filtering needed
   137     if ( !iAccessoryAudioLinkOpenMsg.IsNull() )
   137     if ( !iAccessoryAudioLinkOpenMsg.IsNull() )
   138         {
   138         {
   139         //NotifyAccessoryAudioLinkOpenedL() notification is filtered
   139         //NotifyAccessoryAudioLinkOpened() notification is filtered
   140         //for AccessoryAudioLinkOpen() caller thread.
   140         //for AccessoryAudioLinkOpen() caller thread.
   141         //In this case NotifyAccessoryAudioLinkOpenedL() notification
   141         //In this case NotifyAccessoryAudioLinkOpened() notification
   142         //is ordered after AccessoryAudioLinkOpen() is sent.
   142         //is ordered after AccessoryAudioLinkOpen() is sent.
   143         iConnectionController->ServerModel().SetMsgThreadIDFilterL( iCallerThreadID,
   143         iConnectionController->ServerModel().SetMsgThreadIDFilter( iCallerThreadID,
   144                                                                    EAccessoryAudioLinkOpened );
   144                                                                    EAccessoryAudioLinkOpened );
   145         }
   145         }
   146 
   146 
   147     COM_TRACE_( "[AccFW:AccServer] CAccSrvSubAudioControl::NotifyAccessoryAudioLinkOpenedL - return void" );
   147     COM_TRACE_( "[AccFW:AccServer] CAccSrvSubAudioControl::NotifyAccessoryAudioLinkOpened - return void" );
   148     }
   148     }
   149 
   149 
   150 // -----------------------------------------------------------------------------
   150 // -----------------------------------------------------------------------------
   151 // CAccSrvSubAudioControl::NotifyAccessoryAudioLinkClosedL
   151 // CAccSrvSubAudioControl::NotifyAccessoryAudioLinkClosed
   152 // -----------------------------------------------------------------------------
   152 // -----------------------------------------------------------------------------
   153 //
   153 //
   154 void CAccSrvSubAudioControl::NotifyAccessoryAudioLinkClosedL( const RMessage2& aMessage )
   154 void CAccSrvSubAudioControl::NotifyAccessoryAudioLinkClosed( const RMessage2& aMessage )
   155     {
   155     {
   156     COM_TRACE_( "[AccFW:AccServer] CAccSrvSubAudioControl::NotifyAccessoryAudioLinkClosedL()" );
   156     COM_TRACE_( "[AccFW:AccServer] CAccSrvSubAudioControl::NotifyAccessoryAudioLinkClosed()" );
   157 
   157 
   158     iConnectionController->NotificationQueue().RegisterControlMessage( EAccessoryAudioLinkClosed,
   158     iConnectionController->NotificationQueue().RegisterControlMessage( EAccessoryAudioLinkClosed,
   159                                                                        this );
   159                                                                        this );
   160     iNotifyAccessoryAudioLinkClosedMsg = aMessage;//Store RMessage2 for future completion
   160     iNotifyAccessoryAudioLinkClosedMsg = aMessage;//Store RMessage2 for future completion
   161 
   161 
   162     // If message is null, there is no pending request and no filtering needed
   162     // If message is null, there is no pending request and no filtering needed
   163     if ( !iAccessoryAudioLinkCloseMsg.IsNull() )
   163     if ( !iAccessoryAudioLinkCloseMsg.IsNull() )
   164         {
   164         {
   165         //NotifyAccessoryAudioLinkClosedL() notification is filtered
   165         //NotifyAccessoryAudioLinkClosed() notification is filtered
   166         //for AccessoryAudioLinkClose() caller thread.
   166         //for AccessoryAudioLinkClose() caller thread.
   167         //In this case NotifyAccessoryAudioLinkClosedL() notification
   167         //In this case NotifyAccessoryAudioLinkClosed() notification
   168         //is ordered after AccessoryAudioLinkClose() is sent.
   168         //is ordered after AccessoryAudioLinkClose() is sent.
   169         iConnectionController->ServerModel().SetMsgThreadIDFilterL( iCallerThreadID,
   169         iConnectionController->ServerModel().SetMsgThreadIDFilter( iCallerThreadID,
   170                                                                    EAccessoryAudioLinkClosed );
   170                                                                    EAccessoryAudioLinkClosed );
   171         }
   171         }
   172 
   172 
   173     COM_TRACE_( "[AccFW:AccServer] CAccSrvSubAudioControl::NotifyAccessoryAudioLinkClosedL - return void" );
   173     COM_TRACE_( "[AccFW:AccServer] CAccSrvSubAudioControl::NotifyAccessoryAudioLinkClosed - return void" );
   174     }
   174     }
   175 
   175 
   176 // -----------------------------------------------------------------------------
   176 // -----------------------------------------------------------------------------
   177 // CAccSrvSubAudioControl::AccessoryAudioLinkOpenL
   177 // CAccSrvSubAudioControl::AccessoryAudioLinkOpenL
   178 // -----------------------------------------------------------------------------
   178 // -----------------------------------------------------------------------------
   217     iAccessoryAudioLinkOpenMsg = aMessage;//Store RMessage2 for future completion
   217     iAccessoryAudioLinkOpenMsg = aMessage;//Store RMessage2 for future completion
   218     
   218     
   219     // If message is null, there is no pending request and no filtering needed
   219     // If message is null, there is no pending request and no filtering needed
   220     if ( !iNotifyAccessoryAudioLinkOpenedMsg.IsNull() )
   220     if ( !iNotifyAccessoryAudioLinkOpenedMsg.IsNull() )
   221         {
   221         {
   222         //NotifyAccessoryAudioLinkOpenedL notification() is filtered
   222         //NotifyAccessoryAudioLinkOpened notification() is filtered
   223         //for AccessoryAudioLinkOpen() caller thread
   223         //for AccessoryAudioLinkOpen() caller thread
   224         iConnectionController->ServerModel().SetMsgThreadIDFilterL( iCallerThreadID,
   224         iConnectionController->ServerModel().SetMsgThreadIDFilter( iCallerThreadID,
   225                                                                    EAccessoryAudioLinkOpened );
   225                                                                    EAccessoryAudioLinkOpened );
   226         }
   226         }
   227 
   227 
   228     COM_TRACE_( "[AccFW:AccServer] CAccSrvSubAudioControl::AccessoryAudioLinkOpenL - return void" );
   228     COM_TRACE_( "[AccFW:AccServer] CAccSrvSubAudioControl::AccessoryAudioLinkOpenL - return void" );
   229     }
   229     }
   261     iAccessoryAudioLinkCloseMsg = aMessage;//Store RMessage2 for future completion
   261     iAccessoryAudioLinkCloseMsg = aMessage;//Store RMessage2 for future completion
   262 
   262 
   263     // If message is null, there is no pending request and no filtering needed
   263     // If message is null, there is no pending request and no filtering needed
   264     if ( !iNotifyAccessoryAudioLinkClosedMsg.IsNull() )
   264     if ( !iNotifyAccessoryAudioLinkClosedMsg.IsNull() )
   265         {
   265         {
   266         //NotifyAccessoryAudioLinkClosedL() notification is filtered
   266         //NotifyAccessoryAudioLinkClosed() notification is filtered
   267         //for AccessoryAudioLinkClose() caller thread
   267         //for AccessoryAudioLinkClose() caller thread
   268         iConnectionController->ServerModel().SetMsgThreadIDFilterL( 
   268         iConnectionController->ServerModel().SetMsgThreadIDFilter( 
   269                                                     iCallerThreadID,
   269                                                     iCallerThreadID,
   270                                                     EAccessoryAudioLinkClosed );
   270                                                     EAccessoryAudioLinkClosed );
   271         }
   271         }
   272 
   272 
   273     COM_TRACE_( "[AccFW:AccServer] CAccSrvSubBaseConnection::AccessoryAudioLinkCloseL - return void" );
   273     COM_TRACE_( "[AccFW:AccServer] CAccSrvSubBaseConnection::AccessoryAudioLinkCloseL - return void" );
   309         iConnectionController->NotificationQueue().CancelControlMessage( 
   309         iConnectionController->NotificationQueue().CancelControlMessage( 
   310                                                     EAccessoryAudioLinkOpen,
   310                                                     EAccessoryAudioLinkOpen,
   311                                                     this );
   311                                                     this );
   312 
   312 
   313         //AccessoryAudioLinkOpen() request is cancelled
   313         //AccessoryAudioLinkOpen() request is cancelled
   314         //-> NO filtering needed for NotifyAccessoryAudioLinkOpenedL()
   314         //-> NO filtering needed for NotifyAccessoryAudioLinkOpened()
   315         iConnectionController->ServerModel().FindAndDeleteMsgThreadIDFilter( 
   315         iConnectionController->ServerModel().FindAndDeleteMsgThreadIDFilter( 
   316                                                     iCallerThreadID, 
   316                                                     iCallerThreadID, 
   317                                                     EAccessoryAudioLinkOpened );
   317                                                     EAccessoryAudioLinkOpened );
   318 
   318 
   319         Write( iAccessoryAudioLinkOpenMsg, KAccSrvAccessoryAudioLinkOpenBit );
   319         Write( iAccessoryAudioLinkOpenMsg, KAccSrvAccessoryAudioLinkOpenBit );
   338         {
   338         {
   339         iConnectionController->NotificationQueue().CancelControlMessage( EAccessoryAudioLinkClose,
   339         iConnectionController->NotificationQueue().CancelControlMessage( EAccessoryAudioLinkClose,
   340                                                                          this );
   340                                                                          this );
   341 
   341 
   342         //AccessoryAudioLinkClose() request is cancelled
   342         //AccessoryAudioLinkClose() request is cancelled
   343         //-> NO filtering needed for NotifyAccessoryAudioLinkClosedL()
   343         //-> NO filtering needed for NotifyAccessoryAudioLinkClosed()
   344         iConnectionController->ServerModel().FindAndDeleteMsgThreadIDFilter(
   344         iConnectionController->ServerModel().FindAndDeleteMsgThreadIDFilter(
   345             iCallerThreadID, EAccessoryAudioLinkClosed );
   345             iCallerThreadID, EAccessoryAudioLinkClosed );
   346 
   346 
   347         Write( iAccessoryAudioLinkCloseMsg, KAccSrvAccessoryAudioLinkCloseBit );
   347         Write( iAccessoryAudioLinkCloseMsg, KAccSrvAccessoryAudioLinkCloseBit );
   348         iAccessoryAudioLinkCloseMsg.Complete( KErrCancel );
   348         iAccessoryAudioLinkCloseMsg.Complete( KErrCancel );
   365     if( !iNotifyAccessoryAudioLinkOpenedMsg.IsNull() )
   365     if( !iNotifyAccessoryAudioLinkOpenedMsg.IsNull() )
   366         {
   366         {
   367         iConnectionController->NotificationQueue().CancelControlMessage( 
   367         iConnectionController->NotificationQueue().CancelControlMessage( 
   368             EAccessoryAudioLinkOpened, this );
   368             EAccessoryAudioLinkOpened, this );
   369 
   369 
   370         //NotifyAccessoryAudioLinkOpenedL() notification order is cancelled
   370         //NotifyAccessoryAudioLinkOpened() notification order is cancelled
   371         //-> NO filtering needed for that message
   371         //-> NO filtering needed for that message
   372         iConnectionController->ServerModel().FindAndDeleteMsgThreadIDFilter( 
   372         iConnectionController->ServerModel().FindAndDeleteMsgThreadIDFilter( 
   373             iCallerThreadID, EAccessoryAudioLinkOpened );
   373             iCallerThreadID, EAccessoryAudioLinkOpened );
   374 
   374 
   375         Write( iNotifyAccessoryAudioLinkOpenedMsg, KAccSrvNotifyAccessoryAudioLinkOpenedBit );
   375         Write( iNotifyAccessoryAudioLinkOpenedMsg, KAccSrvNotifyAccessoryAudioLinkOpenedBit );
   392     if( !iNotifyAccessoryAudioLinkClosedMsg.IsNull() )
   392     if( !iNotifyAccessoryAudioLinkClosedMsg.IsNull() )
   393         {
   393         {
   394         iConnectionController->NotificationQueue().CancelControlMessage( 
   394         iConnectionController->NotificationQueue().CancelControlMessage( 
   395             EAccessoryAudioLinkClosed, this );
   395             EAccessoryAudioLinkClosed, this );
   396 
   396 
   397         //NotifyAccessoryAudioLinkClosedL() notification order is cancelled
   397         //NotifyAccessoryAudioLinkClosed() notification order is cancelled
   398         //-> NO filtering needed for that message
   398         //-> NO filtering needed for that message
   399         iConnectionController->ServerModel().FindAndDeleteMsgThreadIDFilter(
   399         iConnectionController->ServerModel().FindAndDeleteMsgThreadIDFilter(
   400             iCallerThreadID, EAccessoryAudioLinkClosed );
   400             iCallerThreadID, EAccessoryAudioLinkClosed );
   401     
   401     
   402         Write( iNotifyAccessoryAudioLinkClosedMsg, KAccSrvNotifyAccessoryAudioLinkClosedBit );
   402         Write( iNotifyAccessoryAudioLinkClosedMsg, KAccSrvNotifyAccessoryAudioLinkClosedBit );
   420 
   420 
   421     switch ( function )
   421     switch ( function )
   422         {
   422         {
   423         case EAccSrvNotifyAccessoryAudioLinkOpened:
   423         case EAccSrvNotifyAccessoryAudioLinkOpened:
   424             {
   424             {
   425             NotifyAccessoryAudioLinkOpenedL( aMessage );
   425             NotifyAccessoryAudioLinkOpened( aMessage );
   426             break;
   426             break;
   427             }
   427             }
   428         case EAccSrvNotifyAccessoryAudioLinkClosed:
   428         case EAccSrvNotifyAccessoryAudioLinkClosed:
   429             {
   429             {
   430             NotifyAccessoryAudioLinkClosedL( aMessage );
   430             NotifyAccessoryAudioLinkClosed( aMessage );
   431             break;
   431             break;
   432             }
   432             }
   433         case EAccSrvAccessoryAudioLinkOpen:
   433         case EAccSrvAccessoryAudioLinkOpen:
   434             {
   434             {
   435             AccessoryAudioLinkOpenL( aMessage );
   435             AccessoryAudioLinkOpenL( aMessage );
   492         {
   492         {
   493         case EAccessoryAudioLinkOpen:
   493         case EAccessoryAudioLinkOpen:
   494             {
   494             {
   495             if( KErrNone != aErrorCode )
   495             if( KErrNone != aErrorCode )
   496                 {
   496                 {
   497                 //Release NotifyAccessoryAudioLinkOpenedL() filtering in error case.
   497                 //Release NotifyAccessoryAudioLinkOpened() filtering in error case.
   498                 //BluetoothAudioLinkOpenedNotify() message is never sent in error case
   498                 //BluetoothAudioLinkOpenedNotify() message is never sent in error case
   499                 iConnectionController->ServerModel().FindAndDeleteMsgThreadIDFilter(
   499                 iConnectionController->ServerModel().FindAndDeleteMsgThreadIDFilter(
   500                                                                     iCallerThreadID,
   500                                                                     iCallerThreadID,
   501                                                                     EAccessoryAudioLinkOpened );
   501                                                                     EAccessoryAudioLinkOpened );
   502                 }  
   502                 }  
   509 
   509 
   510         case EAccessoryAudioLinkClose:
   510         case EAccessoryAudioLinkClose:
   511             {
   511             {
   512             if( KErrNone != aErrorCode )
   512             if( KErrNone != aErrorCode )
   513                 {
   513                 {
   514                 //Release NotifyAccessoryAudioLinkClosedL() filtering in error case.
   514                 //Release NotifyAccessoryAudioLinkClosed() filtering in error case.
   515                 //BluetoothAudioLinkClosedNotify() message is never sent in error case
   515                 //BluetoothAudioLinkClosedNotify() message is never sent in error case
   516                 iConnectionController->ServerModel().FindAndDeleteMsgThreadIDFilter(
   516                 iConnectionController->ServerModel().FindAndDeleteMsgThreadIDFilter(
   517                                                                     iCallerThreadID,
   517                                                                     iCallerThreadID,
   518                                                                     EAccessoryAudioLinkClosed );
   518                                                                     EAccessoryAudioLinkClosed );
   519                 }                
   519                 }                
   524             }
   524             }
   525             break;
   525             break;
   526 
   526 
   527         case EAccessoryAudioLinkOpened:
   527         case EAccessoryAudioLinkOpened:
   528             {
   528             {
   529             // Nothing is done here if filter is set, i.e. NotifyAccessoryAudioLinkOpenedL()
   529             // Nothing is done here if filter is set, i.e. NotifyAccessoryAudioLinkOpened()
   530             // notification was ordered from the same thread that AccessoryAudioLinkOpen() was called
   530             // notification was ordered from the same thread that AccessoryAudioLinkOpen() was called
   531             if ( !iConnectionController->ServerModel().FindAndDeleteMsgThreadIDFilter( 
   531             if ( !iConnectionController->ServerModel().FindAndDeleteMsgThreadIDFilter( 
   532                                                                     iCallerThreadID, 
   532                                                                     iCallerThreadID, 
   533                                                                     EAccessoryAudioLinkOpened ) )
   533                                                                     EAccessoryAudioLinkOpened ) )
   534                 {
   534                 {
   535                 //Complete outstanding NotifyAccessoryAudioLinkOpenedL request
   535                 //Complete outstanding NotifyAccessoryAudioLinkOpened request
   536                 //Notice, This works for single client (Server model can store only one value)
   536                 //Notice, This works for single client (Server model can store only one value)
   537                 TAccAudioType    audioType( iConnectionController->ServerModel().AudioType() );
   537                 TAccAudioType    audioType( iConnectionController->ServerModel().AudioType() );
   538                 TAccPolGenericID genericID;
   538                 TAccPolGenericID genericID;
   539                 iConnectionController->ServerModel().FindWithUniqueIDL( aUniqueID, genericID );
   539                 iConnectionController->ServerModel().FindWithUniqueIDL( aUniqueID, genericID );
   540                 TAccSrvGenericIDPckg genericIDPckg( genericID );
   540                 TAccSrvGenericIDPckg genericIDPckg( genericID );
   553             }
   553             }
   554             break;
   554             break;
   555 
   555 
   556         case EAccessoryAudioLinkClosed:
   556         case EAccessoryAudioLinkClosed:
   557             {
   557             {
   558             // Nothing is done here if filter is set, i.e. NotifyAccessoryAudioLinkClosedL() 
   558             // Nothing is done here if filter is set, i.e. NotifyAccessoryAudioLinkClosed() 
   559             // notification was ordered from the same thread that AccessoryAudioLinkClose() was called
   559             // notification was ordered from the same thread that AccessoryAudioLinkClose() was called
   560             if ( !iConnectionController->ServerModel().FindAndDeleteMsgThreadIDFilter(
   560             if ( !iConnectionController->ServerModel().FindAndDeleteMsgThreadIDFilter(
   561                                                                     iCallerThreadID,
   561                                                                     iCallerThreadID,
   562                                                                     EAccessoryAudioLinkClosed ) )
   562                                                                     EAccessoryAudioLinkClosed ) )
   563                 {
   563                 {
   564                 //Complete outstanding NotifyAccessoryAudioLinkClosedL request
   564                 //Complete outstanding NotifyAccessoryAudioLinkClosed request
   565                 //Notice, This works for single client (Server model can store only one value)
   565                 //Notice, This works for single client (Server model can store only one value)
   566                 TAccAudioType    audioType( iConnectionController->ServerModel().AudioType() );
   566                 TAccAudioType    audioType( iConnectionController->ServerModel().AudioType() );
   567                 TAccPolGenericID genericID;
   567                 TAccPolGenericID genericID;
   568                 iConnectionController->ServerModel().FindWithUniqueIDL( aUniqueID, genericID );
   568                 iConnectionController->ServerModel().FindWithUniqueIDL( aUniqueID, genericID );
   569                 TAccSrvGenericIDPckg genericIDPckg( genericID );
   569                 TAccSrvGenericIDPckg genericIDPckg( genericID );