mirror of
https://github.com/clangen/musikcube.git
synced 2025-03-29 19:20:28 +00:00
Added PlaybackEvent, VolumeChanged, and TimeChanged to PlaybackService.
Mirrors the underlying Transport events, but will raise them on the MessageQueue thread.
This commit is contained in:
parent
4474b96f28
commit
5af9b778f5
@ -67,7 +67,8 @@ using namespace musik::core::audio;
|
||||
#define MESSAGE_PLAYBACK_EVENT 1001
|
||||
#define MESSAGE_PREPARE_NEXT_TRACK 1002
|
||||
#define MESSAGE_VOLUME_CHANGED 1003
|
||||
#define MESSAGE_MODE_CHANGED 1004
|
||||
#define MESSAGE_TIME_CHANGED 1004
|
||||
#define MESSAGE_MODE_CHANGED 1005
|
||||
|
||||
class StreamMessage : public Message {
|
||||
public:
|
||||
@ -130,6 +131,7 @@ PlaybackService::PlaybackService(
|
||||
transport.StreamEvent.connect(this, &PlaybackService::OnStreamEvent);
|
||||
transport.PlaybackEvent.connect(this, &PlaybackService::OnPlaybackEvent);
|
||||
transport.VolumeChanged.connect(this, &PlaybackService::OnVolumeChanged);
|
||||
transport.TimeChanged.connect(this, &PlaybackService::OnTimeChanged);
|
||||
loadPreferences(this->transport, *this, prefs);
|
||||
this->index = NO_POSITION;
|
||||
this->nextIndex = NO_POSITION;
|
||||
@ -274,6 +276,8 @@ void PlaybackService::ProcessMessage(IMessage &message) {
|
||||
for (auto it = remotes.begin(); it != remotes.end(); it++) {
|
||||
(*it)->OnPlaybackStateChanged((PlaybackState) eventType);
|
||||
}
|
||||
|
||||
this->PlaybackEvent(eventType);
|
||||
}
|
||||
else if (type == MESSAGE_PREPARE_NEXT_TRACK) {
|
||||
if (transport.GetPlaybackState() != PlaybackStopped) {
|
||||
@ -285,6 +289,7 @@ void PlaybackService::ProcessMessage(IMessage &message) {
|
||||
for (auto it = remotes.begin(); it != remotes.end(); it++) {
|
||||
(*it)->OnVolumeChanged(volume);
|
||||
}
|
||||
this->VolumeChanged();
|
||||
}
|
||||
else if (type == MESSAGE_MODE_CHANGED) {
|
||||
RepeatMode mode = this->repeatMode;
|
||||
@ -293,6 +298,9 @@ void PlaybackService::ProcessMessage(IMessage &message) {
|
||||
(*it)->OnModeChanged(repeatMode, shuffled);
|
||||
}
|
||||
}
|
||||
else if (type == MESSAGE_TIME_CHANGED) {
|
||||
this->TimeChanged(transport.Position());
|
||||
}
|
||||
}
|
||||
|
||||
void PlaybackService::OnTrackChanged(size_t pos, TrackPtr track) {
|
||||
@ -498,4 +506,8 @@ void PlaybackService::OnPlaybackEvent(int eventType) {
|
||||
|
||||
void PlaybackService::OnVolumeChanged() {
|
||||
POST(this, MESSAGE_VOLUME_CHANGED, 0, 0);
|
||||
}
|
||||
|
||||
void PlaybackService::OnTimeChanged(double time) {
|
||||
POST(this, MESSAGE_TIME_CHANGED, 0, 0);
|
||||
}
|
@ -55,10 +55,17 @@ namespace musik { namespace core { namespace audio {
|
||||
public sigslot::has_slots<>
|
||||
{
|
||||
public:
|
||||
/* our unique events */
|
||||
sigslot::signal2<size_t, musik::core::TrackPtr> TrackChanged;
|
||||
sigslot::signal0<> ModeChanged;
|
||||
sigslot::signal1<bool> Shuffled;
|
||||
|
||||
/* copied from Transport, but will be automatically called on the
|
||||
specified MessageQueue's thread! */
|
||||
sigslot::signal1<int> PlaybackEvent;
|
||||
sigslot::signal0<> VolumeChanged;
|
||||
sigslot::signal1<double> TimeChanged;
|
||||
|
||||
PlaybackService(
|
||||
musik::core::runtime::IMessageQueue& messageQueue,
|
||||
musik::core::LibraryPtr library,
|
||||
@ -103,6 +110,7 @@ namespace musik { namespace core { namespace audio {
|
||||
void OnPlaybackEvent(int eventType);
|
||||
void OnTrackChanged(size_t pos, musik::core::TrackPtr track);
|
||||
void OnVolumeChanged();
|
||||
void OnTimeChanged(double time);
|
||||
void PrepareNextTrack();
|
||||
void InitRemotes();
|
||||
void ResetRemotes();
|
||||
|
@ -149,7 +149,6 @@ namespace musik { namespace core { namespace audio {
|
||||
int state;
|
||||
bool notifiedStarted;
|
||||
float* spectrum;
|
||||
uint64 samplesWritten;
|
||||
DestroyMode destroyMode;
|
||||
int pendingBufferCount;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user