diff options
author | Simon Busch <morphis@gravedo.de> | 2011-03-15 10:31:59 +0100 |
---|---|---|
committer | Simon Busch <morphis@gravedo.de> | 2011-03-15 10:31:59 +0100 |
commit | 46c1fa92304f003988f4af355c538deedb3a204c (patch) | |
tree | 55c2c6ca10b50735cc33e4c9c6c6a8fcb381a61b | |
parent | 8c7a3c536e314e8787afd87f054ea72cf002a7d9 (diff) | |
download | cornucopia-46c1fa92304f003988f4af355c538deedb3a204c.tar.gz cornucopia-46c1fa92304f003988f4af355c538deedb3a204c.tar.bz2 cornucopia-46c1fa92304f003988f4af355c538deedb3a204c.zip |
fsoaudiod: implement new pull/push methods for device changing
-rw-r--r-- | fsoaudiod/configure.ac | 2 | ||||
-rw-r--r-- | fsoaudiod/src/plugins/manager/plugin.vala | 38 |
2 files changed, 36 insertions, 4 deletions
diff --git a/fsoaudiod/configure.ac b/fsoaudiod/configure.ac index 3ca014a7..c42671cb 100644 --- a/fsoaudiod/configure.ac +++ b/fsoaudiod/configure.ac @@ -21,7 +21,7 @@ AC_SUBST(LDFLAGS) GLIB_REQUIRED=2.26.0 GEE_REQUIRED=0.5.0 -FSO_GLIB_REQUIRED=2011.02.01.1 +FSO_GLIB_REQUIRED=2011.03.15.1 FSO_REQUIRED=0.2.3 ALSA_REQUIRED=0.20 diff --git a/fsoaudiod/src/plugins/manager/plugin.vala b/fsoaudiod/src/plugins/manager/plugin.vala index a485dfc8..f873f232 100644 --- a/fsoaudiod/src/plugins/manager/plugin.vala +++ b/fsoaudiod/src/plugins/manager/plugin.vala @@ -98,6 +98,7 @@ namespace FsoAudio private DeviceInfo[] devices; private FreeSmartphone.Audio.Device[] default_devices; private FreeSmartphone.Audio.Device[] current_devices; + private GLib.Queue<FreeSmartphone.Audio.Device> device_stack; public Manager( FsoFramework.Subsystem subsystem ) { @@ -144,6 +145,8 @@ namespace FsoAudio this.routertype = typename; } + device_stack = new GLib.Queue<FreeSmartphone.Audio.Device>(); + devices = new DeviceInfo[] { new DeviceInfo( FreeSmartphone.Audio.Device.BACKSPEAKER ), new DeviceInfo( FreeSmartphone.Audio.Device.FRONTSPEAKER ), @@ -264,6 +267,9 @@ namespace FsoAudio assert( logger.debug( @"Switching mode: $(current_mode) -> $(mode)" ) ); + // we reset the complete device stack for push/pull when the mode changes + device_stack.clear(); + var previous_mode = current_mode; current_mode = mode; @@ -288,18 +294,44 @@ namespace FsoAudio var supported_devices = router.get_available_devices( current_mode ); if ( !( device in supported_devices ) ) { - throw new FreeSmartphone.Error.UNSUPPORTED( "The supplied audio device is not supported by the current router" ); + throw new FreeSmartphone.Audio.Error.NOT_SUPPORTED_DEVICE( "The supplied audio device is not supported by the current router" ); } assert( logger.debug( @"Switching output device: $(current_devices[current_mode]) -> $(device)" ) ); current_devices[ current_mode ] = device; router.set_device( current_devices[ current_mode ] ); - device_changed( current_devices[ current_mode ] ); + device_changed( current_devices[ current_mode ] ); // DBUS signal adjustVolumeSettings(); } + public async void push_device( FreeSmartphone.Audio.Device device ) + throws FreeSmartphone.Audio.Error, FreeSmartphone.Error, GLib.DBusError, GLib.IOError + { + set_device( device ); + device_stack.push_head( device ); + +#if DEBUG + debug( @"device_stack.length = $(device_stack.get_length())" ); +#endif + } + + public async FreeSmartphone.Audio.Device pull_device() + throws FreeSmartphone.Audio.Error, FreeSmartphone.Error, GLib.DBusError, GLib.IOError + { + device_stack.pop_head(); + + if ( device_stack.is_empty() ) + { + throw new FreeSmartphone.Audio.Error.DEVICE_STACK_UNDERFLOW( "No device left to active" ); + } + + var device = device_stack.peek_head(); + set_device( device ); + return device; + } + public async void set_mute( FreeSmartphone.Audio.Control control, bool mute ) throws FreeSmartphone.Error, GLib.DBusError, GLib.IOError { @@ -320,7 +352,7 @@ namespace FsoAudio { var level = devices[ current_device ].get_volume( current_mode, control ); router.set_volume( control, level ); - } + } } public async bool get_mute( FreeSmartphone.Audio.Control control ) |