summaryrefslogtreecommitdiff
path: root/indra/media_plugins
diff options
context:
space:
mode:
authorCallum Linden <callum@lindenlab.com>2016-07-15 12:18:00 -0700
committerCallum Linden <callum@lindenlab.com>2016-07-15 12:18:00 -0700
commit1c4dbc64abc7ff176b5dcbbc64d0454968efad74 (patch)
tree62a86f42cf5d062da675625d0242127e5865b58f /indra/media_plugins
parent8ae7828643fbb04a52a52abefa2133a761dd4179 (diff)
MAINT-6577 FIX No sound in MOAP or browser video
Diffstat (limited to 'indra/media_plugins')
-rw-r--r--indra/media_plugins/libvlc/media_plugin_libvlc.cpp42
1 files changed, 33 insertions, 9 deletions
diff --git a/indra/media_plugins/libvlc/media_plugin_libvlc.cpp b/indra/media_plugins/libvlc/media_plugin_libvlc.cpp
index e00602bad8..8ef4ee2a27 100644
--- a/indra/media_plugins/libvlc/media_plugin_libvlc.cpp
+++ b/indra/media_plugins/libvlc/media_plugin_libvlc.cpp
@@ -54,6 +54,7 @@ class MediaPluginLibVLC :
void initVLC();
void playMedia();
void resetVLC();
+ void setVolume(const F64 volume);
static void* lock(void* data, void** p_pixels);
static void unlock(void* data, void* id, void* const* raw_pixels);
@@ -72,6 +73,7 @@ class MediaPluginLibVLC :
struct gVLCContext gVLCCallbackContext;
std::string mURL;
+ F64 mCurVolume;
};
////////////////////////////////////////////////////////////////////////////////
@@ -90,6 +92,8 @@ MediaPluginLibVLC::MediaPluginLibVLC( LLPluginInstance::sendMessageFunction host
gLibVLCMedia = 0;
gLibVLCMediaPlayer = 0;
+ mCurVolume = 0.0;
+
mURL = std::string();
}
@@ -200,10 +204,10 @@ void MediaPluginLibVLC::playMedia()
message_begin.setValueBoolean("history_forward_available", false);
sendMessage(message_begin);
- // volume should be initialized - when media is in range, the distance based attenuation
- // will set the correct value
- // https://jira.secondlife.com/browse/MAINT-6527
- libvlc_audio_set_volume(gLibVLCMediaPlayer, 0);
+ // volume level gets set before VLC is initialized (thanks media system) so we have to record
+ // it in mCurVolume and set it again here so that volume levels are correctly initialized
+ setVolume(mCurVolume);
+
libvlc_video_set_callbacks(gLibVLCMediaPlayer, lock, unlock, display, &gVLCCallbackContext);
libvlc_video_set_format(gLibVLCMediaPlayer, "RV32", mWidth, mHeight, mWidth * mDepth);
libvlc_media_player_play(gLibVLCMediaPlayer);
@@ -222,6 +226,28 @@ void MediaPluginLibVLC::playMedia()
////////////////////////////////////////////////////////////////////////////////
//
+void MediaPluginLibVLC::setVolume(const F64 volume)
+{
+ mCurVolume = volume;
+
+ if (gLibVLCMediaPlayer)
+ {
+ int result = libvlc_audio_set_volume(gLibVLCMediaPlayer, (int)(volume * 100));
+ if (result != 0)
+ {
+ // volume wasn't set but not much to be done here
+ }
+ }
+ else
+ {
+ // volume change was requested but VLC wasn't ready.
+ // that's okay thought because we saved the value in mCurVolume and
+ // the next volume change after the VLC system is initilzied will set it
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////
+//
void MediaPluginLibVLC::receiveMessage( const char* message_string )
{
LLPluginMessage message_in;
@@ -388,11 +414,9 @@ void MediaPluginLibVLC::receiveMessage( const char* message_string )
}
else if (message_name == "set_volume")
{
- if (gLibVLCMediaPlayer)
- {
- F64 volume = message_in.getValueReal("volume");
- libvlc_audio_set_volume(gLibVLCMediaPlayer, (int)(volume * 100));
- }
+ // volume comes in 0 -> 1.0
+ F64 volume = message_in.getValueReal("volume");
+ setVolume(volume);
}
}
}