Tidy up using clang-format

This commit is contained in:
Mike Brady
2018-03-07 14:35:25 +00:00
parent 07e46565ca
commit c36a7822a3
20 changed files with 255 additions and 228 deletions
+9 -9
View File
@@ -434,7 +434,7 @@ static int init(int argc, char **argv) {
}
}
if (((config.alsa_use_playback_switch_for_mute == 1) &&
(snd_mixer_selem_has_playback_switch(alsa_mix_elem))) ||
(snd_mixer_selem_has_playback_switch(alsa_mix_elem))) ||
mixer_volume_setting_gives_mute) {
audio_alsa.mute = &mute; // insert the mute function now we know it can do muting stuff
// debug(1, "Has mixer and mute ability we will use.");
@@ -462,11 +462,11 @@ int open_alsa_device(void) {
const snd_pcm_uframes_t minimal_buffer_headroom =
352 * 2; // we accept this much headroom in the hardware buffer, but we'll
// accept less
/*
const snd_pcm_uframes_t requested_buffer_headroom =
minimal_buffer_headroom + 2048; // we ask for this much headroom in the
// hardware buffer, but we'll accept less
*/
/*
const snd_pcm_uframes_t requested_buffer_headroom =
minimal_buffer_headroom + 2048; // we ask for this much headroom in the
// hardware buffer, but we'll accept less
*/
int ret, dir = 0;
unsigned int my_sample_rate = desired_sample_rate;
@@ -654,11 +654,11 @@ int open_alsa_device(void) {
if (alsa_characteristics_already_listed == 0) {
alsa_characteristics_already_listed = 1;
int log_level = 2; // the level at which debug information should be output
// int rc;
// int rc;
snd_pcm_access_t access_type;
snd_pcm_format_t format_type;
snd_pcm_subformat_t subformat_type;
// unsigned int val, val2;
// unsigned int val, val2;
unsigned int uval, uval2;
int sval;
int dir;
@@ -852,7 +852,7 @@ static void play(short buf[], int samples) {
}
if (ret == 0) {
pthread_mutex_lock(&alsa_mutex);
// snd_pcm_sframes_t current_delay = 0;
// snd_pcm_sframes_t current_delay = 0;
int err;
if (snd_pcm_state(alsa_handle) == SND_PCM_STATE_XRUN) {
if ((err = snd_pcm_prepare(alsa_handle))) {
+3 -3
View File
@@ -82,9 +82,9 @@ static void stop(void) {
static int init(int argc, char **argv) {
debug(1, "pipe init");
// const char *str;
// int value;
// double dvalue;
// const char *str;
// int value;
// double dvalue;
// set up default values first
+10 -9
View File
@@ -114,9 +114,9 @@ void die(const char *format, ...) {
if ((debuglev) && (config.debugger_show_elapsed_time) && (config.debugger_show_relative_time))
daemon_log(LOG_EMERG, "|% 20.9f|% 20.9f|*fatal error: %s", tss, tsl, s);
else if ((debuglev) && (config.debugger_show_relative_time))
else if ((debuglev) && (config.debugger_show_relative_time))
daemon_log(LOG_EMERG, "% 20.9f|*fatal error: %s", tsl, s);
else if ((debuglev) && (config.debugger_show_elapsed_time))
else if ((debuglev) && (config.debugger_show_elapsed_time))
daemon_log(LOG_EMERG, "% 20.9f|*fatal error: %s", tss, s);
else
daemon_log(LOG_EMERG, "fatal error: %s", s);
@@ -138,12 +138,12 @@ void warn(const char *format, ...) {
va_start(args, format);
vsnprintf(s, sizeof(s), format, args);
va_end(args);
if ((debuglev) && (config.debugger_show_elapsed_time) && (config.debugger_show_relative_time))
daemon_log(LOG_WARNING, "|% 20.9f|% 20.9f|*warning: %s", tss, tsl, s);
else if ((debuglev) && (config.debugger_show_relative_time))
else if ((debuglev) && (config.debugger_show_relative_time))
daemon_log(LOG_WARNING, "% 20.9f|*warning: %s", tsl, s);
else if ((debuglev) && (config.debugger_show_elapsed_time))
else if ((debuglev) && (config.debugger_show_elapsed_time))
daemon_log(LOG_WARNING, "% 20.9f|*warning: %s", tss, s);
else
daemon_log(LOG_WARNING, "%s", s);
@@ -709,11 +709,12 @@ uint32_t uatoi(const char *nptr) {
}
double flat_vol2attn(double vol, long max_db, long min_db) {
double vol_setting = min_db; // if all else fails, set this, for safety
double vol_setting = min_db; // if all else fails, set this, for safety
if ((vol <= 0.0) && (vol >= -30.0)) {
vol_setting = ((max_db - min_db) * (30.0 + vol) / 30) + min_db;
// debug(2, "Linear profile Volume Setting: %f in range %ld to %ld.", vol_setting, min_db, max_db);
// debug(2, "Linear profile Volume Setting: %f in range %ld to %ld.", vol_setting, min_db,
// max_db);
} else if (vol != -144.0) {
debug(1,
"Linear volume request value %f is out of range: should be from 0.0 to -30.0 or -144.0.",
@@ -969,9 +970,9 @@ uint64_t ranarray64u() { return (ranarrayval()); }
int64_t ranarray64i() { return (ranarrayval() >> 1); }
uint32_t nctohl(const uint8_t * p) { // read 4 characters from the p and do ntohl on them
uint32_t nctohl(const uint8_t *p) { // read 4 characters from the p and do ntohl on them
// this is to avoid possible aliasing violations
uint32_t holder;
memcpy(&holder,p,sizeof(holder));
memcpy(&holder, p, sizeof(holder));
return ntohl(holder);
}
+1 -2
View File
@@ -177,8 +177,7 @@ typedef struct {
} shairport_cfg;
uint32_t nctohl(const uint8_t * p); // read 4 characters from the p and do ntohl on them
uint32_t nctohl(const uint8_t *p); // read 4 characters from the p and do ntohl on them
// true if Shairport Sync is supposed to be sending output to the output device, false otherwise
+40 -34
View File
@@ -32,6 +32,7 @@
#include <arpa/inet.h>
#include <errno.h>
#include <inttypes.h>
#include <math.h>
#include <memory.h>
#include <netdb.h>
@@ -40,7 +41,6 @@
#include <stdlib.h>
#include <time.h>
#include <unistd.h>
#include <inttypes.h>
#include "metadata_hub.h"
#include "tinyhttp/http.h"
@@ -271,9 +271,9 @@ void set_dacp_server_information(rtsp_conn_info *conn) { // tell the DACP conver
strncpy(dacp_server.ip_string, conn->client_ip_string, INET6_ADDRSTRLEN);
dacp_server.active_remote_id = conn->dacp_active_remote;
if (dacp_server.port)
dacp_server.scan_enable=1;
dacp_server.scan_enable = 1;
else
dacp_server.scan_enable=0;
dacp_server.scan_enable = 0;
pthread_cond_signal(&dacp_server_information_cv);
pthread_mutex_unlock(&dacp_server_information_lock);
}
@@ -293,23 +293,24 @@ void *dacp_monitor_thread_code(void *na) {
}
scan_index++;
result = dacp_get_volume(NULL); // just want the http code
if ((result==496) || (result==403)|| (result==501)) {
if ((result == 496) || (result == 403) || (result == 501)) {
// debug(1,"Stopping scan because the response to \"dacp_get_volume(NULL)\" is %d.",result);
dacp_server.scan_enable = 0;
}
pthread_mutex_unlock(&dacp_server_information_lock);
// debug(1, "DACP Server ID \"%u\" at \"%s:%u\", scan %d.", dacp_server.active_remote_id,
// dacp_server.ip_string, dacp_server.port, scan_index);
if (result==200) {
if (result == 200) {
ssize_t le;
char *response = NULL;
int32_t item_size;
char command[1024] = "";
snprintf(command, sizeof(command) - 1, "playstatusupdate?revision-number=%d", revision_number);
snprintf(command, sizeof(command) - 1, "playstatusupdate?revision-number=%d",
revision_number);
// debug(1,"Command: \"%s\"",command);
result = dacp_send_command(command, &response, &le);
// debug(1,"Response to \"%s\" is %d.",command,result);
// if (result == 200) {
// if (result == 200) {
if (0) {
char *sp = response;
if (le >= 8) {
@@ -317,7 +318,7 @@ void *dacp_monitor_thread_code(void *na) {
if (dacp_tlv_crawl(&sp, &item_size) == 'cmst') { // status
// here, we know that we are receiving playerstatusupdates, so set a flag
metadata_hub_modify_prolog();
debug(1,"playstatusupdate release track metadata");
debug(1, "playstatusupdate release track metadata");
metadata_hub_reset_track_metadata();
metadata_store.playerstatusupdates_are_received = 1;
sp -= item_size; // drop down into the array -- don't skip over it
@@ -558,7 +559,7 @@ void *dacp_monitor_thread_code(void *na) {
// finished possibly writing to the metadata hub
metadata_hub_modify_epilog(1);
} else {
debug(1,"Status Update not found.\n");
debug(1, "Status Update not found.\n");
}
} else {
debug(1, "Can't find any content in playerstatusupdate request");
@@ -649,18 +650,19 @@ int dacp_get_client_volume(int32_t *result) {
debug(1, "Unexpected response %d to dacp volume control request", response);
} */
if (result) {
*result=overall_volume;
*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);
debug(1, "dacp_set_include_speaker_volume to %" PRId32 ".", vo);
char message[1000];
memset(message, 0, sizeof(message));
sprintf(message, "setproperty?include-speaker-id=%" PRId64 "&dmcp.volume=%" PRId32 "", 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
}
@@ -668,17 +670,19 @@ int dacp_set_include_speaker_volume(int64_t machine_number, int32_t vo) {
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=%" PRId64 "&dmcp.volume=%" PRId32 "", 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) {
int dacp_get_speaker_list(dacp_spkr_stuff *speaker_info, int max_size_of_array,
int *actual_speaker_count) {
// 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
int speaker_count = -1; // will be fixed if there is no problem
ssize_t le;
int response = dacp_send_command("getspeakers", &server_reply, &le);
@@ -698,7 +702,7 @@ int dacp_get_speaker_list(dacp_spkr_stuff *speaker_info, int max_size_of_array,
le -= 8;
speaker_index++;
if (speaker_index == max_size_of_array)
return 413;// Payload Too Large -- too many speakers
return 413; // Payload Too Large -- too many speakers
speaker_info[speaker_index].active = 0;
speaker_info[speaker_index].speaker_number = 0;
speaker_info[speaker_index].volume = 0;
@@ -719,7 +723,8 @@ int dacp_get_speaker_list(dacp_spkr_stuff *speaker_info, int max_size_of_array,
t = sp - item_size;
r = ntohl(*(uint32_t *)(t));
speaker_info[speaker_index].volume = r;
// debug(1,"The individual volume of speaker \"%s\" is \"%d\".",speaker_info[speaker_index].name,r);
// debug(1,"The individual volume of speaker \"%s\" is
// \"%d\".",speaker_info[speaker_index].name,r);
break;
case 'msma':
t = sp - item_size;
@@ -740,12 +745,12 @@ int dacp_get_speaker_list(dacp_spkr_stuff *speaker_info, int max_size_of_array,
case 'cavd':
case 'caiv':
case 'cads':
*(uint32_t *)typestring = htonl(type);
typestring[4] = 0;
t = sp-item_size;
u = *t;
debug(1,"Type: '%s' Value: \"%d\".",typestring,u);
@@ -795,11 +800,11 @@ int dacp_get_volume(int32_t *the_actual_volume) {
int32_t overall_volume = 0;
int32_t actual_volume = 0;
int http_response = dacp_get_client_volume(&overall_volume);
if (http_response==200) {
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);
if (http_response==200) {
http_response = dacp_get_speaker_list((dacp_spkr_stuff *)&speaker_info, 50, &speaker_count);
if (http_response == 200) {
// get our machine number
uint16_t *hn = (uint16_t *)config.hw_addr;
uint32_t *ln = (uint32_t *)(config.hw_addr + 2);
@@ -815,7 +820,7 @@ int dacp_get_volume(int32_t *the_actual_volume) {
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
@@ -824,17 +829,18 @@ int dacp_get_volume(int32_t *the_actual_volume) {
}
}
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;
//metadata_hub_modify_epilog(1);
// metadata_hub_modify_prolog();
// metadata_store.speaker_volume = actual_volume;
// metadata_hub_modify_epilog(1);
} else {
debug(1,"Unexpected return code %d from dacp_get_speaker_list.",http_response);
debug(1, "Unexpected return code %d from dacp_get_speaker_list.", http_response);
}
} else {
debug(1,"Unexpected return code %d from dacp_get_client_volume.",http_response);
}
} else {
debug(1, "Unexpected return code %d from dacp_get_client_volume.", http_response);
}
if (the_actual_volume) {
// debug(1,"dacp_get_volume returns %d.",actual_volume);
*the_actual_volume = actual_volume;
+4 -2
View File
@@ -21,7 +21,8 @@ uint32_t dacp_tlv_crawl(
int dacp_set_speaker_volume(int64_t machine_number, int32_t vo);
int dacp_get_speaker_list(dacp_spkr_stuff *speaker_array, int max_size_of_array, int *actual_speaker_count);
int dacp_get_speaker_list(dacp_spkr_stuff *speaker_array, int max_size_of_array,
int *actual_speaker_count);
void set_dacp_server_information(rtsp_conn_info *conn); // tell the DACP conversation thread that
// the dacp server information has been set
// or changed
@@ -29,4 +30,5 @@ int send_simple_dacp_command(const char *command);
int dacp_set_include_speaker_volume(int64_t machine_number, int32_t vo);
int dacp_get_client_volume(int32_t *result);
int dacp_get_volume(int32_t *the_actual_volume); // get the speaker volume information from the DACP source
int dacp_get_volume(
int32_t *the_actual_volume); // get the speaker volume information from the DACP source
+31 -21
View File
@@ -11,15 +11,14 @@
#include "dacp.h"
#include "metadata_hub.h"
#include "dbus-service.h"
#include "metadata_hub.h"
void dbus_metadata_watcher(struct metadata_bundle *argc, void *userdata) {
// debug(1, "DBUS metadata watcher called");
shairport_sync_set_volume(shairportSyncSkeleton, metadata_store.speaker_volume);
// debug(1, "DBUS metadata watcher called");
shairport_sync_set_volume(shairportSyncSkeleton, metadata_store.speaker_volume);
}
gboolean notify_loudness_filter_active_callback(ShairportSync *skeleton, gpointer user_data) {
debug(1, "\"notify_loudness_filter_active_callback\" called.");
if (shairport_sync_get_loudness_filter_active(skeleton)) {
@@ -71,7 +70,8 @@ gboolean notify_volume_callback(ShairportSync *skeleton, gpointer user_data) {
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 with relative volume.",machine_number,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++;
@@ -85,9 +85,9 @@ gboolean notify_volume_callback(ShairportSync *skeleton, gpointer user_data) {
} 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
@@ -112,29 +112,33 @@ gboolean notify_volume_callback(ShairportSync *skeleton, gpointer user_data) {
}
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.");
@@ -155,7 +159,8 @@ static gboolean on_handle_remote_command(ShairportSync *skeleton, GDBusMethodInv
static void on_dbus_name_acquired(GDBusConnection *connection, const gchar *name,
gpointer user_data) {
// debug(1, "Shairport Sync native D-Bus interface \"%s\" acquired on the %s bus.", name, (config.dbus_service_bus_type == DBT_session) ? "session" : "system");
// debug(1, "Shairport Sync native D-Bus interface \"%s\" acquired on the %s bus.", name,
// (config.dbus_service_bus_type == DBT_session) ? "session" : "system");
shairportSyncSkeleton = shairport_sync_skeleton_new();
g_dbus_interface_skeleton_export(G_DBUS_INTERFACE_SKELETON(shairportSyncSkeleton), connection,
@@ -181,19 +186,22 @@ static void on_dbus_name_acquired(GDBusConnection *connection, const gchar *name
NULL);
g_signal_connect(shairportSyncSkeleton, "handle-remote-command",
G_CALLBACK(on_handle_remote_command), NULL);
add_metadata_watcher(dbus_metadata_watcher, NULL);
debug(1, "Shairport Sync native D-Bus service started at \"%s\" on the %s bus.", name, (config.dbus_service_bus_type == DBT_session) ? "session" : "system");
debug(1, "Shairport Sync native D-Bus service started at \"%s\" on the %s bus.", name,
(config.dbus_service_bus_type == DBT_session) ? "session" : "system");
}
static void on_dbus_name_lost_again(GDBusConnection *connection, const gchar *name,
gpointer user_data) {
warn("Could not acquire a Shairport Sync native D-Bus interface \"%s\" on the %s bus.", name, (config.dbus_service_bus_type == DBT_session) ? "session" : "system");
warn("Could not acquire a Shairport Sync native D-Bus interface \"%s\" on the %s bus.", name,
(config.dbus_service_bus_type == DBT_session) ? "session" : "system");
}
static void on_dbus_name_lost(GDBusConnection *connection, const gchar *name, gpointer user_data) {
//debug(1, "Could not acquire a Shairport Sync native D-Bus interface \"%s\" on the %s bus -- will try adding the process "
// debug(1, "Could not acquire a Shairport Sync native D-Bus interface \"%s\" on the %s bus --
// will try adding the process "
// "number to the end of it.",
// name, (config.dbus_service_bus_type == DBT_session) ? "session" : "system");
pid_t pid = getpid();
@@ -202,7 +210,8 @@ static void on_dbus_name_lost(GDBusConnection *connection, const gchar *name, gp
GBusType dbus_bus_type = G_BUS_TYPE_SYSTEM;
if (config.dbus_service_bus_type == DBT_session)
dbus_bus_type = G_BUS_TYPE_SESSION;
//debug(1, "Looking for a Shairport Sync native D-Bus interface \"%s\" on the %s bus.", interface_name,(config.dbus_service_bus_type == DBT_session) ? "session" : "system");
// debug(1, "Looking for a Shairport Sync native D-Bus interface \"%s\" on the %s bus.",
// interface_name,(config.dbus_service_bus_type == DBT_session) ? "session" : "system");
g_bus_own_name(dbus_bus_type, interface_name, G_BUS_NAME_OWNER_FLAGS_NONE, NULL,
on_dbus_name_acquired, on_dbus_name_lost_again, NULL, NULL);
}
@@ -212,7 +221,8 @@ int start_dbus_service() {
GBusType dbus_bus_type = G_BUS_TYPE_SYSTEM;
if (config.dbus_service_bus_type == DBT_session)
dbus_bus_type = G_BUS_TYPE_SESSION;
// debug(1, "Looking for a Shairport Sync native D-Bus interface \"org.gnome.ShairportSync\" on the %s bus.",(config.dbus_service_bus_type == DBT_session) ? "session" : "system");
// debug(1, "Looking for a Shairport Sync native D-Bus interface \"org.gnome.ShairportSync\" on
// the %s bus.",(config.dbus_service_bus_type == DBT_session) ? "session" : "system");
g_bus_own_name(dbus_bus_type, "org.gnome.ShairportSync", G_BUS_NAME_OWNER_FLAGS_NONE, NULL,
on_dbus_name_acquired, on_dbus_name_lost, NULL, NULL);
return 0; // this is just to quieten a compiler warning
+4 -3
View File
@@ -27,7 +27,7 @@ typedef struct {
#define METADATA_EXPRESSION config.get_coverart ? "md=0,1,2" : "md=0,2"
/*
#define MDNS_RECORD_WITH_METADATA \
#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"
*/
@@ -39,8 +39,9 @@ typedef struct {
#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", \
#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"
*/
+2 -2
View File
@@ -71,7 +71,7 @@ static void resolve_callback(AvahiServiceResolver *r, AVAHI_GCC_UNUSED AvahiIfIn
assert(r);
rtsp_conn_info *conn = (rtsp_conn_info *)userdata;
// dacp_browser_struct *dbs = (dacp_browser_struct *)conn->mdns_private_pointer;
// dacp_browser_struct *dbs = (dacp_browser_struct *)conn->mdns_private_pointer;
/* Called whenever a service has been resolved successfully or timed out */
switch (event) {
@@ -80,7 +80,7 @@ static void resolve_callback(AvahiServiceResolver *r, AVAHI_GCC_UNUSED AvahiIfIn
type, domain, avahi_strerror(avahi_client_errno(avahi_service_resolver_get_client(r))));
break;
case AVAHI_RESOLVER_FOUND: {
// char a[AVAHI_ADDRESS_STR_MAX], *t;
// char a[AVAHI_ADDRESS_STR_MAX], *t;
// debug(1, "Resolve callback: Service '%s' of type '%s' in domain '%s':", name, type, domain);
char *dacpid = strstr(name, "iTunes_Ctrl_");
if (dacpid) {
+2 -2
View File
@@ -63,8 +63,8 @@ static int fork_execvp(const char *file, char *const argv[]) {
// If we reach this point then execve has failed.
// Write erno's value into the pipe and exit.
if(write(execpipe[1], &errno, sizeof(errno)) != sizeof(errno))
debug(1,"Execve has failed and there was a further error writing an error message, duh.");
if (write(execpipe[1], &errno, sizeof(errno)) != sizeof(errno))
debug(1, "Execve has failed and there was a further error writing an error message, duh.");
debug(1, "execve has failed.");
_exit(-1);
return 0; // Just to make the compiler happy.
+6 -6
View File
@@ -62,7 +62,7 @@ pthread_rwlock_t metadata_hub_re_lock = PTHREAD_RWLOCK_INITIALIZER;
void release_char_string(char **str) {
if (*str) {
free(*str);
*str=NULL;
*str = NULL;
}
}
@@ -95,7 +95,7 @@ void metadata_hub_release_track_artwork(void) {
}
void metadata_hub_reset_track_metadata(void) {
//debug(1,"release track metadata");
// debug(1,"release track metadata");
release_char_string(&metadata_store.track_name);
release_char_string(&metadata_store.artist_name);
release_char_string(&metadata_store.album_name);
@@ -259,7 +259,7 @@ void metadata_hub_process_metadata(uint32_t type, uint32_t code, char *data, uin
if (type == 'core') {
switch (code) {
case 'mper':
metadata_store.item_id = ntohl(*(uint32_t*)data);
metadata_store.item_id = ntohl(*(uint32_t *)data);
debug(2, "MH Item ID set to: \"%u\"", metadata_store.item_id);
break;
case 'asal':
@@ -438,15 +438,15 @@ void metadata_hub_process_metadata(uint32_t type, uint32_t code, char *data, uin
case 'pfls':
case 'prsm':
break;
default: {
char typestring[5];
uint32_t tm = htonl(type);
memcpy(typestring,&tm,sizeof(uint32_t));
memcpy(typestring, &tm, sizeof(uint32_t));
typestring[4] = 0;
char codestring[5];
uint32_t cm = htonl(code);
memcpy(codestring,&cm,sizeof(uint32_t));
memcpy(codestring, &cm, sizeof(uint32_t));
codestring[4] = 0;
char *payload;
if (length < 2048)
+2 -2
View File
@@ -29,7 +29,7 @@ typedef void (*metadata_watcher)(struct metadata_bundle *argc, void *userdata);
typedef struct metadata_bundle {
int changed; // normally 0, nonzero if a field has been changed
int playerstatusupdates_are_received; // false if it's "traditional" metadata
int player_thread_active; // true if there is a player threrad; false otherwise
enum play_status_type play_status;
@@ -106,4 +106,4 @@ void metadata_hub_release_track_artwork(void);
// these functions lock and unlock the read-write mutex on the metadata hub and run the watchers
// afterwards
void metadata_hub_modify_prolog(void);
void metadata_hub_modify_epilog(int modified); //set to true if modifications occured, 0 otherwise
void metadata_hub_modify_epilog(int modified); // set to true if modifications occured, 0 otherwise
+36 -31
View File
@@ -32,7 +32,7 @@ void mpris_metadata_watcher(struct metadata_bundle *argc, void *userdata) {
// debug(1,"Set loop status to \"%s\"",response);
media_player2_player_set_loop_status(mprisPlayerPlayerSkeleton, response);
switch (argc->player_state) {
case PS_STOPPED:
strcpy(response, "Stopped");
@@ -46,11 +46,11 @@ void mpris_metadata_watcher(struct metadata_bundle *argc, void *userdata) {
}
// debug(1,"From player_state, set playback status to \"%s\"",response);
media_player2_player_set_playback_status(mprisPlayerPlayerSkeleton, response);
media_player2_player_set_playback_status(mprisPlayerPlayerSkeleton, response);
GVariantBuilder *dict_builder, *aa;
/* Build the metadata array */
/* Build the metadata array */
// debug(1,"Build metadata");
dict_builder = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
@@ -63,7 +63,7 @@ void mpris_metadata_watcher(struct metadata_bundle *argc, void *userdata) {
GVariant *artUrl = g_variant_new("s", artURIstring);
g_variant_builder_add(dict_builder, "{sv}", "mpris:artUrl", artUrl);
}
// Add the TrackID if we have one
// Build the Track ID from the 16-byte item_composite_id in hex prefixed by
// /org/gnome/ShairportSync
@@ -79,27 +79,27 @@ void mpris_metadata_watcher(struct metadata_bundle *argc, void *userdata) {
}
*pt = 0;
if (non_zero) {
//debug(1, "Set ID using composite ID: \"0x%s\".", st);
// debug(1, "Set ID using composite ID: \"0x%s\".", st);
char trackidstring[1024];
sprintf(trackidstring, "/org/gnome/ShairportSync/%s", st);
GVariant* trackid = g_variant_new("o", trackidstring);
GVariant *trackid = g_variant_new("o", trackidstring);
g_variant_builder_add(dict_builder, "{sv}", "mpris:trackid", trackid);
} else if (argc->item_id) {
char trackidstring[128];
//debug(1, "Set ID using mper ID: \"%u\".",argc->item_id);
sprintf(trackidstring, "/org/gnome/ShairportSync/mper_%u", argc->item_id);
GVariant* trackid = g_variant_new("o", trackidstring);
g_variant_builder_add(dict_builder, "{sv}", "mpris:trackid", trackid);
// debug(1, "Set ID using mper ID: \"%u\".",argc->item_id);
sprintf(trackidstring, "/org/gnome/ShairportSync/mper_%u", argc->item_id);
GVariant *trackid = g_variant_new("o", trackidstring);
g_variant_builder_add(dict_builder, "{sv}", "mpris:trackid", trackid);
}
// Add the track length if it's non-zero
if (argc->songtime_in_milliseconds) {
uint64_t track_length_in_microseconds = argc->songtime_in_milliseconds;
track_length_in_microseconds *= 1000; // to microseconds in 64-bit precision
// Make up the track name and album name
//debug(1, "Set tracklength to %lu.", track_length_in_microseconds);
GVariant *tracklength = g_variant_new("x", track_length_in_microseconds);
g_variant_builder_add(dict_builder, "{sv}", "mpris:length", tracklength);
uint64_t track_length_in_microseconds = argc->songtime_in_milliseconds;
track_length_in_microseconds *= 1000; // to microseconds in 64-bit precision
// Make up the track name and album name
// debug(1, "Set tracklength to %lu.", track_length_in_microseconds);
GVariant *tracklength = g_variant_new("x", track_length_in_microseconds);
g_variant_builder_add(dict_builder, "{sv}", "mpris:length", tracklength);
}
// Add the track name if there is one
@@ -108,14 +108,14 @@ void mpris_metadata_watcher(struct metadata_bundle *argc, void *userdata) {
GVariant *trackname = g_variant_new("s", argc->track_name);
g_variant_builder_add(dict_builder, "{sv}", "xesam:title", trackname);
}
// Add the album name if there is one
if (argc->album_name) {
if (argc->album_name) {
// debug(1, "Album name set to \"%s\".", argc->album_name);
GVariant *albumname = g_variant_new("s", argc->album_name);
g_variant_builder_add(dict_builder, "{sv}", "xesam:album", albumname);
}
// Add the artists if there are any (actually there will be at most one, but put it in an array)
if (argc->artist_name) {
/* Build the artists array */
@@ -126,7 +126,7 @@ void mpris_metadata_watcher(struct metadata_bundle *argc, void *userdata) {
g_variant_builder_unref(aa);
g_variant_builder_add(dict_builder, "{sv}", "xesam:artist", artists);
}
// Add the genres if there are any (actually there will be at most one, but put it in an array)
if (argc->genre) {
// debug(1,"Build genre");
@@ -136,15 +136,14 @@ void mpris_metadata_watcher(struct metadata_bundle *argc, void *userdata) {
g_variant_builder_unref(aa);
g_variant_builder_add(dict_builder, "{sv}", "xesam:genre", genres);
}
GVariant *dict = g_variant_builder_end(dict_builder);
g_variant_builder_unref(dict_builder);
// debug(1,"Set metadata");
media_player2_player_set_metadata(mprisPlayerPlayerSkeleton, dict);
media_player2_player_set_volume(mprisPlayerPlayerSkeleton, metadata_store.speaker_volume);
media_player2_player_set_volume(mprisPlayerPlayerSkeleton, metadata_store.speaker_volume);
}
static gboolean on_handle_next(MediaPlayer2Player *skeleton, GDBusMethodInvocation *invocation,
@@ -194,7 +193,8 @@ static void on_mpris_name_acquired(GDBusConnection *connection, const gchar *nam
const char *empty_string_array[] = {NULL};
// debug(1, "MPRIS well-known interface name \"%s\" acquired on the %s bus.", name, (config.mpris_service_bus_type == DBT_session) ? "session" : "system");
// debug(1, "MPRIS well-known interface name \"%s\" acquired on the %s bus.", name,
// (config.mpris_service_bus_type == DBT_session) ? "session" : "system");
mprisPlayerSkeleton = media_player2_skeleton_new();
mprisPlayerPlayerSkeleton = media_player2_player_skeleton_new();
@@ -234,16 +234,19 @@ static void on_mpris_name_acquired(GDBusConnection *connection, const gchar *nam
add_metadata_watcher(mpris_metadata_watcher, NULL);
debug(1, "MPRIS service started at \"%s\" on the %s bus.", name, (config.mpris_service_bus_type == DBT_session) ? "session" : "system");
debug(1, "MPRIS service started at \"%s\" on the %s bus.", name,
(config.mpris_service_bus_type == DBT_session) ? "session" : "system");
}
static void on_mpris_name_lost_again(GDBusConnection *connection, const gchar *name,
gpointer user_data) {
warn("Could not acquire an MPRIS interface named \"%s\" on the %s bus.",name,(config.mpris_service_bus_type == DBT_session) ? "session" : "system");
warn("Could not acquire an MPRIS interface named \"%s\" on the %s bus.", name,
(config.mpris_service_bus_type == DBT_session) ? "session" : "system");
}
static void on_mpris_name_lost(GDBusConnection *connection, const gchar *name, gpointer user_data) {
//debug(1, "Could not acquire MPRIS interface \"%s\" on the %s bus -- will try adding the process "
// debug(1, "Could not acquire MPRIS interface \"%s\" on the %s bus -- will try adding the process
// "
// "number to the end of it.",
// name,(mpris_bus_type==G_BUS_TYPE_SESSION) ? "session" : "system");
pid_t pid = getpid();
@@ -252,7 +255,8 @@ static void on_mpris_name_lost(GDBusConnection *connection, const gchar *name, g
GBusType mpris_bus_type = G_BUS_TYPE_SYSTEM;
if (config.mpris_service_bus_type == DBT_session)
mpris_bus_type = G_BUS_TYPE_SESSION;
// debug(1, "Looking for an MPRIS interface \"%s\" on the %s bus.",interface_name, (mpris_bus_type==G_BUS_TYPE_SESSION) ? "session" : "system");
// debug(1, "Looking for an MPRIS interface \"%s\" on the %s bus.",interface_name,
// (mpris_bus_type==G_BUS_TYPE_SESSION) ? "session" : "system");
g_bus_own_name(mpris_bus_type, interface_name, G_BUS_NAME_OWNER_FLAGS_NONE, NULL,
on_mpris_name_acquired, on_mpris_name_lost_again, NULL, NULL);
}
@@ -263,7 +267,8 @@ int start_mpris_service() {
GBusType mpris_bus_type = G_BUS_TYPE_SYSTEM;
if (config.mpris_service_bus_type == DBT_session)
mpris_bus_type = G_BUS_TYPE_SESSION;
// debug(1, "Looking for an MPRIS interface \"org.mpris.MediaPlayer2.ShairportSync\" on the %s bus.",(mpris_bus_type==G_BUS_TYPE_SESSION) ? "session" : "system");
// debug(1, "Looking for an MPRIS interface \"org.mpris.MediaPlayer2.ShairportSync\" on the %s
// bus.",(mpris_bus_type==G_BUS_TYPE_SESSION) ? "session" : "system");
g_bus_own_name(mpris_bus_type, "org.mpris.MediaPlayer2.ShairportSync",
G_BUS_NAME_OWNER_FLAGS_NONE, NULL, on_mpris_name_acquired, on_mpris_name_lost,
NULL, NULL);
+23 -19
View File
@@ -218,8 +218,8 @@ static inline int seq_order(seq_t a, seq_t b, seq_t base) {
}
static inline seq_t seq_sum(seq_t a, seq_t b) {
// uint32_t p = a & 0xffff;
// uint32_t q = b & 0x0ffff;
// uint32_t p = a & 0xffff;
// uint32_t q = b & 0x0ffff;
uint32_t r = (a + b) & 0xffff;
return r;
}
@@ -530,13 +530,16 @@ void player_put_packet(seq_t seqno, int64_t timestamp, uint8_t *data, int len,
abuf = conn->audio_buffer + BUFIDX(seqno);
/*
if (abuf->ready)
debug(1,"Late apparently duplicate packet received that is %d packets late.",seq_diff(seqno, conn->ab_write, conn->ab_read));
debug(1,"Late apparently duplicate packet received that is %d packets
late.",seq_diff(seqno, conn->ab_write, conn->ab_read));
else
debug(1,"Late packet received that is %d packets late.",seq_diff(seqno, conn->ab_write, conn->ab_read));
*/
debug(1,"Late packet received that is %d packets late.",seq_diff(seqno,
conn->ab_write, conn->ab_read));
*/
} else { // too late.
// debug(1,"Too late packet received that is %d packets late.",seq_diff(seqno, conn->ab_write, conn->ab_read));
// debug(1,"Too late packet received that is %d packets late.",seq_diff(seqno,
// conn->ab_write, conn->ab_read));
conn->too_late_packets++;
}
// pthread_mutex_unlock(&ab_mutex);
@@ -811,8 +814,9 @@ static abuf_t *buffer_get_frame(rtsp_conn_info *conn) {
notified_buffer_empty = 0; // at least one buffer now -- diagnostic only.
if (conn->ab_buffering) { // if we are getting packets but not yet forwarding them to the
// player
int have_sent_prefiller_silence = 0; // set true when we have sent some silent frames to the
// DAC
int have_sent_prefiller_silence =
0; // set true when we have sent some silent frames to the
// DAC
int64_t reference_timestamp;
uint64_t reference_timestamp_time, remote_reference_timestamp_time;
get_reference_timestamp_stuff(&reference_timestamp, &reference_timestamp_time,
@@ -879,7 +883,8 @@ static abuf_t *buffer_get_frame(rtsp_conn_info *conn) {
debug(
1,
"First packet is late! It should have played before now. Flushing 0.5 seconds");
player_flush(conn->first_packet_timestamp + 5 * 4410 * conn->output_sample_ratio, conn);
player_flush(conn->first_packet_timestamp + 5 * 4410 * conn->output_sample_ratio,
conn);
}
}
}
@@ -1062,7 +1067,6 @@ static abuf_t *buffer_get_frame(rtsp_conn_info *conn) {
metadata_store.player_state = PS_PLAYING;
metadata_hub_modify_epilog(1);
#endif
}
}
}
@@ -1170,8 +1174,8 @@ static abuf_t *buffer_get_frame(rtsp_conn_info *conn) {
if (!conn->ab_buffering) {
// check once, after a short period of has elapsed, assuming 352 frames per packet
i = ((250*44100)/352)/1000; // approx 250 ms
if (i<seq_diff(conn->ab_read, conn->ab_write, conn->ab_read)) {
i = ((250 * 44100) / 352) / 1000; // approx 250 ms
if (i < seq_diff(conn->ab_read, conn->ab_write, conn->ab_read)) {
seq_t next = seq_sum(conn->ab_read, i);
abuf = conn->audio_buffer + BUFIDX(next);
if (!abuf->ready) {
@@ -1436,7 +1440,7 @@ static void *player_thread_func(void *arg) {
conn->timestamp_epoch = 0; // indicate that the next timestamp will be the first one.
conn->maximum_timestamp_interval =
conn->input_rate * 60; // actually there shouldn't be more than about 13
conn->input_rate * 60; // actually there shouldn't be more than about 13
// seconds of a gap between successive rtptimes, at
// worst
@@ -1446,8 +1450,8 @@ static void *player_thread_func(void *arg) {
conn->max_frame_size_change =
1 * conn->output_sample_ratio; // we add or subtract one frame at the nominal
// rate, multiply it by the frame ratio.
// but, on some occasions, more than one frame could be added
// rate, multiply it by the frame ratio.
// but, on some occasions, more than one frame could be added
switch (config.output_format) {
case SPS_FORMAT_S24_3LE:
@@ -2508,13 +2512,13 @@ void player_volume(double airplay_volume, rtsp_conn_info *conn) {
command_set_volume(airplay_volume);
#ifdef HAVE_DACP_CLIENT
int32_t actual_volume;
if (dacp_get_volume(&actual_volume)==200) {
if (dacp_get_volume(&actual_volume) == 200) {
metadata_hub_modify_prolog();
if (metadata_store.speaker_volume == actual_volume)
metadata_hub_modify_epilog(0); // no change
else {
metadata_store.speaker_volume = actual_volume;
metadata_hub_modify_epilog(1); // change
metadata_hub_modify_epilog(1); // change
}
}
@@ -2587,7 +2591,7 @@ void player_stop(rtsp_conn_info *conn) {
free(conn->player_thread);
conn->player_thread = NULL;
#ifdef HAVE_METADATA_HUB
metadata_hub_modify_prolog();
metadata_hub_modify_prolog();
metadata_store.player_state = PS_STOPPED;
// debug(1,"player_stop release track metadata and artwork");
metadata_hub_reset_track_metadata();
-1
View File
@@ -131,7 +131,6 @@ typedef struct {
int rtp_running;
uint64_t rtp_time_of_last_resend_request_error_fp;
char client_ip_string[INET6_ADDRSTRLEN]; // the ip string pointing to the client
char self_ip_string[INET6_ADDRSTRLEN]; // the ip string being used by this program -- it
// could be one of many, so we need to know it
+13 -13
View File
@@ -145,7 +145,7 @@ void *rtp_audio_receiver(void *arg) {
// debug(3, "RTP: Packets out of sequence: expected: %d, got %d.", last_seqno, seqno);
last_seqno = seqno; // reset warning...
}
int64_t timestamp = monotonic_timestamp(ntohl(*(uint32_t*)(pktp + 4)), conn);
int64_t timestamp = monotonic_timestamp(ntohl(*(uint32_t *)(pktp + 4)), conn);
// if (packet[1]&0x10)
// debug(1,"Audio packet Extension bit set.");
@@ -227,7 +227,7 @@ void *rtp_control_receiver(void *arg) {
// debug(1,"Remote Sync Time: %0llx.",remote_time_of_sync);
sync_rtp_timestamp = monotonic_timestamp(nctohl(&packet[16]), conn);
// debug(1,"Sync timestamp is %u.",ntohl(*((uint32_t *)&packet[16])));
if (config.userSuppliedLatency) {
@@ -237,8 +237,7 @@ void *rtp_control_receiver(void *arg) {
conn->latency = config.userSuppliedLatency;
} else if (packet[0] &
0x10) { // only set latency if it's a packet just after a flush or resume
int64_t rtp_timestamp_less_latency =
monotonic_timestamp(nctohl(&packet[4]), conn);
int64_t rtp_timestamp_less_latency = monotonic_timestamp(nctohl(&packet[4]), conn);
int64_t la = sync_rtp_timestamp - rtp_timestamp_less_latency + config.fixedLatencyOffset;
if ((conn->maximum_latency) && (conn->maximum_latency < la))
la = conn->maximum_latency;
@@ -285,9 +284,9 @@ void *rtp_control_receiver(void *arg) {
// debug(1, "Control Port -- Retransmitted Audio Data Packet received.");
pktp = packet + 4;
plen -= 4;
seq_t seqno = ntohs(*(uint16_t*)(pktp + 2));
seq_t seqno = ntohs(*(uint16_t *)(pktp + 2));
int64_t timestamp = monotonic_timestamp(ntohl(*(uint32_t*)(pktp + 4)), conn);
int64_t timestamp = monotonic_timestamp(ntohl(*(uint32_t *)(pktp + 4)), conn);
pktp += 12;
plen -= 12;
@@ -450,7 +449,6 @@ void *rtp_timing_receiver(void *arg) {
return_time = arrival_time - conn->departure_time;
uint64_t rtus = (return_time * 1000000) >> 32;
if (rtus < 300000) {
@@ -512,7 +510,7 @@ void *rtp_timing_receiver(void *arg) {
if (l2rtd > conn->local_to_remote_time_difference) {
local_to_remote_time_jitters =
local_to_remote_time_jitters + l2rtd - conn->local_to_remote_time_difference;
// ji = l2rtd - conn->local_to_remote_time_difference;
// ji = l2rtd - conn->local_to_remote_time_difference;
} else {
local_to_remote_time_jitters =
local_to_remote_time_jitters + conn->local_to_remote_time_difference - l2rtd;
@@ -541,7 +539,7 @@ void *rtp_timing_receiver(void *arg) {
} else {
// uint64_t local_time_change = local_time_chosen - first_local_time;
// uint64_t remote_time_change = remote_time_chosen - first_remote_time;
/*
if (remote_time_change >= local_time_change)
clock_drift = remote_time_change - local_time_change;
@@ -554,7 +552,7 @@ void *rtp_timing_receiver(void *arg) {
else
clock_drift_in_usec = -(((-clock_drift) * 1000000) >> 32);
*/
// clock_drift_ppm = (1.0 * clock_drift_in_usec) / (local_time_change >> 32);
}
@@ -843,8 +841,10 @@ void rtp_request_resend(seq_t first, uint32_t count, rtsp_conn_info *conn) {
}
#endif
uint64_t time_of_sending_fp = get_absolute_time_in_fp();
uint64_t resend_error_backoff_time = (uint64_t)10<<32; // ten seconds
if ((conn->rtp_time_of_last_resend_request_error_fp) || ((time_of_sending_fp-conn->rtp_time_of_last_resend_request_error_fp)>resend_error_backoff_time)) {
uint64_t resend_error_backoff_time = (uint64_t)10 << 32; // ten seconds
if ((conn->rtp_time_of_last_resend_request_error_fp) ||
((time_of_sending_fp - conn->rtp_time_of_last_resend_request_error_fp) >
resend_error_backoff_time)) {
if (sendto(conn->audio_socket, req, sizeof(req), 0,
(struct sockaddr *)&conn->rtp_client_control_socket, msgsize) == -1) {
char em[1024];
@@ -852,7 +852,7 @@ void rtp_request_resend(seq_t first, uint32_t count, rtsp_conn_info *conn) {
debug(1, "Error %d using send-to to an audio socket: \"%s\". ", errno, em);
conn->rtp_time_of_last_resend_request_error_fp = time_of_sending_fp;
} else {
conn->rtp_time_of_last_resend_request_error_fp=0;
conn->rtp_time_of_last_resend_request_error_fp = 0;
}
}
} else {
+6 -6
View File
@@ -657,17 +657,17 @@ static void msg_write_response(int fd, rtsp_message *resp) {
}
if (write(fd, pkt, p - pkt) != p - pkt)
debug(1,"Error writing an RTSP packet -- requested bytes not fully written.");
debug(1, "Error writing an RTSP packet -- requested bytes not fully written.");
// Here, if there's content, write it
if (resp->contentlength) {
debug(1, "Content is \"%s\"", resp->content);
if (write(fd, resp->content, resp->contentlength) != resp->contentlength)
debug(1,"Error writing RTSP content -- requested bytes not fully written.");
debug(1, "Error writing RTSP content -- requested bytes not fully written.");
}
if (write(fd, "\r\n", strlen("\r\n")) != strlen("\r\n"))
debug(1,"Error terminating RTSP content.");
debug(1, "Error terminating RTSP content.");
}
static void handle_record(rtsp_conn_info *conn, rtsp_message *req, rtsp_message *resp) {
@@ -867,7 +867,7 @@ static void handle_set_parameter_parameter(rtsp_conn_info *conn, rtsp_message *r
if (!strncmp(cp, "volume: ", 8)) {
float volume = atof(cp + 8);
//debug(2, "AirPlay request to set volume to: %f.", volume);
// debug(2, "AirPlay request to set volume to: %f.", volume);
player_volume(volume, conn);
} else
#ifdef CONFIG_METADATA
@@ -1679,9 +1679,9 @@ static char *make_nonce(void) {
int fd = open("/dev/random", O_RDONLY);
if (fd < 0)
die("could not open /dev/random!");
// int ignore =
// int ignore =
if (read(fd, random, sizeof(random)) != sizeof(random))
debug(1,"Error reading /dev/random");
debug(1, "Error reading /dev/random");
close(fd);
return base64_enc(random, 8);
}
+29 -29
View File
@@ -1,8 +1,8 @@
#include "dbus-interface.h"
#include <popt.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <popt.h>
#include "dbus-interface.h"
GMainLoop *loop;
@@ -73,42 +73,42 @@ int main(int argc, char *argv[]) {
GBusType gbus_type_selected = G_BUS_TYPE_SYSTEM; // set default
// get the options --system or --session for system bus or session bus
signed char c; /* used for argument parsing */
poptContext optCon; /* context for parsing command-line options */
signed char c; /* used for argument parsing */
poptContext optCon; /* context for parsing command-line options */
struct poptOption optionsTable[] = {
{ "system", '\0', POPT_ARG_VAL, &gbus_type_selected, G_BUS_TYPE_SYSTEM,
"Listen on the D-Bus system bus -- pick this option or the \'--session\' option, but not both. This is the default if no option is chosen.", NULL },
{ "session", '\0', POPT_ARG_VAL, &gbus_type_selected, G_BUS_TYPE_SESSION,
"Listen on the D-Bus session bus -- pick this option or the \'--system\' option, but not both.", NULL },
POPT_AUTOHELP
{ NULL, 0, 0, NULL, 0 }
};
struct poptOption optionsTable[] = {
{"system", '\0', POPT_ARG_VAL, &gbus_type_selected, G_BUS_TYPE_SYSTEM,
"Listen on the D-Bus system bus -- pick this option or the \'--session\' option, but not "
"both. This is the default if no option is chosen.",
NULL},
{"session", '\0', POPT_ARG_VAL, &gbus_type_selected, G_BUS_TYPE_SESSION,
"Listen on the D-Bus session bus -- pick this option or the \'--system\' option, but not "
"both.",
NULL},
POPT_AUTOHELP{NULL, 0, 0, NULL, 0}};
optCon = poptGetContext(NULL, argc, (const char **)argv, optionsTable, 0);
poptSetOtherOptionHelp(optCon, "[--system | --session]");
optCon = poptGetContext(NULL, argc, (const char **)argv, optionsTable, 0);
poptSetOtherOptionHelp(optCon, "[--system | --session]");
if (argc > 2) {
poptPrintHelp(optCon, stderr, 0);
exit(1);
}
/* Now do options processing */
while ((c = poptGetNextOpt(optCon)) >= 0) {
}
/* Now do options processing */
while ((c = poptGetNextOpt(optCon)) >= 0) {
}
if (c < -1) {
/* an error occurred during option processing */
fprintf(stderr, "%s: %s\n", poptBadOption(optCon, POPT_BADOPTION_NOALIAS), poptStrerror(c));
return 1;
}
if (c < -1) {
/* an error occurred during option processing */
fprintf(stderr, "%s: %s\n",
poptBadOption(optCon, POPT_BADOPTION_NOALIAS),
poptStrerror(c));
return 1;
}
poptFreeContext(optCon);
printf( "Listening on the D-Bus %s bus.\n", (gbus_type_selected == G_BUS_TYPE_SYSTEM) ? "system" : "session");
printf("Listening on the D-Bus %s bus.\n",
(gbus_type_selected == G_BUS_TYPE_SYSTEM) ? "system" : "session");
pthread_create(&dbus_thread, NULL, &dbus_thread_func, NULL);
@@ -162,7 +162,7 @@ int main(int argc, char *argv[]) {
shairport_sync_call_remote_command(SHAIRPORT_SYNC(proxy), "string",NULL,NULL,NULL);
*/
g_print("Finished test. Waiting for property changes...\n");
// g_main_loop_quit(loop);
// g_main_loop_quit(loop);
pthread_join(dbus_thread, NULL);
printf("exiting program.\n");
+33 -33
View File
@@ -1,9 +1,9 @@
#include "mpris-interface.h"
#include "mpris-player-interface.h"
#include <popt.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <popt.h>
#include "mpris-interface.h"
#include "mpris-player-interface.h"
GMainLoop *loop;
@@ -51,52 +51,52 @@ void *dbus_thread_func(void *arg) {
int main(int argc, char *argv[]) {
GBusType gbus_type_selected = G_BUS_TYPE_SYSTEM; // set default
// get the options --system or --session for system bus or session bus
signed char c; /* used for argument parsing */
poptContext optCon; /* context for parsing command-line options */
signed char c; /* used for argument parsing */
poptContext optCon; /* context for parsing command-line options */
struct poptOption optionsTable[] = {
{ "system", '\0', POPT_ARG_VAL, &gbus_type_selected, G_BUS_TYPE_SYSTEM,
"Listen on the D-Bus system bus -- pick this option or the \'--session\' option, but not both. This is the default if no option is chosen.", NULL },
{ "session", '\0', POPT_ARG_VAL, &gbus_type_selected, G_BUS_TYPE_SESSION,
"Listen on the D-Bus session bus -- pick this option or the \'--system\' option, but not both.", NULL },
POPT_AUTOHELP
{ NULL, 0, 0, NULL, 0 }
};
struct poptOption optionsTable[] = {
{"system", '\0', POPT_ARG_VAL, &gbus_type_selected, G_BUS_TYPE_SYSTEM,
"Listen on the D-Bus system bus -- pick this option or the \'--session\' option, but not "
"both. This is the default if no option is chosen.",
NULL},
{"session", '\0', POPT_ARG_VAL, &gbus_type_selected, G_BUS_TYPE_SESSION,
"Listen on the D-Bus session bus -- pick this option or the \'--system\' option, but not "
"both.",
NULL},
POPT_AUTOHELP{NULL, 0, 0, NULL, 0}};
optCon = poptGetContext(NULL, argc, (const char **)argv, optionsTable, 0);
poptSetOtherOptionHelp(optCon, "[--system | --session]");
optCon = poptGetContext(NULL, argc, (const char **)argv, optionsTable, 0);
poptSetOtherOptionHelp(optCon, "[--system | --session]");
if (argc > 2) {
poptPrintHelp(optCon, stderr, 0);
exit(1);
}
/* Now do options processing */
while ((c = poptGetNextOpt(optCon)) >= 0) {
}
/* Now do options processing */
while ((c = poptGetNextOpt(optCon)) >= 0) {
}
if (c < -1) {
/* an error occurred during option processing */
fprintf(stderr, "%s: %s\n", poptBadOption(optCon, POPT_BADOPTION_NOALIAS), poptStrerror(c));
return 1;
}
if (c < -1) {
/* an error occurred during option processing */
fprintf(stderr, "%s: %s\n",
poptBadOption(optCon, POPT_BADOPTION_NOALIAS),
poptStrerror(c));
return 1;
}
poptFreeContext(optCon);
printf( "Listening on the D-Bus %s bus...\n", (gbus_type_selected == G_BUS_TYPE_SYSTEM) ? "system" : "session");
printf("Listening on the D-Bus %s bus...\n",
(gbus_type_selected == G_BUS_TYPE_SYSTEM) ? "system" : "session");
pthread_create(&dbus_thread, NULL, &dbus_thread_func, NULL);
MediaPlayer2Player *proxy;
GError *error = NULL;
GError *error = NULL;
proxy = media_player2_player_proxy_new_for_bus_sync(gbus_type_selected, G_DBUS_PROXY_FLAGS_NONE,
"org.mpris.MediaPlayer2.ShairportSync",
"/org/mpris/MediaPlayer2", NULL, &error);
"org.mpris.MediaPlayer2.ShairportSync",
"/org/mpris/MediaPlayer2", NULL, &error);
g_signal_connect(proxy, "g-properties-changed", G_CALLBACK(on_properties_changed), NULL);
// g_main_loop_quit(loop);
pthread_join(dbus_thread, NULL);
+1 -1
View File
@@ -31,11 +31,11 @@
#include <libconfig.h>
#include <libgen.h>
#include <memory.h>
#include <sys/socket.h>
#include <net/if.h>
#include <popt.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/wait.h>