comparison src/xmms-sid.c @ 798:4c5b695fd85e

Rename variables.
author Matti Hamalainen <ccr@tnsp.org>
date Wed, 07 Nov 2012 11:24:29 +0200
parents 02512cbc6d9f
children 13483b855058
comparison
equal deleted inserted replaced
797:02512cbc6d9f 798:4c5b695fd85e
126 gint engine; 126 gint engine;
127 gboolean initialized = FALSE; 127 gboolean initialized = FALSE;
128 128
129 /* Stop playing, if we are */ 129 /* Stop playing, if we are */
130 XS_MUTEX_LOCK(xs_status); 130 XS_MUTEX_LOCK(xs_status);
131 if (xs_status.isPlaying) 131 if (xs_status.playing)
132 { 132 {
133 XS_MUTEX_UNLOCK(xs_status); 133 XS_MUTEX_UNLOCK(xs_status);
134 xs_stop(); 134 xs_stop();
135 } 135 }
136 else 136 else
319 /* 319 /*
320 * Main player loop: while not stopped, loop here - play subtunes 320 * Main player loop: while not stopped, loop here - play subtunes
321 */ 321 */
322 audioOpen = FALSE; 322 audioOpen = FALSE;
323 doPlay = TRUE; 323 doPlay = TRUE;
324 while (xs_status.isPlaying && doPlay) 324 while (xs_status.playing && doPlay)
325 { 325 {
326 /* Automatic sub-tune change logic */ 326 /* Automatic sub-tune change logic */
327 XS_MUTEX_LOCK(xs_cfg); 327 XS_MUTEX_LOCK(xs_cfg);
328 XS_MUTEX_LOCK(xs_status); 328 XS_MUTEX_LOCK(xs_status);
329 myStatus.isPlaying = TRUE; 329 myStatus.playing = TRUE;
330 330
331 if (xs_status.currSong < 1 || myStatus.currSong < 1) 331 if (xs_status.currSong < 1 || myStatus.currSong < 1)
332 { 332 {
333 XS_MUTEX_UNLOCK(xs_status); 333 XS_MUTEX_UNLOCK(xs_status);
334 XS_MUTEX_UNLOCK(xs_cfg); 334 XS_MUTEX_UNLOCK(xs_cfg);
415 myStatus.audioFormat, 415 myStatus.audioFormat,
416 myStatus.audioFrequency, 416 myStatus.audioFrequency,
417 myStatus.audioChannels); 417 myStatus.audioChannels);
418 418
419 XS_MUTEX_LOCK(xs_status); 419 XS_MUTEX_LOCK(xs_status);
420 xs_status.isError = TRUE; 420 xs_status.error = TRUE;
421 XS_MUTEX_UNLOCK(xs_status); 421 XS_MUTEX_UNLOCK(xs_status);
422 goto xs_err_exit; 422 goto xs_err_exit;
423 } 423 }
424 424
425 audioOpen = TRUE; 425 audioOpen = TRUE;
441 XSDEBUG("playing\n"); 441 XSDEBUG("playing\n");
442 442
443 /* 443 /*
444 * Play the subtune 444 * Play the subtune
445 */ 445 */
446 while (xs_status.isPlaying && myStatus.isPlaying && (xs_status.currSong == myStatus.currSong)) 446 while (xs_status.playing && myStatus.playing && (xs_status.currSong == myStatus.currSong))
447 { 447 {
448 audioGot = myStatus.engine->plrFillBuffer( 448 audioGot = myStatus.engine->plrFillBuffer(
449 &myStatus, audioBuffer, XS_AUDIOBUF_SIZE); 449 &myStatus, audioBuffer, XS_AUDIOBUF_SIZE);
450 450
451 /* I <3 visualice/haujobb */ 451 /* I <3 visualice/haujobb */
453 xs_plugin_ip.output->written_time(), 453 xs_plugin_ip.output->written_time(),
454 myStatus.audioFormat, myStatus.audioChannels, 454 myStatus.audioFormat, myStatus.audioChannels,
455 audioGot, audioBuffer); 455 audioGot, audioBuffer);
456 456
457 /* Wait a little */ 457 /* Wait a little */
458 while (xs_status.isPlaying && 458 while (xs_status.playing &&
459 (xs_status.currSong == myStatus.currSong) && 459 (xs_status.currSong == myStatus.currSong) &&
460 (xs_plugin_ip.output->buffer_free() < audioGot)) 460 (xs_plugin_ip.output->buffer_free() < audioGot))
461 xmms_usleep(500); 461 xmms_usleep(500);
462 462
463 /* Output audio */ 463 /* Output audio */
464 if (xs_status.isPlaying && xs_status.currSong == myStatus.currSong) 464 if (xs_status.playing && xs_status.currSong == myStatus.currSong)
465 xs_plugin_ip.output->write_audio(audioBuffer, audioGot); 465 xs_plugin_ip.output->write_audio(audioBuffer, audioGot);
466 466
467 /* Check if we have played enough */ 467 /* Check if we have played enough */
468 if (xs_cfg.playMaxTimeEnable) 468 if (xs_cfg.playMaxTimeEnable)
469 { 469 {
470 if (xs_cfg.playMaxTimeUnknown) 470 if (xs_cfg.playMaxTimeUnknown)
471 { 471 {
472 if (songLength < 0 && 472 if (songLength < 0 &&
473 xs_plugin_ip.output->output_time() >= xs_cfg.playMaxTime * 1000) 473 xs_plugin_ip.output->output_time() >= xs_cfg.playMaxTime * 1000)
474 myStatus.isPlaying = FALSE; 474 myStatus.playing = FALSE;
475 } 475 }
476 else 476 else
477 { 477 {
478 if (xs_plugin_ip.output->output_time() >= xs_cfg.playMaxTime * 1000) 478 if (xs_plugin_ip.output->output_time() >= xs_cfg.playMaxTime * 1000)
479 myStatus.isPlaying = FALSE; 479 myStatus.playing = FALSE;
480 } 480 }
481 } 481 }
482 482
483 if (songLength >= 0) 483 if (songLength >= 0)
484 { 484 {
485 if (xs_plugin_ip.output->output_time() >= songLength * 1000) 485 if (xs_plugin_ip.output->output_time() >= songLength * 1000)
486 myStatus.isPlaying = FALSE; 486 myStatus.playing = FALSE;
487 } 487 }
488 } 488 }
489 489
490 XSDEBUG("subtune ended/stopped\n"); 490 XSDEBUG("subtune ended/stopped\n");
491 491
497 audioOpen = FALSE; 497 audioOpen = FALSE;
498 XSDEBUG("closed\n"); 498 XSDEBUG("closed\n");
499 } 499 }
500 500
501 /* Now determine if we continue by selecting other subtune or something */ 501 /* Now determine if we continue by selecting other subtune or something */
502 if (!myStatus.isPlaying && !xs_cfg.subAutoEnable) 502 if (!myStatus.playing && !xs_cfg.subAutoEnable)
503 doPlay = FALSE; 503 doPlay = FALSE;
504 } 504 }
505 505
506 xs_err_exit: 506 xs_err_exit:
507 XSDEBUG("out of playing loop\n"); 507 XSDEBUG("out of playing loop\n");
520 * XMMS next calls xs_get_time(), it can return appropriate 520 * XMMS next calls xs_get_time(), it can return appropriate
521 * value "not playing" status and XMMS knows to move to 521 * value "not playing" status and XMMS knows to move to
522 * next entry in the playlist .. or whatever it wishes. 522 * next entry in the playlist .. or whatever it wishes.
523 */ 523 */
524 XS_MUTEX_LOCK(xs_status); 524 XS_MUTEX_LOCK(xs_status);
525 xs_status.isPlaying = FALSE; 525 xs_status.playing = FALSE;
526 XS_MUTEX_UNLOCK(xs_status); 526 XS_MUTEX_UNLOCK(xs_status);
527 527
528 /* Exit the playing thread */ 528 /* Exit the playing thread */
529 XSDEBUG("exiting thread, bye.\n"); 529 XSDEBUG("exiting thread, bye.\n");
530 XS_THREAD_EXIT(NULL); 530 XS_THREAD_EXIT(NULL);
557 } 557 }
558 558
559 XSDEBUG("load ok\n"); 559 XSDEBUG("load ok\n");
560 560
561 /* Set general status information */ 561 /* Set general status information */
562 xs_status.isPlaying = TRUE; 562 xs_status.playing = TRUE;
563 xs_status.isError = FALSE; 563 xs_status.error = FALSE;
564 xs_status.currSong = xs_status.tuneInfo->startTune; 564 xs_status.currSong = xs_status.tuneInfo->startTune;
565 565
566 /* Start the playing thread! */ 566 /* Start the playing thread! */
567 if (pthread_create(&xs_decode_thread, NULL, xs_playthread, NULL) < 0) 567 if (pthread_create(&xs_decode_thread, NULL, xs_playthread, NULL) < 0)
568 { 568 {
597 /* Close the sub-tune control window, if any */ 597 /* Close the sub-tune control window, if any */
598 xs_subctrl_close(); 598 xs_subctrl_close();
599 599
600 /* Lock xs_status and stop playing thread */ 600 /* Lock xs_status and stop playing thread */
601 XS_MUTEX_LOCK(xs_status); 601 XS_MUTEX_LOCK(xs_status);
602 if (xs_status.isPlaying) 602 if (xs_status.playing)
603 { 603 {
604 XSDEBUG("stopping...\n"); 604 XSDEBUG("stopping...\n");
605 xs_status.isPlaying = FALSE; 605 xs_status.playing = FALSE;
606 XS_MUTEX_UNLOCK(xs_status); 606 XS_MUTEX_UNLOCK(xs_status);
607 XS_THREAD_JOIN(xs_decode_thread); 607 XS_THREAD_JOIN(xs_decode_thread);
608 } 608 }
609 else 609 else
610 { 610 {
653 gint n; 653 gint n;
654 654
655 XS_MUTEX_LOCK(xs_status); 655 XS_MUTEX_LOCK(xs_status);
656 XS_MUTEX_LOCK(xs_subctrl); 656 XS_MUTEX_LOCK(xs_subctrl);
657 657
658 if (xs_status.tuneInfo && xs_status.isPlaying) 658 if (xs_status.tuneInfo && xs_status.playing)
659 { 659 {
660 n = (gint) GTK_ADJUSTMENT(xs_subctrl_adj)->value; 660 n = (gint) GTK_ADJUSTMENT(xs_subctrl_adj)->value;
661 if (n >= 1 && n <= xs_status.tuneInfo->nsubTunes) 661 if (n >= 1 && n <= xs_status.tuneInfo->nsubTunes)
662 xs_status.currSong = n; 662 xs_status.currSong = n;
663 } 663 }
669 669
670 void xs_subctrl_prevsong(void) 670 void xs_subctrl_prevsong(void)
671 { 671 {
672 XS_MUTEX_LOCK(xs_status); 672 XS_MUTEX_LOCK(xs_status);
673 673
674 if (xs_status.tuneInfo && xs_status.isPlaying) 674 if (xs_status.tuneInfo && xs_status.playing)
675 { 675 {
676 if (xs_status.currSong > 1) 676 if (xs_status.currSong > 1)
677 xs_status.currSong--; 677 xs_status.currSong--;
678 } 678 }
679 679
685 685
686 void xs_subctrl_nextsong(void) 686 void xs_subctrl_nextsong(void)
687 { 687 {
688 XS_MUTEX_LOCK(xs_status); 688 XS_MUTEX_LOCK(xs_status);
689 689
690 if (xs_status.tuneInfo && xs_status.isPlaying) 690 if (xs_status.tuneInfo && xs_status.playing)
691 { 691 {
692 if (xs_status.currSong < xs_status.tuneInfo->nsubTunes) 692 if (xs_status.currSong < xs_status.tuneInfo->nsubTunes)
693 xs_status.currSong++; 693 xs_status.currSong++;
694 } 694 }
695 695
707 XS_MUTEX_LOCK(xs_subctrl); 707 XS_MUTEX_LOCK(xs_subctrl);
708 708
709 /* Check if control window exists, we are currently playing and have a tune */ 709 /* Check if control window exists, we are currently playing and have a tune */
710 if (xs_subctrl) 710 if (xs_subctrl)
711 { 711 {
712 if (xs_status.tuneInfo && xs_status.isPlaying) 712 if (xs_status.tuneInfo && xs_status.playing)
713 { 713 {
714 tmpAdj = GTK_ADJUSTMENT(xs_subctrl_adj); 714 tmpAdj = GTK_ADJUSTMENT(xs_subctrl_adj);
715 715
716 tmpAdj->value = xs_status.currSong; 716 tmpAdj->value = xs_status.currSong;
717 tmpAdj->lower = 1; 717 tmpAdj->lower = 1;
766 { 766 {
767 GtkWidget *frame25, *hbox15, *subctrl_prev, *subctrl_current, *subctrl_next; 767 GtkWidget *frame25, *hbox15, *subctrl_prev, *subctrl_current, *subctrl_next;
768 768
769 XS_MUTEX_LOCK(xs_subctrl); 769 XS_MUTEX_LOCK(xs_subctrl);
770 770
771 if (!xs_status.tuneInfo || !xs_status.isPlaying || 771 if (!xs_status.tuneInfo || !xs_status.playing ||
772 xs_subctrl || xs_status.tuneInfo->nsubTunes <= 1) 772 xs_subctrl || xs_status.tuneInfo->nsubTunes <= 1)
773 goto out; 773 goto out;
774 774
775 /* Create the pop-up window */ 775 /* Create the pop-up window */
776 xs_subctrl = gtk_window_new(GTK_WINDOW_DIALOG); 776 xs_subctrl = gtk_window_new(GTK_WINDOW_DIALOG);
837 * other method of seeking is used (keyboard, etc.) 837 * other method of seeking is used (keyboard, etc.)
838 */ 838 */
839 void xs_seek(gint time) 839 void xs_seek(gint time)
840 { 840 {
841 XS_MUTEX_LOCK(xs_status); 841 XS_MUTEX_LOCK(xs_status);
842 if (!xs_status.tuneInfo || !xs_status.isPlaying) 842 if (!xs_status.tuneInfo || !xs_status.playing)
843 goto out; 843 goto out;
844 844
845 switch (xs_cfg.subsongControl) 845 switch (xs_cfg.subsongControl)
846 { 846 {
847 case XS_SSC_SEEK: 847 case XS_SSC_SEEK:
887 { 887 {
888 int err; 888 int err;
889 889
890 /* If errorflag is set, return -2 to signal it to XMMS's idle callback */ 890 /* If errorflag is set, return -2 to signal it to XMMS's idle callback */
891 XS_MUTEX_LOCK(xs_status); 891 XS_MUTEX_LOCK(xs_status);
892 if (xs_status.isError) 892 if (xs_status.error)
893 { 893 {
894 err = -2; 894 err = -2;
895 goto error; 895 goto error;
896 } 896 }
897 897
898 /* If there is no tune or tune has ended, return -1 */ 898 /* If there is no tune or tune has ended, return -1 */
899 if (!xs_status.tuneInfo || !xs_status.isPlaying) 899 if (!xs_status.tuneInfo || !xs_status.playing)
900 { 900 {
901 err = -1; 901 err = -1;
902 goto error; 902 goto error;
903 } 903 }
904 904