93 lines
3.3 KiB
Bash
Executable File
93 lines
3.3 KiB
Bash
Executable File
#!/bin/bash
|
||
# SYSTEM: UPDATE AUDIO FRAME SIZE
|
||
# Run debug then search log for instance of frame size. Assgn to variable then write to anonradio-config.json
|
||
|
||
|
||
# Includes and Declarations (global variables, formatting, and functions)
|
||
source "${APPLICATION_ROOT}/scripts/system/system-functions"
|
||
source "${APPLICATION_ROOT}/scripts/system/system-declarations"
|
||
|
||
|
||
# Kill process (as a safeguard)
|
||
sudo pkill "liquidsoap";
|
||
|
||
|
||
# Get active config name, construct path to streamable config file (for validation)
|
||
CURRENTLY_ACTIVE_CONFIG_NAME=$(<"$CONFIG_FILE_IDENTIFIER_PATH")
|
||
STREAMABLE_CONFIG_FILE_PATH="$CONFIG_DIRECTORY/config-$CURRENTLY_ACTIVE_CONFIG_NAME.json"
|
||
|
||
|
||
# Check if config file exists
|
||
if [[ -f "$STREAMABLE_CONFIG_FILE_PATH" ]];
|
||
|
||
# If exists
|
||
then
|
||
|
||
# Set up timestamp formatting, path, then create file and set permission for coming log-dump
|
||
TIMESTAMP_FILENAME="log-$(date +%s)"
|
||
CURRENT_CHOWN_USER=$(whoami)
|
||
FULL_LOG_FILE_PATH="$LOG_FOLDER_PATH/buffer_evaluation_$TIMESTAMP_FILENAME"
|
||
sudo touch "$FULL_LOG_FILE_PATH"
|
||
sudo chmod 755 "$FULL_LOG_FILE_PATH"
|
||
sudo chown "$CURRENT_CHOWN_USER" "$FULL_LOG_FILE_PATH"
|
||
|
||
|
||
# Log color formatting of log, then export log to specified log file (butter_evaluation_log-[timestamp])
|
||
printf "${COLOR_GRAY}";
|
||
liquidsoap -v --debug 'input.alsa(bufferize=false)' >> $FULL_LOG_FILE_PATH & sleep 3;
|
||
sudo pkill "liquidsoap";
|
||
sleep 2
|
||
printf "${COLOR_DEFAULT}"
|
||
|
||
|
||
# Notification of command edecution
|
||
confirmation_message "[H] Review Hardware Audio Frame Size:"
|
||
|
||
|
||
# sed to strip away just want
|
||
# Example log line (for reference):
|
||
# 2019/11/09 19:11:09 [frame:3] Frame size must be a multiple of 1764 ticks = 1764 audio samples = 1 video samples.
|
||
BUFFER_RECOMMENDED=$(sed -e s/"^.*ticks = "// -e s/" audio samples.*$"// <<< $(sed -n "s/Frame size must be a multiple of//p" $FULL_LOG_FILE_PATH))
|
||
BUFFER_DECLARED=$(sed -e s/'[ \t]*\"\"\:\"'// -e s/'".*'// <<< $(sed -n "s/"hardware_audio_frame_size"//p" $STREAMABLE_CONFIG_FILE_PATH))
|
||
|
||
|
||
# Check if declared AFS buffer size is a multiple of recommended AFS buffer (using bc)
|
||
# Then, if checked result has 8 decimal places of zeroes, then echo appropriate notice
|
||
BUFFER_MULTIPLE_CHECK=`echo "scale=8; $BUFFER_DECLARED/$BUFFER_RECOMMENDED" | bc -l`
|
||
if [[ $BUFFER_MULTIPLE_CHECK == *".00000000"* ]]; then
|
||
NOTICE="${COLOR_GREEN}${SYMBOL_CHECKMARK}${COLOR_DEFAULT} ${FONT_BOLD}Config settings OK! (config AFS is multiple of recommended AFS)${FONT_DEFAULT}"
|
||
else
|
||
NOTICE="${FONT_BOLD}${COLOR_YELLOW}${SYMBOL_HAZARD}${COLOR_DEFAULT} Warning: Config AFS is not a multiple of recommended AFS${FONT_DEFAULT}"
|
||
fi
|
||
|
||
|
||
# Output / Reporting:
|
||
printf "\n"
|
||
printf "\n"
|
||
printf "${FONT_BOLD} HARDWARE, AUDIO FRAME SIZE (AFS):${FONT_DEFAULT}\n"
|
||
printf "\n"
|
||
# printf " • Default system frame size - $BUFFER_OBSERVED\n"
|
||
printf " • Recommended frame size - $BUFFER_RECOMMENDED\n"
|
||
printf " • Your current config's frame size - $BUFFER_DECLARED\n"
|
||
printf "\n"
|
||
printf " $NOTICE\n"
|
||
printf "\n"
|
||
printf "\n"
|
||
printf "\n"
|
||
|
||
|
||
# Unset Variables
|
||
IDENTIFYING_STRING=""
|
||
BUFFER_LINE=""
|
||
EVALUATED_SAMPLES=""
|
||
BUFFER_OBSERVED=""
|
||
NOTICE=""
|
||
|
||
# If no config file exists
|
||
else
|
||
error_message "[H] Review Hardware Audio Frame Size: No config file to reference. Please specify."
|
||
echo ""
|
||
|
||
fi
|
||
|