mirror of
				https://github.com/owntone/owntone-server.git
				synced 2025-10-29 15:55:02 -04:00 
			
		
		
		
	Rework RAOP volume setting to be per-speaker
Player now pilots RAOP volume setting directly on a per-speaker basis.
This commit is contained in:
		
							parent
							
								
									9bd6d459a2
								
							
						
					
					
						commit
						9e9c3e42cc
					
				| @ -2514,13 +2514,16 @@ volume_set(struct player_command *cmd) | |||||||
|   master_volume = cmd->arg.intval; |   master_volume = cmd->arg.intval; | ||||||
| 
 | 
 | ||||||
|   laudio_volume = master_volume; |   laudio_volume = master_volume; | ||||||
| 
 |  | ||||||
|   cmd->raop_pending = raop_set_volume(master_volume, device_command_cb); |  | ||||||
|   laudio_set_volume(laudio_volume); |   laudio_set_volume(laudio_volume); | ||||||
| 
 | 
 | ||||||
|  |   cmd->raop_pending = 0; | ||||||
|  | 
 | ||||||
|   for (rd = dev_list; rd; rd = rd->next) |   for (rd = dev_list; rd; rd = rd->next) | ||||||
|     { |     { | ||||||
|       rd->volume = master_volume; |       rd->volume = master_volume; | ||||||
|  | 
 | ||||||
|  |       if (rd->session) | ||||||
|  | 	cmd->raop_pending += raop_set_volume_one(rd->session, rd->volume, device_command_cb); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|   if (cmd->raop_pending > 0) |   if (cmd->raop_pending > 0) | ||||||
| @ -3501,8 +3504,6 @@ player_init(void) | |||||||
|       goto raop_fail; |       goto raop_fail; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|   raop_set_volume(master_volume, NULL); |  | ||||||
| 
 |  | ||||||
|   ret = mdns_browse("_raop._tcp", raop_device_cb); |   ret = mdns_browse("_raop._tcp", raop_device_cb); | ||||||
|   if (ret < 0) |   if (ret < 0) | ||||||
|     { |     { | ||||||
|  | |||||||
							
								
								
									
										67
									
								
								src/raop.c
									
									
									
									
									
								
							
							
						
						
									
										67
									
								
								src/raop.c
									
									
									
									
									
								
							| @ -106,6 +106,7 @@ struct raop_session | |||||||
|   char *devname; |   char *devname; | ||||||
|   char *address; |   char *address; | ||||||
| 
 | 
 | ||||||
|  |   int volume; | ||||||
|   uint64_t start_rtptime; |   uint64_t start_rtptime; | ||||||
| 
 | 
 | ||||||
|   /* Do not dereference - only passed to the status cb */ |   /* Do not dereference - only passed to the status cb */ | ||||||
| @ -207,9 +208,6 @@ static int pktbuf_size; | |||||||
| static struct raop_v2_packet *pktbuf_head; | static struct raop_v2_packet *pktbuf_head; | ||||||
| static struct raop_v2_packet *pktbuf_tail; | static struct raop_v2_packet *pktbuf_tail; | ||||||
| 
 | 
 | ||||||
| /* Volume */ |  | ||||||
| static double raop_volume; |  | ||||||
| 
 |  | ||||||
| /* FLUSH timer */ | /* FLUSH timer */ | ||||||
| static struct event flush_timer; | static struct event flush_timer; | ||||||
| 
 | 
 | ||||||
| @ -1642,6 +1640,8 @@ raop_session_make(struct raop_device *rd, int family, raop_status_cb cb) | |||||||
|   rs->devname = strdup(rd->name); |   rs->devname = strdup(rd->name); | ||||||
|   rs->address = strdup(address); |   rs->address = strdup(address); | ||||||
| 
 | 
 | ||||||
|  |   rs->volume = rd->volume; | ||||||
|  | 
 | ||||||
|   rs->next = sessions; |   rs->next = sessions; | ||||||
|   sessions = rs; |   sessions = rs; | ||||||
| 
 | 
 | ||||||
| @ -1667,10 +1667,28 @@ raop_session_failure_cb(struct evrtsp_request *req, void *arg) | |||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| /* Volume handling */ | /* Volume handling */ | ||||||
|  | static double | ||||||
|  | raop_volume_convert(int volume) | ||||||
|  | { | ||||||
|  |   double raop_volume; | ||||||
|  | 
 | ||||||
|  |   /* RAOP volume
 | ||||||
|  |    *  -144.0 is off | ||||||
|  |    *  0 - -30.0 maps to 100 - 0 | ||||||
|  |    */ | ||||||
|  |   if (volume == 0) | ||||||
|  |     raop_volume = -144.0; | ||||||
|  |   else | ||||||
|  |     raop_volume = -30.0 + ((double)volume * 30.0) / 100.0; | ||||||
|  | 
 | ||||||
|  |   return raop_volume; | ||||||
|  | } | ||||||
|  | 
 | ||||||
| static int | static int | ||||||
| raop_set_volume_internal(struct raop_session *rs, evrtsp_req_cb cb) | raop_set_volume_internal(struct raop_session *rs, int volume, evrtsp_req_cb cb) | ||||||
| { | { | ||||||
|   struct evbuffer *evbuf; |   struct evbuffer *evbuf; | ||||||
|  |   double raop_volume; | ||||||
|   int ret; |   int ret; | ||||||
| 
 | 
 | ||||||
|   evbuf = evbuffer_new(); |   evbuf = evbuffer_new(); | ||||||
| @ -1681,6 +1699,8 @@ raop_set_volume_internal(struct raop_session *rs, evrtsp_req_cb cb) | |||||||
|       return -1; |       return -1; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |   raop_volume = raop_volume_convert(volume); | ||||||
|  | 
 | ||||||
|   /* Don't let locales get in the way here */ |   /* Don't let locales get in the way here */ | ||||||
|   ret = evbuffer_add_printf(evbuf, "volume: %d.%06d", (int)raop_volume, (int)(1000000.0 * (raop_volume - floor(raop_volume)))); |   ret = evbuffer_add_printf(evbuf, "volume: %d.%06d", (int)raop_volume, (int)(1000000.0 * (raop_volume - floor(raop_volume)))); | ||||||
|   if (ret < 0) |   if (ret < 0) | ||||||
| @ -1741,42 +1761,25 @@ raop_set_volume_cb(struct evrtsp_request *req, void *arg) | |||||||
| 
 | 
 | ||||||
| /* Volume in [0 - 100] */ | /* Volume in [0 - 100] */ | ||||||
| int | int | ||||||
| raop_set_volume(int volume, raop_status_cb cb) | raop_set_volume_one(struct raop_session *rs, int volume, raop_status_cb cb) | ||||||
| { | { | ||||||
|   struct raop_session *rs; |  | ||||||
|   int pending; |  | ||||||
|   int ret; |   int ret; | ||||||
| 
 | 
 | ||||||
|   /* RAOP volume
 |   if (!(rs->state & RAOP_CONNECTED)) | ||||||
|    *  -144.0 is off |     return 0; | ||||||
|    *  0 - -30.0 maps to 100 - 0 |  | ||||||
|    */ |  | ||||||
|   if (volume == 0) |  | ||||||
|     raop_volume = -144.0; |  | ||||||
|   else |  | ||||||
|     raop_volume = -30.0 + ((double)volume * 30.0) / 100.0; |  | ||||||
| 
 | 
 | ||||||
|   pending = 0; |   ret = raop_set_volume_internal(rs, volume, raop_set_volume_cb); | ||||||
|   for (rs = sessions; rs; rs = rs->next) |   if (ret < 0) | ||||||
|     { |     { | ||||||
|       if (!(rs->state & RAOP_CONNECTED)) |       raop_session_failure(rs); | ||||||
| 	continue; |  | ||||||
| 
 | 
 | ||||||
|       ret = raop_set_volume_internal(rs, raop_set_volume_cb); |       return 0; | ||||||
|       if (ret < 0) |  | ||||||
| 	{ |  | ||||||
| 	  raop_session_failure(rs); |  | ||||||
| 
 |  | ||||||
| 	  continue; |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
|       rs->status_cb = cb; |  | ||||||
|       pending++; |  | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|   return pending; |   rs->status_cb = cb; | ||||||
| } |  | ||||||
| 
 | 
 | ||||||
|  |   return 1; | ||||||
|  | } | ||||||
| 
 | 
 | ||||||
| static void | static void | ||||||
| raop_flush_cb(struct evrtsp_request *req, void *arg) | raop_flush_cb(struct evrtsp_request *req, void *arg) | ||||||
| @ -2895,7 +2898,7 @@ raop_cb_startup_record(struct evrtsp_request *req, void *arg) | |||||||
|   rs->state = RAOP_RECORD; |   rs->state = RAOP_RECORD; | ||||||
| 
 | 
 | ||||||
|   /* Set initial volume */ |   /* Set initial volume */ | ||||||
|   raop_set_volume_internal(rs, raop_cb_startup_volume); |   raop_set_volume_internal(rs, rs->volume, raop_cb_startup_volume); | ||||||
| 
 | 
 | ||||||
|   return; |   return; | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -102,7 +102,7 @@ raop_playback_stop(void); | |||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| int | int | ||||||
| raop_set_volume(int volume, raop_status_cb cb); | raop_set_volume_one(struct raop_session *rs, int volume, raop_status_cb cb); | ||||||
| 
 | 
 | ||||||
| int | int | ||||||
| raop_flush(raop_status_cb cb, uint64_t rtptime); | raop_flush(raop_status_cb cb, uint64_t rtptime); | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user