XMMS2
common.h
Go to the documentation of this file.
1 /* XMMS2 - X Music Multiplexer System
2  * Copyright (C) 2003-2011 XMMS2 Team
3  *
4  * PLUGINS ARE NOT CONSIDERED TO BE DERIVED WORK !!!
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  */
16 
17 #ifndef __VISUALIZATION_COMMON_H__
18 #define __VISUALIZATION_COMMON_H__
19 
20 #include <glib.h>
21 
22 #include "xmmspriv/xmms_log.h"
25 
26 /**
27  * The structures for a vis client
28  */
29 
30 typedef struct {
31  union {
34  } transport;
36  unsigned short format;
39 
40 /* provided by object.c */
41 xmms_vis_client_t *get_client (int32_t id);
42 void delete_client (int32_t id);
43 void send_data (int channels, int size, int16_t *buf);
44 
45 /* provided by unixshm.c / dummy.c */
46 int32_t init_shm (xmms_visualization_t *vis, int32_t id, int32_t shmid, xmms_error_t *err);
48 gboolean write_start_shm (int32_t id, xmmsc_vis_unixshm_t *t, xmmsc_vischunk_t **dest);
49 void write_finish_shm (int32_t id, xmmsc_vis_unixshm_t *t, xmmsc_vischunk_t *dest);
50 
51 gboolean write_shm (xmmsc_vis_unixshm_t *t, xmms_vis_client_t *c, int32_t id, struct timeval *time, int channels, int size, short *buf);
52 
53 /* provided by udp.c */
54 int32_t init_udp (xmms_visualization_t *vis, int32_t id, xmms_error_t *err);
55 void cleanup_udp (xmmsc_vis_udp_t *t, xmms_socket_t socket);
56 gboolean write_udp (xmmsc_vis_udp_t *t, xmms_vis_client_t *c, int32_t id, struct timeval *time, int channels, int size, short *buf, int socket);
57 
58 /* provided by format.c */
59 void fft_init (void);
60 short fill_buffer (int16_t *dest, xmmsc_vis_properties_t* prop, int channels, int size, short *src);
61 
62 /* never call a fetch without a guaranteed release following! */
63 #define x_fetch_client(id) \
64  g_mutex_lock (vis->clientlock); \
65  c = get_client (id); \
66  if (!c) { \
67  xmms_error_set (err, XMMS_ERROR_INVAL, "invalid server-side identifier provided"); \
68  g_mutex_unlock (vis->clientlock); \
69  return -1; \
70  }
71 #define x_release_client() \
72  g_mutex_unlock (vis->clientlock);
73 
74 /**
75  * The structures for the vis module
76  */
77 
82  GIOChannel *socketio;
83 
84  GMutex *clientlock;
85  int32_t clientc;
87 };
88 
89 #endif