Changeset View
Changeset View
Standalone View
Standalone View
usr.sbin/virtual_oss/virtual_oss/main.c
| Show First 20 Lines • Show All 1,624 Lines • ▼ Show 20 Lines | |||||
| static int voss_baseclone = 0; | static int voss_baseclone = 0; | ||||
| static const char *voss_pid_path; | static const char *voss_pid_path; | ||||
| uint32_t voss_dsp_rx_refresh; | uint32_t voss_dsp_rx_refresh; | ||||
| uint32_t voss_dsp_tx_refresh; | uint32_t voss_dsp_tx_refresh; | ||||
| char voss_dsp_rx_device[VMAX_STRING]; | char voss_dsp_rx_device[VMAX_STRING]; | ||||
| char voss_dsp_tx_device[VMAX_STRING]; | char voss_dsp_tx_device[VMAX_STRING]; | ||||
| char voss_ctl_device[VMAX_STRING]; | char voss_ctl_device[VMAX_STRING]; | ||||
| static int have_default_ctldev = 0; | |||||
| uint32_t voss_jitter_up; | uint32_t voss_jitter_up; | ||||
| uint32_t voss_jitter_down; | uint32_t voss_jitter_down; | ||||
| struct voss_backend *voss_rx_backend; | struct voss_backend *voss_rx_backend; | ||||
| struct voss_backend *voss_tx_backend; | struct voss_backend *voss_tx_backend; | ||||
| static int voss_dups; | static int voss_dups; | ||||
| ▲ Show 20 Lines • Show All 268 Lines • ▼ Show 20 Lines | if (strcmp(ptr->oss_name, "dsp") == 0) { | ||||
| x = 0; | x = 0; | ||||
| size = sizeof(int); | size = sizeof(int); | ||||
| if (sysctlbyname(SYSCTL_BASECLONE, &voss_baseclone, | if (sysctlbyname(SYSCTL_BASECLONE, &voss_baseclone, | ||||
| &size, &x, size) < 0) | &size, &x, size) < 0) | ||||
| return ("Could not disable " SYSCTL_BASECLONE); | return ("Could not disable " SYSCTL_BASECLONE); | ||||
| printf(SYSCTL_BASECLONE ": %d -> 0\n", voss_baseclone); | printf(SYSCTL_BASECLONE ": %d -> 0\n", voss_baseclone); | ||||
| if (atexit(restore_baseclone) < 0) | if (atexit(restore_baseclone) < 0) | ||||
| return ("Could not set atexit callback"); | return ("Could not set atexit callback"); | ||||
| /* | |||||
| * Hardcode control device name when we replace | |||||
| * /dev/dsp with our own. This is an easy way for other | |||||
| * programs to know which is the control device when we | |||||
| * have a virtual_oss-created /dev/dsp. For an example, | |||||
| * see sbin/devd/snd.conf. | |||||
| */ | |||||
| strlcpy(voss_ctl_device, "vdsp.ctl", | |||||
| sizeof(voss_ctl_device)); | |||||
| have_default_ctldev = 1; | |||||
| } | } | ||||
| /* create DSP character device */ | /* create DSP character device */ | ||||
| pdev = cuse_dev_create(&vclient_oss_methods, ptr, NULL, | pdev = cuse_dev_create(&vclient_oss_methods, ptr, NULL, | ||||
| 0, 0, voss_dsp_perm, ptr->oss_name); | 0, 0, voss_dsp_perm, ptr->oss_name); | ||||
| if (pdev == NULL) { | if (pdev == NULL) { | ||||
| free(ptr); | free(ptr); | ||||
| return ("Could not create CUSE DSP device"); | return ("Could not create CUSE DSP device"); | ||||
| ▲ Show 20 Lines • Show All 373 Lines • ▼ Show 20 Lines | case 's': | ||||
| voss_dsp_samples = voss_dsp_sample_rate * samples_ms / 1000.0; | voss_dsp_samples = voss_dsp_sample_rate * samples_ms / 1000.0; | ||||
| } else { | } else { | ||||
| voss_dsp_samples = atoi(optarg); | voss_dsp_samples = atoi(optarg); | ||||
| } | } | ||||
| if (voss_dsp_samples >= (1U << 24)) | if (voss_dsp_samples >= (1U << 24)) | ||||
| return ("-s option requires a non-zero positive value"); | return ("-s option requires a non-zero positive value"); | ||||
| break; | break; | ||||
| case 't': | case 't': | ||||
| if (have_default_ctldev) { | |||||
| return ("Creating /dev/dsp automatically " | |||||
| "creates a /dev/vdsp.ctl control device " | |||||
| "and cannot be overwritten"); | |||||
| } | |||||
| if (voss_ctl_device[0]) | if (voss_ctl_device[0]) | ||||
| return ("-t parameter may only be used once"); | return ("-t parameter may only be used once"); | ||||
| strlcpy(voss_ctl_device, optarg, sizeof(voss_ctl_device)); | strlcpy(voss_ctl_device, optarg, sizeof(voss_ctl_device)); | ||||
| break; | break; | ||||
| case 'm': | case 'm': | ||||
| ptr = optarg; | ptr = optarg; | ||||
| val = 0; | val = 0; | ||||
| ▲ Show 20 Lines • Show All 340 Lines • Show Last 20 Lines | |||||