diff --git a/html/changeconf.php b/html/changeconf.php index 27a42f1..9ccd246 100755 --- a/html/changeconf.php +++ b/html/changeconf.php @@ -34,7 +34,71 @@ if (isset($msg)) { echo "}, 30000);\r\n"; echo "\r\n"; } elseif ($msg == "audio") { - echo "Not implemented..."; + $selected = $_POST['output']; + $hda = $_POST['hda']; + $output_old = $_POST['output_old']; + $hda_old = $_POST['hda_old']; + if (isset($selected)) { + if ( ($selected == $output_old) and ($hda == $hda_old) ) { + echo "No changes in audio output configuration.
\r\n"; + echo "\r\n"; + } else { + $end = shell_exec('sudo ./scripts/get_audio_info.sh'); + $lines = explode(PHP_EOL, $end); + if (count($lines) < 4 ) { + echo "There is only ONE audio output in Your PiRadio!

"; + $selected = 'internal'; + } + // Set default mixer and device names for internal audio + $mixer = "PCM"; + $device = "Internal audio device"; + // Prepare pwm parameter + $pwm = ( $hda == 'hdaudio') ? "2" : "1"; + // If external USB audio selected + if ( $selected == 'usb' ) { + // Check number of USB card + preg_match('/bcm2835/', $lines[0], $matches); + $usbline = (isset($matches[0])) ? 2 : 0; + // strange !!! + preg_match("/\[(.*?)\]/", $lines[$usbline], $matches); + $device = $matches[1]; + preg_match("/\'(.*?)\'/", $lines[$usbline + 1], $matches); + $mixer = $matches[1]; + } + echo "New audio device settings.
"; + echo "
Device: ".$device."
"; + echo "Mixer: ".$mixer."
"; + echo "Internal audio high quality mode: "; + if ( $pwm == 2 ) { + echo "Yes"; + } else { + echo "No"; + } + echo "

"; + $end = shell_exec('sudo ./scripts/set_audio.sh '.$selected.' '.$mixer.' '.$pwm ); + echo "Reboot in progress.
\r\n"; + echo "Wait!
\r\n"; + echo "\r\n"; + } + } else { + echo "Audio output device not selected.
\r\n"; + echo "\r\n"; + } } elseif ($msg == "remote") { $selected = $_POST['remote']; if (isset($selected)) { diff --git a/html/hconfig.php b/html/hconfig.php index 99eb88a..9fc897d 100644 --- a/html/hconfig.php +++ b/html/hconfig.php @@ -52,7 +52,7 @@ if ( $hqa_v == 2 ) { } echo '">'; ?> - +
@@ -94,4 +94,4 @@ Update to last build from github - + \ No newline at end of file