[vlc-commits] chromecast: send the volume and mute status in one command

Steve Lhomme git at videolan.org
Tue Aug 9 11:28:50 CEST 2016


vlc | branch: master | Steve Lhomme <robux4 at videolabs.io> | Tue Aug  9 08:38:40 2016 +0200| [7c79ab50e09265040104746bb224bd354c5c24f5] | committer: Jean-Baptiste Kempf

chromecast: send the volume and mute status in one command

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=7c79ab50e09265040104746bb224bd354c5c24f5
---

 modules/stream_out/chromecast/chromecast.h        |  3 +--
 modules/stream_out/chromecast/chromecast_ctrl.cpp | 28 ++++-------------------
 2 files changed, 5 insertions(+), 26 deletions(-)

diff --git a/modules/stream_out/chromecast/chromecast.h b/modules/stream_out/chromecast/chromecast.h
index 0b46a93..f203643 100644
--- a/modules/stream_out/chromecast/chromecast.h
+++ b/modules/stream_out/chromecast/chromecast.h
@@ -150,8 +150,7 @@ private:
     void msgPlayerPause();
     void msgPlayerGetStatus();
     void msgPlayerSeek(const std::string & currentTime);
-    void msgPlayerSetVolume(float volume);
-    void msgPlayerSetMute(bool mute);
+    void msgPlayerSetVolume(float volume, bool mute);
 
     void processMessage(const castchannel::CastMessage &msg);
 
diff --git a/modules/stream_out/chromecast/chromecast_ctrl.cpp b/modules/stream_out/chromecast/chromecast_ctrl.cpp
index eff06eb..77068ea 100644
--- a/modules/stream_out/chromecast/chromecast_ctrl.cpp
+++ b/modules/stream_out/chromecast/chromecast_ctrl.cpp
@@ -582,10 +582,7 @@ void intf_sys_t::processMessage(const castchannel::CastMessage &msg)
                     }
                     m_time_playback_started = VLC_TS_INVALID;
                     if (!mediaSessionId.empty())
-                    {
-                        msgPlayerSetMute( var_InheritBool( p_module, "mute" ) );
-                        msgPlayerSetVolume( var_InheritFloat( p_module, "volume" ) );
-                    }
+                        msgPlayerSetVolume( var_InheritFloat( p_module, "volume" ), var_InheritBool( p_module, "mute" ) );
                     break;
 
                 case RECEIVER_PLAYING:
@@ -603,10 +600,7 @@ void intf_sys_t::processMessage(const castchannel::CastMessage &msg)
 
                 case RECEIVER_PAUSED:
                     if (!mediaSessionId.empty())
-                    {
-                        msgPlayerSetMute( var_InheritBool( p_module, "mute" ) );
-                        msgPlayerSetVolume( var_InheritFloat( p_module, "volume" ) );
-                    }
+                        msgPlayerSetVolume( var_InheritFloat( p_module, "volume" ), var_InheritBool( p_module, "mute" ) );
 
                     m_chromecast_start_time = (1 + mtime_t( double( status[0]["currentTime"] ) ) ) * 1000000L;
 #ifndef NDEBUG
@@ -854,7 +848,7 @@ void intf_sys_t::msgPlayerPause()
     pushMediaPlayerMessage( ss );
 }
 
-void intf_sys_t::msgPlayerSetVolume(float f_volume)
+void intf_sys_t::msgPlayerSetVolume(float f_volume, bool b_mute)
 {
     assert(!mediaSessionId.empty());
 
@@ -863,21 +857,7 @@ void intf_sys_t::msgPlayerSetVolume(float f_volume)
 
     std::stringstream ss;
     ss << "{\"type\":\"SET_VOLUME\","
-       <<  "\"volume\":{\"level\":" << f_volume << "},"
-       <<  "\"mediaSessionId\":" << mediaSessionId << ","
-       <<  "\"requestId\":" << i_requestId++
-       << "}";
-
-    pushMediaPlayerMessage( ss );
-}
-
-void intf_sys_t::msgPlayerSetMute(bool b_mute)
-{
-    assert(!mediaSessionId.empty());
-
-    std::stringstream ss;
-    ss << "{\"type\":\"SET_VOLUME\","
-       <<  "\"volume\":{\"muted\":" << ( b_mute ? "true" : "false" ) << "},"
+       <<  "\"volume\":{\"level\":" << f_volume << ",\"muted\":" << ( b_mute ? "true" : "false" ) << "},"
        <<  "\"mediaSessionId\":" << mediaSessionId << ","
        <<  "\"requestId\":" << i_requestId++
        << "}";



More information about the vlc-commits mailing list