Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

[AirTunes] - add volume control using libshairport #2439

Merged
merged 2 commits into from

4 participants

@Memphiz
Owner

This adds volume control when using libshairport (all platforms beside windows). We do the same on windows (utilising libshairplay) already and this should sync up the feature on all platforms.

Upstream libshairport (used for linux distributions and maintained by amejia) got a PR for the libshairport change aswell.

@davilla

what is this android.patch with no prepended number ? can't we follow convention ? The others have numbers for a reason, there is an implied order.

Owner

ponks @theuni :p

Owner

It was originally a hack that was only safe for android, so it had to be special-cased when patched. That's not the case anymore. Will make it 013.

@Memphiz
Owner

queued for april

@Memphiz Memphiz was assigned
@MartijnKaijser MartijnKaijser merged commit 40a87ac into from
@Memphiz
Owner

@wsnipex - this needs a libshairport bump for linux. You would need to compile it from amejia1 tree with this pr applied.

amejia1/libshairport#4

@amejia1 - please merge this pr into your tree ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 14, 2013
  1. @Memphiz
  2. @Memphiz

    [airtunes] - add volume contro for airtunes using libshairport (same …

    Memphiz authored
    …like we already do on windows using libshairplay)
This page is out of date. Refresh to see the latest.
View
28 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;
+ }
View
1  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)
View
16 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)
@@ -676,6 +687,11 @@ bool CAirTunesServer::Initialize(const CStdString &password)
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;
View
1  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,
Something went wrong with that request. Please try again.