From 9ec91d0a5d726ee1e3453e37b40279a2cebc9ab6 Mon Sep 17 00:00:00 2001 From: Memphiz Date: Thu, 14 Mar 2013 21:17:43 +0100 Subject: [PATCH 1/2] [depends/libshairport] - add volume control and AudioOutput struct versioning --- .../libshairport/012_add_volume_control.patch | 28 +++++++++++++++++++ tools/depends/target/libshairport/Makefile | 1 + 2 files changed, 29 insertions(+) create mode 100644 tools/depends/target/libshairport/012_add_volume_control.patch diff --git a/tools/depends/target/libshairport/012_add_volume_control.patch b/tools/depends/target/libshairport/012_add_volume_control.patch new file mode 100644 index 0000000000000..c036b94c6e301 --- /dev/null +++ b/tools/depends/target/libshairport/012_add_volume_control.patch @@ -0,0 +1,28 @@ +--- src/ao.h 2013-03-14 19:07:04.000000000 +0100 ++++ src/ao.h 2013-03-14 20:45:15.000000000 +0100 +@@ -141,6 +141,7 @@ + + #endif /* __AO_H__ */ + ++#define SHAIRPORT_AUDIOOUTPUT_VERSION 2 + extern struct AudioOutput g_ao; + struct AudioOutput + { +@@ -155,4 +156,5 @@ + char* (*ao_get_option)(ao_option *, const char* ); + void (*ao_set_metadata)(const char *buffer, unsigned int size); + void (*ao_set_metadata_coverart)(const char *buffer, unsigned int size); ++ void (*ao_set_volume)(float volume); + }; +diff -uPr orig/src/hairtunes.c macosx10.6_i386-target/src/hairtunes.c +--- src/hairtunes.c 2013-03-14 19:07:04.000000000 +0100 ++++ src/hairtunes.c 2013-03-14 20:46:33.000000000 +0100 +@@ -265,6 +265,8 @@ + assert(f<=0); + if (debug) + xprintf("VOL: %lf\n", f); ++ if (g_ao.ao_set_volume) ++ g_ao.ao_set_volume(f); + volume = pow(10.0,0.05*f); + fix_volume = 65536.0 * volume; + } diff --git a/tools/depends/target/libshairport/Makefile b/tools/depends/target/libshairport/Makefile index bb553bf3a88b5..03016ca5da4da 100644 --- a/tools/depends/target/libshairport/Makefile +++ b/tools/depends/target/libshairport/Makefile @@ -36,6 +36,7 @@ $(PLATFORM): $(TARBALLS_LOCATION)/$(ARCHIVE) $(DEPS) cd $(PLATFORM); patch -p0 < ../010_handle_metadata.patch cd $(PLATFORM); patch -p0 < ../011_fix_ipv4_fallback.patch cd $(PLATFORM); patch -p0 < ../android.patch + cd $(PLATFORM); patch -p0 < ../012_add_volume_control.patch cd $(PLATFORM); $(AUTORECONF) -vif cd $(PLATFORM); $(CONFIGURE) From 664493da639ac873fb3b6501901982ec305d755a Mon Sep 17 00:00:00 2001 From: Memphiz Date: Thu, 14 Mar 2013 21:18:39 +0100 Subject: [PATCH 2/2] [airtunes] - add volume contro for airtunes using libshairport (same like we already do on windows using libshairplay) --- xbmc/network/AirTunesServer.cpp | 16 ++++++++++++++++ xbmc/network/AirTunesServer.h | 1 + 2 files changed, 17 insertions(+) diff --git a/xbmc/network/AirTunesServer.cpp b/xbmc/network/AirTunesServer.cpp index 49121fedf5143..9973c78ea7f09 100644 --- a/xbmc/network/AirTunesServer.cpp +++ b/xbmc/network/AirTunesServer.cpp @@ -288,6 +288,17 @@ void CAirTunesServer::AudioOutputFunctions::ao_initialize(void) { } +void CAirTunesServer::AudioOutputFunctions::ao_set_volume(float volume) +{ + //volume from -30 - 0 - -144 means mute + float volPercent = volume < -30.0f ? 0 : 1 - volume/-30; +#ifdef HAS_AIRPLAY + CAirPlayServer::backupVolume(); +#endif + g_application.SetVolume(volPercent, false);//non-percent volume 0.0-1.0 +} + + int CAirTunesServer::AudioOutputFunctions::ao_play(ao_device *device, char *output_samples, uint32_t num_bytes) { if (!device) @@ -675,6 +686,11 @@ bool CAirTunesServer::Initialize(const CStdString &password) #ifdef HAVE_STRUCT_AUDIOOUTPUT_AO_SET_METADATA ao.ao_set_metadata = AudioOutputFunctions::ao_set_metadata; ao.ao_set_metadata_coverart = AudioOutputFunctions::ao_set_metadata_coverart; +#endif +#if defined(SHAIRPORT_AUDIOOUTPUT_VERSION) +#if SHAIRPORT_AUDIOOUTPUT_VERSION >= 2 + ao.ao_set_volume = AudioOutputFunctions::ao_set_volume; +#endif #endif struct printfPtr funcPtr; funcPtr.extprintf = shairport_log; diff --git a/xbmc/network/AirTunesServer.h b/xbmc/network/AirTunesServer.h index 62ff7f09932db..3525133604ce7 100644 --- a/xbmc/network/AirTunesServer.h +++ b/xbmc/network/AirTunesServer.h @@ -86,6 +86,7 @@ class CAirTunesServer : public CThread static void audio_destroy(void *cls, void *session); #else static void ao_initialize(void); + static void ao_set_volume(float volume); static int ao_play(ao_device *device, char *output_samples, uint32_t num_bytes); static int ao_default_driver_id(void); static ao_device* ao_open_live( int driver_id, ao_sample_format *format,