wavelength 1.0.0
Loading...
Searching...
No Matches
streamtask.h
Go to the documentation of this file.
1#pragma once
2
3#include <memory>
4
5#include "os/task.h"
7
14class StreamTask : public Task {
15public:
22 ~StreamTask() override = default;
23
34 StreamTask(const char *pszName, const char *pszDirectory);
35
43 void SetWaitingTask(Task *pTask);
44
52 void SetPaused(bool bPaused);
53
55 const char *GetName() const {
56 return mName;
57 }
58
61 return mPlayer.get();
62 }
63
64private:
65 Task *mWaitingTask;
66 std::unique_ptr<StreamPlayer> mPlayer;
67 const char *mName;
68 const char *mDirectory;
69
70protected:
77 void OnStart() override;
78
85 void OnStop() override;
86
93 void OnPoll() override;
94};
Stream of sound data read from a file and handed to the sound output a run at a time.
Definition streamplayer.h:13
void OnStop() override
Stop the stream and release it.
void OnStart() override
Open the stream file and give it to the sound output to play.
void SetWaitingTask(Task *pTask)
Set the task that learns when the stream is done.
StreamTask(const char *pszName, const char *pszDirectory)
Construct a task for a stream file.
StreamPlayer * GetPlayer() const
Definition streamtask.h:60
void OnPoll() override
Once the stream has ended, release it, finish the task, and report to the waiting task.
const char * GetName() const
Definition streamtask.h:55
~StreamTask() override=default
Destroy the object.
void SetPaused(bool bPaused)
Pause or resume the stream.
Unit of work an owner starts, polls until it reports that it is done, and stops.
Definition task.h:9
Task()
Construct an idle task.
Definition task.h:24