@@ -688,6 +688,9 @@ namespace WPEFramework
688
688
m_currentActiveSource = -1 ;
689
689
m_isHdmiInConnected = false ;
690
690
hdmiCecAudioDeviceConnected = false ;
691
+ m_isAudioStatusInfoUpdated = false ;
692
+ m_audioStatusReceived = false ;
693
+ m_audioStatusTimerStarted = false ;
691
694
m_audioDevicePowerStatusRequested = false ;
692
695
m_pollNextState = POLL_THREAD_STATE_NONE;
693
696
m_pollThreadState = POLL_THREAD_STATE_NONE;
@@ -697,22 +700,24 @@ namespace WPEFramework
697
700
698
701
logicalAddressDeviceType = " None" ;
699
702
logicalAddress = 0xFF ;
703
+ // load persistence setting
704
+ loadSettings ();
705
+
706
+ int err;
707
+ dsHdmiInGetNumberOfInputsParam_t hdmiInput;
708
+ InitializeIARM ();
700
709
m_sendKeyEventThreadExit = false ;
701
710
m_sendKeyEventThread = std::thread (threadSendKeyEvent);
702
711
703
712
m_currentArcRoutingState = ARC_STATE_ARC_TERMINATED;
704
713
m_semSignaltoArcRoutingThread.acquire ();
705
714
m_arcRoutingThread = std::thread (threadArcRouting);
706
715
707
-
716
+ m_audioStatusDetectionTimer.connect ( std::bind ( &HdmiCecSink::audioStatusTimerFunction, this ) );
717
+ m_audioStatusDetectionTimer.setSingleShot (true );
708
718
m_arcStartStopTimer.connect ( std::bind ( &HdmiCecSinkImplementation::arcStartStopTimerFunction, this ) );
709
719
m_arcStartStopTimer.setSingleShot (true );
710
- // load persistence setting
711
- loadSettings ();
712
720
713
- int err;
714
- dsHdmiInGetNumberOfInputsParam_t hdmiInput;
715
- InitializeIARM ();
716
721
// get power state:
717
722
uint32_t res = Core::ERROR_GENERAL;
718
723
PowerState pwrStateCur = WPEFramework::Exchange::IPowerManager::POWER_STATE_UNKNOWN;
@@ -764,8 +769,8 @@ namespace WPEFramework
764
769
}
765
770
}
766
771
getCecVersion ();
767
- getHdmiArcPortID ( );
768
- return (std::string ());
772
+ LOGINFO ( " HdmiCecSink plugin Initialize completed \n " );
773
+ return (std::string ());
769
774
770
775
}
771
776
@@ -1092,6 +1097,18 @@ namespace WPEFramework
1092
1097
{
1093
1098
if (!HdmiCecSinkImplementation::_instance)
1094
1099
return ;
1100
+ if (m_audioStatusTimerStarted)
1101
+ {
1102
+ m_audioStatusReceived = true ;
1103
+ m_isAudioStatusInfoUpdated = true ;
1104
+ m_audioStatusTimerStarted = false ;
1105
+ if (m_audioStatusDetectionTimer.isActive ())
1106
+ {
1107
+ LOGINFO (" AudioStatus received from the Audio Device and the timer is still active. So stopping the timer!\n " );
1108
+ m_audioStatusDetectionTimer.stop ();
1109
+ }
1110
+ LOGINFO (" AudioStatus received from the Audio Device. Updating the AudioStatus info! m_isAudioStatusInfoUpdated :%d, m_audioStatusReceived :%d, m_audioStatusTimerStarted:%d " , m_isAudioStatusInfoUpdated,m_audioStatusReceived,m_audioStatusTimerStarted);
1111
+ }
1095
1112
LOGINFO (" Command: ReportAudioStatus %s audio Mute status %d means %s and current Volume level is %d \n " ,GetOpName (msg.opCode ()),msg.status .getAudioMuteStatus (),msg.status .toString ().c_str (),msg.status .getAudioVolume ());
1096
1113
while (index != _hdmiCecSourceNotifications.end ()) {
1097
1114
(*index)->ReportAudioStatusEvent (msg.status .getAudioMuteStatus (), msg.status .getAudioVolume ());
@@ -2393,6 +2410,13 @@ namespace WPEFramework
2393
2410
LOGINFO (" logicalAddress =%d , Audio device removed, Notify Device Settings" , logicalAddress );
2394
2411
2395
2412
hdmiCecAudioDeviceConnected = false ;
2413
+ if (m_audioStatusDetectionTimer.isActive ()){
2414
+ m_audioStatusDetectionTimer.stop ();
2415
+ }
2416
+ m_isAudioStatusInfoUpdated = false ;
2417
+ m_audioStatusReceived = false ;
2418
+ m_audioStatusTimerStarted = false ;
2419
+ LOGINFO (" Audio device removed, reset the audio status info. m_isAudioStatusInfoUpdated :%d, m_audioStatusReceived :%d, m_audioStatusTimerStarted:%d " , m_isAudioStatusInfoUpdated,m_audioStatusReceived,m_audioStatusTimerStarted);
2396
2420
while (index != _hdmiCecSourceNotifications.end ()) {
2397
2421
(*index)->ReportAudioDeviceConnectedStatus (" success" , " false" );
2398
2422
index++;
@@ -2642,29 +2666,44 @@ namespace WPEFramework
2642
2666
_instance->allocateLogicalAddress (DeviceType::TV);
2643
2667
if ( _instance->m_logicalAddressAllocated != LogicalAddress::UNREGISTERED)
2644
2668
{
2645
- logicalAddress = LogicalAddress (_instance->m_logicalAddressAllocated );
2646
- LibCCEC::getInstance ().addLogicalAddress (logicalAddress);
2647
- _instance->smConnection ->setSource (logicalAddress);
2648
- _instance->m_numberOfDevices = 0 ;
2649
- _instance->deviceList [_instance->m_logicalAddressAllocated ].m_deviceType = DeviceType::TV;
2650
- _instance->deviceList [_instance->m_logicalAddressAllocated ].m_isDevicePresent = true ;
2651
- _instance->deviceList [_instance->m_logicalAddressAllocated ].update (physical_addr);
2652
- _instance->deviceList [_instance->m_logicalAddressAllocated ].m_cecVersion = Version::V_1_4;
2653
- _instance->deviceList [_instance->m_logicalAddressAllocated ].m_vendorID = appVendorId;
2654
- _instance->deviceList [_instance->m_logicalAddressAllocated ].m_powerStatus = PowerStatus (powerState);
2655
- _instance->deviceList [_instance->m_logicalAddressAllocated ].m_currentLanguage = defaultLanguage;
2656
- _instance->deviceList [_instance->m_logicalAddressAllocated ].m_osdName = osdName.toString ().c_str ();
2657
- if (cecVersion == 2.0 ) {
2658
- _instance->deviceList [_instance->m_logicalAddressAllocated ].m_cecVersion = Version::V_2_0;
2659
- _instance->smConnection ->sendTo (LogicalAddress (LogicalAddress::BROADCAST),
2660
- MessageEncoder ().encode (ReportFeatures (Version::V_2_0,allDevicetype,rcProfile,deviceFeatures)), 500 );
2669
+ try {
2670
+
2671
+ logicalAddress = LogicalAddress (_instance->m_logicalAddressAllocated );
2672
+ LibCCEC::getInstance ().addLogicalAddress (logicalAddress);
2673
+ _instance->smConnection ->setSource (logicalAddress);
2674
+ _instance->m_numberOfDevices = 0 ;
2675
+ _instance->deviceList [_instance->m_logicalAddressAllocated ].m_deviceType = DeviceType::TV;
2676
+ _instance->deviceList [_instance->m_logicalAddressAllocated ].m_isDevicePresent = true ;
2677
+ _instance->deviceList [_instance->m_logicalAddressAllocated ].update (physical_addr);
2678
+ _instance->deviceList [_instance->m_logicalAddressAllocated ].m_cecVersion = Version::V_1_4;
2679
+ _instance->deviceList [_instance->m_logicalAddressAllocated ].m_vendorID = appVendorId;
2680
+ _instance->deviceList [_instance->m_logicalAddressAllocated ].m_powerStatus = PowerStatus (powerState);
2681
+ _instance->deviceList [_instance->m_logicalAddressAllocated ].m_currentLanguage = defaultLanguage;
2682
+ _instance->deviceList [_instance->m_logicalAddressAllocated ].m_osdName = osdName.toString ().c_str ();
2683
+ if (cecVersion == 2.0 ) {
2684
+ _instance->deviceList [_instance->m_logicalAddressAllocated ].m_cecVersion = Version::V_2_0;
2685
+ _instance->smConnection ->sendTo (LogicalAddress (LogicalAddress::BROADCAST),
2686
+ MessageEncoder ().encode (ReportFeatures (Version::V_2_0,allDevicetype,rcProfile,deviceFeatures)), 500 );
2687
+ }
2688
+ _instance->smConnection ->addFrameListener (_instance->msgFrameListener );
2689
+ _instance->smConnection ->sendTo (LogicalAddress (LogicalAddress::BROADCAST),
2690
+ MessageEncoder ().encode (ReportPhysicalAddress (physical_addr, _instance->deviceList [_instance->m_logicalAddressAllocated ].m_deviceType )), 100 );
2691
+
2692
+ _instance->m_sleepTime = 0 ;
2693
+ _instance->m_pollThreadState = POLL_THREAD_STATE_PING;
2694
+ }
2695
+ catch (InvalidStateException &e){
2696
+ LOGWARN (" InvalidStateException caught while allocated logical address. %s" , e.what ());
2697
+ _instance->m_pollThreadState = POLL_THREAD_STATE_EXIT;
2698
+ }
2699
+ catch (IOException &e){
2700
+ LOGWARN (" IOException caught while allocated logical address. %s" , e.what ());
2701
+ _instance->m_pollThreadState = POLL_THREAD_STATE_EXIT;
2702
+ }
2703
+ catch (...){
2704
+ LOGWARN (" Exception caught while allocated logical address." );
2705
+ _instance->m_pollThreadState = POLL_THREAD_STATE_EXIT;
2661
2706
}
2662
- _instance->smConnection ->addFrameListener (_instance->msgFrameListener );
2663
- _instance->smConnection ->sendTo (LogicalAddress (LogicalAddress::BROADCAST),
2664
- MessageEncoder ().encode (ReportPhysicalAddress (physical_addr, _instance->deviceList [_instance->m_logicalAddressAllocated ].m_deviceType )), 100 );
2665
-
2666
- _instance->m_sleepTime = 0 ;
2667
- _instance->m_pollThreadState = POLL_THREAD_STATE_PING;
2668
2707
}
2669
2708
else
2670
2709
{
@@ -2900,9 +2939,14 @@ namespace WPEFramework
2900
2939
{
2901
2940
LibCCEC::getInstance ().init (" HdmiCecSink" );
2902
2941
}
2903
- catch (const std::exception& e)
2904
- {
2905
- LOGWARN (" CEC exception caught from LibCCEC::getInstance().init()" );
2942
+ catch (InvalidStateException &e){
2943
+ LOGWARN (" InvalidStateException caught in LibCCEC::init %s" , e.what ());
2944
+ }
2945
+ catch (IOException &e){
2946
+ LOGWARN (" IOException caught in LibCCEC::init %s" , e.what ());
2947
+ }
2948
+ catch (...){
2949
+ LOGWARN (" Exception caught in LibCCEC::init" );
2906
2950
}
2907
2951
}
2908
2952
libcecInitStatus++;
@@ -2998,7 +3042,14 @@ namespace WPEFramework
2998
3042
}
2999
3043
3000
3044
m_logicalAddressAllocated = LogicalAddress::UNREGISTERED;
3001
- m_currentArcRoutingState = ARC_STATE_ARC_TERMINATED;
3045
+ m_currentArcRoutingState = ARC_STATE_ARC_TERMINATED;
3046
+ if (m_audioStatusDetectionTimer.isActive ()){
3047
+ m_audioStatusDetectionTimer.stop ();
3048
+ }
3049
+ m_isAudioStatusInfoUpdated = false ;
3050
+ m_audioStatusReceived = false ;
3051
+ m_audioStatusTimerStarted = false ;
3052
+ LOGINFO (" CEC Disabled, reset the audio status info. m_isAudioStatusInfoUpdated :%d, m_audioStatusReceived :%d, m_audioStatusTimerStarted:%d " , m_isAudioStatusInfoUpdated,m_audioStatusReceived,m_audioStatusTimerStarted);
3002
3053
3003
3054
for (int i=0 ; i< 16 ; i++)
3004
3055
{
@@ -3014,10 +3065,14 @@ namespace WPEFramework
3014
3065
{
3015
3066
LibCCEC::getInstance ().term ();
3016
3067
}
3017
- catch (const std::exception& e)
3018
- {
3019
- LOGWARN (" CEC exception caught from LibCCEC::getInstance().term() " );
3068
+ catch (InvalidStateException &e){
3069
+ LOGWARN (" InvalidStateException caught in LibCCEC::term %s" , e.what ());
3020
3070
}
3071
+ catch (IOException &e){
3072
+ LOGWARN (" IOException caught in LibCCEC::term %s" , e.what ());
3073
+ }
3074
+ catch (...){
3075
+ LOGWARN (" Exception caught in LibCCEC::term" );
3021
3076
}
3022
3077
3023
3078
libcecInitStatus--;
@@ -3253,12 +3308,45 @@ namespace WPEFramework
3253
3308
3254
3309
if ((_instance->m_SendKeyQueue .size ()<=1 || (_instance->m_SendKeyQueue .size () % 2 == 0 )) && ((keyInfo.keyCode == VOLUME_UP) || (keyInfo.keyCode == VOLUME_DOWN) || (keyInfo.keyCode == MUTE)) )
3255
3310
{
3256
- _instance->sendGiveAudioStatusMsg ();
3311
+ if (keyInfo.keyCode == MUTE)
3312
+ {
3313
+ _instance->sendGiveAudioStatusMsg ();
3314
+ }
3315
+ else
3316
+ {
3317
+ LOGINFO (" m_isAudioStatusInfoUpdated :%d, m_audioStatusReceived :%d, m_audioStatusTimerStarted:%d " ,_instance->m_isAudioStatusInfoUpdated ,_instance->m_audioStatusReceived ,_instance->m_audioStatusTimerStarted );
3318
+ if (!_instance->m_isAudioStatusInfoUpdated )
3319
+ {
3320
+ if ( !(_instance->m_audioStatusDetectionTimer .isActive ()))
3321
+ {
3322
+ LOGINFO (" Audio status info not updated. Starting the Timer!" );
3323
+ _instance->m_audioStatusTimerStarted = true ;
3324
+ _instance->m_audioStatusDetectionTimer .start ((HDMICECSINK_UPDATE_AUDIO_STATUS_INTERVAL_MS));
3325
+ }
3326
+ LOGINFO (" m_isAudioStatusInfoUpdated :%d, m_audioStatusReceived :%d, m_audioStatusTimerStarted:%d " , _instance->m_isAudioStatusInfoUpdated ,_instance->m_audioStatusReceived ,_instance->m_audioStatusTimerStarted );
3327
+ }
3328
+ else
3329
+ {
3330
+ if (!_instance->m_audioStatusReceived ){
3331
+ _instance->sendGiveAudioStatusMsg ();
3332
+ }
3333
+ }
3334
+ }
3335
+ }
3257
3336
}
3258
3337
3259
3338
}// while(!_instance->m_sendKeyEventThreadExit)
3260
3339
}// threadSendKeyEvent
3261
3340
3341
+ void HdmiCecSinkImplementation::audioStatusTimerFunction ()
3342
+ {
3343
+ m_audioStatusTimerStarted = false ;
3344
+ m_isAudioStatusInfoUpdated = true ;
3345
+ LOGINFO (" Timer Expired. Requesting the AudioStatus since not received.\n " );
3346
+ sendGiveAudioStatusMsg ();
3347
+ LOGINFO (" m_isAudioStatusInfoUpdated :%d, m_audioStatusReceived :%d, m_audioStatusTimerStarted:%d " , m_isAudioStatusInfoUpdated,m_audioStatusReceived,m_audioStatusTimerStarted);
3348
+ }
3349
+
3262
3350
3263
3351
void HdmiCecSinkImplementation::threadArcRouting ()
3264
3352
{
@@ -3269,7 +3357,7 @@ namespace WPEFramework
3269
3357
return ;
3270
3358
3271
3359
LOGINFO (" Running threadArcRouting" );
3272
-
3360
+ _instance-> getHdmiArcPortID ();
3273
3361
3274
3362
while (1 )
3275
3363
{
0 commit comments