Remove AudioPlayer::GetProvider()

There's really no reason why anything should ever be getting the audio
provider from an audio player.

Originally committed to SVN as r6603.
This commit is contained in:
Thomas Goyne 2012-03-25 04:05:31 +00:00
parent e120bec4f0
commit 55f9ccc18d
5 changed files with 7 additions and 12 deletions

View File

@ -370,7 +370,7 @@ void AlsaPlayer::OpenStream()
CloseStream(); CloseStream();
ps->Reset(); ps->Reset();
ps->provider = GetProvider(); ps->provider = provider;
wxString device_name = lagi_wxString(OPT_GET("Player/Audio/ALSA/Device")->GetString()); wxString device_name = lagi_wxString(OPT_GET("Player/Audio/ALSA/Device")->GetString());
ps->device_name = std::string(device_name.utf8_str()); ps->device_name = std::string(device_name.utf8_str());

View File

@ -70,9 +70,6 @@ DirectSoundPlayer::~DirectSoundPlayer() {
/// @brief Open stream /// @brief Open stream
/// ///
void DirectSoundPlayer::OpenStream() { void DirectSoundPlayer::OpenStream() {
// Get provider
AudioProvider *provider = GetProvider();
// Initialize the DirectSound object // Initialize the DirectSound object
HRESULT res; HRESULT res;
res = DirectSoundCreate8(&DSDEVID_DefaultPlayback,&directSound,NULL); // TODO: support selecting audio device res = DirectSoundCreate8(&DSDEVID_DefaultPlayback,&directSound,NULL); // TODO: support selecting audio device
@ -147,7 +144,6 @@ bool DirectSoundPlayer::FillBuffer(bool fill) {
HRESULT res; HRESULT res;
void *ptr1, *ptr2; void *ptr1, *ptr2;
unsigned long int size1, size2; unsigned long int size1, size2;
AudioProvider *provider = GetProvider();
int bytesps = provider->GetBytesPerSample(); int bytesps = provider->GetBytesPerSample();
// To write length // To write length

View File

@ -834,7 +834,7 @@ void DirectSoundPlayer2::OpenStream()
try try
{ {
thread.reset(new DirectSoundPlayer2Thread(GetProvider(), WantedLatency, BufferLength)); thread.reset(new DirectSoundPlayer2Thread(provider, WantedLatency, BufferLength));
} }
catch (const char *msg) catch (const char *msg)
{ {
@ -847,16 +847,16 @@ void DirectSoundPlayer2::CloseStream()
thread.reset(); thread.reset();
} }
void DirectSoundPlayer2::SetProvider(AudioProvider *provider) void DirectSoundPlayer2::SetProvider(AudioProvider *new_provider)
{ {
try try
{ {
if (IsThreadAlive() && provider != GetProvider()) if (IsThreadAlive() && new_provider != provider)
{ {
thread.reset(new DirectSoundPlayer2Thread(provider, WantedLatency, BufferLength)); thread.reset(new DirectSoundPlayer2Thread(new_provider, WantedLatency, BufferLength));
} }
AudioPlayer::SetProvider(provider); AudioPlayer::SetProvider(new_provider);
} }
catch (const char *msg) catch (const char *msg)
{ {

View File

@ -241,7 +241,7 @@ int PortAudioPlayer::paCallback(const void *inputBuffer, void *outputBuffer,
// Play something // Play something
if (lenAvailable > 0) { if (lenAvailable > 0) {
player->GetProvider()->GetAudioWithVolume(outputBuffer, player->current, lenAvailable, player->GetVolume()); player->provider->GetAudioWithVolume(outputBuffer, player->current, lenAvailable, player->GetVolume());
// Set play position // Set play position
player->current += lenAvailable; player->current += lenAvailable;

View File

@ -79,7 +79,6 @@ public:
virtual void SetCurrentPosition(int64_t pos)=0; virtual void SetCurrentPosition(int64_t pos)=0;
virtual void SetProvider(AudioProvider *new_provider) { provider = new_provider; } virtual void SetProvider(AudioProvider *new_provider) { provider = new_provider; }
AudioProvider *GetProvider() const { return provider; }
}; };
class AudioPlayerFactory : public Factory0<AudioPlayer> { class AudioPlayerFactory : public Factory0<AudioPlayer> {