[airplay] Separate naming of AirPlay 1 and 2, incl log domains

This commit is contained in:
ejurgensen
2021-01-04 00:05:04 +01:00
parent f16dc204b2
commit ef0f41dc46
13 changed files with 752 additions and 680 deletions

View File

@@ -34,11 +34,15 @@
#include <stdint.h>
#include <stdio.h>
#include <stdarg.h>
#include <inttypes.h>
#include <limits.h>
#include <sys/param.h>
#ifndef CLOCK_REALTIME
#include <sys/time.h>
#endif
#ifdef HAVE_UUID
#include <uuid/uuid.h>
#endif
#include <unistr.h>
#include <uniconv.h>
@@ -1011,6 +1015,46 @@ murmur_hash64(const void *key, int len, uint32_t seed)
# error Platform not supported
#endif
#ifdef HAVE_UUID
void
uuid_make(char *str)
{
uuid_t uu;
uuid_generate_random(uu);
uuid_unparse_upper(uu, str);
}
#else
void
uuid_make(char *str)
{
uint16_t uuid[8];
time_t now;
int i;
now = time(NULL);
srand((unsigned int)now);
for (i = 0; i < ARRAY_SIZE(uuid); i++)
{
uuid[i] = (uint16_t)rand();
// time_hi_and_version, set version to 4 (=random)
if (i == 3)
uuid[i] = (uuid[i] & 0x0FFF) | 0x4000;
// clock_seq, variant 1
if (i == 4)
uuid[i] = (uuid[i] & 0x3FFF) | 0x8000;
if (i == 2 || i == 3 || i == 4 || i == 5)
str += sprintf(str, "-");
str += sprintf(str, "%04" PRIX16, uuid[i]);
}
}
#endif
int
linear_regression(double *m, double *b, double *r2, const double *x, const double *y, int n)