@@ -134,8 +134,6 @@ pub struct Model {
134134 active_sink_device : Option < u32 > ,
135135 /// Index of active sink device.
136136 active_sink : Option < usize > ,
137- /// Card profile index of active sink device.
138- active_sink_profile : Option < usize > ,
139137
140138 /** Source devices */
141139
@@ -147,8 +145,6 @@ pub struct Model {
147145 active_source_device : Option < u32 > ,
148146 /// Index of active source device.
149147 active_source : Option < usize > ,
150- /// Card profile index of active source device.
151- active_source_profile : Option < usize > ,
152148
153149 /// Device identifier of the default sink.
154150 default_sink : String ,
@@ -176,18 +172,10 @@ impl Model {
176172 self . active_sink
177173 }
178174
179- pub fn active_sink_profile ( & self ) -> Option < usize > {
180- self . active_sink_profile
181- }
182-
183175 pub fn active_source ( & self ) -> Option < usize > {
184176 self . active_source
185177 }
186178
187- pub fn active_source_profile ( & self ) -> Option < usize > {
188- self . active_source_profile
189- }
190-
191179 pub fn sinks ( & self ) -> & [ String ] {
192180 & self . sinks
193181 }
@@ -210,20 +198,16 @@ impl Model {
210198 /// Sets and applies a profile to a device with wpctl.
211199 ///
212200 /// Requires using the device ID rather than a node ID.
213- pub fn set_profile ( & mut self , device_id : DeviceId , pos : usize ) {
201+ pub fn set_profile ( & mut self , device_id : DeviceId , index : u32 ) {
202+ eprintln ! ( "set profile {device_id} {index}" ) ;
214203 if let Some ( profiles) = self . device_profiles . get ( device_id) {
215- if let Some ( profile) = profiles. get ( pos) {
216- let index = profile. index as u32 ;
217- tokio:: spawn ( async move {
218- wpctl:: set_profile ( device_id, index) . await ;
219- } ) ;
220-
221- self . active_profiles . insert ( device_id, profile. clone ( ) ) ;
204+ for profile in profiles {
205+ if profile. index as u32 == index {
206+ tokio:: spawn ( async move {
207+ wpctl:: set_profile ( device_id, index) . await ;
208+ } ) ;
222209
223- if self . active_sink_device == Some ( device_id) {
224- self . active_sink_profile = Some ( pos)
225- } else if self . active_source_device == Some ( device_id) {
226- self . active_source_profile = Some ( pos) ;
210+ self . active_profiles . insert ( device_id, profile. clone ( ) ) ;
227211 }
228212 }
229213 }
0 commit comments