⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 core.c

📁 Aqualung is an advanced music player primarily targeted for the GNU/Linux operating system, but als
💻 C
📖 第 1 页 / 共 5 页
字号:
					} else {						fprintf(stderr, "Invalid ports specification: argument "							"contains too few ports\n");						exit(0);					}					default_ports = 0;				}#endif /* HAVE_JACK */				break;			case 'R':				try_realtime = 1;				break;			case 'P':				priority = atoi(optarg);				break;			case 'D':				disk_try_realtime = 1;				break;			case 'Y':				disk_priority = atoi(optarg);				break;			case 's':#ifdef HAVE_SRC				if (optarg) {					src_type = atoi(optarg);					++src_type_parsed;				} else {					int i = 0;										fprintf(stderr, "List of available Sample Rate Converters:\n\n");					while (src_get_name(i)) {						fprintf(stderr, "Converter #%d: %s\n%s\n\n",						       i, src_get_name(i), src_get_description(i));						++i;					}					fprintf(stderr,						"Type aqualung --srctype=n ... or aqualung -sn ... to choose "						"Converter #n.\n\n");					exit(0);				}#else				if (optarg) {					fprintf(stderr,						"You attempted to set the type of the internal Sample Rate "						"Converter,"						"\nbut this instance of Aqualung is compiled without "						"support for"						"\ninternal Sample Rate Conversion. Type aqualung -v to get "						"a list"						"\nof compiled-in features.\n");				} else {					fprintf(stderr,						"You attempted to list the available types for the internal "						"Sample"						"\nRate Converter, but this instance of Aqualung is "						"compiled without"						"\nsupport for internal Sample Rate Conversion. Type "						"aqualung -v to"						"\nget a list of compiled-in features.\n");				}				exit(1);#endif /* HAVE_SRC */				break;                        case 'l':                               if(!strncmp(optarg, "yes", 3)) {                                        playlist_state = 1;                               } else if(!strncmp(optarg, "no", 2)) {                                        playlist_state = 0;                               }                               break;                        case 'm':                                if(!strncmp(optarg, "yes", 3)) {                                        browser_state = 1;                                } else if(!strncmp(optarg, "no", 2)) {                                        browser_state = 0;                                }                                break;			case 'N':				no_session = atoi(optarg);				break;			case 'B':				back++;				break;			case 'L':				play++;				break;			case 'U':				pause++;				break;			case 'T':				stop++;				break;			case 'F':				fwd++;				break;			case 'E':				enqueue++;				break;			case 'V':				voladj_arg = strdup(optarg);				break;			case 'Q':				remote_quit++;				break;			default:				show_usage++;				break;			}		}	}		if (show_version) {		print_version();		close_app_socket();		exit(1);	}	if (show_usage) {		print_usage();		close_app_socket();		exit(1);	}	if (back) {		if (no_session == -1)			no_session = 0;		rcmd = RCMD_BACK;		send_message_to_session(no_session, &rcmd, 1);		close_app_socket();		exit(0);	}	if (pause) {		if (no_session == -1)			no_session = 0;		rcmd = RCMD_PAUSE;		send_message_to_session(no_session, &rcmd, 1);		close_app_socket();		exit(0);	}	if (stop) {		if (no_session == -1)			no_session = 0;		rcmd = RCMD_STOP;		send_message_to_session(no_session, &rcmd, 1);		close_app_socket();		exit(0);	}	if (fwd) {		if (no_session == -1)			no_session = 0;		rcmd = RCMD_FWD;		send_message_to_session(no_session, &rcmd, 1);		close_app_socket();		exit(0);	}	if (remote_quit) {		if (no_session == -1)			no_session = 0;		rcmd = RCMD_QUIT;		send_message_to_session(no_session, &rcmd, 1);		close_app_socket();		exit(1);	}	if (voladj_arg) {		char buf[MAXLEN];		if (no_session == -1)			no_session = 0;		buf[0] = RCMD_VOLADJ;		buf[1] = '\0';		strncat(buf, voladj_arg, MAXLEN-1);		send_message_to_session(no_session, buf, strlen(buf));		close_app_socket();		exit(1);	}	{		int i;		char buffer[MAXLEN];		char fullname[MAXLEN];		char * home;		char * path;		if ((no_session != -1) && (no_session != aqualung_session_id)) {			for (i = optind; argv[i] != NULL; i++) {								switch (argv[i][0]) {				case '/':					strcpy(fullname, argv[i]);					break;				case '~':					path = argv[i];					++path;					if (!(home = getenv("HOME"))) {						fprintf(stderr,	"main(): cannot resolve home directory\n");						return 1;					}					snprintf(fullname, MAXLEN-1, "%s/%s", home, path);					break;				default:					snprintf(fullname, MAXLEN-1, "%s/%s", options.cwd, argv[i]);					break;				}				if ((enqueue) || (i > optind)) {					buffer[0] = RCMD_ENQUEUE;					buffer[1] = '\0';					strncat(buffer, fullname, MAXLEN-1);					send_message_to_session(no_session, buffer, strlen(buffer));				} else {					buffer[0] = RCMD_LOAD;					buffer[1] = '\0';					strncat(buffer, fullname, MAXLEN-1);					send_message_to_session(no_session, buffer, strlen(buffer));				}			}			if (play) {				rcmd = RCMD_PLAY;				send_message_to_session(no_session, &rcmd, 1);			}			close_app_socket();			exit(0);		}	}	if (play) {		if ((no_session == -1) || (no_session == aqualung_session_id)) {			immediate_start = 1;		} else {			rcmd = RCMD_PLAY;			send_message_to_session(no_session, &rcmd, 1);			close_app_socket();			exit(0);		}	}#ifdef _WIN32	if (output == 0) {		output = WIN32_DRIVER;	}#endif /* _WIN32 */	memset(&thread_info, 0, sizeof(thread_info));#ifdef HAVE_JACK	if ((output != JACK_DRIVER) && (rate == 0)) {		rate = 44100;	}#else	if (rate == 0) {		rate = 44100;	}#endif /* HAVE_JACK */	/* try to find a suitable output driver */	if (output == 0) {		printf("No output driver specified, probing for a usable driver.\n");	}#ifdef HAVE_JACK	if (output == 0) {		int ret;		/* probe Jack */		printf("Probing JACK driver... ");		ret = jack_init(&thread_info);		if (ret == -1) {			printf("JACK server not found\n");		} else if (ret < 0) {			printf("Output samplerate (%d Hz) out of range\n", -ret);		} else {			output = JACK_DRIVER;			rate = thread_info.out_SR;			auto_connect = 1;			auto_driver_found = 1;			printf("OK\n");		}	}#endif /* HAVE_JACK */#ifdef HAVE_ALSA	if (output == 0) { /* probe ALSA */		int ret;		printf("Probing ALSA driver... ");		period = 8192;		nperiods = 2;		device_name = strdup("plughw:0,0");		thread_info.out_SR = rate;		thread_info.pcm_name = strdup(device_name);		ret = alsa_init(&thread_info, 0);		if (ret == -1) {			printf("device busy\n");					} else if (ret < 0) {			printf("unable to start with default params\n");		} else {			output = ALSA_DRIVER;			auto_driver_found = 1;			printf("OK\n");		}	}#endif /* HAVE_ALSA */#ifdef HAVE_OSS	if (output == 0) { /* probe OSS */		int ret;		printf("Probing OSS driver... ");		device_name = strdup("/dev/dsp");		thread_info.out_SR = rate;		ret = oss_init(&thread_info, 0);		if (ret == -1) {			printf("device busy\n");					} else if (ret < 0) {			printf("unable to start with default params\n");		} else {			output = OSS_DRIVER;			auto_driver_found = 1;			printf("OK\n");		}	}#endif /* HAVE_OSS */	/* if no output driver was found, give up and exit */	if (output == 0) {		fprintf(stderr,			"No usable output driver was found. Please see aqualung --help\n"			"and the docs for more info on successfully starting the program.\n");		close_app_socket();		exit(1);	}	#ifdef HAVE_JACK	if ((output == JACK_DRIVER) && (!auto_driver_found) && (rate > 0)) {		fprintf(stderr,			"You attempted to set the output rate for the JACK output.\n"			"We won't do this; please use the --rate option with the\n"			"oss and alsa outputs only.\n"			"In case of the JACK output, the (already running) JACK server\n"			"will determine the output sample rate to use.\n");		close_app_socket();		exit(1);	}#endif /* HAVE_JACK */	if (device_name == NULL) {#ifdef HAVE_OSS		if (output == OSS_DRIVER) {			device_name = strdup("/dev/dsp");		}#endif /* HAVE_OSS */#ifdef HAVE_ALSA		if (output == ALSA_DRIVER) {			device_name = strdup("plughw:0,0");		}#endif /* HAVE_ALSA */	}#ifdef HAVE_ALSA	if (output == ALSA_DRIVER) {		if (period == 0) {			period = 8192;		}		if (nperiods == 0) {			nperiods = 2;		}	}#endif /* HAVE_ALSA */#ifdef HAVE_JACK	if (output == JACK_DRIVER) {		if (!auto_driver_found) {			int ret = jack_init(&thread_info);			if (ret == -1) {				print_jack_failed_connection();				close_app_socket();				exit(1);			} else if (ret < 0) {				print_jack_SR_out_of_range(-ret);				close_app_socket();				exit(1);			} else {				rate = thread_info.out_SR;			}		}	}#endif /* HAVE_JACK */#ifdef HAVE_ALSA	if (output == ALSA_DRIVER) {		if (!auto_driver_found) {			int ret;			thread_info.out_SR = rate;			thread_info.pcm_name = strdup(device_name);			ret = alsa_init(&thread_info, 1);			if (ret < 0) {				close_app_socket();				exit(1);			}		}	}#endif /* HAVE_ALSA */#ifdef HAVE_OSS	if (output == OSS_DRIVER) {		thread_info.out_SR = rate;	}#endif /* HAVE_OSS */#ifdef _WIN32	if (output == WIN32_DRIVER) {		thread_info.out_SR = rate;	}#endif /* _WIN32 */	thread_info.rb_size = RB_AUDIO_SIZE * thread_info.out_SR / 44100.0;        rb = rb_create(2*sample_size * thread_info.rb_size);	memset(rb->buf, 0, rb->size);	rb_disk2gui = rb_create(RB_CONTROL_SIZE);	memset(rb_disk2gui->buf, 0, rb_disk2gui->size);	rb_gui2disk = rb_create(RB_CONTROL_SIZE);	memset(rb_gui2disk->buf, 0, rb_gui2disk->size);	rb_disk2out = rb_create(RB_CONTROL_SIZE);	memset(rb_disk2out->buf, 0, rb_disk2out->size);	thread_info.is_streaming = 0;	thread_info.is_mono = 0;	thread_info.in_SR = 0;	/* startup disk thread */	AQUALUNG_THREAD_CREATE(thread_info.disk_thread_id, NULL, disk_thread, &thread_info)	if (disk_try_realtime) {#ifdef _WIN32		printf("Warning: setting thread priorities is unsupported under Win32.\n");#else		int x;		memset(&param, 0, sizeof(param));		param.sched_priority = disk_priority;		if ((x = pthread_setschedparam(thread_info.disk_thread_id,					       SCHED_FIFO, &param)) != 0) {			fprintf(stderr,				"Warning: cannot use real-time scheduling for disk thread (FIFO/%d) "				"(%d: %s)\n", param.sched_priority, x, strerror(x));		}#endif /* _WIN32 */	}#ifdef HAVE_OSS	if (output == OSS_DRIVER) {		if (!auto_driver_found) {			int ret = oss_init(&thread_info, 1);			if (ret < 0) {				close_app_socket();				exit(1);			}		}	}#endif /* HAVE_OSS */#ifdef HAVE_ALSA	if (output == ALSA_DRIVER) {		AQUALUNG_THREAD_CREATE(thread_info.alsa_thread_id, NULL, alsa_thread, &thread_info)		if (try_realtime) {#ifdef _WIN32			printf("Warning: setting thread priorities is unsupported under Win32.\n");#else			int x;			memset(&param, 0, sizeof(param));			param.sched_priority = priority;			if ((x = pthread_setschedparam(thread_info.alsa_thread_id,						       SCHED_FIFO, &param)) != 0) {				fprintf(stderr,					"Warning: cannot use real-time scheduling for ALSA output thread (FIFO/%d) "					"(%d: %s)\n", param.sched_priority, x, strerror(x));			}#endif /* _WIN32 */		}	}#endif /* HAVE_ALSA */#ifdef _WIN32	if (output == WIN32_DRIVER) {		AQUALUNG_THREAD_CREATE(thread_info.win32_thread_id, NULL, win32_thread, &thread_info)	}#endif /* _WIN32 */	create_gui(argc, argv, optind, enqueue, rate, RB_AUDIO_SIZE * rate / 44100.0);	run_gui(); /* control stays here until user exits program */	AQUALUNG_THREAD_JOIN(thread_info.disk_thread_id)#ifdef HAVE_OSS	if (output == OSS_DRIVER) {		AQUALUNG_THREAD_JOIN(thread_info.oss_thread_id)		free(thread_info.oss_short_buf);		ioctl(thread_info.fd_oss, SNDCTL_DSP_RESET, 0);		close(thread_info.fd_

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -