// Called by slimproto when the "vers" command is received from the // server to signal the version. static int vers_callback(slimproto_t *p, const unsigned char *buf, int buf_len, void *user_data) { slimaudio_t* const audio = (slimaudio_t*)user_data; if (audio->keepalive_interval != -1) { // Keepalive interval has been set explicitly, don't overwrite. DEBUGF("Explicit keepalive interval: %d s. " "Will not override.\n", audio->keepalive_interval); return 0; } slimproto_msg_t msg; slimproto_parse_command(buf, buf_len, &msg); DEBUGF("Server version: %x\n", msg.vers.version); if ((msg.vers.version >= 0x00060500) && (msg.vers.version < 0x00070200)) { // 6.5.0<->7.2.0 Squeezebox Server needs a player to send // a keepalive message every 10 seconds or so before it declares // it down. slimaudio_set_keepalive_interval(audio, 10); DEBUGF("Using 6.5.x default keepalive interval: %d s.\n", audio->keepalive_interval); } return 0; }
/* * Callback for the 'audg' command */ static int audg_callback(slimproto_t *proto, const unsigned char *buf, int buf_len, void *user_data) { slimproto_msg_t msg; slimaudio_t* const audio = (slimaudio_t *) user_data; slimproto_parse_command(buf, buf_len, &msg); DEBUGF("audg cmd: left_gain:%u right_gain:%u volume:%f old_left_gain:%u old_right_gain:%u", msg.audg.left_gain, msg.audg.right_gain, audio->volume, msg.audg.old_left_gain, msg.audg.old_right_gain); VDEBUGF(" preamp:%hhu digital_volume_control:%hhu", msg.audg.preamp, msg.audg.digital_volume_control); DEBUGF("\n"); audio->vol_adjust = (float) (msg.audg.left_gain) / 65536.0; slimaudio_output_vol_adjust(audio); return 0; }
/* * Callback for 'strm' command. */ static int strm_callback(slimproto_t *proto, const unsigned char *buf, int buf_len, void *user_data) { slimproto_msg_t msg; slimaudio_t *audio = (slimaudio_t *) user_data; slimproto_parse_command(buf, buf_len, &msg); DEBUGF("strm cmd %c\n", msg.strm.command); switch (msg.strm.command) { case 's': /* start */ slimaudio_http_connect(audio, &msg); slimaudio_decoder_connect(audio, &msg); slimaudio_output_connect(audio, &msg); break; case 'p': /* pause */ slimaudio_output_pause(audio); break; case 'u': /* unpause */ slimaudio_output_unpause(audio); break; case 'q': /* stop */ audio_stop(audio); break; case 't': /* status */ break; } slimaudio_stat(audio, (char *)&msg.strm.cmd); DEBUGF("DONE strm cmd %c\n", msg.strm.command); return 0; }
/* * Callback for 'strm' command. */ static int strm_callback(slimproto_t *proto, const unsigned char *buf, int buf_len, void *user_data) { slimproto_msg_t msg; float replay_gain; slimaudio_t *audio = (slimaudio_t *) user_data; slimproto_parse_command(buf, buf_len, &msg); DEBUGF("strm cmd %c strm.replay_gain:%u ", msg.strm.command, msg.strm.replay_gain); switch (msg.strm.command) { case 's': /* start */ replay_gain = (float) (msg.strm.replay_gain) / 65536.0; audio->start_replay_gain = replay_gain == 0.0 ? 1.0 : replay_gain; if (audio->replay_gain == -1.0) audio->replay_gain = audio->start_replay_gain; DEBUGF("start_replay_gain:%f\n", audio->start_replay_gain); slimaudio_stat(audio, "STMc", (u32_t) 0); /* connect, acknowledge strm-s */ slimaudio_http_connect(audio, &msg); slimaudio_decoder_connect(audio, &msg); slimaudio_output_connect(audio, &msg); break; case 'p': /* pause */ DEBUGF("\n"); slimaudio_output_pause(audio); /* Only send STMp if interval is zero */ if (! msg.strm.replay_gain) slimaudio_stat(audio, "STMp", (u32_t) 0); /* pause */ break; case 'u': /* unpause */ DEBUGF("\n"); slimaudio_output_unpause(audio); slimaudio_stat(audio, "STMr", (u32_t) 0); /* resume */ break; case 'q': /* stop */ DEBUGF("\n"); audio_stop(audio); slimaudio_stat(audio, "STMf", (u32_t) 0); /* acknowledge stop cmd */ break; case 'f': /* flush */ DEBUGF("\n"); slimaudio_buffer_flush(audio->decoder_buffer); slimaudio_buffer_flush(audio->output_buffer); slimaudio_stat(audio, "STMf", (u32_t) 0); /* acknowledge flush cmd */ break; case 'a': /* skip ahead */ DEBUGF("\n"); break; case 't': /* status */ DEBUGF("\n"); slimaudio_stat(audio, "STMt", msg.strm.replay_gain); break; } DEBUGF("DONE strm cmd %c\n", msg.strm.command); return 0; }