[xiph-commits] r3095 - liboggplay/trunk/plugin/audio
tahn at svn.annodex.net
tahn at svn.annodex.net
Wed Jun 27 02:47:55 PDT 2007
Author: tahn
Date: 2007-06-27 02:47:54 -0700 (Wed, 27 Jun 2007)
New Revision: 3095
Modified:
liboggplay/trunk/plugin/audio/sydney_audio_mac.c
liboggplay/trunk/plugin/audio/sydney_audio_new.h
Log:
Implemented volume handling, using some non-standard extension functions.
Modified: liboggplay/trunk/plugin/audio/sydney_audio_mac.c
===================================================================
--- liboggplay/trunk/plugin/audio/sydney_audio_mac.c 2007-06-27 09:46:33 UTC (rev 3094)
+++ liboggplay/trunk/plugin/audio/sydney_audio_mac.c 2007-06-27 09:47:54 UTC (rev 3095)
@@ -349,7 +349,9 @@
* the audio callback function to slurp some more data up.
*/
if (nbytes > 0 && s->n_bufs == BUF_LIMIT) {
- printf("TOO MUCH DATA\n");
+#ifdef TIMING_TRACE
+ printf("#"); /* too much audio data */
+#endif
if (!s->playing) {
/*
* We haven't even started playing yet! That means the
@@ -357,6 +359,7 @@
* do here; spinning won't help because the audio callback
* hasn't been enabled yet. Oh well, error time.
*/
+ printf("Too much audio data received before audio device enabled!\n");
result = SA_ERROR_SYSTEM;
break;
}
@@ -412,7 +415,7 @@
) {
#ifdef TIMING_TRACE
- printf(".");
+ printf("."); /* audio read 'tick' */
#endif
/*
@@ -471,7 +474,7 @@
sa_buf * next = s->bl_head->next;
if (next == NULL) {
#ifdef TIMING_TRACE
- printf("!");
+ printf("!"); /* not enough audio data */
#endif
memset(dst, 0, bytes_to_copy);
break;
@@ -539,57 +542,6 @@
int
-sa_stream_change_write_volume(sa_stream_t *s, const int32_t vol[], unsigned int n) {
-//!todo
- if (s == NULL || s->output_unit == NULL) {
- return SA_ERROR_NO_INIT;
- }
- if (n != 1) {
- return SA_ERROR_NOT_SUPPORTED;
- }
-
- pthread_mutex_lock(&s->mutex);
-
- Float32 volume = 0;
- AudioUnitGetParameter(s->output_unit, kHALOutputParam_Volume,
- kAudioUnitParameterFlag_Output, 0, &volume);
-
- /*
- * The vol parameter is in hundredths of dB. If our current volume
- * is the reference level, we can calculate the new volume by
- * applying a factor of 10^(dB/20).
- */
- volume *= pow(10, (double)vol[0] / 2000);
-
- AudioUnitSetParameter(s->output_unit, kHALOutputParam_Volume,
- kAudioUnitParameterFlag_Output, 0, volume, 0);
- printf("set_vol: %f\n", volume);
-
- pthread_mutex_unlock(&s->mutex);
- return SA_SUCCESS;
-}
-
-
-int
-sa_stream_get_write_volume(sa_stream_t *s, int32_t vol[], unsigned int *n) {
-//!todo
- if (s == NULL || s->output_unit == NULL) {
- return SA_ERROR_NO_INIT;
- }
-
- pthread_mutex_lock(&s->mutex);
-
- Float32 volume;
- AudioUnitGetParameter(s->output_unit, kHALOutputParam_Volume,
- kAudioUnitParameterFlag_Output, 0, &volume);
- printf("get_vol: %f\n", volume);
-
- pthread_mutex_unlock(&s->mutex);
- return SA_SUCCESS;
-}
-
-
-int
sa_stream_pause(sa_stream_t *s) {
if (s == NULL || s->output_unit == NULL) {
@@ -640,6 +592,45 @@
/*
* -----------------------------------------------------------------------------
+ * Extension functions
+ * -----------------------------------------------------------------------------
+ */
+
+int
+sa_stream_set_volume_abs(sa_stream_t *s, float vol) {
+
+ if (s == NULL || s->output_unit == NULL) {
+ return SA_ERROR_NO_INIT;
+ }
+
+ pthread_mutex_lock(&s->mutex);
+ AudioUnitSetParameter(s->output_unit, kHALOutputParam_Volume,
+ kAudioUnitParameterFlag_Output, 0, vol, 0);
+ pthread_mutex_unlock(&s->mutex);
+ return SA_SUCCESS;
+}
+
+
+int
+sa_stream_get_volume_abs(sa_stream_t *s, float *vol) {
+
+ if (s == NULL || s->output_unit == NULL) {
+ return SA_ERROR_NO_INIT;
+ }
+
+ pthread_mutex_lock(&s->mutex);
+ Float32 local_vol = 0;
+ AudioUnitGetParameter(s->output_unit, kHALOutputParam_Volume,
+ kAudioUnitParameterFlag_Output, 0, &local_vol);
+ *vol = local_vol;
+ pthread_mutex_unlock(&s->mutex);
+ return SA_SUCCESS;
+}
+
+
+
+/*
+ * -----------------------------------------------------------------------------
* Unsupported functions
* -----------------------------------------------------------------------------
*/
@@ -659,6 +650,7 @@
UNSUPPORTED(int sa_stream_stop_thread(sa_stream_t *s))
UNSUPPORTED(int sa_stream_change_device(sa_stream_t *s, const char *device_name))
UNSUPPORTED(int sa_stream_change_read_volume(sa_stream_t *s, const int32_t vol[], unsigned int n))
+UNSUPPORTED(int sa_stream_change_write_volume(sa_stream_t *s, const int32_t vol[], unsigned int n))
UNSUPPORTED(int sa_stream_change_rate(sa_stream_t *s, unsigned int rate))
UNSUPPORTED(int sa_stream_change_meta_data(sa_stream_t *s, const char *name, const void *data, size_t size))
UNSUPPORTED(int sa_stream_change_user_data(sa_stream_t *s, const void *value))
@@ -683,6 +675,7 @@
UNSUPPORTED(int sa_stream_get_driver(sa_stream_t *s, char *driver_name, size_t *size))
UNSUPPORTED(int sa_stream_get_device(sa_stream_t *s, char *device_name, size_t *size))
UNSUPPORTED(int sa_stream_get_read_volume(sa_stream_t *s, int32_t vol[], unsigned int *n))
+UNSUPPORTED(int sa_stream_get_write_volume(sa_stream_t *s, int32_t vol[], unsigned int *n))
UNSUPPORTED(int sa_stream_get_meta_data(sa_stream_t *s, const char *name, void*data, size_t *size))
UNSUPPORTED(int sa_stream_get_adjust_rate(sa_stream_t *s, sa_adjust_t *direction))
UNSUPPORTED(int sa_stream_get_adjust_nchannels(sa_stream_t *s, sa_adjust_t *direction))
Modified: liboggplay/trunk/plugin/audio/sydney_audio_new.h
===================================================================
--- liboggplay/trunk/plugin/audio/sydney_audio_new.h 2007-06-27 09:46:33 UTC (rev 3094)
+++ liboggplay/trunk/plugin/audio/sydney_audio_new.h 2007-06-27 09:47:54 UTC (rev 3095)
@@ -402,4 +402,11 @@
/** Return a human readable error */
const char *sa_strerror(int code);
+/* Extensions */
+int
+sa_stream_set_volume_abs(sa_stream_t *s, float vol);
+
+int
+sa_stream_get_volume_abs(sa_stream_t *s, float *vol);
+
#endif
More information about the commits
mailing list