Simplify creating Promises
Less typing, less reading We can now make this `auto` simplification because we give the compiler information about the expected type of the promise body.
This commit is contained in:
parent
112d29d931
commit
9c9c4ec037
|
@ -45,8 +45,7 @@ AudioOutputHandler::AudioOutputHandler(IGetTrackSequence* getSequence)
|
|||
|
||||
Promise<AudioOutputParams> AudioOutputHandler::outputParams(const TrackSequenceId sequenceId, const TrackId trackId) const
|
||||
{
|
||||
return Promise<AudioOutputParams>([this, sequenceId, trackId](Promise<AudioOutputParams>::Resolve resolve,
|
||||
Promise<AudioOutputParams>::Reject reject) {
|
||||
return Promise<AudioOutputParams>([this, sequenceId, trackId](auto resolve, auto reject) {
|
||||
ONLY_AUDIO_WORKER_THREAD;
|
||||
|
||||
ITrackSequencePtr s = sequence(sequenceId);
|
||||
|
@ -87,8 +86,7 @@ Channel<TrackSequenceId, TrackId, AudioOutputParams> AudioOutputHandler::outputP
|
|||
|
||||
Promise<AudioOutputParams> AudioOutputHandler::masterOutputParams() const
|
||||
{
|
||||
return Promise<AudioOutputParams>([this](Promise<AudioOutputParams>::Resolve resolve,
|
||||
Promise<AudioOutputParams>::Reject reject) {
|
||||
return Promise<AudioOutputParams>([this](auto resolve, auto reject) {
|
||||
ONLY_AUDIO_WORKER_THREAD;
|
||||
|
||||
IF_ASSERT_FAILED(mixer()) {
|
||||
|
@ -121,8 +119,7 @@ Channel<AudioOutputParams> AudioOutputHandler::masterOutputParamsChanged() const
|
|||
|
||||
Promise<AudioResourceMetaList> AudioOutputHandler::availableOutputResources() const
|
||||
{
|
||||
return Promise<AudioResourceMetaList>([this](Promise<AudioResourceMetaList>::Resolve resolve,
|
||||
Promise<AudioResourceMetaList>::Reject /*reject*/) {
|
||||
return Promise<AudioResourceMetaList>([this](auto resolve, auto /*reject*/) {
|
||||
ONLY_AUDIO_WORKER_THREAD;
|
||||
|
||||
return resolve(fxResolver()->resolveAvailableResources());
|
||||
|
@ -131,8 +128,7 @@ Promise<AudioResourceMetaList> AudioOutputHandler::availableOutputResources() co
|
|||
|
||||
Promise<AudioSignalChanges> AudioOutputHandler::signalChanges(const TrackSequenceId sequenceId, const TrackId trackId) const
|
||||
{
|
||||
return Promise<AudioSignalChanges>([this, sequenceId, trackId](Promise<AudioSignalChanges>::Resolve resolve,
|
||||
Promise<AudioSignalChanges>::Reject reject) {
|
||||
return Promise<AudioSignalChanges>([this, sequenceId, trackId](auto resolve, auto reject) {
|
||||
ONLY_AUDIO_WORKER_THREAD;
|
||||
|
||||
ITrackSequencePtr s = sequence(sequenceId);
|
||||
|
@ -151,8 +147,7 @@ Promise<AudioSignalChanges> AudioOutputHandler::signalChanges(const TrackSequenc
|
|||
|
||||
Promise<AudioSignalChanges> AudioOutputHandler::masterSignalChanges() const
|
||||
{
|
||||
return Promise<AudioSignalChanges>([this](Promise<AudioSignalChanges>::Resolve resolve,
|
||||
Promise<AudioSignalChanges>::Reject reject) {
|
||||
return Promise<AudioSignalChanges>([this](auto resolve, auto reject) {
|
||||
ONLY_AUDIO_WORKER_THREAD;
|
||||
|
||||
IF_ASSERT_FAILED(mixer()) {
|
||||
|
|
|
@ -49,7 +49,7 @@ void Playback::init()
|
|||
|
||||
Promise<TrackSequenceId> Playback::addSequence()
|
||||
{
|
||||
return Promise<TrackSequenceId>([this](Promise<TrackSequenceId>::Resolve resolve, Promise<TrackSequenceId>::Reject /*reject*/) {
|
||||
return Promise<TrackSequenceId>([this](auto resolve, auto /*reject*/) {
|
||||
ONLY_AUDIO_WORKER_THREAD;
|
||||
|
||||
TrackSequenceId newId = static_cast<TrackSequenceId>(m_sequences.size());
|
||||
|
@ -63,8 +63,7 @@ Promise<TrackSequenceId> Playback::addSequence()
|
|||
|
||||
Promise<TrackSequenceIdList> Playback::sequenceIdList() const
|
||||
{
|
||||
return Promise<TrackSequenceIdList>([this](Promise<TrackSequenceIdList>::Resolve resolve,
|
||||
Promise<TrackSequenceIdList>::Reject /*reject*/) {
|
||||
return Promise<TrackSequenceIdList>([this](auto resolve, auto /*reject*/) {
|
||||
ONLY_AUDIO_WORKER_THREAD;
|
||||
|
||||
TrackSequenceIdList result(m_sequences.size());
|
||||
|
|
|
@ -116,7 +116,7 @@ void PlayerHandler::setDuration(const TrackSequenceId sequenceId, const msecs_t
|
|||
|
||||
Promise<bool> PlayerHandler::setLoop(const TrackSequenceId sequenceId, const msecs_t fromMsec, const msecs_t toMsec)
|
||||
{
|
||||
return Promise<bool>([this, sequenceId, fromMsec, toMsec](Promise<bool>::Resolve resolve, Promise<bool>::Reject reject) {
|
||||
return Promise<bool>([this, sequenceId, fromMsec, toMsec](auto resolve, auto reject) {
|
||||
ONLY_AUDIO_WORKER_THREAD;
|
||||
|
||||
ITrackSequencePtr s = sequence(sequenceId);
|
||||
|
|
|
@ -45,7 +45,7 @@ TracksHandler::~TracksHandler()
|
|||
|
||||
Promise<TrackIdList> TracksHandler::trackIdList(const TrackSequenceId sequenceId) const
|
||||
{
|
||||
return Promise<TrackIdList>([this, sequenceId](Promise<TrackIdList>::Resolve resolve, Promise<TrackIdList>::Reject reject) {
|
||||
return Promise<TrackIdList>([this, sequenceId](auto resolve, auto reject) {
|
||||
ONLY_AUDIO_WORKER_THREAD;
|
||||
|
||||
ITrackSequencePtr s = sequence(sequenceId);
|
||||
|
@ -60,7 +60,7 @@ Promise<TrackIdList> TracksHandler::trackIdList(const TrackSequenceId sequenceId
|
|||
|
||||
Promise<TrackName> TracksHandler::trackName(const TrackSequenceId sequenceId, const TrackId trackId) const
|
||||
{
|
||||
return Promise<TrackName>([this, sequenceId, trackId](Promise<TrackName>::Resolve resolve, Promise<TrackName>::Reject reject) {
|
||||
return Promise<TrackName>([this, sequenceId, trackId](auto resolve, auto reject) {
|
||||
ONLY_AUDIO_WORKER_THREAD;
|
||||
|
||||
ITrackSequencePtr s = sequence(sequenceId);
|
||||
|
@ -77,8 +77,7 @@ Promise<TrackId, AudioParams> TracksHandler::addTrack(const TrackSequenceId sequ
|
|||
io::Device* playbackData,
|
||||
AudioParams&& params)
|
||||
{
|
||||
return Promise<TrackId, AudioParams>([this, sequenceId, trackName, playbackData, params](Promise<TrackId, AudioParams>::Resolve resolve,
|
||||
Promise<TrackId, AudioParams>::Reject reject) {
|
||||
return Promise<TrackId, AudioParams>([this, sequenceId, trackName, playbackData, params](auto resolve, auto reject) {
|
||||
ONLY_AUDIO_WORKER_THREAD;
|
||||
|
||||
ITrackSequencePtr s = sequence(sequenceId);
|
||||
|
@ -100,8 +99,7 @@ Promise<TrackId, AudioParams> TracksHandler::addTrack(const TrackSequenceId sequ
|
|||
Promise<TrackId, AudioParams> TracksHandler::addTrack(const TrackSequenceId sequenceId, const std::string& trackName,
|
||||
const mpe::PlaybackData& playbackData, AudioParams&& params)
|
||||
{
|
||||
return Promise<TrackId, AudioParams>([this, sequenceId, trackName, playbackData, params](Promise<TrackId, AudioParams>::Resolve resolve,
|
||||
Promise<TrackId, AudioParams>::Reject reject) {
|
||||
return Promise<TrackId, AudioParams>([this, sequenceId, trackName, playbackData, params](auto resolve, auto reject) {
|
||||
ONLY_AUDIO_WORKER_THREAD;
|
||||
|
||||
ITrackSequencePtr s = sequence(sequenceId);
|
||||
|
@ -168,8 +166,7 @@ Channel<TrackSequenceId, TrackId> TracksHandler::trackRemoved() const
|
|||
|
||||
Promise<AudioResourceMetaList> TracksHandler::availableInputResources() const
|
||||
{
|
||||
return Promise<AudioResourceMetaList>([this](Promise<AudioResourceMetaList>::Resolve resolve,
|
||||
Promise<AudioResourceMetaList>::Reject /*reject*/) {
|
||||
return Promise<AudioResourceMetaList>([this](auto resolve, auto /*reject*/) {
|
||||
ONLY_AUDIO_WORKER_THREAD;
|
||||
|
||||
return resolve(resolver()->resolveAvailableResources());
|
||||
|
@ -178,8 +175,7 @@ Promise<AudioResourceMetaList> TracksHandler::availableInputResources() const
|
|||
|
||||
Promise<AudioInputParams> TracksHandler::inputParams(const TrackSequenceId sequenceId, const TrackId trackId) const
|
||||
{
|
||||
return Promise<AudioInputParams>([this, sequenceId, trackId](Promise<AudioInputParams>::Resolve resolve,
|
||||
Promise<AudioInputParams>::Reject reject) {
|
||||
return Promise<AudioInputParams>([this, sequenceId, trackId](auto resolve, auto reject) {
|
||||
ONLY_AUDIO_WORKER_THREAD;
|
||||
|
||||
ITrackSequencePtr s = sequence(sequenceId);
|
||||
|
|
Loading…
Reference in a new issue