mirror of
https://github.com/lwvmobile/dsd-fme.git
synced 2026-11-17 03:07:24 -05:00
Configure OSS Output to be more Dynamic;
This commit is contained in:
108
src/dsd_main.c
108
src/dsd_main.c
@@ -2703,111 +2703,9 @@ main (int argc, char **argv)
|
||||
fprintf (stderr, "Switching to /dev/dsp.\n");
|
||||
}
|
||||
|
||||
if (opts.audio_in_type == 5) //if((strncmp(opts.audio_in_dev, "/dev/dsp", 8) == 0)) or 'split' == 0
|
||||
{
|
||||
|
||||
if((strncmp(opts.audio_out_dev, "/dev/dsp", 8) == 0))
|
||||
{
|
||||
fprintf (stderr, "OSS Output %s.\n", opts.audio_out_dev);
|
||||
opts.audio_out_fd = open (opts.audio_out_dev, O_RDWR);
|
||||
if (opts.audio_out_fd == -1)
|
||||
{
|
||||
fprintf (stderr, "Error, couldn't open #1 %s\n", opts.audio_out_dev);
|
||||
opts.audio_out = 0;
|
||||
exit(1);
|
||||
}
|
||||
|
||||
fmt = 0;
|
||||
if (ioctl (opts.audio_out_fd, SNDCTL_DSP_RESET) < 0)
|
||||
{
|
||||
fprintf (stderr, "ioctl reset error \n");
|
||||
}
|
||||
|
||||
fmt = speed;
|
||||
if (ioctl (opts.audio_out_fd, SNDCTL_DSP_SPEED, &fmt) < 0)
|
||||
{
|
||||
fprintf (stderr, "ioctl speed error \n");
|
||||
}
|
||||
|
||||
fmt = 0; //this seems okay to be 1 or 0, not sure what the difference really is (works in stereo on 0)
|
||||
if (ioctl (opts.audio_out_fd, SNDCTL_DSP_STEREO, &fmt) < 0)
|
||||
{
|
||||
fprintf (stderr, "ioctl stereo error \n");
|
||||
}
|
||||
|
||||
fmt = AFMT_S16_LE;
|
||||
if (ioctl (opts.audio_out_fd, SNDCTL_DSP_SETFMT, &fmt) < 0)
|
||||
{
|
||||
fprintf (stderr, "ioctl setfmt error \n");
|
||||
}
|
||||
|
||||
opts.audio_out_type = 5; //5 for 1 channel - 48k OSS 16-bit short output (matching with input)
|
||||
opts.pulse_digi_rate_out = 48000; //this is used to force to upsample
|
||||
opts.pulse_digi_out_channels = 1;
|
||||
opts.audio_gain = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (opts.audio_in_type != 5) //split == 1
|
||||
{
|
||||
|
||||
if((strncmp(opts.audio_out_dev, "/dev/dsp", 8) == 0))
|
||||
{
|
||||
fprintf (stderr, "OSS Output %s.\n", opts.audio_out_dev);
|
||||
opts.audio_out_fd = open (opts.audio_out_dev, O_WRONLY);
|
||||
if (opts.audio_out_fd == -1)
|
||||
{
|
||||
fprintf (stderr, "Error, couldn't open %s\n", opts.audio_out_dev);
|
||||
opts.audio_out = 0;
|
||||
exit(1);
|
||||
}
|
||||
|
||||
//Setup the device. Note that it's important to set the sample format, number of channels and sample rate exactly in this order. Some devices depend on the order.
|
||||
|
||||
fmt = 0;
|
||||
if (ioctl (opts.audio_out_fd, SNDCTL_DSP_RESET) < 0)
|
||||
{
|
||||
fprintf (stderr, "ioctl reset error \n");
|
||||
}
|
||||
|
||||
fmt = AFMT_S16_LE; //Sample Format
|
||||
if (ioctl (opts.audio_out_fd, SNDCTL_DSP_SETFMT, &fmt) < 0)
|
||||
{
|
||||
fprintf (stderr, "ioctl setfmt error \n");
|
||||
}
|
||||
|
||||
fmt = opts.pulse_digi_out_channels; //number of channels //was 2
|
||||
if (ioctl (opts.audio_out_fd, SNDCTL_DSP_CHANNELS, &fmt) < 0)
|
||||
{
|
||||
fprintf (stderr, "ioctl channel error \n");
|
||||
}
|
||||
|
||||
speed = opts.pulse_digi_rate_out; //since we have split input/output, we want 2-channel/8k //8000 -- mirror pulse rate instead
|
||||
fmt = speed; //output rate
|
||||
if (ioctl (opts.audio_out_fd, SNDCTL_DSP_SPEED, &fmt) < 0)
|
||||
{
|
||||
fprintf (stderr, "ioctl speed error \n");
|
||||
}
|
||||
if (opts.pulse_digi_out_channels == 2)
|
||||
fmt = 1;
|
||||
else fmt = 0;
|
||||
|
||||
if (ioctl (opts.audio_out_fd, SNDCTL_DSP_STEREO, &fmt) < 0)
|
||||
{
|
||||
fprintf (stderr, "ioctl stereo error \n");
|
||||
}
|
||||
|
||||
//TODO: Multiple output returns based on 8k/1, 8k/2, or maybe 48k/1? (2,3,5)??
|
||||
if (opts.pulse_digi_out_channels == 2)
|
||||
opts.audio_out_type = 2; //2 for 2 channel 8k OSS 16-bit short output
|
||||
else if (opts.frame_m17 == 1)
|
||||
opts.audio_out_type = 2;
|
||||
else opts.audio_out_type = 5;
|
||||
|
||||
//debug
|
||||
fprintf (stderr, "Using OSS Output with %dk/%d channel configuration.\n", opts.pulse_digi_rate_out, opts.pulse_digi_out_channels);
|
||||
}
|
||||
}
|
||||
//this will only open OSS output if its listed as a type
|
||||
//changed to this so I could call it freely inside of ncurses terminal
|
||||
openOSSOutput(&opts);
|
||||
|
||||
if (opts.playfiles == 1) //redo?
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user