mirror of
				https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
				synced 2025-10-29 05:40:23 -04:00 
			
		
		
		
	* add new parameter to pa_open_config_file() to specify open mode
* modify pa_sink_input_new() to take initial volume settings as argument * call pa_sink_input_set_volume() when changing stream volume in protocol-esound.c to make sure that subscribe events are issued properly git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@858 fefdeb5f-60dc-0310-8127-8f9354f1896f
This commit is contained in:
		
							parent
							
								
									e46f8f8eb3
								
							
						
					
					
						commit
						be05b18c6f
					
				
					 15 changed files with 43 additions and 34 deletions
				
			
		|  | @ -84,7 +84,7 @@ pa_daemon_conf* pa_daemon_conf_new(void) { | |||
|     FILE *f; | ||||
|     pa_daemon_conf *c = pa_xmemdup(&default_conf, sizeof(default_conf)); | ||||
| 
 | ||||
|     if ((f = pa_open_config_file(DEFAULT_SCRIPT_FILE, DEFAULT_SCRIPT_FILE_USER, ENV_SCRIPT_FILE, &c->default_script_file))) | ||||
|     if ((f = pa_open_config_file(DEFAULT_SCRIPT_FILE, DEFAULT_SCRIPT_FILE_USER, ENV_SCRIPT_FILE, &c->default_script_file, "r"))) | ||||
|         fclose(f); | ||||
| 
 | ||||
| #ifdef DLSEARCHPATH | ||||
|  | @ -233,7 +233,7 @@ int pa_daemon_conf_load(pa_daemon_conf *c, const char *filename) { | |||
| 
 | ||||
|     f = filename ? | ||||
|         fopen(c->config_file = pa_xstrdup(filename), "r") : | ||||
|         pa_open_config_file(DEFAULT_CONFIG_FILE, DEFAULT_CONFIG_FILE_USER, ENV_CONFIG_FILE, &c->config_file); | ||||
|         pa_open_config_file(DEFAULT_CONFIG_FILE, DEFAULT_CONFIG_FILE_USER, ENV_CONFIG_FILE, &c->config_file, "r"); | ||||
| 
 | ||||
|     if (!f && errno != ENOENT) { | ||||
|         pa_log(__FILE__": WARNING: failed to open configuration file '%s': %s", filename, strerror(errno)); | ||||
|  |  | |||
|  | @ -238,7 +238,7 @@ static struct output *output_new(struct userdata *u, pa_sink *sink, int resample | |||
|             sink->core->memblock_stat); | ||||
| 
 | ||||
|     snprintf(t, sizeof(t), "%s: output #%u", u->sink->name, u->n_outputs+1); | ||||
|     if (!(o->sink_input = pa_sink_input_new(sink, __FILE__, t, &u->sink->sample_spec, &u->sink->channel_map, 1, resample_method))) | ||||
|     if (!(o->sink_input = pa_sink_input_new(sink, __FILE__, t, &u->sink->sample_spec, &u->sink->channel_map, NULL, 1, resample_method))) | ||||
|         goto fail; | ||||
| 
 | ||||
|     o->sink_input->get_latency = sink_input_get_latency_cb; | ||||
|  |  | |||
|  | @ -43,7 +43,7 @@ | |||
| #include "module-match-symdef.h" | ||||
| 
 | ||||
| PA_MODULE_AUTHOR("Lennart Poettering") | ||||
| PA_MODULE_DESCRIPTION("Sink input matching module") | ||||
| PA_MODULE_DESCRIPTION("Playback stream expression matching module") | ||||
| PA_MODULE_USAGE("table=<filename>") | ||||
| PA_MODULE_VERSION(PACKAGE_VERSION) | ||||
| 
 | ||||
|  | @ -81,7 +81,7 @@ static int load_rules(struct userdata *u, const char *filename) { | |||
| 
 | ||||
|     f = filename ? | ||||
|         fopen(fn = pa_xstrdup(filename), "r") : | ||||
|         pa_open_config_file(DEFAULT_MATCH_TABLE_FILE, DEFAULT_MATCH_TABLE_FILE_USER, NULL, &fn); | ||||
|         pa_open_config_file(DEFAULT_MATCH_TABLE_FILE, DEFAULT_MATCH_TABLE_FILE_USER, NULL, &fn, "r"); | ||||
| 
 | ||||
|     if (!f) { | ||||
|         pa_log(__FILE__": failed to open file '%s': %s", fn, strerror(errno)); | ||||
|  |  | |||
|  | @ -141,7 +141,7 @@ int pa__init(pa_core *c, pa_module*m) { | |||
|     calc_sine(u->memblock->data, u->memblock->length, frequency); | ||||
| 
 | ||||
|     snprintf(t, sizeof(t), "Sine Generator at %u Hz", frequency); | ||||
|     if (!(u->sink_input = pa_sink_input_new(sink, __FILE__, t, &ss, NULL, 0, -1))) | ||||
|     if (!(u->sink_input = pa_sink_input_new(sink, __FILE__, t, &ss, NULL, NULL, 0, -1))) | ||||
|         goto fail; | ||||
| 
 | ||||
|     u->sink_input->peek = sink_input_peek; | ||||
|  |  | |||
|  | @ -286,7 +286,7 @@ static struct session *session_new(struct userdata *u, const pa_sdp_info *sdp_in | |||
|                           sdp_info->session_name ? sdp_info->session_name : "",  | ||||
|                           sdp_info->session_name ? ")" : ""); | ||||
| 
 | ||||
|     s->sink_input = pa_sink_input_new(sink, __FILE__, c, &sdp_info->sample_spec, NULL, 0, PA_RESAMPLER_INVALID); | ||||
|     s->sink_input = pa_sink_input_new(sink, __FILE__, c, &sdp_info->sample_spec, NULL, NULL, 0, PA_RESAMPLER_INVALID); | ||||
|     pa_xfree(c); | ||||
|          | ||||
|     if (!s->sink_input) { | ||||
|  |  | |||
|  | @ -119,7 +119,7 @@ int pa_client_conf_load(pa_client_conf *c, const char *filename) { | |||
| 
 | ||||
|     f = filename ? | ||||
|         fopen((fn = pa_xstrdup(filename)), "r") : | ||||
|         pa_open_config_file(DEFAULT_CLIENT_CONFIG_FILE, DEFAULT_CLIENT_CONFIG_FILE_USER, ENV_CLIENT_CONFIG_FILE, &fn); | ||||
|         pa_open_config_file(DEFAULT_CLIENT_CONFIG_FILE, DEFAULT_CLIENT_CONFIG_FILE_USER, ENV_CLIENT_CONFIG_FILE, &fn, "r"); | ||||
| 
 | ||||
|     if (!f && errno != EINTR) { | ||||
|         pa_log(__FILE__": WARNING: failed to open configuration file '%s': %s", filename, strerror(errno)); | ||||
|  |  | |||
|  | @ -98,12 +98,9 @@ int pa_play_memchunk( | |||
|     if (cvolume && pa_cvolume_is_muted(cvolume)) | ||||
|         return 0; | ||||
| 
 | ||||
|     if (!(si = pa_sink_input_new(sink, name, __FILE__, ss, map, 0, PA_RESAMPLER_INVALID))) | ||||
|     if (!(si = pa_sink_input_new(sink, name, __FILE__, ss, map, cvolume, 0, PA_RESAMPLER_INVALID))) | ||||
|         return -1; | ||||
| 
 | ||||
|     if (cvolume) | ||||
|         si->volume = *cvolume; | ||||
|      | ||||
|     si->peek = sink_input_peek; | ||||
|     si->drop = sink_input_drop; | ||||
|     si->kill = sink_input_kill; | ||||
|  |  | |||
|  | @ -345,7 +345,7 @@ static int esd_proto_stream_play(struct connection *c, PA_GCC_UNUSED esd_proto_t | |||
| 
 | ||||
|     assert(!c->sink_input && !c->input_memblockq); | ||||
| 
 | ||||
|     c->sink_input = pa_sink_input_new(sink, __FILE__, name, &ss, NULL, 0, -1); | ||||
|     c->sink_input = pa_sink_input_new(sink, __FILE__, name, &ss, NULL, NULL, 0, -1); | ||||
| 
 | ||||
|     CHECK_VALIDITY(c->sink_input, "Failed to create sink input."); | ||||
| 
 | ||||
|  | @ -532,9 +532,10 @@ static int esd_proto_all_info(struct connection *c, esd_proto_t request, const v | |||
|         assert(t >= k*2+s); | ||||
|          | ||||
|         if (conn->sink_input) { | ||||
|             pa_cvolume volume = *pa_sink_input_get_volume(conn->sink_input); | ||||
|             rate = conn->sink_input->sample_spec.rate; | ||||
|             lvolume = (conn->sink_input->volume.values[0]*ESD_VOLUME_BASE)/PA_VOLUME_NORM; | ||||
|             rvolume = (conn->sink_input->volume.values[1]*ESD_VOLUME_BASE)/PA_VOLUME_NORM; | ||||
|             lvolume = (volume.values[0]*ESD_VOLUME_BASE)/PA_VOLUME_NORM; | ||||
|             rvolume = (volume.values[1]*ESD_VOLUME_BASE)/PA_VOLUME_NORM; | ||||
|             format = format_native2esd(&conn->sink_input->sample_spec); | ||||
|         } | ||||
|          | ||||
|  | @ -643,11 +644,12 @@ static int esd_proto_stream_pan(struct connection *c, PA_GCC_UNUSED esd_proto_t | |||
|     rvolume = MAYBE_UINT32_SWAP(c->swap_byte_order, rvolume); | ||||
|     data = (const char*)data + sizeof(uint32_t); | ||||
| 
 | ||||
|     if ((conn = pa_idxset_get_by_index(c->protocol->connections, idx))) { | ||||
|         assert(conn->sink_input); | ||||
|         conn->sink_input->volume.values[0] = (lvolume*PA_VOLUME_NORM)/ESD_VOLUME_BASE; | ||||
|         conn->sink_input->volume.values[1] = (rvolume*PA_VOLUME_NORM)/ESD_VOLUME_BASE; | ||||
|         conn->sink_input->volume.channels = 2; | ||||
|     if ((conn = pa_idxset_get_by_index(c->protocol->connections, idx)) && conn->sink_input) { | ||||
|         pa_cvolume volume; | ||||
|         volume.values[0] = (lvolume*PA_VOLUME_NORM)/ESD_VOLUME_BASE; | ||||
|         volume.values[1] = (rvolume*PA_VOLUME_NORM)/ESD_VOLUME_BASE; | ||||
|         volume.channels = 2; | ||||
|         pa_sink_input_set_volume(conn->sink_input, &volume); | ||||
|         ok = 1; | ||||
|     } else | ||||
|         ok = 0; | ||||
|  |  | |||
|  | @ -386,7 +386,7 @@ static struct playback_stream* playback_stream_new( | |||
|     if (ssync && ssync->sink_input->sink != sink) | ||||
|         return NULL; | ||||
|      | ||||
|     if (!(sink_input = pa_sink_input_new(sink, __FILE__, name, ss, map, 0, -1))) | ||||
|     if (!(sink_input = pa_sink_input_new(sink, __FILE__, name, ss, map, volume, 0, -1))) | ||||
|         return NULL; | ||||
|      | ||||
|     s = pa_xnew(struct playback_stream, 1); | ||||
|  | @ -437,8 +437,6 @@ static struct playback_stream* playback_stream_new( | |||
|     s->requested_bytes = 0; | ||||
|     s->drain_request = 0; | ||||
|      | ||||
|     s->sink_input->volume = *volume; | ||||
|      | ||||
|     pa_idxset_put(c->output_streams, s, &s->index); | ||||
| 
 | ||||
|     return s; | ||||
|  |  | |||
|  | @ -346,7 +346,7 @@ static void on_connection(pa_socket_server*s, pa_iochannel *io, void *userdata) | |||
|             goto fail; | ||||
|         } | ||||
| 
 | ||||
|         if (!(c->sink_input = pa_sink_input_new(sink, __FILE__, c->client->name, &p->sample_spec, NULL, 0, -1))) { | ||||
|         if (!(c->sink_input = pa_sink_input_new(sink, __FILE__, c->client->name, &p->sample_spec, NULL, NULL, 0, -1))) { | ||||
|             pa_log(__FILE__": Failed to create sink input."); | ||||
|             goto fail; | ||||
|         } | ||||
|  |  | |||
|  | @ -43,6 +43,7 @@ pa_sink_input* pa_sink_input_new( | |||
|     const char *name, | ||||
|     const pa_sample_spec *spec, | ||||
|     const pa_channel_map *map, | ||||
|     const pa_cvolume *volume,  | ||||
|     int variable_rate, | ||||
|     int resample_method) { | ||||
|      | ||||
|  | @ -56,6 +57,7 @@ pa_sink_input* pa_sink_input_new( | |||
|     assert(spec); | ||||
|     assert(s->state == PA_SINK_RUNNING); | ||||
| 
 | ||||
| 
 | ||||
|     if (pa_idxset_size(s->inputs) >= PA_MAX_INPUTS_PER_SINK) { | ||||
|         pa_log_warn(__FILE__": Failed to create sink input: too many inputs per sink."); | ||||
|         return NULL; | ||||
|  | @ -64,8 +66,16 @@ pa_sink_input* pa_sink_input_new( | |||
|     if (resample_method == PA_RESAMPLER_INVALID) | ||||
|         resample_method = s->core->resample_method; | ||||
|      | ||||
|     if (map && spec->channels != map->channels) | ||||
|         return NULL; | ||||
| 
 | ||||
|     if (volume && spec->channels != volume->channels) | ||||
|         return NULL; | ||||
| 
 | ||||
|     if (!map) { | ||||
|         pa_channel_map_init_auto(&tmap, spec->channels); | ||||
|         if (!(pa_channel_map_init_auto(&tmap, spec->channels))) | ||||
|             return NULL; | ||||
|          | ||||
|         map = &tmap; | ||||
|     } | ||||
| 
 | ||||
|  | @ -85,6 +95,9 @@ pa_sink_input* pa_sink_input_new( | |||
|     i->sample_spec = *spec; | ||||
|     i->channel_map = *map; | ||||
| 
 | ||||
|     if (volume) | ||||
|         i->volume = *volume; | ||||
|     else | ||||
|         pa_cvolume_reset(&i->volume, spec->channels); | ||||
|      | ||||
|     i->peek = NULL; | ||||
|  |  | |||
|  | @ -75,6 +75,7 @@ pa_sink_input* pa_sink_input_new( | |||
|     const char *name, | ||||
|     const pa_sample_spec *spec, | ||||
|     const pa_channel_map *map, | ||||
|     const pa_cvolume *volume, | ||||
|     int variable_rate, | ||||
|     int resample_method); | ||||
| 
 | ||||
|  |  | |||
|  | @ -158,11 +158,9 @@ int pa_play_file(pa_sink *sink, const char *fname, const pa_cvolume *volume) { | |||
|         goto fail; | ||||
|     } | ||||
|      | ||||
|     if (!(u->sink_input = pa_sink_input_new(sink, __FILE__, fname, &ss, NULL, 0, -1))) | ||||
|     if (!(u->sink_input = pa_sink_input_new(sink, __FILE__, fname, &ss, NULL, volume, 0, -1))) | ||||
|         goto fail; | ||||
| 
 | ||||
|     if (volume) | ||||
|         u->sink_input->volume = *volume; | ||||
|     u->sink_input->peek = sink_input_peek; | ||||
|     u->sink_input->drop = sink_input_drop; | ||||
|     u->sink_input->kill = sink_input_kill; | ||||
|  |  | |||
|  | @ -1037,7 +1037,7 @@ int pa_unlock_lockfile(const char *fn, int fd) { | |||
|  * file system. If "result" is non-NULL, a pointer to a newly | ||||
|  * allocated buffer containing the used configuration file is | ||||
|  * stored there.*/ | ||||
| FILE *pa_open_config_file(const char *global, const char *local, const char *env, char **result) { | ||||
| FILE *pa_open_config_file(const char *global, const char *local, const char *env, char **result, const char *mode) { | ||||
|     const char *fn; | ||||
|     char h[PATH_MAX]; | ||||
| 
 | ||||
|  | @ -1058,7 +1058,7 @@ FILE *pa_open_config_file(const char *global, const char *local, const char *env | |||
|         if (result) | ||||
|             *result = pa_xstrdup(fn); | ||||
| 
 | ||||
|         return fopen(fn, "r"); | ||||
|         return fopen(fn, mode); | ||||
|     } | ||||
| 
 | ||||
|     if (local && pa_get_home_dir(h, sizeof(h))) { | ||||
|  | @ -1073,7 +1073,7 @@ FILE *pa_open_config_file(const char *global, const char *local, const char *env | |||
|         fn = buf; | ||||
| #endif | ||||
| 
 | ||||
|         f = fopen(fn, "r"); | ||||
|         f = fopen(fn, mode); | ||||
| 
 | ||||
|         if (f || errno != ENOENT) { | ||||
|             if (result) | ||||
|  | @ -1101,7 +1101,7 @@ FILE *pa_open_config_file(const char *global, const char *local, const char *env | |||
|     if (result) | ||||
|         *result = pa_xstrdup(global); | ||||
|      | ||||
|     return fopen(global, "r"); | ||||
|     return fopen(global, mode); | ||||
| } | ||||
|                   | ||||
| /* Format the specified data as a hexademical string */ | ||||
|  |  | |||
|  | @ -87,7 +87,7 @@ int pa_lock_fd(int fd, int b); | |||
| int pa_lock_lockfile(const char *fn); | ||||
| int pa_unlock_lockfile(const char *fn, int fd); | ||||
| 
 | ||||
| FILE *pa_open_config_file(const char *env, const char *global, const char *local, char **result); | ||||
| FILE *pa_open_config_file(const char *global, const char *local, const char *env, char **result, const char *mode); | ||||
| 
 | ||||
| char *pa_hexstr(const uint8_t* d, size_t dlength, char *s, size_t slength); | ||||
| size_t pa_parsehex(const char *p, uint8_t *d, size_t dlength); | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Lennart Poettering
						Lennart Poettering