Skip to content

Commit

Permalink
Reordering struct members to have char arrays at the end
Browse files Browse the repository at this point in the history
Allowing for 10 times MAX_OUTPUT_LENGTH for actual output
  • Loading branch information
mariusor committed Apr 20, 2020
1 parent b07e88a commit 054fc1d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,8 @@ void print_mpris_info(mpris_properties *props, const char* format)
char length_label[15];
snprintf(length_label, 15, "%.2lfs", (props->metadata.length / 1000000.0));

char output[MAX_OUTPUT_LENGTH];
memcpy(&output, format, MAX_OUTPUT_LENGTH - 1);
char output[MAX_OUTPUT_LENGTH*10];
memcpy(output, format, strlen(format) + 1);

str_replace(output, "\\n", "\n");
str_replace(output, "\\t", "\t");
Expand Down
16 changes: 8 additions & 8 deletions src/sdbus.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@
#define MAX_PLAYERS 20

typedef struct mpris_metadata {
uint64_t length; // mpris specific
unsigned short track_number;
unsigned short bitrate;
unsigned short disc_number;
char album_artist[MAX_OUTPUT_LENGTH];
char composer[MAX_OUTPUT_LENGTH];
char genre[MAX_OUTPUT_LENGTH];
Expand All @@ -76,27 +80,23 @@ typedef struct mpris_metadata {
char title[MAX_OUTPUT_LENGTH];
char url[MAX_OUTPUT_LENGTH];
char art_url[MAX_OUTPUT_LENGTH]; //mpris specific
uint64_t length; // mpris specific
unsigned short track_number;
unsigned short bitrate;
unsigned short disc_number;

} mpris_metadata;

typedef struct mpris_properties {
mpris_metadata metadata;
double volume;
uint64_t position;
char player_name[MAX_OUTPUT_LENGTH];
char loop_status[MAX_OUTPUT_LENGTH];
char playback_status[MAX_OUTPUT_LENGTH];
bool can_control;
bool can_go_next;
bool can_go_previous;
bool can_play;
bool can_pause;
bool can_seek;
bool shuffle;
char player_name[MAX_OUTPUT_LENGTH];
char loop_status[MAX_OUTPUT_LENGTH];
char playback_status[MAX_OUTPUT_LENGTH];
mpris_metadata metadata;
} mpris_properties;

typedef struct mpris_player {
Expand Down

0 comments on commit 054fc1d

Please sign in to comment.