Partition: add method EmitIdle()

Prepare for moving idle events to class Partition.  Right now, it's
just a wrapper for idle_add().
This commit is contained in:
Max Kellermann 2016-03-05 19:16:39 +01:00
parent e52ac0b187
commit b24a5e0662
7 changed files with 21 additions and 13 deletions

View File

@ -77,7 +77,6 @@ Instance::OnDatabaseModified()
stats_invalidate();
partition->DatabaseModified(*database);
idle_add(IDLE_DATABASE);
}
void
@ -102,13 +101,13 @@ Instance::OnDatabaseSongRemoved(const LightSong &song)
void
Instance::FoundNeighbor(gcc_unused const NeighborInfo &info)
{
idle_add(IDLE_NEIGHBOR);
partition->EmitIdle(IDLE_NEIGHBOR);
}
void
Instance::LostNeighbor(gcc_unused const NeighborInfo &info)
{
idle_add(IDLE_NEIGHBOR);
partition->EmitIdle(IDLE_NEIGHBOR);
}
#endif

View File

@ -25,6 +25,12 @@
#include "Idle.hxx"
#include "GlobalEvents.hxx"
void
Partition::EmitIdle(unsigned mask)
{
idle_add(mask);
}
#ifdef ENABLE_DATABASE
const Database *
@ -37,6 +43,7 @@ void
Partition::DatabaseModified(const Database &db)
{
playlist.DatabaseModified(db);
EmitIdle(IDLE_DATABASE);
}
#endif
@ -75,5 +82,5 @@ Partition::OnMixerVolumeChanged(gcc_unused Mixer &mixer, gcc_unused int volume)
InvalidateHardwareVolume();
/* notify clients */
idle_add(IDLE_MIXER);
EmitIdle(IDLE_MIXER);
}

View File

@ -53,6 +53,8 @@ struct Partition final : private PlayerListener, private MixerListener {
outputs(*this),
pc(*this, outputs, buffer_chunks, buffered_before_play) {}
void EmitIdle(unsigned mask);
void ClearQueue() {
playlist.Clear(pc);
}

View File

@ -19,7 +19,6 @@
#include "config.h"
#include "ReplayGainConfig.hxx"
#include "Idle.hxx"
#include "config/Param.hxx"
#include "config/ConfigGlobal.hxx"
#include "system/FatalError.hxx"
@ -74,8 +73,6 @@ replay_gain_set_mode_string(const char *p)
else
return false;
idle_add(IDLE_OPTIONS);
return true;
}

View File

@ -19,6 +19,7 @@
#include "config.h"
#include "ClientInternal.hxx"
#include "Partition.hxx"
#include "Idle.hxx"
#include <assert.h>
@ -40,7 +41,7 @@ Client::Subscribe(const char *channel)
++num_subscriptions;
idle_add(IDLE_SUBSCRIPTION);
partition.EmitIdle(IDLE_SUBSCRIPTION);
return Client::SubscribeResult::OK;
}
@ -57,7 +58,7 @@ Client::Unsubscribe(const char *channel)
subscriptions.erase(i);
--num_subscriptions;
idle_add(IDLE_SUBSCRIPTION);
partition.EmitIdle(IDLE_SUBSCRIPTION);
assert((num_subscriptions == 0) ==
subscriptions.empty());

View File

@ -28,6 +28,7 @@
#include "mixer/Volume.hxx"
#include "Partition.hxx"
#include "Instance.hxx"
#include "Idle.hxx"
#include "AudioFormat.hxx"
#include "ReplayGainConfig.hxx"
@ -348,6 +349,7 @@ handle_replay_gain_mode(Client &client, Request args, Response &r)
}
client.partition.outputs.SetReplayGainMode(replay_gain_get_real_mode(client.playlist.queue.random));
client.partition.EmitIdle(IDLE_OPTIONS);
return CommandResult::OK;
}

View File

@ -230,7 +230,7 @@ handle_mount(Client &client, Request args, Response &r)
}
composite.Mount(local_uri, storage);
idle_add(IDLE_MOUNT);
client.partition.EmitIdle(IDLE_MOUNT);
#ifdef ENABLE_DATABASE
Database *_db = client.partition.instance.database;
@ -249,7 +249,7 @@ handle_mount(Client &client, Request args, Response &r)
// TODO: call Instance::OnDatabaseModified()?
// TODO: trigger database update?
idle_add(IDLE_DATABASE);
client.partition.EmitIdle(IDLE_DATABASE);
}
#endif
@ -287,7 +287,7 @@ handle_unmount(Client &client, Request args, Response &r)
if (db.Unmount(local_uri))
// TODO: call Instance::OnDatabaseModified()?
idle_add(IDLE_DATABASE);
client.partition.EmitIdle(IDLE_DATABASE);
}
#endif
@ -296,7 +296,7 @@ handle_unmount(Client &client, Request args, Response &r)
return CommandResult::ERROR;
}
idle_add(IDLE_MOUNT);
client.partition.EmitIdle(IDLE_MOUNT);
return CommandResult::OK;
}