Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

[r35733]: branches / AudioEngine / xbmc / cores / AudioEngine / Engines / PulseAEStream.h Maximize Restore History

Download this file

PulseAEStream.h    122 lines (96 with data), 3.9 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#pragma once
/*
* Copyright (C) 2005-2010 Team XBMC
* http://xbmc.org
*
* This Program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This Program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with XBMC; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
* http://www.gnu.org/copyleft/gpl.html
*
*/
#ifdef HAS_PULSEAUDIO
#include "AEStream.h"
#include "PulseAEEventThread.h"
#include <pulse/pulseaudio.h>
class CPulseAEEventThread;
class CPulseAEStream : public IAEStream
{
public:
/* this should NEVER be called directly, use AE.GetStream */
CPulseAEStream(pa_context *context, pa_threaded_mainloop *mainLoop, enum AEDataFormat format, unsigned int sampleRate, unsigned int channelCount, AEChLayout channelLayout, unsigned int options);
virtual ~CPulseAEStream();
virtual void Destroy();
virtual void SetDataCallback (AECBFunc *cbFunc, void *arg); /* called when the buffer < 50% full */
virtual void SetDrainCallback(AECBFunc *cbFunc, void *arg); /* called when the buffer has been drained */
virtual unsigned int AddData(void *data, unsigned int size);
virtual float GetDelay();
int GetSpace();
virtual bool IsPaused ();
virtual bool IsDraining ();
virtual bool IsFreeOnDrain();
virtual bool IsDestroyed ();
virtual void Pause ();
virtual void Resume ();
virtual void Drain ();
virtual void Flush ();
virtual float GetVolume ();
virtual float GetReplayGain();
virtual void SetVolume (float volume);
virtual void SetReplayGain(float factor);
virtual void AppendPostProc (IAEPostProc *pp);
virtual void PrependPostProc(IAEPostProc *pp);
virtual void RemovePostProc (IAEPostProc *pp);
virtual unsigned int GetFrameSize ();
virtual unsigned int GetChannelCount();
virtual unsigned int GetSampleRate ();
virtual enum AEDataFormat GetDataFormat ();
/* for dynamic sample rate changes (smoothvideo) */
virtual double GetResampleRatio();
virtual void SetResampleRatio(double ratio);
/* vizualization callback register function */
virtual void RegisterAudioCallback(IAudioCallback* pCallback);
virtual void UnRegisterAudioCallback();
void SetFreeOnDrain() { m_options |= AESTREAM_FREE_ON_DRAIN; }
/* trigger the stream to update its volume relative to AE */
void UpdateVolume(float max);
private:
static void StreamRequestCallback(pa_stream *s, size_t length, void *userdata);
static void StreamLatencyUpdateCallback(pa_stream *s, void *userdata);
static void StreamStateCallback(pa_stream *s, void *userdata);
static void StreamDrainComplete(pa_stream *s, int success, void *userdata);
static inline bool WaitForOperation(pa_operation *op, pa_threaded_mainloop *mainloop, const char *LogEntry);
bool Cork(bool cork);
bool m_Destroyed;
bool m_Initialized;
bool m_Paused;
pa_stream *m_Stream;
pa_sample_spec m_SampleSpec;
float m_MaxVolume;
float m_Volume;
pa_cvolume m_ChVolume;
pa_context *m_Context;
pa_threaded_mainloop *m_MainLoop;
IAudioCallback* m_AudioCallback;
CPulseAEEventThread *m_AudioDataThread;
CPulseAEEventThread *m_AudioDrainThread;
enum AEDataFormat m_format;
unsigned int m_sampleRate;
unsigned int m_channelCount;
AEChLayout m_channelLayout;
unsigned int m_options;
unsigned int m_frameSize;
unsigned int m_frameSamples;
bool m_draining;
};
#endif