comparison src/icecast/icecast.c @ 2909:639241e725e2

fixed mod_samples when shout==NULL
author Andrew O. Shadoura <bugzilla@tut.by>
date Wed, 13 Aug 2008 21:56:39 +0300
parents 8220728cc77b
children 6c40707ce9d5
comparison
equal deleted inserted replaced
2908:43115ea335b9 2909:639241e725e2
164 } 164 }
165 165
166 static void ice_init(void) 166 static void ice_init(void)
167 { 167 {
168 ConfigDb *db; 168 ConfigDb *db;
169 /*g_debug("ICE_INIT");*/ 169 g_debug("ICE_INIT");
170 if (initialized==TRUE) return; 170 if (initialized==TRUE) return;
171 shout_init(); 171 shout_init();
172 g_message("Using libshout %s", shout_version(NULL, NULL, NULL)); 172 g_message("Using libshout %s", shout_version(NULL, NULL, NULL));
173 173
174 db = aud_cfg_db_open(); 174 db = aud_cfg_db_open();
385 385
386 convert_init(fmt, plugin.format_required, nch); 386 convert_init(fmt, plugin.format_required, nch);
387 387
388 rv = (plugin.open)(); 388 rv = (plugin.open)();
389 389
390 /*g_debug("ICE_OPEN");*/ 390 g_debug("ICE_OPEN");
391 return rv; 391 return rv;
392 } 392 }
393 393
394 static void ice_write(void *ptr, gint length) 394 static void ice_write(void *ptr, gint length)
395 { 395 {
405 if (ice_tid) 405 if (ice_tid)
406 g_source_remove(ice_tid); 406 g_source_remove(ice_tid);
407 407
408 if (!shout) 408 if (!shout)
409 { 409 {
410 if (ice_open(afmt, srate, nch)) 410 ice_open(afmt, srate, nch);
411 { 411 }
412 if (shout) 412 if (shout)
413 { 413 {
414 int len; 414 int len;
415 ep_playing = TRUE; 415 ep_playing = TRUE;
416 len = convert_process(d, length); 416 len = convert_process(d, length);
417 plugin.write(convert_output, length); 417 plugin.write(convert_output, length);
418 ice_tid = g_timeout_add_seconds(ice_close_timeout, ice_real_close, NULL); 418 ice_tid = g_timeout_add_seconds(ice_close_timeout, ice_real_close, NULL);
419 }
420 }
421 } 419 }
422 return length; 420 return length;
423 } 421 }
424 422
425 static gint ice_real_write(void* ptr, gint length) 423 static gint ice_real_write(void* ptr, gint length)
426 { 424 {
427 gint ret; 425 gint ret;
428 if (!length) return length; 426 if (!length) return length;
429 ret = shout_send(shout, ptr, length); 427 ret = shout_send(shout, ptr, length);
430 shout_sync(shout); 428 shout_sync(shout);
431 /*g_debug("ice_write[%d:%d]", ret, length);*/ 429 g_debug("ice_write[%d:%d]", ret, length);
432 return 0; 430 return 0;
433 } 431 }
434 432
435 static gint ice_write_output(void *ptr, gint length) 433 static gint ice_write_output(void *ptr, gint length)
436 { 434 {
467 written = 0; 465 written = 0;
468 shout_close(shout); 466 shout_close(shout);
469 } 467 }
470 shout = NULL; 468 shout = NULL;
471 ice_tid = 0; 469 ice_tid = 0;
472 /*g_debug("ICE_REAL_CLOSE");*/ 470 g_debug("ICE_REAL_CLOSE");
473 return FALSE; 471 return FALSE;
474 } 472 }
475 473
476 474
477 static void ice_close(void) 475 static void ice_close(void)
478 { 476 {
479 if (ice_tid) 477 if (ice_tid)
480 g_source_remove(ice_tid); 478 g_source_remove(ice_tid);
481 ice_tid = g_timeout_add_seconds(ice_close_timeout, ice_real_close, NULL); 479 ice_tid = g_timeout_add_seconds(ice_close_timeout, ice_real_close, NULL);
482 /*g_debug("ICE_CLOSE: starting timer");*/ 480 g_debug("ICE_CLOSE: starting timer");
483 } 481 }
484 482
485 static void ice_flush(gint time) 483 static void ice_flush(gint time)
486 { 484 {
487 if (time < 0) 485 if (time < 0)