[xiph-commits] r3099 - liboggplay/trunk/plugin/audio
laser13 at svn.annodex.net
laser13 at svn.annodex.net
Wed Jun 27 18:12:19 PDT 2007
Author: laser13
Date: 2007-06-27 18:12:19 -0700 (Wed, 27 Jun 2007)
New Revision: 3099
Modified:
liboggplay/trunk/plugin/audio/sydney_audio_waveapi.c
Log:
Win32 Sydney audio volume set/get functions implemented.
Modified: liboggplay/trunk/plugin/audio/sydney_audio_waveapi.c
===================================================================
--- liboggplay/trunk/plugin/audio/sydney_audio_waveapi.c 2007-06-27 13:41:17 UTC (rev 3098)
+++ liboggplay/trunk/plugin/audio/sydney_audio_waveapi.c 2007-06-28 01:12:19 UTC (rev 3099)
@@ -99,6 +99,9 @@
return SA_ERROR_NO_INIT; \
}
+#define LEFT_CHANNEL_MASK 0x0000FFFF
+#define RIGHT_CHANNEL_MASK 0xFFFF0000
+
/* local implementation of the sa_stream_t type */
struct sa_stream {
char* deviceName;
@@ -211,15 +214,44 @@
/** volume in hundreths of dB*/
int sa_stream_get_write_volume(sa_stream_t *s, int32_t vol[], unsigned int *n) {
+ int status;
+ DWORD volume;
+ WORD left;
+ WORD right;
+
ERROR_IF_NO_INIT(s);
+ status = waveOutGetVolume(s->hWaveOut, &volume);
+ HANDLE_WAVE_ERROR(status, "reading audio volume level");
+
+ left = volume & LEFT_CHANNEL_MASK;
+ right = (volume & RIGHT_CHANNEL_MASK) >> 16;
+ //printf("Volume level is on the left channel %d, on the right %d\n", left, right);
+ vol[0] = (int32_t)(left + right /2);
+
return SA_SUCCESS;
}
/** volume in hundreths of dB*/
int sa_stream_change_write_volume(sa_stream_t *s, const int32_t vol[], unsigned int n) {
+ int status;
+ DWORD volume;
+ WORD left;
+ WORD right;
+
ERROR_IF_NO_INIT(s);
+
+ volume = vol[0] * 65535;
+ //printf("Volume %d\n", volume);
+ left = volume & LEFT_CHANNEL_MASK;
+ //printf("Volume low bits %d\n", left);
+ right = left << 16;
+ //printf("Volume high bits %d\n", right);
+ volume = right | left;
+
+ status = waveOutSetVolume(s->hWaveOut, volume);
+ HANDLE_WAVE_ERROR(status, "setting new audio volume level");
return SA_SUCCESS;
More information about the commits
mailing list