mmserv/tms/tmscallserver/src/tmscsdownlink.cpp
branchRCL_3
changeset 17 60e492b28869
parent 11 3570217d8c21
child 19 095bea5f582e
equal deleted inserted replaced
15:ab526b8cacfb 17:60e492b28869
    23 
    23 
    24 const gint KDefaultVolume = 4;
    24 const gint KDefaultVolume = 4;
    25 const gint KDefaultMaxVolume = 10;
    25 const gint KDefaultMaxVolume = 10;
    26 
    26 
    27 // -----------------------------------------------------------------------------
    27 // -----------------------------------------------------------------------------
       
    28 // Constructor
       
    29 // -----------------------------------------------------------------------------
       
    30 //
       
    31 TMSCSDownlink::TMSCSDownlink(TMSCSDevSoundObserver& observer) :
       
    32     TMSCSDevSound(observer)
       
    33     {
       
    34     }
       
    35 
       
    36 // -----------------------------------------------------------------------------
       
    37 // Second phase constructor
       
    38 // -----------------------------------------------------------------------------
       
    39 //
       
    40 void TMSCSDownlink::ConstructL()
       
    41     {
       
    42     TMSCSDevSound::ConstructL(TMS_STREAM_DOWNLINK);
       
    43 
       
    44     if (iDevSound)
       
    45         {
       
    46         iDevSound->SetVolume(KDefaultVolume);
       
    47         }
       
    48     }
       
    49 
       
    50 // -----------------------------------------------------------------------------
    28 // Static constructor
    51 // Static constructor
    29 // -----------------------------------------------------------------------------
    52 // -----------------------------------------------------------------------------
    30 //
    53 //
    31 TMSCSDownlink* TMSCSDownlink::NewL(TMSCSPDevSoundObserver& aObserver)
    54 TMSCSDownlink* TMSCSDownlink::NewL(TMSCSDevSoundObserver& observer)
    32     {
    55     {
    33     TMSCSDownlink* self = new (ELeave) TMSCSDownlink(aObserver);
    56     TMSCSDownlink* self = new (ELeave) TMSCSDownlink(observer);
    34     CleanupStack::PushL(self);
    57     CleanupStack::PushL(self);
    35     self->ConstructL();
    58     self->ConstructL();
    36     CleanupStack::Pop(self);
    59     CleanupStack::Pop(self);
    37     return self;
    60     return self;
    38     }
    61     }
    39 
    62 
    40 // -----------------------------------------------------------------------------
    63 // -----------------------------------------------------------------------------
    41 // Destructor.
    64 // Destructor
    42 // -----------------------------------------------------------------------------
    65 // -----------------------------------------------------------------------------
    43 //
    66 //
    44 TMSCSDownlink::~TMSCSDownlink()
    67 TMSCSDownlink::~TMSCSDownlink()
    45     {
    68     {
    46     }
    69     }
    47 
    70 
    48 // -----------------------------------------------------------------------------
    71 // -----------------------------------------------------------------------------
    49 // Sets volume
    72 // Sets volume
    50 // -----------------------------------------------------------------------------
    73 // -----------------------------------------------------------------------------
    51 //
    74 //
    52 void TMSCSDownlink::SetVolume(gint aVolume)
    75 void TMSCSDownlink::SetVolume(gint volume)
    53     {
    76     {
    54     if (iDevSound)
    77     if (iDevSound)
    55         {
    78         {
    56         gint maxVolume(iDevSound->MaxVolume());
    79         gint maxVolume(iDevSound->MaxVolume());
    57         maxVolume = (maxVolume > 0) ? maxVolume : KDefaultMaxVolume;
    80         maxVolume = (maxVolume > 0) ? maxVolume : KDefaultMaxVolume;
    58         gint scaledVolume = (aVolume * maxVolume) / KDefaultMaxVolume;
    81         gint scaledVolume = (volume * maxVolume) / KDefaultMaxVolume;
    59         iDevSound->SetVolume(scaledVolume);
    82         iDevSound->SetVolume(scaledVolume);
    60         }
    83         }
    61     }
    84     }
    62 
    85 
    63 // -----------------------------------------------------------------------------
    86 // -----------------------------------------------------------------------------
    64 // Gives volume
    87 // Returns volume
    65 // -----------------------------------------------------------------------------
    88 // -----------------------------------------------------------------------------
    66 //
    89 //
    67 gint TMSCSDownlink::Volume()
    90 gint TMSCSDownlink::Volume()
    68     {
    91     {
    69     gint vol = 0;
    92     gint vol = 0;
    73         }
    96         }
    74     return vol;
    97     return vol;
    75     }
    98     }
    76 
    99 
    77 // -----------------------------------------------------------------------------
   100 // -----------------------------------------------------------------------------
    78 // Gives max volume
   101 // Returns device's max volume
    79 // -----------------------------------------------------------------------------
   102 // -----------------------------------------------------------------------------
    80 //
   103 //
    81 gint TMSCSDownlink::MaxVolume()
   104 gint TMSCSDownlink::MaxVolume()
    82     {
   105     {
    83     gint vol = 0;
   106     gint vol = 0;
    93 // Downlink stream has been activated successfully.
   116 // Downlink stream has been activated successfully.
    94 // -----------------------------------------------------------------------------
   117 // -----------------------------------------------------------------------------
    95 //
   118 //
    96 void TMSCSDownlink::BufferToBeFilled(CMMFBuffer* /*aBuffer*/)
   119 void TMSCSDownlink::BufferToBeFilled(CMMFBuffer* /*aBuffer*/)
    97     {
   120     {
    98     //CSPLOGSTRING( CSPINT, "TMSCSDownlink:: activated" );
   121     //TRACE_PRN_N(_L("TMSCSDownlink::BufferToBeFilled"));
       
   122 
    99     // We dont react to devsound messages unless we are activating.
   123     // We dont react to devsound messages unless we are activating.
   100     if (IsActivationOngoing())
   124     if (iActivationOngoing)
   101         {
   125         {
   102         iActive = ETrue;
   126         iActive = ETrue;
   103         iActivationOngoing = EFalse;
   127         iActivationOngoing = EFalse;
   104         iObserver.DownlinkActivatedSuccessfully();
   128         iObserver.DownlinkActivationCompleted(KErrNone);
   105         }
   129         }
   106     }
   130     }
   107 
   131 
   108 // -----------------------------------------------------------------------------
   132 // -----------------------------------------------------------------------------
   109 // From class MDevSoundObserver
   133 // From class MDevSoundObserver
   110 // Downlink stream activation failed
   134 // Downlink stream activation failed
   111 // -----------------------------------------------------------------------------
   135 // -----------------------------------------------------------------------------
   112 //
   136 //
   113 void TMSCSDownlink::PlayError(TInt aError)
   137 void TMSCSDownlink::PlayError(TInt aError)
   114     {
   138     {
   115     //CSPLOGSTRING( CSPINT, "TMSCSDownlink::PlayError" );
   139     //TRACE_PRN_N1(_L("TMSCSDownlink::PlayError[%d]"), aError);
   116 
   140 
   117     // We dont react to devsound messages unless we are activating.
   141     // We don't react to devsound errors unless we are activating.
   118     if (IsActivationOngoing())
   142     if (iActivationOngoing && aError == KErrAccessDenied)
   119         {
   143         {
   120         //CSPLOGSTRING( CSPINT, "TMSCSDownlink::PlayError activation failed" );
   144         iActivationOngoing = EFalse;
   121         if (aError == KErrAccessDenied)
   145         iObserver.DownlinkActivationCompleted(aError);
   122             {
       
   123             iActivationOngoing = EFalse;
       
   124             iObserver.DownlinkActivationFailed();
       
   125             }
       
   126         }
   146         }
   127     }
   147     }
   128 
   148 
   129 // -----------------------------------------------------------------------------
   149 // -----------------------------------------------------------------------------
   130 // From class CSPDevsound
   150 // From class TMSCSDevSound
   131 // Tries to activate Downlink stream.
   151 // Activates Downlink stream.
   132 // -----------------------------------------------------------------------------
   152 // -----------------------------------------------------------------------------
   133 //
   153 //
   134 void TMSCSDownlink::DoActivateL()
   154 void TMSCSDownlink::DoActivateL()
   135     {
   155     {
   136     if (iDevSound)
   156     if (iDevSound)
   137         {
   157         {
   138         iDevSound->PlayInitL();
   158         iDevSound->PlayInitL();
   139         }
   159         }
   140     }
   160     }
   141 
   161 
   142 // -----------------------------------------------------------------------------
       
   143 // Constructor
       
   144 // -----------------------------------------------------------------------------
       
   145 //
       
   146 TMSCSDownlink::TMSCSDownlink(TMSCSPDevSoundObserver& aObserver) :
       
   147     TMSCSPDevSound(aObserver)
       
   148     {
       
   149     }
       
   150 
       
   151 // -----------------------------------------------------------------------------
       
   152 // Second phase constructor
       
   153 // -----------------------------------------------------------------------------
       
   154 //
       
   155 void TMSCSDownlink::ConstructL()
       
   156     {
       
   157     TMSCSPDevSound::ConstructL(EMMFStatePlaying, KAudioPrefCSCallDownlink,
       
   158             KAudioPriorityCSCallDownlink);
       
   159 
       
   160     if (iDevSound)
       
   161         {
       
   162         iDevSound->SetVolume(KDefaultVolume);
       
   163         }
       
   164     }
       
   165 
       
   166 //  End of File
   162 //  End of File