More comprhensive saving and restoring of hardware and software level when a session is stopped and started. Does hardware as well as software.
This commit is contained in:
@@ -1227,16 +1227,16 @@ static int stuff_buffer_basic_32(int32_t *inptr, int length, enum sps_format_t l
|
||||
|
||||
pthread_mutex_lock(&conn->vol_mutex);
|
||||
for (i = 0; i < stuffsamp; i++) { // the whole frame, if no stuffing
|
||||
process_sample(*inptr++, &l_outptr, l_output_format, config.fix_volume, dither, conn);
|
||||
process_sample(*inptr++, &l_outptr, l_output_format, config.fix_volume, dither, conn);
|
||||
process_sample(*inptr++, &l_outptr, l_output_format, conn->fix_volume, dither, conn);
|
||||
process_sample(*inptr++, &l_outptr, l_output_format, conn->fix_volume, dither, conn);
|
||||
};
|
||||
if (tstuff) {
|
||||
if (tstuff == 1) {
|
||||
// debug(3, "+++++++++");
|
||||
// interpolate one sample
|
||||
process_sample(mean_32(inptr[-2], inptr[0]), &l_outptr, l_output_format, config.fix_volume,
|
||||
process_sample(mean_32(inptr[-2], inptr[0]), &l_outptr, l_output_format, conn->fix_volume,
|
||||
dither, conn);
|
||||
process_sample(mean_32(inptr[-1], inptr[1]), &l_outptr, l_output_format, config.fix_volume,
|
||||
process_sample(mean_32(inptr[-1], inptr[1]), &l_outptr, l_output_format, conn->fix_volume,
|
||||
dither, conn);
|
||||
} else if (stuff == -1) {
|
||||
// debug(3, "---------");
|
||||
@@ -1251,8 +1251,8 @@ static int stuff_buffer_basic_32(int32_t *inptr, int length, enum sps_format_t l
|
||||
remainder = remainder + tstuff; // don't run over the correct end of the output buffer
|
||||
|
||||
for (i = stuffsamp; i < remainder; i++) {
|
||||
process_sample(*inptr++, &l_outptr, l_output_format, config.fix_volume, dither, conn);
|
||||
process_sample(*inptr++, &l_outptr, l_output_format, config.fix_volume, dither, conn);
|
||||
process_sample(*inptr++, &l_outptr, l_output_format, conn->fix_volume, dither, conn);
|
||||
process_sample(*inptr++, &l_outptr, l_output_format, conn->fix_volume, dither, conn);
|
||||
}
|
||||
}
|
||||
pthread_mutex_unlock(&conn->vol_mutex);
|
||||
@@ -1329,8 +1329,8 @@ static int stuff_buffer_soxr_32(int32_t *inptr, int32_t *scratchBuffer, int leng
|
||||
ip = scratchBuffer;
|
||||
char *l_outptr = outptr;
|
||||
for (i = 0; i < length + tstuff; i++) {
|
||||
process_sample(*ip++, &l_outptr, l_output_format, config.fix_volume, dither, conn);
|
||||
process_sample(*ip++, &l_outptr, l_output_format, config.fix_volume, dither, conn);
|
||||
process_sample(*ip++, &l_outptr, l_output_format, conn->fix_volume, dither, conn);
|
||||
process_sample(*ip++, &l_outptr, l_output_format, conn->fix_volume, dither, conn);
|
||||
};
|
||||
|
||||
} else { // the whole frame, if no stuffing
|
||||
@@ -1341,8 +1341,8 @@ static int stuff_buffer_soxr_32(int32_t *inptr, int32_t *scratchBuffer, int leng
|
||||
int i;
|
||||
|
||||
for (i = 0; i < length; i++) {
|
||||
process_sample(*ip++, &l_outptr, l_output_format, config.fix_volume, dither, conn);
|
||||
process_sample(*ip++, &l_outptr, l_output_format, config.fix_volume, dither, conn);
|
||||
process_sample(*ip++, &l_outptr, l_output_format, conn->fix_volume, dither, conn);
|
||||
process_sample(*ip++, &l_outptr, l_output_format, conn->fix_volume, dither, conn);
|
||||
};
|
||||
}
|
||||
conn->amountStuffed = tstuff;
|
||||
@@ -1535,7 +1535,7 @@ static void *player_thread_func(void *arg) {
|
||||
debug(1, "Dithering will be enabled because the input bit depth is greater than the output bit "
|
||||
"depth");
|
||||
}
|
||||
if (config.fix_volume != 0x10000) {
|
||||
if (conn->fix_volume != 0x10000) {
|
||||
debug(1, "Dithering will be enabled because the output volume is being altered in software");
|
||||
}
|
||||
|
||||
@@ -1623,6 +1623,11 @@ static void *player_thread_func(void *arg) {
|
||||
}
|
||||
}
|
||||
|
||||
// set the default volume to whaterver it was before, as stored in the config airplay_volume
|
||||
debug(1,"Set initial volume to %f.",config.airplay_volume);
|
||||
|
||||
player_volume(config.airplay_volume,conn);
|
||||
|
||||
uint64_t tens_of_seconds = 0;
|
||||
while (!conn->player_thread_please_stop) {
|
||||
abuf_t *inframe = buffer_get_frame(conn);
|
||||
@@ -1649,7 +1654,7 @@ static void *player_thread_func(void *arg) {
|
||||
config.output->play(silence, conn->max_frames_per_packet * conn->output_sample_ratio);
|
||||
} else {
|
||||
int enable_dither = 0;
|
||||
if ((config.fix_volume != 0x10000) || (conn->input_bit_depth > output_bit_depth) ||
|
||||
if ((conn->fix_volume != 0x10000) || (conn->input_bit_depth > output_bit_depth) ||
|
||||
(config.playback_mode == ST_mono))
|
||||
enable_dither = 1;
|
||||
|
||||
@@ -1951,7 +1956,7 @@ static void *player_thread_func(void *arg) {
|
||||
// Apply volume and loudness
|
||||
// Volume must be applied here because the loudness filter will increase the
|
||||
// signal level and it would saturate the int32_t otherwise
|
||||
float gain = config.fix_volume / 65536.0f;
|
||||
float gain = conn->fix_volume / 65536.0f;
|
||||
float gain_db = 20 * log10(gain);
|
||||
// debug(1, "Applying soft volume dB: %f k: %f", gain_db, gain);
|
||||
|
||||
@@ -2440,7 +2445,7 @@ void player_volume_without_notification(double airplay_volume, rtsp_conn_info *c
|
||||
// %f",software_attenuation,temp_fix_volume,airplay_volume);
|
||||
|
||||
pthread_mutex_lock(&conn->vol_mutex);
|
||||
config.fix_volume = temp_fix_volume;
|
||||
conn->fix_volume = temp_fix_volume;
|
||||
pthread_mutex_unlock(&conn->vol_mutex);
|
||||
|
||||
if (config.loudness)
|
||||
@@ -2462,6 +2467,9 @@ void player_volume_without_notification(double airplay_volume, rtsp_conn_info *c
|
||||
send_ssnc_metadata('pvol', dv, strlen(dv), 1);
|
||||
}
|
||||
#endif
|
||||
|
||||
// here, store the volume for possible use in the future
|
||||
config.airplay_volume = airplay_volume;
|
||||
}
|
||||
|
||||
void player_volume(double airplay_volume, rtsp_conn_info *conn) {
|
||||
|
||||
Reference in New Issue
Block a user