#include <stdlib.h>
#include <time.h>
#include <unistd.h>
+#include <inttypes.h>
#include "metadata_hub.h"
#include "tinyhttp/http.h"
void *dacp_monitor_thread_code(void *na) {
int scan_index = 0;
- char server_reply[10000];
+ // char server_reply[10000];
// debug(1, "DACP monitor thread started.");
// wait until we get a valid port number to begin monitoring it
int32_t revision_number = 1;
metadata_store.playerstatusupdates_are_received = 1;
sp -= item_size; // drop down into the array -- don't skip over it
le -= 8;
- char typestring[5];
+ // char typestring[5];
// we need to acquire the metadata data structure and possibly update it
while (le >= 8) {
uint32_t type = dacp_tlv_crawl(&sp, &item_size);
le -= item_size + 8;
char *t;
- char u;
- char *st;
+ // char u;
+ // char *st;
int32_t r;
- uint64_t s, v;
- int i;
+ // uint64_t v;
+ // int i;
switch (type) {
case 'cmsr': // revision number
}
int dacp_get_client_volume(int32_t *result) {
+ debug(1,"dacp_get_client_volume");
char *server_reply = NULL;
int32_t overall_volume = -1;
ssize_t reply_size;
} /* else {
debug(1, "Unexpected response %d to dacp volume control request", response);
} */
- if (result)
+ if (result) {
*result=overall_volume;
+ debug(1,"dacp_get_client_volume returns: %" PRId32 ".",overall_volume);
+ }
return response;
}
int dacp_set_include_speaker_volume(int64_t machine_number, int32_t vo) {
+ debug(1,"dacp_set_include_speaker_volume to %" PRId32 ".",vo);
char message[1000];
memset(message, 0, sizeof(message));
- sprintf(message, "setproperty?include-speaker-id=%ld&dmcp.volume=%d", machine_number, vo);
- // debug(1,"sending \"%s\"",message);
+ sprintf(message, "setproperty?include-speaker-id=%" PRId64 "&dmcp.volume=%" PRId32 "", machine_number, vo);
+ debug(1,"sending \"%s\"",message);
return send_simple_dacp_command(message);
// should return 204
}
int dacp_set_speaker_volume(int64_t machine_number, int32_t vo) {
char message[1000];
memset(message, 0, sizeof(message));
- sprintf(message, "setproperty?speaker-id=%ld&dmcp.volume=%d", machine_number, vo);
- // debug(1,"sending \"%s\"",message);
+ sprintf(message, "setproperty?speaker-id=%" PRId64 "&dmcp.volume=%" PRId32 "", machine_number, vo);
+ debug(1,"sending \"%s\"",message);
return send_simple_dacp_command(message);
// should return 204
}
int dacp_get_speaker_list(dacp_spkr_stuff *speaker_info, int max_size_of_array, int *actual_speaker_count) {
- char typestring[5];
+ // char typestring[5];
char *server_reply = NULL;
int speaker_index = -1; // will be incremented before use
int speaker_count = -1; // will be fixed if there is no problem
} else {
le -= item_size + 8;
char *t;
- char u;
+ // char u;
int32_t r;
int64_t s, v;
switch (type) {
int32_t overall_volume = 0;
int32_t actual_volume = 0;
int http_response = dacp_get_client_volume(&overall_volume);
- // debug(1, "DACP Volume: %d.", overall_volume);
if (http_response==200) {
+ debug(1,"Overall volume is: %u.",overall_volume);
int speaker_count = 0;
http_response = dacp_get_speaker_list((dacp_spkr_stuff *)&speaker_info, 50,&speaker_count);
- // debug(1,"DACP Speaker Count: %d.",speaker_count);
if (http_response==200) {
// get our machine number
uint16_t *hn = (uint16_t *)config.hw_addr;
int32_t relative_volume = 0;
for (i = 0; i < speaker_count; i++) {
if (speaker_info[i].speaker_number == machine_number) {
- // debug(1,"Our speaker number found: %ld.",machine_number);
relative_volume = speaker_info[i].volume;
- /*
+ debug(1,"Our speaker was found with a relative volume of: %u.",relative_volume);
+
if (speaker_info[i].active)
debug(1,"Our speaker is active.");
else
debug(1,"Our speaker is inactive.");
- */
+
}
}
actual_volume = (overall_volume * relative_volume + 50) / 100;
- // debug(1,"Overall volume: %d, relative volume: %d%, actual volume:
- // %d.",overall_volume,relative_volume,actual_volume);
+ debug(1,"Overall volume: %d, relative volume: %d%, actual volume: %d.",overall_volume,relative_volume,actual_volume);
// debug(1,"Our actual speaker volume is %d.",actual_volume);
//metadata_hub_modify_prolog();
//metadata_store.speaker_volume = actual_volume;
} else {
debug(1,"Unexpected return code %d from dacp_get_speaker_list.",http_response);
}
- } /* else {
+ } else {
debug(1,"Unexpected return code %d from dacp_get_client_volume.",http_response);
- } */
- if (the_actual_volume)
+ }
+ if (the_actual_volume) {
+ debug(1,"dacp_get_volume returns %d.",actual_volume);
*the_actual_volume = actual_volume;
- return http_response;
+ }
+ return http_response;
}
}
gboolean notify_volume_callback(ShairportSync *skeleton, gpointer user_data) {
- gint vo = shairport_sync_get_volume(skeleton);
+ gint gvo = shairport_sync_get_volume(skeleton);
+ int32_t vo = gvo;
if ((vo >= 0) && (vo <= 100)) {
if (playing_conn) {
if (vo !=
playing_conn
->dacp_volume) { // this is to stop an infinite loop of setting->checking->setting...
- // debug(1, "Remote-setting volume to %d.", vo);
+ debug(1, "Remote-setting volume to %d.", vo);
// get the information we need -- the absolute volume, the speaker list, our ID
struct dacp_speaker_stuff speaker_info[50];
int32_t overall_volume;
// Let's find our own speaker in the array and pick up its relative volume
int i;
- int32_t relative_volume = 0;
int32_t active_speakers = 0;
for (i = 0; i < speaker_count; i++) {
if (speaker_info[i].speaker_number == machine_number) {
- // debug(1,"Our speaker number found: %ld.",machine_number);
- relative_volume = speaker_info[i].volume;
+ debug(1,"Our speaker number found: %ld with relative volume.",machine_number,speaker_info[i].volume);
}
if (speaker_info[i].active == 1) {
active_speakers++;
if (active_speakers == 1) {
// must be just this speaker
+ debug(1, "Remote-setting volume to %d on just one speaker.", vo);
dacp_set_include_speaker_volume(machine_number, vo);
} else if (active_speakers == 0) {
debug(1, "No speakers!");
} else {
- // debug(1, "Speakers: %d, active: %d",speaker_count,active_speakers);
+ debug(1, "Speakers: %d, active: %d",speaker_count,active_speakers);
if (vo >= overall_volume) {
- // debug(1,"Multiple speakers active, but desired new volume is highest");
+ debug(1,"Multiple speakers active, but desired new volume is highest");
dacp_set_include_speaker_volume(machine_number, vo);
} else {
// the desired volume is less than the current overall volume and there is more than one
}
highest_other_volume = (highest_other_volume * overall_volume + 50) / 100;
if (highest_other_volume <= vo) {
- // debug(1,"Highest other volume %d is less than or equal to the desired new volume
- // %d.",highest_other_volume,vo);
+ debug(1,"Highest other volume %d is less than or equal to the desired new volume %d.",highest_other_volume,vo);
dacp_set_include_speaker_volume(machine_number, vo);
} else {
- // debug(1,"Highest other volume %d is greater than the desired new volume
- // %d.",highest_other_volume,vo);
+ debug(1,"Highest other volume %d is greater than the desired new volume %d.",highest_other_volume,vo);
// if the present overall volume is higher than the highest other volume at present,
// then bring it down to it.
if (overall_volume > highest_other_volume) {
- // debug(1,"Lower overall volume to new highest volume.");
+ debug(1,"Lower overall volume to new highest volume.");
dacp_set_include_speaker_volume(
machine_number,
highest_other_volume); // set the overall volume to the highest one
}
int32_t desired_relative_volume =
(vo * 100 + (highest_other_volume / 2)) / highest_other_volume;
- // debug(1,"Set our speaker volume relative to the highest volume.");
+ debug(1,"Set our speaker volume relative to the highest volume.");
dacp_set_speaker_volume(
machine_number,
desired_relative_volume); // set the overall volume to the highest one
}
}
}
- // } else {
- // debug(1, "No need to remote-set volume to %d, as it is already set to this
- // value.",playing_conn->dacp_volume);
+ } else {
+ debug(1, "No need to remote-set volume to %d, as it is already set to this value.",playing_conn->dacp_volume);
}
} else
debug(1, "no thread playing -- ignored.");
#define METADATA_EXPRESSION config.get_coverart ? "md=0,1,2" : "md=0,2"
-// #define MDNS_RECORD_WITH_METADATA \
-// "tp=UDP", "sm=false", "ek=1", "et=0,1", "cn=0,1", "ch=2", METADATA_EXPRESSION, "ss=16", \
-// "sr=44100", "vn=3", "txtvers=1", config.password ? "pw=true" : "pw=false"
-
+/*
+ #define MDNS_RECORD_WITH_METADATA \
+ "tp=UDP", "sm=false", "ek=1", "et=0,1", "cn=0,1", "ch=2", METADATA_EXPRESSION, "ss=16", \
+ "sr=44100", "vn=3", "txtvers=1", config.password ? "pw=true" : "pw=false"
+*/
#define MDNS_RECORD_WITH_METADATA \
"sf=0x4", "fv=76400.10", "am=ShairportSync", "vs=105.1", "tp=TCP,UDP", "vn=65537", \
METADATA_EXPRESSION, "ss=16", "sr=44100", "da=true", "sv=false", "et=0,1", "ek=1", "cn=0,1", \
#endif
-// #define MDNS_RECORD_WITHOUT_METADATA \
-// "tp=UDP", "sm=false", "ek=1", "et=0,1", "cn=0,1", "ch=2", METADATA_EXPRESSION, "ss=16", "sr=44100", "vn=3", \
-// "txtvers=1", config.password ? "pw=true" : "pw=false"
+/*
+ #define MDNS_RECORD_WITHOUT_METADATA \
+ "tp=UDP", "sm=false", "ek=1", "et=0,1", "cn=0,1", "ch=2", METADATA_EXPRESSION, "ss=16", "sr=44100", "vn=3", \
+ "txtvers=1", config.password ? "pw=true" : "pw=false"
+*/
#define MDNS_RECORD_WITHOUT_METADATA \
"sf=0x4", "fv=76400.10", "am=ShairportSync", "vs=105.1", "tp=TCP,UDP", "vn=65537", "ss=16", \
#include "player.h"
#include "rtp.h"
+uint64_t static local_to_remote_time_jitters;
+uint64_t static local_to_remote_time_jitters_count;
+
void memory_barrier();
void rtp_initialise(rtsp_conn_info *conn) {
uint64_t *remote_timestamp_time, rtsp_conn_info *conn);
void clear_reference_timestamp(rtsp_conn_info *conn);
-uint64_t static local_to_remote_time_jitters;
-uint64_t static local_to_remote_time_jitters_count;
-
#endif // _RTP_H
char *raw_service_name = NULL; /* Used to pick up the service name before possibly expanding it */
char *stuffing = NULL; /* used for picking up the stuffing option */
signed char c; /* used for argument parsing */
- int i = 0; /* used for tracking options */
+ // int i = 0; /* used for tracking options */
int fResyncthreshold = (int)(config.resyncthreshold * 44100);
int fTolerance = (int)(config.tolerance * 44100);
poptContext optCon; /* context for parsing command-line options */
config.cover_art_cache_dir = "/tmp/shairport-sync/.cache/coverart";
#endif
- config_setting_t *setting;
+ // config_setting_t *setting;
const char *str = 0;
int value = 0;
double dvalue = 0.0;