summaryrefslogtreecommitdiff
path: root/src/audio/player.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/audio/player.c')
-rw-r--r--src/audio/player.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/audio/player.c b/src/audio/player.c
index 9e026561..94bcd065 100644
--- a/src/audio/player.c
+++ b/src/audio/player.c
@@ -455,6 +455,8 @@ struct Impl_Player {
455 iAVFAudioPlayer * avfPlayer; /* iOS */ 455 iAVFAudioPlayer * avfPlayer; /* iOS */
456}; 456};
457 457
458static iPlayer *activePlayer_;
459
458iDefineTypeConstruction(Player) 460iDefineTypeConstruction(Player)
459 461
460static size_t sampleSize_Player_(const iPlayer *d) { 462static size_t sampleSize_Player_(const iPlayer *d) {
@@ -655,8 +657,14 @@ void deinit_Player(iPlayer *d) {
655#if defined (iPlatformAppleMobile) 657#if defined (iPlatformAppleMobile)
656 if (d->avfPlayer) { 658 if (d->avfPlayer) {
657 delete_AVFAudioPlayer(d->avfPlayer); 659 delete_AVFAudioPlayer(d->avfPlayer);
660 if (activePlayer_ == d) {
661 clearNowPlayingInfo_iOS();
662 }
658 } 663 }
659#endif 664#endif
665 if (activePlayer_ == d) {
666 activePlayer_ = NULL;
667 }
660} 668}
661 669
662iBool isStarted_Player(const iPlayer *d) { 670iBool isStarted_Player(const iPlayer *d) {
@@ -724,6 +732,13 @@ void updateSourceData_Player(iPlayer *d, const iString *mimeType, const iBlock *
724 unlock_Mutex(&input->mtx); 732 unlock_Mutex(&input->mtx);
725} 733}
726 734
735size_t sourceDataSize_Player(const iPlayer *d) {
736 lock_Mutex(&d->data->mtx);
737 const size_t size = size_Block(&d->data->data);
738 unlock_Mutex(&d->data->mtx);
739 return size;
740}
741
727iBool start_Player(iPlayer *d) { 742iBool start_Player(iPlayer *d) {
728 if (isStarted_Player(d)) { 743 if (isStarted_Player(d)) {
729 return iFalse; 744 return iFalse;
@@ -732,6 +747,7 @@ iBool start_Player(iPlayer *d) {
732 if (d->avfPlayer) { 747 if (d->avfPlayer) {
733 play_AVFAudioPlayer(d->avfPlayer); 748 play_AVFAudioPlayer(d->avfPlayer);
734 setNotIdle_Player(d); 749 setNotIdle_Player(d);
750 activePlayer_ = d;
735 return iTrue; 751 return iTrue;
736 } 752 }
737#endif 753#endif
@@ -749,6 +765,7 @@ iBool start_Player(iPlayer *d) {
749 d->decoder->gain = d->volume; 765 d->decoder->gain = d->volume;
750 SDL_PauseAudioDevice(d->device, SDL_FALSE); 766 SDL_PauseAudioDevice(d->device, SDL_FALSE);
751 setNotIdle_Player(d); 767 setNotIdle_Player(d);
768 activePlayer_ = d;
752 return iTrue; 769 return iTrue;
753} 770}
754 771
@@ -882,3 +899,7 @@ iString *metadataLabel_Player(const iPlayer *d) {
882 } 899 }
883 return meta; 900 return meta;
884} 901}
902
903iPlayer *active_Player(void) {
904 return activePlayer_;
905}