diff options
Diffstat (limited to 'src/audio')
-rw-r--r-- | src/audio/player.c | 21 | ||||
-rw-r--r-- | src/audio/player.h | 3 |
2 files changed, 24 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 | ||
458 | static iPlayer *activePlayer_; | ||
459 | |||
458 | iDefineTypeConstruction(Player) | 460 | iDefineTypeConstruction(Player) |
459 | 461 | ||
460 | static size_t sampleSize_Player_(const iPlayer *d) { | 462 | static 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 | ||
662 | iBool isStarted_Player(const iPlayer *d) { | 670 | iBool 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 | ||
735 | size_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 | |||
727 | iBool start_Player(iPlayer *d) { | 742 | iBool 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 | |||
903 | iPlayer *active_Player(void) { | ||
904 | return activePlayer_; | ||
905 | } | ||
diff --git a/src/audio/player.h b/src/audio/player.h index 8753d811..ca307dc4 100644 --- a/src/audio/player.h +++ b/src/audio/player.h | |||
@@ -48,6 +48,7 @@ enum iPlayerTag { | |||
48 | 48 | ||
49 | void updateSourceData_Player (iPlayer *, const iString *mimeType, const iBlock *data, | 49 | void updateSourceData_Player (iPlayer *, const iString *mimeType, const iBlock *data, |
50 | enum iPlayerUpdate update); | 50 | enum iPlayerUpdate update); |
51 | size_t sourceDataSize_Player (const iPlayer *); | ||
51 | 52 | ||
52 | iBool start_Player (iPlayer *); | 53 | iBool start_Player (iPlayer *); |
53 | void stop_Player (iPlayer *); | 54 | void stop_Player (iPlayer *); |
@@ -67,3 +68,5 @@ float streamProgress_Player (const iPlayer *); /* normalized 0...1 */ | |||
67 | 68 | ||
68 | uint32_t idleTimeMs_Player (const iPlayer *); | 69 | uint32_t idleTimeMs_Player (const iPlayer *); |
69 | iString * metadataLabel_Player (const iPlayer *); | 70 | iString * metadataLabel_Player (const iPlayer *); |
71 | |||
72 | iPlayer * active_Player (void); | ||