[xiph-commits] r3100 - liboggplay/trunk/plugin

shans at svn.annodex.net shans at svn.annodex.net
Wed Jun 27 18:24:33 PDT 2007


Author: shans
Date: 2007-06-27 18:24:33 -0700 (Wed, 27 Jun 2007)
New Revision: 3100

Modified:
   liboggplay/trunk/plugin/plugin_gui_linux.c
Log:
Volume changing in linux.  This is somewhat faked (I scale the audio data
directly to avoid modifying the global volume) 



Modified: liboggplay/trunk/plugin/plugin_gui_linux.c
===================================================================
--- liboggplay/trunk/plugin/plugin_gui_linux.c	2007-06-28 01:12:19 UTC (rev 3099)
+++ liboggplay/trunk/plugin/plugin_gui_linux.c	2007-06-28 01:24:33 UTC (rev 3100)
@@ -70,6 +70,7 @@
   gboolean	            tried_audio;
   int64_t               playback_target;
   nsPluginInstance    * pluginInstance;
+  float                 volume;
  } PluginWindowInfo;
 
 void
@@ -205,6 +206,15 @@
 calc_offset:
   
   if (info->audio_opened == TRUE) {
+    /* apply volume */
+    if (frame_data.size > 0 && info->volume < 1.0) {
+      short * samples = (short *)frame_data.samples;
+      int     i;
+      for (i = 0; i < frame_data.size/sizeof(short); i ++) {
+        samples[i] *= info->volume;
+      }
+    }
+
   	/* buffer audio */
   	if 
     (
@@ -340,6 +350,7 @@
   // set depending on the plugin startup settings
   info->playback_state = PLAYING; 
   info->playback_finished = FALSE;
+  info->volume = 1.0;
   /*
    * create semaphore to lock replacement of oggplay object
    */
@@ -435,13 +446,20 @@
 
 void
 gui_set_volume(void *handle, float volume) {
-//!todo
+  PluginWindowInfo  * info = (PluginWindowInfo *)handle;
+  if (volume > 1.0) {
+    volume = 1.0;
+  }
+  if (volume < 0.0) {
+    volume = 0.0;
+  }
+  info->volume = volume;
 }
 
 float
 gui_get_volume(void *handle) {
-//!todo
-  return 0.0f;
+  PluginWindowInfo  * info = (PluginWindowInfo *)handle;
+  return info->volume;
 }
 
 long



More information about the commits mailing list