Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef __XMMS_VIS_COMMON_H__
00023 #define __XMMS_VIS_COMMON_H__
00024
00025
00026
00027 #define XMMSC_VISUALIZATION_WINDOW_SIZE 512
00028
00029 #ifdef __cplusplus
00030 extern "C" {
00031 #endif
00032
00033 #include <sys/time.h>
00034
00035 #include "xmmsc/xmmsc_stdint.h"
00036 #include "xmmsc/xmmsc_sockets.h"
00037
00038 double tv2ts (struct timeval *t);
00039 double net2ts (int32_t* s);
00040 void ts2net (int32_t* d, double t);
00041 void tv2net (int32_t* d, struct timeval *t);
00042
00043
00044
00045
00046
00047 #define XMMS_VISPACKET_VERSION 1
00048
00049
00050
00051
00052
00053
00054 #define XMMS_VISPACKET_SHMCOUNT 500
00055
00056
00057
00058
00059
00060 typedef struct {
00061 int32_t timestamp[2];
00062 uint16_t format;
00063 uint16_t size;
00064 int16_t data[2 * XMMSC_VISUALIZATION_WINDOW_SIZE];
00065 } xmmsc_vischunk_t;
00066
00067
00068
00069
00070
00071 typedef struct {
00072 char *__unaligned_type; ;
00073 uint16_t *__unaligned_grace;
00074 xmmsc_vischunk_t *__unaligned_data;
00075 int size;
00076 } xmmsc_vis_udp_data_t;
00077
00078 #define XMMSC_VIS_UNALIGNED_WRITE(dst, src, typ) do { \
00079 typ *__d = (dst); \
00080 typ __s = (src); \
00081 memcpy (__d, &__s, sizeof (typ)); \
00082 } while (0)
00083
00084 #define XMMSC_VIS_UNALIGNED_READ(dst, src, typ) do { \
00085 typ *__s = (src); \
00086 memcpy (&(dst), __s, sizeof (typ)); \
00087 } while (0)
00088
00089
00090
00091 #define XMMS_VISPACKET_UDP_OFFSET (1 + sizeof (uint16_t))
00092
00093
00094
00095
00096
00097 typedef struct {
00098 char *__unaligned_type;
00099 int32_t *__unaligned_id;
00100 int32_t *__unaligned_clientstamp;
00101 int32_t *__unaligned_serverstamp;
00102 int size;
00103 } xmmsc_vis_udp_timing_t;
00104
00105 char* packet_init_data (xmmsc_vis_udp_data_t *p);
00106 char* packet_init_timing (xmmsc_vis_udp_timing_t *p);
00107
00108
00109
00110
00111
00112 typedef enum {
00113 VIS_PCM,
00114 VIS_SPECTRUM,
00115 VIS_PEAK
00116 } xmmsc_vis_data_t;
00117
00118
00119
00120
00121
00122
00123 typedef struct {
00124
00125 xmmsc_vis_data_t type;
00126
00127 int stereo;
00128
00129 int pcm_hardwire;
00130
00131
00132 double freq;
00133 double timeframe;
00134
00135 int pcm_samplecount;
00136
00137
00138 } xmmsc_vis_properties_t;
00139
00140
00141
00142
00143
00144 typedef enum {
00145 VIS_UNIXSHM,
00146 VIS_UDP,
00147 VIS_NONE
00148 } xmmsc_vis_transport_t;
00149
00150 typedef enum {
00151 VIS_NEW,
00152 VIS_TRYING_UNIXSHM,
00153 VIS_TO_TRY_UDP,
00154 VIS_TRYING_UDP,
00155 VIS_ERRORED,
00156 VIS_WORKING,
00157 } xmmsc_vis_state_t;
00158
00159
00160
00161
00162
00163 typedef struct {
00164 int semid;
00165 int shmid;
00166 xmmsc_vischunk_t *buffer;
00167 int pos, size;
00168 } xmmsc_vis_unixshm_t;
00169
00170
00171
00172
00173
00174 typedef struct {
00175
00176 struct sockaddr_storage addr;
00177
00178 xmms_socket_t socket[2];
00179
00180 double timediff;
00181
00182 int grace;
00183 } xmmsc_vis_udp_t;
00184
00185 #ifdef __cplusplus
00186 }
00187 #endif
00188
00189 #endif
00190
00191