diff --git a/DigestPlay.c b/DigestPlay.c index 44df47c..740603e 100644 --- a/DigestPlay.c +++ b/DigestPlay.c @@ -18,6 +18,8 @@ #define DSD_MAGIC_SIZE 4 #define DSD_AMBE_CHUNK_SIZE 8 +#define LINEAR_FRAME_SIZE 7 + #define HELPER(value) #value #define STRING(value) HELPER(value) @@ -190,6 +192,8 @@ int main(int argc, char* argv[]) // Wait for timer event (60 milliseconds) while (read(handle, &mark, sizeof(uint64_t)) > 0) { + // Read AMBE chunks of DSD format + ssize_t length1 = read(STDIN_FILENO, buffer + 0 * DSD_AMBE_CHUNK_SIZE, DSD_AMBE_CHUNK_SIZE); ssize_t length2 = read(STDIN_FILENO, buffer + 1 * DSD_AMBE_CHUNK_SIZE, DSD_AMBE_CHUNK_SIZE); ssize_t length3 = read(STDIN_FILENO, buffer + 2 * DSD_AMBE_CHUNK_SIZE, DSD_AMBE_CHUNK_SIZE); @@ -202,11 +206,19 @@ int main(int argc, char* argv[]) break; } + // Convert to linear format + buffer[0 * DSD_AMBE_CHUNK_SIZE + 7] <<= 7; buffer[1 * DSD_AMBE_CHUNK_SIZE + 7] <<= 7; buffer[2 * DSD_AMBE_CHUNK_SIZE + 7] <<= 7; - TransmitRewindData(context, REWIND_TYPE_DMR_AUDIO_FRAME, REWIND_FLAG_REAL_TIME_1, buffer, 3 * DSD_AMBE_CHUNK_SIZE); + memmove(buffer + 0 * LINEAR_FRAME_SIZE, buffer + 0 * DSD_AMBE_CHUNK_SIZE + 1, LINEAR_FRAME_SIZE); + memmove(buffer + 1 * LINEAR_FRAME_SIZE, buffer + 1 * DSD_AMBE_CHUNK_SIZE + 1, LINEAR_FRAME_SIZE); + memmove(buffer + 2 * LINEAR_FRAME_SIZE, buffer + 2 * DSD_AMBE_CHUNK_SIZE + 1, LINEAR_FRAME_SIZE); + + // Transmit DMR linear frame + + TransmitRewindData(context, REWIND_TYPE_DMR_AUDIO_FRAME, REWIND_FLAG_REAL_TIME_1, buffer, 3 * LINEAR_FRAME_SIZE); if ((count % 83) == 0) {