Clean up native dbus interface files and associated changes to existing files.
This commit is contained in:
@@ -984,24 +984,23 @@ void memory_barrier() {
|
||||
pthread_mutex_unlock(&barrier_mutex);
|
||||
}
|
||||
|
||||
int ss_pthread_mutex_timedlock(pthread_mutex_t *mutex, useconds_t dally_time, const char * debugmessage, int debuglevel) {
|
||||
int ss_pthread_mutex_timedlock(pthread_mutex_t *mutex, useconds_t dally_time,
|
||||
const char *debugmessage, int debuglevel) {
|
||||
|
||||
int time_to_wait = dally_time;
|
||||
int r = pthread_mutex_trylock(mutex);
|
||||
while ((r) && (time_to_wait>0)) {
|
||||
while ((r) && (time_to_wait > 0)) {
|
||||
int st = time_to_wait;
|
||||
if (st>20000)
|
||||
st=20000;
|
||||
if (st > 20000)
|
||||
st = 20000;
|
||||
usleep(st);
|
||||
time_to_wait -= st;
|
||||
time_to_wait -= st;
|
||||
r = pthread_mutex_trylock(mutex);
|
||||
}
|
||||
if (r!=0) {
|
||||
if (r != 0) {
|
||||
char errstr[1000];
|
||||
debug(debuglevel,"error %d: \"%s\" waiting for a mutex: \"%s\".",r,strerror_r(r,errstr,sizeof(errstr)),debugmessage);
|
||||
}
|
||||
debug(debuglevel, "error %d: \"%s\" waiting for a mutex: \"%s\".", r,
|
||||
strerror_r(r, errstr, sizeof(errstr)), debugmessage);
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
#ifndef _COMMON_H
|
||||
#define _COMMON_H
|
||||
|
||||
#include <unistd.h>
|
||||
#include <libconfig.h>
|
||||
#include <signal.h>
|
||||
#include <stdint.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "audio.h"
|
||||
#include "config.h"
|
||||
@@ -181,7 +181,6 @@ typedef struct {
|
||||
uint32_t nctohl(const uint8_t *p); // read 4 characters from the p and do ntohl on them
|
||||
void memory_barrier();
|
||||
|
||||
|
||||
// true if Shairport Sync is supposed to be sending output to the output device, false otherwise
|
||||
|
||||
int get_requested_connection_state_to_output();
|
||||
@@ -252,6 +251,7 @@ void shairport_shutdown();
|
||||
extern sigset_t pselect_sigset;
|
||||
|
||||
// wait for the specified time in microseconds -- it checks every 20 milliseconds
|
||||
int ss_pthread_mutex_timedlock(pthread_mutex_t *mutex, useconds_t dally_time, const char * debugmessage, int debuglevel);
|
||||
int ss_pthread_mutex_timedlock(pthread_mutex_t *mutex, useconds_t dally_time,
|
||||
const char *debugmessage, int debuglevel);
|
||||
|
||||
#endif // _COMMON_H
|
||||
|
||||
@@ -46,13 +46,14 @@
|
||||
#include "tinyhttp/http.h"
|
||||
|
||||
typedef struct {
|
||||
int players_connection_thread_index; // the connection thread index when a player thread is associated with this, zero otherwise
|
||||
int scan_enable; // set to 1 if if sacanning should be considered
|
||||
uint16_t port; // zero if no port discovered
|
||||
short connection_family; // AF_INET6 or AF_INET
|
||||
uint32_t scope_id; // if it's an ipv6 connection, this will be its scope id
|
||||
char ip_string[INET6_ADDRSTRLEN]; // the ip string pointing to the client
|
||||
uint32_t active_remote_id; // send this when you want to send remote control commands
|
||||
int players_connection_thread_index; // the connection thread index when a player thread is
|
||||
// associated with this, zero otherwise
|
||||
int scan_enable; // set to 1 if if sacanning should be considered
|
||||
uint16_t port; // zero if no port discovered
|
||||
short connection_family; // AF_INET6 or AF_INET
|
||||
uint32_t scope_id; // if it's an ipv6 connection, this will be its scope id
|
||||
char ip_string[INET6_ADDRSTRLEN]; // the ip string pointing to the client
|
||||
uint32_t active_remote_id; // send this when you want to send remote control commands
|
||||
} dacp_server_record;
|
||||
|
||||
pthread_t dacp_monitor_thread;
|
||||
@@ -158,7 +159,7 @@ int dacp_send_command(const char *command, char **body, ssize_t *bodysize) {
|
||||
|
||||
// only do this one at a time -- not sure it is necessary, but better safe than sorry
|
||||
|
||||
int mutex_reply = ss_pthread_mutex_timedlock(&dacp_conversation_lock,1000000,command,1);
|
||||
int mutex_reply = ss_pthread_mutex_timedlock(&dacp_conversation_lock, 1000000, command, 1);
|
||||
if (mutex_reply == 0) {
|
||||
// debug(1,"dacp_conversation_lock acquired for command \"%s\".",command);
|
||||
|
||||
@@ -263,9 +264,13 @@ int send_simple_dacp_command(const char *command) {
|
||||
}
|
||||
|
||||
void relinquish_dacp_server_information(rtsp_conn_info *conn) {
|
||||
// this will set the dacp_server.players_connection_thread_index to zero iff it has the same value as the conn's connection number
|
||||
// this is to signify that the player has stopped, but only if another thread (with a different index) hasn't already taken over the dacp service
|
||||
ss_pthread_mutex_timedlock(&dacp_server_information_lock,500000,"set_dacp_server_information couldn't get DACP server information lock in 0.5 second!.",1);
|
||||
// this will set the dacp_server.players_connection_thread_index to zero iff it has the same value
|
||||
// as the conn's connection number
|
||||
// this is to signify that the player has stopped, but only if another thread (with a different
|
||||
// index) hasn't already taken over the dacp service
|
||||
ss_pthread_mutex_timedlock(
|
||||
&dacp_server_information_lock, 500000,
|
||||
"set_dacp_server_information couldn't get DACP server information lock in 0.5 second!.", 1);
|
||||
if (dacp_server.players_connection_thread_index == conn->connection_number)
|
||||
dacp_server.players_connection_thread_index = 0;
|
||||
pthread_mutex_unlock(&dacp_server_information_lock);
|
||||
@@ -274,7 +279,9 @@ void relinquish_dacp_server_information(rtsp_conn_info *conn) {
|
||||
// this will be running on the thread of its caller, not of the conversation thread...
|
||||
void set_dacp_server_information(rtsp_conn_info *conn) { // tell the DACP conversation thread that
|
||||
// the port has been set or changed
|
||||
ss_pthread_mutex_timedlock(&dacp_server_information_lock,500000,"set_dacp_server_information couldn't get DACP server information lock in 0.5 second!.",1);
|
||||
ss_pthread_mutex_timedlock(
|
||||
&dacp_server_information_lock, 500000,
|
||||
"set_dacp_server_information couldn't get DACP server information lock in 0.5 second!.", 1);
|
||||
dacp_server.players_connection_thread_index = conn->connection_number;
|
||||
dacp_server.port = conn->dacp_port;
|
||||
dacp_server.connection_family = conn->connection_ip_family;
|
||||
@@ -302,7 +309,9 @@ void *dacp_monitor_thread_code(__attribute__((unused)) void *na) {
|
||||
int32_t revision_number = 1;
|
||||
while (1) {
|
||||
int result;
|
||||
ss_pthread_mutex_timedlock(&dacp_server_information_lock,500000,"dacp_monitor_thread_code couldn't get DACP server information lock in 0.5 second!.",1);
|
||||
ss_pthread_mutex_timedlock(
|
||||
&dacp_server_information_lock, 500000,
|
||||
"dacp_monitor_thread_code couldn't get DACP server information lock in 0.5 second!.", 1);
|
||||
while (dacp_server.scan_enable == 0) {
|
||||
// debug(1, "Wait for a valid DACP port");
|
||||
pthread_cond_wait(&dacp_server_information_cv, &dacp_server_information_lock);
|
||||
@@ -313,7 +322,7 @@ void *dacp_monitor_thread_code(__attribute__((unused)) void *na) {
|
||||
// debug(1,"Stopping scan because the response to \"dacp_get_volume(NULL)\" is %d.",result);
|
||||
dacp_server.scan_enable = 0;
|
||||
metadata_hub_modify_prolog();
|
||||
int ch = metadata_store.dacp_server_active !=0;
|
||||
int ch = metadata_store.dacp_server_active != 0;
|
||||
metadata_store.dacp_server_active = 0;
|
||||
metadata_hub_modify_epilog(ch);
|
||||
}
|
||||
|
||||
+106
-75
@@ -20,19 +20,21 @@ ShairportSyncBasicRemoteControl *shairportSyncBasicRemoteControlSkeleton;
|
||||
void dbus_metadata_watcher(struct metadata_bundle *argc, __attribute__((unused)) void *userdata) {
|
||||
// debug(1, "DBUS metadata watcher called");
|
||||
shairport_sync_set_volume(shairportSyncSkeleton, argc->speaker_volume);
|
||||
|
||||
|
||||
// debug(1, "No diagnostics watcher required");
|
||||
|
||||
// debug(1, "DBUS basic remote control watcher called");
|
||||
|
||||
shairport_sync_basic_remote_control_set_airplay_volume(shairportSyncBasicRemoteControlSkeleton, argc->airplay_volume);
|
||||
|
||||
|
||||
shairport_sync_basic_remote_control_set_airplay_volume(shairportSyncBasicRemoteControlSkeleton,
|
||||
argc->airplay_volume);
|
||||
|
||||
if (argc->dacp_server_active)
|
||||
shairport_sync_basic_remote_control_set_server(shairportSyncBasicRemoteControlSkeleton, argc->client_ip);
|
||||
shairport_sync_basic_remote_control_set_server(shairportSyncBasicRemoteControlSkeleton,
|
||||
argc->client_ip);
|
||||
else
|
||||
shairport_sync_basic_remote_control_set_server(shairportSyncBasicRemoteControlSkeleton, "");
|
||||
|
||||
GVariantBuilder *dict_builder, *aa;
|
||||
shairport_sync_basic_remote_control_set_server(shairportSyncBasicRemoteControlSkeleton, "");
|
||||
|
||||
GVariantBuilder *dict_builder, *aa;
|
||||
|
||||
/* Build the metadata array */
|
||||
// debug(1,"Build metadata");
|
||||
@@ -56,7 +58,7 @@ void dbus_metadata_watcher(struct metadata_bundle *argc, __attribute__((unused))
|
||||
GVariant *trackid = g_variant_new("o", trackidstring);
|
||||
g_variant_builder_add(dict_builder, "{sv}", "mpris:trackid", trackid);
|
||||
}
|
||||
|
||||
|
||||
// Add the track name if there is one
|
||||
if (argc->track_name) {
|
||||
// debug(1, "Track name set to \"%s\".", argc->track_name);
|
||||
@@ -97,104 +99,114 @@ void dbus_metadata_watcher(struct metadata_bundle *argc, __attribute__((unused))
|
||||
|
||||
// debug(1,"Set metadata");
|
||||
shairport_sync_basic_remote_control_set_metadata(shairportSyncBasicRemoteControlSkeleton, dict);
|
||||
|
||||
|
||||
}
|
||||
|
||||
static gboolean on_handle_fast_forward(ShairportSyncBasicRemoteControl *skeleton, GDBusMethodInvocation *invocation,
|
||||
__attribute__((unused)) gpointer user_data) {
|
||||
static gboolean on_handle_fast_forward(ShairportSyncBasicRemoteControl *skeleton,
|
||||
GDBusMethodInvocation *invocation,
|
||||
__attribute__((unused)) gpointer user_data) {
|
||||
send_simple_dacp_command("beginff");
|
||||
shairport_sync_basic_remote_control_complete_fast_forward(skeleton, invocation);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean on_handle_rewind(ShairportSyncBasicRemoteControl *skeleton, GDBusMethodInvocation *invocation,
|
||||
__attribute__((unused)) gpointer user_data) {
|
||||
static gboolean on_handle_rewind(ShairportSyncBasicRemoteControl *skeleton,
|
||||
GDBusMethodInvocation *invocation,
|
||||
__attribute__((unused)) gpointer user_data) {
|
||||
send_simple_dacp_command("beginrew");
|
||||
shairport_sync_basic_remote_control_complete_rewind(skeleton, invocation);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean on_handle_toggle_mute(ShairportSyncBasicRemoteControl *skeleton, GDBusMethodInvocation *invocation,
|
||||
__attribute__((unused)) gpointer user_data) {
|
||||
static gboolean on_handle_toggle_mute(ShairportSyncBasicRemoteControl *skeleton,
|
||||
GDBusMethodInvocation *invocation,
|
||||
__attribute__((unused)) gpointer user_data) {
|
||||
send_simple_dacp_command("mutetoggle");
|
||||
shairport_sync_basic_remote_control_complete_toggle_mute(skeleton, invocation);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean on_handle_next(ShairportSyncBasicRemoteControl *skeleton, GDBusMethodInvocation *invocation,
|
||||
static gboolean on_handle_next(ShairportSyncBasicRemoteControl *skeleton,
|
||||
GDBusMethodInvocation *invocation,
|
||||
__attribute__((unused)) gpointer user_data) {
|
||||
send_simple_dacp_command("nextitem");
|
||||
shairport_sync_basic_remote_control_complete_next(skeleton, invocation);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean on_handle_previous(ShairportSyncBasicRemoteControl *skeleton, GDBusMethodInvocation *invocation,
|
||||
__attribute__((unused)) gpointer user_data) {
|
||||
static gboolean on_handle_previous(ShairportSyncBasicRemoteControl *skeleton,
|
||||
GDBusMethodInvocation *invocation,
|
||||
__attribute__((unused)) gpointer user_data) {
|
||||
send_simple_dacp_command("previtem");
|
||||
shairport_sync_basic_remote_control_complete_previous(skeleton, invocation);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean on_handle_pause(ShairportSyncBasicRemoteControl *skeleton, GDBusMethodInvocation *invocation,
|
||||
__attribute__((unused)) gpointer user_data) {
|
||||
static gboolean on_handle_pause(ShairportSyncBasicRemoteControl *skeleton,
|
||||
GDBusMethodInvocation *invocation,
|
||||
__attribute__((unused)) gpointer user_data) {
|
||||
send_simple_dacp_command("pause");
|
||||
shairport_sync_basic_remote_control_complete_pause(skeleton, invocation);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean on_handle_play_pause(ShairportSyncBasicRemoteControl *skeleton, GDBusMethodInvocation *invocation,
|
||||
__attribute__((unused)) gpointer user_data) {
|
||||
static gboolean on_handle_play_pause(ShairportSyncBasicRemoteControl *skeleton,
|
||||
GDBusMethodInvocation *invocation,
|
||||
__attribute__((unused)) gpointer user_data) {
|
||||
send_simple_dacp_command("playpause");
|
||||
shairport_sync_basic_remote_control_complete_play_pause(skeleton, invocation);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean on_handle_play(ShairportSyncBasicRemoteControl *skeleton, GDBusMethodInvocation *invocation,
|
||||
static gboolean on_handle_play(ShairportSyncBasicRemoteControl *skeleton,
|
||||
GDBusMethodInvocation *invocation,
|
||||
__attribute__((unused)) gpointer user_data) {
|
||||
send_simple_dacp_command("play");
|
||||
shairport_sync_basic_remote_control_complete_play(skeleton, invocation);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean on_handle_stop(ShairportSyncBasicRemoteControl *skeleton, GDBusMethodInvocation *invocation,
|
||||
static gboolean on_handle_stop(ShairportSyncBasicRemoteControl *skeleton,
|
||||
GDBusMethodInvocation *invocation,
|
||||
__attribute__((unused)) gpointer user_data) {
|
||||
send_simple_dacp_command("stop");
|
||||
shairport_sync_basic_remote_control_complete_stop(skeleton, invocation);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean on_handle_resume(ShairportSyncBasicRemoteControl *skeleton, GDBusMethodInvocation *invocation,
|
||||
__attribute__((unused)) gpointer user_data) {
|
||||
static gboolean on_handle_resume(ShairportSyncBasicRemoteControl *skeleton,
|
||||
GDBusMethodInvocation *invocation,
|
||||
__attribute__((unused)) gpointer user_data) {
|
||||
send_simple_dacp_command("playresume");
|
||||
shairport_sync_basic_remote_control_complete_resume(skeleton, invocation);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
static gboolean on_handle_shuffle_songs(ShairportSyncBasicRemoteControl *skeleton, GDBusMethodInvocation *invocation,
|
||||
__attribute__((unused)) gpointer user_data) {
|
||||
static gboolean on_handle_shuffle_songs(ShairportSyncBasicRemoteControl *skeleton,
|
||||
GDBusMethodInvocation *invocation,
|
||||
__attribute__((unused)) gpointer user_data) {
|
||||
send_simple_dacp_command("shuffle_songs");
|
||||
shairport_sync_basic_remote_control_complete_shuffle_songs(skeleton, invocation);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean on_handle_volume_up(ShairportSyncBasicRemoteControl *skeleton, GDBusMethodInvocation *invocation,
|
||||
__attribute__((unused)) gpointer user_data) {
|
||||
static gboolean on_handle_volume_up(ShairportSyncBasicRemoteControl *skeleton,
|
||||
GDBusMethodInvocation *invocation,
|
||||
__attribute__((unused)) gpointer user_data) {
|
||||
send_simple_dacp_command("volumeup");
|
||||
shairport_sync_basic_remote_control_complete_volume_up(skeleton, invocation);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean on_handle_volume_down(ShairportSyncBasicRemoteControl *skeleton, GDBusMethodInvocation *invocation,
|
||||
__attribute__((unused)) gpointer user_data) {
|
||||
static gboolean on_handle_volume_down(ShairportSyncBasicRemoteControl *skeleton,
|
||||
GDBusMethodInvocation *invocation,
|
||||
__attribute__((unused)) gpointer user_data) {
|
||||
send_simple_dacp_command("volumedown");
|
||||
shairport_sync_basic_remote_control_complete_volume_down(skeleton, invocation);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean notify_elapsed_time_callback(ShairportSyncDiagnostics *skeleton,
|
||||
__attribute__((unused)) gpointer user_data) {
|
||||
__attribute__((unused)) gpointer user_data) {
|
||||
// debug(1, "\"notify_elapsed_time_callback\" called.");
|
||||
if (shairport_sync_diagnostics_get_elapsed_time(skeleton)) {
|
||||
config.debugger_show_elapsed_time = 1;
|
||||
@@ -207,7 +219,7 @@ gboolean notify_elapsed_time_callback(ShairportSyncDiagnostics *skeleton,
|
||||
}
|
||||
|
||||
gboolean notify_delta_time_callback(ShairportSyncDiagnostics *skeleton,
|
||||
__attribute__((unused)) gpointer user_data) {
|
||||
__attribute__((unused)) gpointer user_data) {
|
||||
// debug(1, "\"notify_delta_time_callback\" called.");
|
||||
if (shairport_sync_diagnostics_get_delta_time(skeleton)) {
|
||||
config.debugger_show_relative_time = 1;
|
||||
@@ -220,7 +232,7 @@ gboolean notify_delta_time_callback(ShairportSyncDiagnostics *skeleton,
|
||||
}
|
||||
|
||||
gboolean notify_statistics_callback(ShairportSyncDiagnostics *skeleton,
|
||||
__attribute__((unused)) gpointer user_data) {
|
||||
__attribute__((unused)) gpointer user_data) {
|
||||
// debug(1, "\"notify_statistics_callback\" called.");
|
||||
if (shairport_sync_diagnostics_get_statistics(skeleton)) {
|
||||
debug(1, ">> start logging statistics");
|
||||
@@ -233,10 +245,10 @@ gboolean notify_statistics_callback(ShairportSyncDiagnostics *skeleton,
|
||||
}
|
||||
|
||||
gboolean notify_verbosity_callback(ShairportSyncDiagnostics *skeleton,
|
||||
__attribute__((unused)) gpointer user_data) {
|
||||
__attribute__((unused)) gpointer user_data) {
|
||||
gint th = shairport_sync_diagnostics_get_verbosity(skeleton);
|
||||
if ((th >= 0) && (th <= 3)) {
|
||||
if (th==0)
|
||||
if (th == 0)
|
||||
debug(1, ">> log verbosity set to %d.", th);
|
||||
debuglev = th;
|
||||
debug(1, ">> log verbosity set to %d.", th);
|
||||
@@ -289,7 +301,8 @@ static gboolean on_handle_remote_command(ShairportSync *skeleton, GDBusMethodInv
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void on_dbus_name_acquired(GDBusConnection *connection, const gchar *name, gpointer user_data) {
|
||||
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");
|
||||
@@ -321,35 +334,41 @@ static void on_dbus_name_acquired(GDBusConnection *connection, const gchar *name
|
||||
|
||||
// debug(1,"dbus_diagnostics_on_dbus_name_acquired");
|
||||
shairportSyncDiagnosticsSkeleton = shairport_sync_diagnostics_skeleton_new();
|
||||
g_dbus_interface_skeleton_export(G_DBUS_INTERFACE_SKELETON(shairportSyncDiagnosticsSkeleton), connection,
|
||||
"/org/gnome/ShairportSync", NULL);
|
||||
|
||||
shairport_sync_diagnostics_set_verbosity(SHAIRPORT_SYNC_DIAGNOSTICS(shairportSyncDiagnosticsSkeleton),
|
||||
debuglev);
|
||||
|
||||
g_dbus_interface_skeleton_export(G_DBUS_INTERFACE_SKELETON(shairportSyncDiagnosticsSkeleton),
|
||||
connection, "/org/gnome/ShairportSync", NULL);
|
||||
|
||||
shairport_sync_diagnostics_set_verbosity(
|
||||
SHAIRPORT_SYNC_DIAGNOSTICS(shairportSyncDiagnosticsSkeleton), debuglev);
|
||||
|
||||
// debug(2,">> log verbosity is %d.",debuglev);
|
||||
|
||||
if (config.statistics_requested == 0) {
|
||||
shairport_sync_diagnostics_set_statistics(SHAIRPORT_SYNC_DIAGNOSTICS(shairportSyncDiagnosticsSkeleton), FALSE);
|
||||
shairport_sync_diagnostics_set_statistics(
|
||||
SHAIRPORT_SYNC_DIAGNOSTICS(shairportSyncDiagnosticsSkeleton), FALSE);
|
||||
// debug(1, ">> statistics logging is off");
|
||||
} else {
|
||||
shairport_sync_diagnostics_set_statistics(SHAIRPORT_SYNC_DIAGNOSTICS(shairportSyncDiagnosticsSkeleton), TRUE);
|
||||
shairport_sync_diagnostics_set_statistics(
|
||||
SHAIRPORT_SYNC_DIAGNOSTICS(shairportSyncDiagnosticsSkeleton), TRUE);
|
||||
// debug(1, ">> statistics logging is on");
|
||||
}
|
||||
|
||||
|
||||
if (config.debugger_show_elapsed_time == 0) {
|
||||
shairport_sync_diagnostics_set_elapsed_time(SHAIRPORT_SYNC_DIAGNOSTICS(shairportSyncDiagnosticsSkeleton), FALSE);
|
||||
shairport_sync_diagnostics_set_elapsed_time(
|
||||
SHAIRPORT_SYNC_DIAGNOSTICS(shairportSyncDiagnosticsSkeleton), FALSE);
|
||||
// debug(1, ">> elapsed time is included in log entries");
|
||||
} else {
|
||||
shairport_sync_diagnostics_set_elapsed_time(SHAIRPORT_SYNC_DIAGNOSTICS(shairportSyncDiagnosticsSkeleton), TRUE);
|
||||
shairport_sync_diagnostics_set_elapsed_time(
|
||||
SHAIRPORT_SYNC_DIAGNOSTICS(shairportSyncDiagnosticsSkeleton), TRUE);
|
||||
// debug(1, ">> elapsed time is not included in log entries");
|
||||
}
|
||||
|
||||
if (config.debugger_show_relative_time == 0) {
|
||||
shairport_sync_diagnostics_set_delta_time(SHAIRPORT_SYNC_DIAGNOSTICS(shairportSyncDiagnosticsSkeleton), FALSE);
|
||||
shairport_sync_diagnostics_set_delta_time(
|
||||
SHAIRPORT_SYNC_DIAGNOSTICS(shairportSyncDiagnosticsSkeleton), FALSE);
|
||||
// debug(1, ">> delta time is included in log entries");
|
||||
} else {
|
||||
shairport_sync_diagnostics_set_delta_time(SHAIRPORT_SYNC_DIAGNOSTICS(shairportSyncDiagnosticsSkeleton), TRUE);
|
||||
shairport_sync_diagnostics_set_delta_time(
|
||||
SHAIRPORT_SYNC_DIAGNOSTICS(shairportSyncDiagnosticsSkeleton), TRUE);
|
||||
// debug(1, ">> delta time is not included in log entries");
|
||||
}
|
||||
|
||||
@@ -364,32 +383,44 @@ static void on_dbus_name_acquired(GDBusConnection *connection, const gchar *name
|
||||
|
||||
g_signal_connect(shairportSyncDiagnosticsSkeleton, "notify::delta-time",
|
||||
G_CALLBACK(notify_delta_time_callback), NULL);
|
||||
|
||||
|
||||
// debug(1,"dbus_basic_remote_control_on_dbus_name_acquired");
|
||||
shairportSyncBasicRemoteControlSkeleton = shairport_sync_basic_remote_control_skeleton_new();
|
||||
g_dbus_interface_skeleton_export(G_DBUS_INTERFACE_SKELETON(shairportSyncBasicRemoteControlSkeleton), connection,
|
||||
"/org/gnome/ShairportSync", NULL);
|
||||
|
||||
g_signal_connect(shairportSyncBasicRemoteControlSkeleton, "handle-fast-forward", G_CALLBACK(on_handle_fast_forward), NULL);
|
||||
g_signal_connect(shairportSyncBasicRemoteControlSkeleton, "handle-rewind", G_CALLBACK(on_handle_rewind), NULL);
|
||||
g_signal_connect(shairportSyncBasicRemoteControlSkeleton, "handle-toggle-mute", G_CALLBACK(on_handle_toggle_mute), NULL);
|
||||
g_signal_connect(shairportSyncBasicRemoteControlSkeleton, "handle-next", G_CALLBACK(on_handle_next), NULL);
|
||||
g_signal_connect(shairportSyncBasicRemoteControlSkeleton, "handle-previous", G_CALLBACK(on_handle_previous), NULL);
|
||||
g_signal_connect(shairportSyncBasicRemoteControlSkeleton, "handle-pause", G_CALLBACK(on_handle_pause), NULL);
|
||||
g_signal_connect(shairportSyncBasicRemoteControlSkeleton, "handle-play-pause", G_CALLBACK(on_handle_play_pause), NULL);
|
||||
g_signal_connect(shairportSyncBasicRemoteControlSkeleton, "handle-play", G_CALLBACK(on_handle_play), NULL);
|
||||
g_signal_connect(shairportSyncBasicRemoteControlSkeleton, "handle-stop", G_CALLBACK(on_handle_stop), NULL);
|
||||
g_signal_connect(shairportSyncBasicRemoteControlSkeleton, "handle-resume", G_CALLBACK(on_handle_resume), NULL);
|
||||
g_signal_connect(shairportSyncBasicRemoteControlSkeleton, "handle-shuffle-songs", G_CALLBACK(on_handle_shuffle_songs), NULL);
|
||||
g_signal_connect(shairportSyncBasicRemoteControlSkeleton, "handle-volume-up", G_CALLBACK(on_handle_volume_up), NULL);
|
||||
g_signal_connect(shairportSyncBasicRemoteControlSkeleton, "handle-volume-down", G_CALLBACK(on_handle_volume_down), NULL);
|
||||
g_dbus_interface_skeleton_export(
|
||||
G_DBUS_INTERFACE_SKELETON(shairportSyncBasicRemoteControlSkeleton), connection,
|
||||
"/org/gnome/ShairportSync", NULL);
|
||||
|
||||
g_signal_connect(shairportSyncBasicRemoteControlSkeleton, "handle-fast-forward",
|
||||
G_CALLBACK(on_handle_fast_forward), NULL);
|
||||
g_signal_connect(shairportSyncBasicRemoteControlSkeleton, "handle-rewind",
|
||||
G_CALLBACK(on_handle_rewind), NULL);
|
||||
g_signal_connect(shairportSyncBasicRemoteControlSkeleton, "handle-toggle-mute",
|
||||
G_CALLBACK(on_handle_toggle_mute), NULL);
|
||||
g_signal_connect(shairportSyncBasicRemoteControlSkeleton, "handle-next",
|
||||
G_CALLBACK(on_handle_next), NULL);
|
||||
g_signal_connect(shairportSyncBasicRemoteControlSkeleton, "handle-previous",
|
||||
G_CALLBACK(on_handle_previous), NULL);
|
||||
g_signal_connect(shairportSyncBasicRemoteControlSkeleton, "handle-pause",
|
||||
G_CALLBACK(on_handle_pause), NULL);
|
||||
g_signal_connect(shairportSyncBasicRemoteControlSkeleton, "handle-play-pause",
|
||||
G_CALLBACK(on_handle_play_pause), NULL);
|
||||
g_signal_connect(shairportSyncBasicRemoteControlSkeleton, "handle-play",
|
||||
G_CALLBACK(on_handle_play), NULL);
|
||||
g_signal_connect(shairportSyncBasicRemoteControlSkeleton, "handle-stop",
|
||||
G_CALLBACK(on_handle_stop), NULL);
|
||||
g_signal_connect(shairportSyncBasicRemoteControlSkeleton, "handle-resume",
|
||||
G_CALLBACK(on_handle_resume), NULL);
|
||||
g_signal_connect(shairportSyncBasicRemoteControlSkeleton, "handle-shuffle-songs",
|
||||
G_CALLBACK(on_handle_shuffle_songs), NULL);
|
||||
g_signal_connect(shairportSyncBasicRemoteControlSkeleton, "handle-volume-up",
|
||||
G_CALLBACK(on_handle_volume_up), NULL);
|
||||
g_signal_connect(shairportSyncBasicRemoteControlSkeleton, "handle-volume-down",
|
||||
G_CALLBACK(on_handle_volume_down), NULL);
|
||||
|
||||
|
||||
|
||||
add_metadata_watcher(dbus_metadata_watcher, NULL);
|
||||
|
||||
#ifdef HAVE_DBUS_BASIC_REMOTE_CONTROL
|
||||
dbus_basic_remote_control_on_dbus_name_acquired(connection,name,user_data);
|
||||
dbus_basic_remote_control_on_dbus_name_acquired(connection, name, user_data);
|
||||
#endif
|
||||
|
||||
debug(1, "Shairport Sync native D-Bus service started at \"%s\" on the %s bus.", name,
|
||||
@@ -423,7 +454,7 @@ static void on_dbus_name_lost(__attribute__((unused)) GDBusConnection *connectio
|
||||
}
|
||||
|
||||
int start_dbus_service() {
|
||||
// shairportSyncSkeleton = NULL;
|
||||
// shairportSyncSkeleton = NULL;
|
||||
GBusType dbus_bus_type = G_BUS_TYPE_SYSTEM;
|
||||
if (config.dbus_service_bus_type == DBT_session)
|
||||
dbus_bus_type = G_BUS_TYPE_SESSION;
|
||||
|
||||
+9
-7
@@ -143,13 +143,15 @@ static void browse_callback(AvahiServiceBrowser *b, AvahiIfIndex interface, Avah
|
||||
if (conn->dacp_id != 0) {
|
||||
debug(3, "Client's DACP status withdrawn.");
|
||||
conn->dacp_port = 0;
|
||||
/*
|
||||
#ifdef HAVE_DACP_CLIENT
|
||||
// this might be in a race condition with another connection that could come into effect before this one has terminated.
|
||||
set_dacp_server_information(conn); // this will have the effect of telling the scanner
|
||||
// that the DACP server is no longer working
|
||||
#endif
|
||||
*/
|
||||
/*
|
||||
#ifdef HAVE_DACP_CLIENT
|
||||
// this might be in a race condition with another connection that could come into effect
|
||||
before this one has terminated.
|
||||
set_dacp_server_information(conn); // this will have the effect of telling the
|
||||
scanner
|
||||
// that the DACP server is no longer working
|
||||
#endif
|
||||
*/
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
+8
-8
@@ -86,10 +86,10 @@ void add_metadata_watcher(metadata_watcher fn, void *userdata) {
|
||||
void metadata_hub_modify_prolog(void) {
|
||||
// always run this before changing an entry or a sequence of entries in the metadata_hub
|
||||
// debug(1, "locking metadata hub for writing");
|
||||
if (pthread_rwlock_trywrlock(&metadata_hub_re_lock)!=0) {
|
||||
debug(1,"Metadata_hub write lock is already taken -- must wait.");
|
||||
pthread_rwlock_wrlock(&metadata_hub_re_lock);
|
||||
debug(1,"Okay -- acquired the metadata_hub write lock.");
|
||||
if (pthread_rwlock_trywrlock(&metadata_hub_re_lock) != 0) {
|
||||
debug(1, "Metadata_hub write lock is already taken -- must wait.");
|
||||
pthread_rwlock_wrlock(&metadata_hub_re_lock);
|
||||
debug(1, "Okay -- acquired the metadata_hub write lock.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -137,10 +137,10 @@ void metadata_hub_modify_epilog(int modified) {
|
||||
void metadata_hub_read_prolog(void) {
|
||||
// always run this before reading an entry or a sequence of entries in the metadata_hub
|
||||
// debug(1, "locking metadata hub for reading");
|
||||
if (pthread_rwlock_tryrdlock(&metadata_hub_re_lock)!=0) {
|
||||
debug(1,"Metadata_hub read lock is already taken -- must wait.");
|
||||
pthread_rwlock_rdlock(&metadata_hub_re_lock);
|
||||
debug(1,"Okay -- acquired the metadata_hub read lock.");
|
||||
if (pthread_rwlock_tryrdlock(&metadata_hub_re_lock) != 0) {
|
||||
debug(1, "Metadata_hub read lock is already taken -- must wait.");
|
||||
pthread_rwlock_rdlock(&metadata_hub_re_lock);
|
||||
debug(1, "Okay -- acquired the metadata_hub read lock.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+6
-4
@@ -28,8 +28,9 @@ typedef void (*metadata_watcher)(struct metadata_bundle *argc, void *userdata);
|
||||
|
||||
typedef struct metadata_bundle {
|
||||
|
||||
int dacp_server_active; // true if there's a reachable DACP server (assumed to be the Airplay client) ; false otherwise
|
||||
|
||||
int dacp_server_active; // true if there's a reachable DACP server (assumed to be the Airplay
|
||||
// client) ; false otherwise
|
||||
|
||||
int changed; // normally 0, nonzero if a field has been changed
|
||||
int playerstatusupdates_are_received; // false if it's "traditional" metadata
|
||||
|
||||
@@ -68,7 +69,8 @@ typedef struct metadata_bundle {
|
||||
char *sort_as; // a malloced string -- if non-zero, free it before replacing it
|
||||
int sort_as_changed;
|
||||
|
||||
char *client_ip; // IP number used by the audio source (i.e. the "client"), which is also the DACP server
|
||||
char *client_ip; // IP number used by the audio source (i.e. the "client"), which is also the DACP
|
||||
// server
|
||||
int client_ip_changed;
|
||||
|
||||
char *server_ip; // IP number used by Shairport Sync
|
||||
@@ -93,7 +95,7 @@ typedef struct metadata_bundle {
|
||||
// int previous_speaker_volume; // this is needed to prevent a loop
|
||||
|
||||
int airplay_volume;
|
||||
|
||||
|
||||
metadata_watcher watchers[number_of_watchers]; // functions to call if the metadata is changed.
|
||||
void *watchers_data[number_of_watchers]; // their individual data
|
||||
|
||||
|
||||
@@ -1604,13 +1604,13 @@ static void *player_thread_func(void *arg) {
|
||||
// stop looking elsewhere for DACP stuff
|
||||
conn->dacp_port = 0;
|
||||
#ifdef HAVE_DACP_CLIENT
|
||||
set_dacp_server_information(conn); // this will stop scanning until a port is registered by the code initiated by the mdns_dacp_monitor
|
||||
set_dacp_server_information(conn); // this will stop scanning until a port is registered by the
|
||||
// code initiated by the mdns_dacp_monitor
|
||||
#endif
|
||||
// start an mdns/zeroconf thread to look for DACP messages containing our DACP_ID and getting the
|
||||
// port number
|
||||
// mdns_dacp_monitor(conn->dacp_id, &conn->dacp_port, &conn->dacp_private);
|
||||
mdns_dacp_monitor(conn);
|
||||
|
||||
|
||||
conn->framesProcessedInThisEpoch = 0;
|
||||
conn->framesGeneratedInThisEpoch = 0;
|
||||
@@ -1658,9 +1658,9 @@ static void *player_thread_func(void *arg) {
|
||||
|
||||
player_volume(config.airplay_volume, conn);
|
||||
int64_t frames_to_drop = 0;
|
||||
debug(1,"Play begin");
|
||||
if (play_number % 100 == 0)
|
||||
debug(3,"Play frame %d.",play_number);
|
||||
debug(1, "Play begin");
|
||||
if (play_number % 100 == 0)
|
||||
debug(3, "Play frame %d.", play_number);
|
||||
while (!conn->player_thread_please_stop) {
|
||||
abuf_t *inframe = buffer_get_frame(conn);
|
||||
if (inframe) {
|
||||
@@ -2522,7 +2522,7 @@ void player_volume(double airplay_volume, rtsp_conn_info *conn) {
|
||||
int32_t actual_volume;
|
||||
int gv = dacp_get_volume(&actual_volume);
|
||||
metadata_hub_modify_prolog();
|
||||
if ((gv==200) && (metadata_store.speaker_volume != actual_volume)) {
|
||||
if ((gv == 200) && (metadata_store.speaker_volume != actual_volume)) {
|
||||
metadata_store.speaker_volume = actual_volume;
|
||||
modified = 1;
|
||||
}
|
||||
|
||||
@@ -101,7 +101,6 @@ static rtsp_conn_info **conns = NULL;
|
||||
|
||||
int RTSP_connection_index = 1;
|
||||
|
||||
|
||||
#ifdef CONFIG_METADATA
|
||||
typedef struct {
|
||||
pthread_mutex_t pc_queue_lock;
|
||||
@@ -1920,7 +1919,8 @@ static void *rtsp_conversation_thread_func(void *pconn) {
|
||||
debug(3, "Synchronously terminate playing thread of RTSP conversation thread %d.",
|
||||
conn->connection_number);
|
||||
if (conn->player_thread)
|
||||
debug(1, "RTSP Channel unexpectedly closed or a serious error occured -- closing the player thread.");
|
||||
debug(1, "RTSP Channel unexpectedly closed or a serious error occured -- closing the "
|
||||
"player thread.");
|
||||
player_stop(conn);
|
||||
debug(3, "Successful termination of playing thread of RTSP conversation thread %d.",
|
||||
conn->connection_number);
|
||||
|
||||
Reference in New Issue
Block a user