summaryrefslogtreecommitdiffstats
path: root/libao2
diff options
context:
space:
mode:
authoratmos4 <atmos4@b3059339-0415-0410-9bf9-f77b7e298cf2>2002-05-25 11:08:53 +0000
committeratmos4 <atmos4@b3059339-0415-0410-9bf9-f77b7e298cf2>2002-05-25 11:08:53 +0000
commitaefac09349bb9094eb73b1361f41922d4ebfbda4 (patch)
tree3e26bdfd234a7dd951c089f428749a1faabf7d4f /libao2
parent0a581e3bf3cb184be828b58a2c6bbd64a568a4d8 (diff)
downloadmpv-aefac09349bb9094eb73b1361f41922d4ebfbda4.tar.bz2
mpv-aefac09349bb9094eb73b1361f41922d4ebfbda4.tar.xz
Add volume control, patch by
Colin Leroy <colin at colino.net> git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@6185 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libao2')
-rw-r--r--libao2/ao_sdl.c24
1 files changed, 20 insertions, 4 deletions
diff --git a/libao2/ao_sdl.c b/libao2/ao_sdl.c
index ab00cdd24d..4a70a59560 100644
--- a/libao2/ao_sdl.c
+++ b/libao2/ao_sdl.c
@@ -16,6 +16,7 @@
#include "audio_out.h"
#include "audio_out_internal.h"
#include "afmt.h"
+#include <SDL.h>
#include "../libvo/fastmemcpy.h"
@@ -46,7 +47,7 @@ static unsigned int buf_read=0;
static unsigned int buf_write=0;
static unsigned int buf_read_pos=0;
static unsigned int buf_write_pos=0;
-
+static unsigned int volume=127;
static int full_buffers=0;
static int buffered_bytes=0;
@@ -79,6 +80,7 @@ static int read_buffer(unsigned char* data,int len){
x=BUFFSIZE-buf_read_pos;
if(x>len) x=len;
memcpy(data+len2,buffer[buf_read]+buf_read_pos,x);
+ SDL_MixAudio(data+len2, data+len2, x, volume);
len2+=x; len-=x;
buffered_bytes-=x; buf_read_pos+=x;
if(buf_read_pos>=BUFFSIZE){
@@ -93,8 +95,6 @@ static int read_buffer(unsigned char* data,int len){
// end ring buffer stuff
-#include <SDL.h>
-
#if defined(sun) && defined(__svr4__)
/* setenv is missing on solaris */
static void setenv(const char *name, const char *val, int _xx)
@@ -114,7 +114,23 @@ static void setenv(const char *name, const char *val, int _xx)
// to set/get/query special features/parameters
static int control(int cmd,int arg){
- return -1;
+ switch (cmd) {
+ case AOCONTROL_GET_VOLUME:
+ {
+ ao_control_vol_t* vol = (ao_control_vol_t*)arg;
+ vol->left = vol->right = (float)((volume + 127)/2.55);
+ return CONTROL_OK;
+ }
+ case AOCONTROL_SET_VOLUME:
+ {
+ float diff;
+ ao_control_vol_t* vol = (ao_control_vol_t*)arg;
+ diff = (vol->left+vol->right) / 2;
+ volume = (int)(diff * 2.55) - 127;
+ return CONTROL_OK;
+ }
+ }
+ return -1;
}
// SDL Callback function