mirror of
				https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
				synced 2025-11-03 09:01:50 -05:00 
			
		
		
		
	add new command line option --no-cpu-limit. This is useful when running PulseAudio in valgrind's massif or callgrind tools
git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@1149 fefdeb5f-60dc-0310-8127-8f9354f1896f
This commit is contained in:
		
							parent
							
								
									563fab983f
								
							
						
					
					
						commit
						61ce8bb002
					
				
					 5 changed files with 42 additions and 16 deletions
				
			
		| 
						 | 
					@ -59,6 +59,7 @@ enum {
 | 
				
			||||||
    ARG_KILL,
 | 
					    ARG_KILL,
 | 
				
			||||||
    ARG_USE_PID_FILE,
 | 
					    ARG_USE_PID_FILE,
 | 
				
			||||||
    ARG_CHECK,
 | 
					    ARG_CHECK,
 | 
				
			||||||
 | 
					    ARG_NO_CPU_LIMIT,
 | 
				
			||||||
    ARG_SYSTEM
 | 
					    ARG_SYSTEM
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -86,6 +87,7 @@ static struct option long_options[] = {
 | 
				
			||||||
    {"use-pid-file",                2, 0, ARG_USE_PID_FILE},
 | 
					    {"use-pid-file",                2, 0, ARG_USE_PID_FILE},
 | 
				
			||||||
    {"check",                       0, 0, ARG_CHECK},
 | 
					    {"check",                       0, 0, ARG_CHECK},
 | 
				
			||||||
    {"system",                      2, 0, ARG_SYSTEM},
 | 
					    {"system",                      2, 0, ARG_SYSTEM},
 | 
				
			||||||
 | 
					    {"no-cpu-limit",                2, 0, ARG_NO_CPU_LIMIT},
 | 
				
			||||||
    {NULL, 0, 0, 0}
 | 
					    {NULL, 0, 0, 0}
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -128,7 +130,9 @@ void pa_cmdline_help(const char *argv0) {
 | 
				
			||||||
           "                                        (one of src-sinc-medium-quality,\n"
 | 
					           "                                        (one of src-sinc-medium-quality,\n"
 | 
				
			||||||
           "                                        src-sinc-best-quality,src-sinc-fastest\n"
 | 
					           "                                        src-sinc-best-quality,src-sinc-fastest\n"
 | 
				
			||||||
           "                                        src-zero-order-hold,src-linear,trivial)\n"
 | 
					           "                                        src-zero-order-hold,src-linear,trivial)\n"
 | 
				
			||||||
           "      --use-pid-file[=BOOL]             Create a PID file\n\n"
 | 
					           "      --use-pid-file[=BOOL]             Create a PID file\n"
 | 
				
			||||||
 | 
					           "      --no-cpu-limit[=BOOL]             Do not install CPU load limiter on\n"
 | 
				
			||||||
 | 
					           "                                        platforms that support it.\n\n"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
           "STARTUP SCRIPT:\n"
 | 
					           "STARTUP SCRIPT:\n"
 | 
				
			||||||
           "  -L, --load=\"MODULE ARGUMENTS\"         Load the specified plugin module with\n"
 | 
					           "  -L, --load=\"MODULE ARGUMENTS\"         Load the specified plugin module with\n"
 | 
				
			||||||
| 
						 | 
					@ -286,6 +290,14 @@ int pa_cmdline_parse(pa_daemon_conf *conf, int argc, char *const argv [], int *d
 | 
				
			||||||
                    goto fail;
 | 
					                    goto fail;
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                break;
 | 
					                break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            case ARG_NO_CPU_LIMIT:
 | 
				
			||||||
 | 
					                if ((conf->no_cpu_limit = optarg ? pa_parse_boolean(optarg) : 1) < 0) {
 | 
				
			||||||
 | 
					                    pa_log(__FILE__": --no-cpu-limit expects boolean argument");
 | 
				
			||||||
 | 
					                    goto fail;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                break;
 | 
				
			||||||
 | 
					                
 | 
				
			||||||
                
 | 
					                
 | 
				
			||||||
            default:
 | 
					            default:
 | 
				
			||||||
                goto fail;
 | 
					                goto fail;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -72,7 +72,8 @@ static const pa_daemon_conf default_conf = {
 | 
				
			||||||
    .resample_method = PA_RESAMPLER_SRC_SINC_FASTEST,
 | 
					    .resample_method = PA_RESAMPLER_SRC_SINC_FASTEST,
 | 
				
			||||||
    .config_file = NULL,
 | 
					    .config_file = NULL,
 | 
				
			||||||
    .use_pid_file = 1,
 | 
					    .use_pid_file = 1,
 | 
				
			||||||
    .system_instance = 0
 | 
					    .system_instance = 0,
 | 
				
			||||||
 | 
					    .no_cpu_limit = 0
 | 
				
			||||||
#ifdef HAVE_SYS_RESOURCE_H
 | 
					#ifdef HAVE_SYS_RESOURCE_H
 | 
				
			||||||
    , .rlimit_as = { .value = 0, .is_set = 0 },
 | 
					    , .rlimit_as = { .value = 0, .is_set = 0 },
 | 
				
			||||||
    .rlimit_core = { .value = 0, .is_set = 0 },
 | 
					    .rlimit_core = { .value = 0, .is_set = 0 },
 | 
				
			||||||
| 
						 | 
					@ -246,6 +247,7 @@ int pa_daemon_conf_load(pa_daemon_conf *c, const char *filename) {
 | 
				
			||||||
        { "resample-method",         parse_resample_method,   NULL },
 | 
					        { "resample-method",         parse_resample_method,   NULL },
 | 
				
			||||||
        { "use-pid-file",            pa_config_parse_bool,    NULL },
 | 
					        { "use-pid-file",            pa_config_parse_bool,    NULL },
 | 
				
			||||||
        { "system-instance",         pa_config_parse_bool,    NULL },
 | 
					        { "system-instance",         pa_config_parse_bool,    NULL },
 | 
				
			||||||
 | 
					        { "no-cpu-limit",            pa_config_parse_bool,    NULL },
 | 
				
			||||||
#ifdef HAVE_SYS_RESOURCE_H
 | 
					#ifdef HAVE_SYS_RESOURCE_H
 | 
				
			||||||
        { "rlimit-as",               parse_rlimit,            NULL },
 | 
					        { "rlimit-as",               parse_rlimit,            NULL },
 | 
				
			||||||
        { "rlimit-core",             parse_rlimit,            NULL },
 | 
					        { "rlimit-core",             parse_rlimit,            NULL },
 | 
				
			||||||
| 
						 | 
					@ -278,21 +280,22 @@ int pa_daemon_conf_load(pa_daemon_conf *c, const char *filename) {
 | 
				
			||||||
    table[12].data = c;
 | 
					    table[12].data = c;
 | 
				
			||||||
    table[13].data = &c->use_pid_file;
 | 
					    table[13].data = &c->use_pid_file;
 | 
				
			||||||
    table[14].data = &c->system_instance;
 | 
					    table[14].data = &c->system_instance;
 | 
				
			||||||
 | 
					    table[15].data = &c->no_cpu_limit;
 | 
				
			||||||
#ifdef HAVE_SYS_RESOURCE_H
 | 
					#ifdef HAVE_SYS_RESOURCE_H
 | 
				
			||||||
    table[15].data = &c->rlimit_as;
 | 
					    table[16].data = &c->rlimit_as;
 | 
				
			||||||
    table[16].data = &c->rlimit_core;
 | 
					    table[17].data = &c->rlimit_core;
 | 
				
			||||||
    table[17].data = &c->rlimit_data;
 | 
					    table[18].data = &c->rlimit_data;
 | 
				
			||||||
    table[18].data = &c->rlimit_fsize;
 | 
					    table[19].data = &c->rlimit_fsize;
 | 
				
			||||||
    table[19].data = &c->rlimit_nofile;
 | 
					    table[20].data = &c->rlimit_nofile;
 | 
				
			||||||
    table[20].data = &c->rlimit_stack;
 | 
					    table[21].data = &c->rlimit_stack;
 | 
				
			||||||
#ifdef RLIMIT_NPROC
 | 
					#ifdef RLIMIT_NPROC
 | 
				
			||||||
    table[21].data = &c->rlimit_nproc;
 | 
					    table[22].data = &c->rlimit_nproc;
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
#ifdef RLIMIT_MEMLOCK
 | 
					#ifdef RLIMIT_MEMLOCK
 | 
				
			||||||
#ifndef RLIMIT_NPROC
 | 
					#ifndef RLIMIT_NPROC
 | 
				
			||||||
#error "Houston, we have a numbering problem!"
 | 
					#error "Houston, we have a numbering problem!"
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
    table[22].data = &c->rlimit_memlock;
 | 
					    table[23].data = &c->rlimit_memlock;
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
| 
						 | 
					@ -363,6 +366,7 @@ char *pa_daemon_conf_dump(pa_daemon_conf *c) {
 | 
				
			||||||
    pa_strbuf_printf(s, "resample-method = %s\n", pa_resample_method_to_string(c->resample_method));
 | 
					    pa_strbuf_printf(s, "resample-method = %s\n", pa_resample_method_to_string(c->resample_method));
 | 
				
			||||||
    pa_strbuf_printf(s, "use-pid-file = %i\n", c->use_pid_file);
 | 
					    pa_strbuf_printf(s, "use-pid-file = %i\n", c->use_pid_file);
 | 
				
			||||||
    pa_strbuf_printf(s, "system-instance = %i\n", !!c->system_instance);
 | 
					    pa_strbuf_printf(s, "system-instance = %i\n", !!c->system_instance);
 | 
				
			||||||
 | 
					    pa_strbuf_printf(s, "no-cpu-limit = %i\n", !!c->no_cpu_limit);
 | 
				
			||||||
#ifdef HAVE_SYS_RESOURCE_H
 | 
					#ifdef HAVE_SYS_RESOURCE_H
 | 
				
			||||||
    pa_strbuf_printf(s, "rlimit-as = %li\n", c->rlimit_as.is_set ? (long int) c->rlimit_as.value : -1);
 | 
					    pa_strbuf_printf(s, "rlimit-as = %li\n", c->rlimit_as.is_set ? (long int) c->rlimit_as.value : -1);
 | 
				
			||||||
    pa_strbuf_printf(s, "rlimit-core = %li\n", c->rlimit_core.is_set ? (long int) c->rlimit_core.value : -1);
 | 
					    pa_strbuf_printf(s, "rlimit-core = %li\n", c->rlimit_core.is_set ? (long int) c->rlimit_core.value : -1);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -58,7 +58,8 @@ typedef struct pa_daemon_conf {
 | 
				
			||||||
        scache_idle_time,
 | 
					        scache_idle_time,
 | 
				
			||||||
        auto_log_target,
 | 
					        auto_log_target,
 | 
				
			||||||
        use_pid_file,
 | 
					        use_pid_file,
 | 
				
			||||||
        system_instance;
 | 
					        system_instance,
 | 
				
			||||||
 | 
					        no_cpu_limit;
 | 
				
			||||||
    char *script_commands, *dl_search_path, *default_script_file;
 | 
					    char *script_commands, *dl_search_path, *default_script_file;
 | 
				
			||||||
    pa_log_target_t log_target;
 | 
					    pa_log_target_t log_target;
 | 
				
			||||||
    pa_log_level_t log_level;
 | 
					    pa_log_level_t log_level;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -79,6 +79,11 @@
 | 
				
			||||||
## effectively disables multiple instances.
 | 
					## effectively disables multiple instances.
 | 
				
			||||||
; use-pid-file = 1
 | 
					; use-pid-file = 1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## Do not install the CPU load limit, even on platforms where it is
 | 
				
			||||||
 | 
					## supported. This option is useful when debugging/profiling 
 | 
				
			||||||
 | 
					## PulseAudio to disable disturbing SIGXCPU signals.
 | 
				
			||||||
 | 
					; no-cpu-limit = 0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
## Run the daemon as system-wide instance, requires root priviliges
 | 
					## Run the daemon as system-wide instance, requires root priviliges
 | 
				
			||||||
; system-instance = 0
 | 
					; system-instance = 0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -588,10 +588,12 @@ int main(int argc, char *argv[]) {
 | 
				
			||||||
        c->running_as_daemon = 1;
 | 
					        c->running_as_daemon = 1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    oil_init();
 | 
					    oil_init();
 | 
				
			||||||
    
 | 
					
 | 
				
			||||||
    r = pa_cpu_limit_init(pa_mainloop_get_api(mainloop));
 | 
					    if (!conf->no_cpu_limit) {
 | 
				
			||||||
    assert(r == 0);
 | 
					        r = pa_cpu_limit_init(pa_mainloop_get_api(mainloop));
 | 
				
			||||||
    
 | 
					        assert(r == 0);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
    buf = pa_strbuf_new();
 | 
					    buf = pa_strbuf_new();
 | 
				
			||||||
    if (conf->default_script_file)
 | 
					    if (conf->default_script_file)
 | 
				
			||||||
        r = pa_cli_command_execute_file(c, conf->default_script_file, buf, &conf->fail);
 | 
					        r = pa_cli_command_execute_file(c, conf->default_script_file, buf, &conf->fail);
 | 
				
			||||||
| 
						 | 
					@ -645,7 +647,9 @@ int main(int argc, char *argv[]) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    pa_core_free(c);
 | 
					    pa_core_free(c);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    pa_cpu_limit_done();
 | 
					    if (!conf->no_cpu_limit)
 | 
				
			||||||
 | 
					        pa_cpu_limit_done();
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
    pa_signal_done();
 | 
					    pa_signal_done();
 | 
				
			||||||
    pa_mainloop_free(mainloop);
 | 
					    pa_mainloop_free(mainloop);
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue