Skip to content

Commit

Permalink
Add "FirstFramePostion" property set when first frame of a play sessi…
Browse files Browse the repository at this point in the history
…on is sent.
  • Loading branch information
mikebrady committed Nov 28, 2022
1 parent 4044666 commit 37f060f
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 1 deletion.
9 changes: 9 additions & 0 deletions dbus-service.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,15 @@ void dbus_metadata_watcher(struct metadata_bundle *argc, __attribute__((unused))
}
}

if (argc->first_frame_position_string) {
// debug(1, "Check first frame position string");
th = shairport_sync_get_first_frame_position(shairportSyncSkeleton);
if ((th == NULL) || (strcasecmp(th, argc->first_frame_position_string) != 0)) {
// debug(1, "First frame position string should be changed");
shairport_sync_set_first_frame_position(shairportSyncSkeleton, argc->first_frame_position_string);
}
}

if (argc->stream_type) {
// debug(1, "Check stream type");
th = shairport_sync_remote_control_get_stream_type(shairportSyncRemoteControlSkeleton);
Expand Down
11 changes: 10 additions & 1 deletion metadata_hub.c
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,16 @@ void metadata_hub_process_metadata(uint32_t type, uint32_t code, char *data, uin
if (string_update(&metadata_store.frame_position_string,
&metadata_store.frame_position_string_changed, cs)) {
changed = 1;
debug(2, "MH Frame Position String set to: \"%s\"", metadata_store.progress_string);
debug(2, "MH Frame Position String set to: \"%s\"", metadata_store.frame_position_string);
}
free(cs);
break;
case 'phb0':
cs = strndup(data, length);
if (string_update(&metadata_store.first_frame_position_string,
&metadata_store.first_frame_position_string_changed, cs)) {
changed = 1;
debug(2, "MH First Frame Position String set to: \"%s\"", metadata_store.first_frame_position_string);
}
free(cs);
break;
Expand Down
3 changes: 3 additions & 0 deletions metadata_hub.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ typedef struct metadata_bundle {
char *frame_position_string; // frame position string emitted by SPS on request
int frame_position_string_changed;

char *first_frame_position_string; // first frame position string emitted by SPS on request
int first_frame_position_string_changed;

int player_thread_active; // true if a play thread is running
int dacp_server_active; // true if there's a reachable DACP server (assumed to be the Airplay
// client) ; false otherwise
Expand Down
1 change: 1 addition & 0 deletions org.gnome.ShairportSync.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
<property name="ServiceName" type="s" access="read" />
<property name="OutputFormat" type="s" access="read" />
<property name="OutputRate" type="i" access="read" />
<property name="FirstFramePosition" type="s" access="read" />
<property name="FramePosition" type="s" access="read" />
<method name="SetFramePositionUpdateInterval">
<arg name="seconds" type="d" direction="in" />
Expand Down
2 changes: 2 additions & 0 deletions player.c
Original file line number Diff line number Diff line change
Expand Up @@ -3056,6 +3056,7 @@ void *player_thread_func(void *arg) {
memset(hb, 0, 128);
snprintf(hb, 127, "%" PRIu32 "/%" PRId64 "", inframe->given_timestamp,
should_be_time);
send_ssnc_metadata('phb0', hb, strlen(hb), 1);
send_ssnc_metadata('phbt', hb, strlen(hb), 1);
time_of_last_metadata_progress_update = local_time_now;
} else {
Expand Down Expand Up @@ -3131,6 +3132,7 @@ void *player_thread_func(void *arg) {
memset(hb, 0, 128);
snprintf(hb, 127, "%" PRIu32 "/%" PRId64 "", inframe->given_timestamp,
should_be_time);
send_ssnc_metadata('phb0', hb, strlen(hb), 1);
send_ssnc_metadata('phbt', hb, strlen(hb), 1);
time_of_last_metadata_progress_update = local_time_now;
} else {
Expand Down

0 comments on commit 37f060f

Please sign in to comment.