comparison src/sndfile/plugin.c @ 2550:6fdb69f0f169

Use Glib types.
author Matti Hamalainen <ccr@tnsp.org>
date Thu, 08 May 2008 21:54:55 +0300
parents f6efe94f2793
children 92300fe06f15
comparison
equal deleted inserted replaced
2549:f6efe94f2793 2550:6fdb69f0f169
43 #include <sndfile.h> 43 #include <sndfile.h>
44 44
45 static SNDFILE *sndfile = NULL; 45 static SNDFILE *sndfile = NULL;
46 static SF_INFO sfinfo; 46 static SF_INFO sfinfo;
47 47
48 static int song_length; 48 static gint song_length;
49 static int bit_rate = 0; 49 static gint bit_rate = 0;
50 static glong seek_time = -1; 50 static glong seek_time = -1;
51 51
52 static GThread *decode_thread; 52 static GThread *decode_thread;
53 static GMutex *decode_mutex; 53 static GMutex *decode_mutex;
54 static GCond *decode_cond; 54 static GCond *decode_cond;
125 g_cond_free(decode_cond); 125 g_cond_free(decode_cond);
126 g_mutex_free(decode_mutex); 126 g_mutex_free(decode_mutex);
127 } 127 }
128 128
129 static void 129 static void
130 fill_song_tuple (char *filename, Tuple *ti) 130 fill_song_tuple (gchar *filename, Tuple *ti)
131 { 131 {
132 VFSFile *vfsfile = NULL; 132 VFSFile *vfsfile = NULL;
133 SNDFILE *tmp_sndfile; 133 SNDFILE *tmp_sndfile;
134 SF_INFO tmp_sfinfo; 134 SF_INFO tmp_sfinfo;
135 unsigned int lossy = 0; 135 guint lossy = 0;
136 gchar *codec = NULL, *format, *subformat = NULL; 136 gchar *codec = NULL, *format, *subformat = NULL;
137 GString *codec_gs = NULL; 137 GString *codec_gs = NULL;
138 138
139 tmp_sndfile = open_sndfile_from_uri(filename, vfsfile, &tmp_sfinfo); 139 tmp_sndfile = open_sndfile_from_uri(filename, vfsfile, &tmp_sfinfo);
140 if ( sf_get_string(tmp_sndfile, SF_STR_TITLE) == NULL) 140 if ( sf_get_string(tmp_sndfile, SF_STR_TITLE) == NULL)
317 aud_tuple_associate_string(ti, FIELD_QUALITY, NULL, "lossy"); 317 aud_tuple_associate_string(ti, FIELD_QUALITY, NULL, "lossy");
318 else 318 else
319 aud_tuple_associate_string(ti, FIELD_QUALITY, NULL, "lossless"); 319 aud_tuple_associate_string(ti, FIELD_QUALITY, NULL, "lossless");
320 } 320 }
321 321
322 static gchar *get_title(char *filename) 322 static gchar *get_title(gchar *filename)
323 { 323 {
324 Tuple *tuple; 324 Tuple *tuple;
325 gchar *title; 325 gchar *title;
326 326
327 tuple = aud_tuple_new_from_filename(filename); 327 tuple = aud_tuple_new_from_filename(filename);
335 335
336 aud_tuple_free(tuple); 336 aud_tuple_free(tuple);
337 return title; 337 return title;
338 } 338 }
339 339
340 static int 340 static gint
341 is_our_file (char *filename) 341 is_our_file (gchar *filename)
342 { 342 {
343 VFSFile *vfsfile = NULL; 343 VFSFile *vfsfile = NULL;
344 SNDFILE *tmp_sndfile; 344 SNDFILE *tmp_sndfile;
345 SF_INFO tmp_sfinfo; 345 SF_INFO tmp_sfinfo;
346 346
359 } 359 }
360 360
361 static gpointer 361 static gpointer
362 play_loop (gpointer arg) 362 play_loop (gpointer arg)
363 { 363 {
364 static short buffer [BUFFER_SIZE]; 364 static gshort buffer[BUFFER_SIZE];
365 int samples; 365 gint samples;
366 InputPlayback *playback = arg; 366 InputPlayback *playback = arg;
367 367
368 for (;;) 368 for (;;)
369 { 369 {
370 GTimeVal sleeptime; 370 GTimeVal sleeptime;
430 430
431 static void 431 static void
432 play_start (InputPlayback *playback) 432 play_start (InputPlayback *playback)
433 { 433 {
434 VFSFile *vfsfile = NULL; 434 VFSFile *vfsfile = NULL;
435 int pcmbitwidth; 435 gint pcmbitwidth;
436 gchar *song_title; 436 gchar *song_title;
437 437
438 if (sndfile) /* already opened */ 438 if (sndfile) /* already opened */
439 return; 439 return;
440 440
519 Tuple *ti = aud_tuple_new_from_filename(filename); 519 Tuple *ti = aud_tuple_new_from_filename(filename);
520 fill_song_tuple(filename, ti); 520 fill_song_tuple(filename, ti);
521 return ti; 521 return ti;
522 } 522 }
523 523
524 static int is_our_file_from_vfs(char *filename, VFSFile *fin) 524 static gint is_our_file_from_vfs(gchar *filename, VFSFile *fin)
525 { 525 {
526 SNDFILE *tmp_sndfile; 526 SNDFILE *tmp_sndfile;
527 SF_INFO tmp_sfinfo; 527 SF_INFO tmp_sfinfo;
528 528
529 /* Have to open the file to see if libsndfile can handle it. */ 529 /* Have to open the file to see if libsndfile can handle it. */