namespace tizen_media_audio {
-
-
/**
- * PULSE Thread
+ * PULSE ThreadMainloop Locker
*/
- class CPulseAudioVolume;
- class CPulseAudioPolicy;
class CPulseStreamSpec;
+
class CPulseAudioClient {
public:
enum class EStreamDirection : unsigned int {
~CPulseAudioClient();
/* Implemented Methods */
- void initialize() throw(CAudioError);
+ void initialize();
void finalize();
/* Methods */
- int read(void* buffer, size_t length) throw(CAudioError);
- int peek(const void** buffer, size_t* length) throw(CAudioError);
- int drop() throw(CAudioError);
- int write(const void* buffer, size_t length) throw(CAudioError);
+ int read(void* buffer, size_t length);
+ int peek(const void** buffer, size_t* length);
+ int drop();
+ int write(const void* buffer, size_t length);
- void cork(bool cork) throw(CAudioError);
- bool isCorked() throw(CAudioError);
+ void cork(bool cork);
+ bool isCorked();
- bool drain() throw(CAudioError);
- bool flush() throw(CAudioError);
+ bool drain();
+ bool flush();
- void checkRunningState() throw(CAudioError);
- bool isInThread() throw(CAudioError);
+ void checkRunningState();
+ bool isInThread() const;
- size_t getWritableSize() throw(CAudioError);
- size_t getReadableSize() throw(CAudioError);
+ size_t getWritableSize();
+ size_t getReadableSize();
- size_t getBufferSize() throw(CAudioError);
+ size_t getBufferSize();
- pa_usec_t getLatency() throw(CAudioError);
- pa_usec_t getFinalLatency() throw(CAudioError);
+ pa_usec_t getLatency();
+ pa_usec_t getFinalLatency();
- /* Setter & Getter */
- EStreamDirection getStreamDirection();
- CPulseStreamSpec getStreamSpec();
+ void applyRecordVolume(double volume);
private:
/* Members */
- EStreamDirection __mDirection;
+ EStreamDirection __mDirection {};
CPulseStreamSpec __mSpec;
- IPulseStreamListener* __mpListener;
+ IPulseStreamListener* __mpListener {};
- pa_threaded_mainloop* __mpMainloop;
- pa_context* __mpContext;
- pa_stream* __mpStream;
- pa_proplist* __mpPropList;
+ pa_threaded_mainloop* __mpMainloop {};
+ pa_context* __mpContext {};
+ pa_stream* __mpStream {};
+ pa_proplist* __mpPropList {};
- bool __mIsInit;
- bool __mIsOperationSuccess;
+ bool __mIsInit {};
+ bool __mIsOperationSuccess {};
- const void* __mpSyncReadDataPtr;
- size_t __mSyncReadIndex;
- size_t __mSyncReadLength;
- bool __mIsUsedSyncRead;
- bool __mIsFirstStream;
- bool __mIsDraining;
+ const void* __mpSyncReadDataPtr {};
+ size_t __mSyncReadIndex {};
+ size_t __mSyncReadLength {};
+ bool __mIsUsedSyncRead {};
+ bool __mIsFirstStream {};
+ bool __mIsDraining {};
+ bool __mIsStarted {};
/* Static Methods */
/* Private Method */
+ void resetStreamCallbacks();
+ void resetInternalObjects();
- /* Private Calblack Method */
+ /* Private Callback Method */
static void __contextStateChangeCb(pa_context* c, void* user_data);
- static void __successContextCb(pa_context* c, int success, void* user_data);
-
static void __streamStateChangeCb(pa_stream* s, void* user_data);
static void __streamCaptureCb(pa_stream* s, size_t length, void* user_data);
static void __streamPlaybackCb(pa_stream* s, size_t length, void* user_data);
static void __streamLatencyUpdateCb(pa_stream* s, void* user_data);
+ static void __streamStartedCb(pa_stream* s, void* user_data);
+ static void __streamUnderflowCb(pa_stream* s, void* user_data);
+ static void __streamOverflowCb(pa_stream* s, void* user_data);
static void __streamEventCb(pa_stream* s, const char *name, pa_proplist *pl, void *user_data);
static void __successStreamCb(pa_stream* s, int success, void* user_data);
static void __successDrainCb(pa_stream* s, int success, void* user_data);
static void __successDrainCbInThread(pa_stream* s, int success, void* user_data);
+ static void __successVolumeCb(pa_context* c, int success, void* user_data);
+
+ class CPulseThreadLocker {
+ public:
+ explicit CPulseThreadLocker(pa_threaded_mainloop* mainloop);
+ virtual ~CPulseThreadLocker();
+
+ private:
+ const pa_threaded_mainloop* ml{};
+ };
};