Permalink
Browse files

Make NULL always fail.

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...
1 parent e407a00 commit 76b4eec51740ec6e205d3da8badbf6ff0fe71fdc @jyavenard jyavenard committed Mar 1, 2011
Showing with 34 additions and 14 deletions.
  1. +33 −10 mythtv/libs/libmyth/audio/audiooutputnull.cpp
  2. +1 −4 mythtv/libs/libmyth/audio/audiooutputnull.h
@@ -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);
@@ -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)
{
@@ -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

0 comments on commit 76b4eec

Please sign in to comment.