Skip to content

Commit

Permalink
Make NULL always fail.
Browse files Browse the repository at this point in the history
Change of behaviour with the NULL device. It will now simply fail when trying to open it. The consequence of this is that audio will be disabled which was ultimately why the NULL device exists to start with.
Change the NULL device to report that it supports all audio types, channels and format, so audio processing will never occur

Fixes #8816
  • Loading branch information
jyavenard committed Mar 1, 2011
1 parent e407a00 commit 76b4eec
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 14 deletions.
43 changes: 33 additions & 10 deletions mythtv/libs/libmyth/audio/audiooutputnull.cpp
Expand Up @@ -20,13 +20,13 @@ using namespace std;
#include "mythverbose.h"
#include "audiooutputnull.h"

#define CHANNELS_MIN 1
#define CHANNELS_MAX 8

AudioOutputNULL::AudioOutputNULL(const AudioSettings &settings) :
AudioOutputBase(settings),
pcm_output_buffer_mutex(QMutex::NonRecursive),
current_buffer_size(0),
locked_channels(settings.channels),
locked_format(settings.format),
locked_samplerate(settings.samplerate)
current_buffer_size(0)
{
memset(pcm_output_buffer, 0, sizeof(char) * NULLAUDIO_OUTPUT_BUFFER_SIZE);
InitSettings(settings);
Expand All @@ -41,22 +41,45 @@ AudioOutputNULL::~AudioOutputNULL()

bool AudioOutputNULL::OpenDevice()
{
VERBOSE(VB_GENERAL, "Opening NULL audio device.");
VERBOSE(VB_GENERAL, "Opening NULL audio device, will fail.");

fragment_size = NULLAUDIO_OUTPUT_BUFFER_SIZE / 2;
soundcard_buffer_size = NULLAUDIO_OUTPUT_BUFFER_SIZE;

format = locked_format;
channels = locked_channels;
samplerate = locked_samplerate;

return true;
return false;
}

void AudioOutputNULL::CloseDevice()
{
}

AudioOutputSettings* AudioOutputNULL::GetOutputSettings(bool /*digital*/)
{
// Pretend that we support everything
AudioFormat fmt;
int rate;
AudioOutputSettings *settings = new AudioOutputSettings();

while ((rate = settings->GetNextRate()))
{
settings->AddSupportedRate(rate);
}

while ((fmt = settings->GetNextFormat()))
{
settings->AddSupportedFormat(fmt);
}

for (uint channels = CHANNELS_MIN; channels <= CHANNELS_MAX; channels++)
{
settings->AddSupportedChannels(channels);
}

settings->setPassthrough(-1); // no passthrough

return settings;
}


void AudioOutputNULL::WriteAudio(unsigned char* aubuf, int size)
{
Expand Down
5 changes: 1 addition & 4 deletions mythtv/libs/libmyth/audio/audiooutputnull.h
Expand Up @@ -40,15 +40,12 @@ class AudioOutputNULL : public AudioOutputBase
virtual void CloseDevice(void);
virtual void WriteAudio(unsigned char *aubuf, int size);
virtual int GetBufferedOnSoundcard(void) const;
virtual AudioOutputSettings* GetOutputSettings(bool digital);

private:
QMutex pcm_output_buffer_mutex;
unsigned char pcm_output_buffer[NULLAUDIO_OUTPUT_BUFFER_SIZE];
int current_buffer_size;

int locked_channels;
AudioFormat locked_format;
int locked_samplerate;
};

#endif
Expand Down

0 comments on commit 76b4eec

Please sign in to comment.