2 * Copyright (C) 2011-2013 Team XBMC
5 * This Program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2, or (at your option)
10 * This Program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with XBMC; see the file COPYING. If not, see
17 * <http://www.gnu.org/licenses/>.
21 #include <samplerate.h>
23 #include "CoreAudioAESound.h"
25 #include "CoreAudioAE.h"
26 #include "threads/SingleLock.h"
27 #include "cores/AudioEngine/AEFactory.h"
28 #include "cores/AudioEngine/Utils/AEAudioFormat.h"
29 #include "cores/AudioEngine/Interfaces/AESound.h"
30 #include "cores/AudioEngine/Utils/AEConvert.h"
31 #include "cores/AudioEngine/Utils/AERemap.h"
32 #include "cores/AudioEngine/Utils/AEUtil.h"
33 #include "utils/log.h"
34 #include "utils/EndianSwap.h"
36 /* typecast AE to CCoreAudioAE */
37 #define AE (*(CCoreAudioAE*)CAEFactory::GetEngine())
39 CCoreAudioAESound::CCoreAudioAESound(const std::string &filename) :
41 m_filename (filename),
45 m_wavLoader.Load(filename);
48 CCoreAudioAESound::~CCoreAudioAESound()
54 std::string CCoreAudioAESound::GetFileName()
59 void CCoreAudioAESound::DeInitialize()
63 bool CCoreAudioAESound::Initialize()
65 if (!m_wavLoader.IsValid())
68 return m_wavLoader.Initialize(
70 AE.GetChannelLayout(),
75 void CCoreAudioAESound::SetVolume(float volume)
77 m_volume = std::max(0.0f, std::min(1.0f, volume));
80 float CCoreAudioAESound::GetVolume()
85 unsigned int CCoreAudioAESound::GetSampleCount()
87 CSingleLock cs(m_critSection);
88 if (m_wavLoader.IsValid())
89 return m_wavLoader.GetSampleCount();
93 float* CCoreAudioAESound::GetSamples()
95 CSingleLock cs(m_critSection);
96 if (!m_wavLoader.IsValid())
100 return m_wavLoader.GetSamples();
103 void CCoreAudioAESound::ReleaseSamples()
105 CSingleLock cs(m_critSection);
110 bool CCoreAudioAESound::IsPlaying()
112 CSingleLock cs(m_critSection);
113 return (m_inUse > 0);
116 void CCoreAudioAESound::Play()
121 void CCoreAudioAESound::Stop()