iAudioTask.h
1 #pragma once
2 
3 #include <map>
4 #include <list>
5 #include <vector>
6 #include <string>
7 #include <boost/system/error_code.hpp>
8 #include <mutex>
9 
10 #include "audioTypes.h"
11 
12 namespace dpyAudio {
13 
18 {
20  QUEUED = 1,
21  PROCESSING = 2,
27 };
28 
34  std::string audioFilePath = "";
37 
38  std::list<dpyAudio::AudioConfig> configurations;
39 
40  AudioTaskInformation(): port("user", "", dpyAudio::NA_TYPE ), audioFilePath(""),status(dpyAudio::AudioTaskStatus::UNKNOWN_STATUS), type(dpyAudio::TaskType::PLAY) {
41  }
42 
51  AudioTaskInformation(dpyAudio::Port p, std::string a, dpyAudio::AudioTaskStatus s, dpyAudio::TaskType t, std::list<dpyAudio::AudioConfig> c): port(p), audioFilePath(a), status(s), type(t), configurations(c) {
52  }
53 
54 };
55 
56 }
57 
58 
64 {
65 public:
72  virtual void AudioTaskStatusChange(const int taskId,const dpyAudio::TaskType type, const dpyAudio::AudioTaskStatus& status) = 0;
77  {
78  }
79 };
80 
86 {
87 private:
88  dpyAudio::TaskType mType;
90  dpyAudio::AudioTaskInformation mAudioTaskInformation;
91  int mTaskId;
92  std::vector<AudioTaskObserver*> mObserversList;
93  static int mTaskCounter;
94  std::mutex mMutex;
95 
96  std::list<dpyAudio::AudioConfig> mConfigurations;
97 
98  int mVolume = 100;
99 
100 public:
101  boost::system::error_code subscribe(AudioTaskObserver* observer);
102  boost::system::error_code unsubscribe(AudioTaskObserver* observer);
103 
104  static void setTaskCounter(int taskCounter);
105  static int getTaskCounter();
106 
107  IAudioTask(dpyAudio::TaskType type, dpyAudio::Port port,std::string audioFilePath, std::list<dpyAudio::AudioConfig> configurations);
111  virtual ~IAudioTask();
112  void setStatus(dpyAudio::AudioTaskStatus status);
113 
119  return mStatus;
120  }
121 
127  return mAudioTaskInformation;
128  }
129 
134  inline int getId() const
135  {
136  return mTaskId;
137  }
138 
144  {
145  return mType;
146  }
147 
152  inline std::list<dpyAudio::AudioConfig> getConfiguration() const {
153  return mConfigurations;
154  }
155 
160  inline int getVolume() const {
161  return mVolume;
162  }
163 
164 };
virtual ~AudioTaskObserver()
Destructor.
Definition: iAudioTask.h:76
ERROR WHILE PROCESSING.
Definition: iAudioTask.h:24
Struct defining a port.
Definition: audioTypes.h:79
dpyAudio::AudioTaskStatus getStatus() const
Get Task status.
Definition: iAudioTask.h:118
AudioTaskInformation(dpyAudio::Port p, std::string a, dpyAudio::AudioTaskStatus s, dpyAudio::TaskType t, std::list< dpyAudio::AudioConfig > c)
AudioTaskInformation constructor.
Definition: iAudioTask.h:51
PROCESSING.
Definition: iAudioTask.h:21
QUEUED.
Definition: iAudioTask.h:20
dpyAudio::Port port
Port information.
Definition: iAudioTask.h:33
std::string audioFilePath
Audio file corresponding to the Task.
Definition: iAudioTask.h:34
Audio Task Observer class.
Definition: iAudioTask.h:63
int getId() const
Definition: iAudioTask.h:134
Deepsy Audio namespace that includes the different enums, structs or method signatures that should be...
TaskType
Enumeration defining the different type of audio tasks.
Definition: audioTypes.h:69
PROCESSED OK.
Definition: iAudioTask.h:22
dpyAudio::TaskType type
Type of audio task.
Definition: iAudioTask.h:36
ERROR AFTER PROCESSING.
Definition: iAudioTask.h:25
int getVolume() const
Get Task volume.
Definition: iAudioTask.h:160
dpyAudio::AudioTaskInformation getAudioTaskInformation() const
Definition: iAudioTask.h:126
ERROR BEFORE PROCESSING.
Definition: iAudioTask.h:23
dpyAudio::TaskType getType() const
Definition: iAudioTask.h:143
Structure containing Task information.
Definition: iAudioTask.h:32
UNKNOWN.
Definition: iAudioTask.h:19
PLAY.
Definition: audioTypes.h:71
Interface representing a Audio Task which will be reproduced in a specific port.
Definition: iAudioTask.h:85
NA_TYPE.
Definition: audioTypes.h:23
STOPPED.
Definition: iAudioTask.h:26
dpyAudio::AudioTaskStatus status
Status corresponding to the Task.
Definition: iAudioTask.h:35
AudioTaskStatus
Enumeration that includes the possible status of an Audio Task within the Audio system.
Definition: iAudioTask.h:17
std::list< dpyAudio::AudioConfig > configurations
Configurations of the audio task.
Definition: iAudioTask.h:38
std::list< dpyAudio::AudioConfig > getConfiguration() const
Get Task configuration.
Definition: iAudioTask.h:152