Ticket #4981: 4981-v1.patch

File 4981-v1.patch, 62.7 KB (added by danielk, 12 years ago)

first draft of AudioOutput? cleanup

  • mythplugins/mythmusic/mythmusic/playbackbox.cpp

     
    12861286        return;
    12871287    }
    12881288
    1289     if (gPlayer->getOutput() && gPlayer->getOutput()->GetPause())
     1289    if (gPlayer->getOutput() && gPlayer->getOutput()->IsPaused())
    12901290    {
    12911291        gPlayer->pause();
    12921292        return;
     
    21342134
    21352135        QString time_string = getTimeString(maxTime, 0);
    21362136
    2137         if (gPlayer->getOutput() && gPlayer->getOutput()->GetPause())
     2137        if (gPlayer->getOutput() && gPlayer->getOutput()->IsPaused())
    21382138        {
    21392139            gPlayer->stop();
    21402140        }
  • mythplugins/mythmusic/mythmusic/miniplayer.cpp

     
    181181                if (gPlayer->isPlaying())
    182182                    return;
    183183
    184                 if (gPlayer->getOutput() && gPlayer->getOutput()->GetPause())
     184                if (gPlayer->getOutput() && gPlayer->getOutput()->IsPaused())
    185185                {
    186186                    gPlayer->pause();
    187187                    return;
     
    198198                    if (gPlayer->isPlaying())
    199199                        gPlayer->stop();
    200200
    201                     if (gPlayer->getOutput() && gPlayer->getOutput()->GetPause())
     201                    if (gPlayer->getOutput() &&
     202                        gPlayer->getOutput()->IsPaused())
    202203                    {
    203204                        gPlayer->pause();
    204205                        return;
  • mythplugins/mythmusic/mythmusic/vorbisdecoder.cpp

     
    187187
    188188    if (output())
    189189    {
    190         output()->Reconfigure(16, chan, freq, false /*AC3/DTS pass through*/);
     190        const AudioSettings settings(
     191            16, chan, freq, false /*AC3/DTS pass through*/);
     192        output()->Reconfigure(settings);
    191193        output()->SetSourceBitrate(bitrate);
    192194    }
    193195
  • mythplugins/mythmusic/mythmusic/avfdecoder.cpp

     
    184184
    185185    if (output())
    186186    {
    187         output()->Reconfigure(16, audio_dec->channels, audio_dec->sample_rate,
    188                               false /* AC3/DTS pass through */);
     187        const AudioSettings settings(
     188            16 /*bits*/, audio_dec->channels, audio_dec->sample_rate,
     189            false /* AC3/DTS pass through */);
     190        output()->Reconfigure(settings);
    189191        output()->SetSourceBitrate(audio_dec->bit_rate);
    190192    }
    191193
  • mythplugins/mythmusic/mythmusic/flacdecoder.cpp

     
    150150   
    151151    if (output())
    152152    {
    153         output()->Reconfigure(bitspersample, chan,
    154                               freq, false /* AC3/DTS pass through */);
     153        const AudioSettings settings(
     154            bitspersample, chan, freq, false /* AC3/DTS pass through */);
     155        output()->Reconfigure(settings);
    155156        output()->SetSourceBitrate(44100 * 2 * 16);
    156157    }
    157158}
  • mythplugins/mythmusic/mythmusic/musicplayer.cpp

     
    184184
    185185    if (m_output)
    186186    {
    187         if (m_output->GetPause())
     187        if (m_output->IsPaused())
    188188        {
    189189            pause();
    190190        }
  • mythplugins/mythmusic/mythmusic/cddecoder.cpp

     
    136136
    137137    if (output())
    138138    {
    139         output()->Reconfigure(16, chan, freq, false /* AC3/DTS passthru */);
     139        const AudioSettings settings(
     140            16 /*bits*/, chan, freq, false /* AC3/DTS passthru */);
     141        output()->Reconfigure(settings);
    140142        output()->SetSourceBitrate(44100 * 2 * 16);
    141143    }
    142144
  • mythplugins/mythmusic/mythmusic/maddecoder.cpp

     
    111111
    112112    if (output())
    113113    {
    114         output()->Reconfigure(16, channels, freq, false /*AC3/DTS passthru*/);
     114        const AudioSettings settings(
     115            16, channels, freq, false /* AC3/DTS pass through */);
     116        output()->Reconfigure(settings);
    115117        output()->SetSourceBitrate(bitrate);
    116118    }
    117119
     
    479481        {
    480482            freq = newfreq;
    481483            channels = newchannels;
    482             output()->Reconfigure(16, channels, freq, false /*AC3/DTS passthru*/);
     484            const AudioSettings settings(
     485                16, channels, freq, false /*AC3/DTS passthru*/);
     486            output()->Reconfigure(settings);
    483487        }
    484488        if (newbitrate != bitrate)
    485489        {
  • mythtv/libs/libmythtv/NuppelVideoPlayer.cpp

     
    481481bool NuppelVideoPlayer::IsPaused(bool *is_pause_still_possible) const
    482482{
    483483    bool rbf_playing = (ringBuffer != NULL) && !ringBuffer->isPaused();
    484     bool aud_playing = (audioOutput != NULL) && !audioOutput->GetPause();
     484    bool aud_playing = (audioOutput != NULL) && !audioOutput->IsPaused();
    485485    if (is_pause_still_possible)
    486486    {
    487487        bool decoder_pausing = (0.0f == next_play_speed) && !next_normal_speed;
     
    798798
    799799    if (audioOutput)
    800800    {
    801         audioOutput->Reconfigure(audio_bits, audio_channels,
    802                                  audio_samplerate, audio_passthru,
    803                                  audio_codec);
     801        const AudioSettings settings(
     802            audio_bits, audio_channels, audio_samplerate,
     803            audio_passthru, audio_codec);
     804        audioOutput->Reconfigure(settings);
    804805        errMsg = audioOutput->GetError();
    805806        if (!errMsg.isEmpty())
    806807            audioOutput->SetStretchFactor(audio_stretchfactor);
     
    27262727        videoOutput->ProcessFrame(frame, osd, videoFilters, pipplayer);
    27272728    videofiltersLock.unlock();
    27282729
    2729     if (audioOutput && !audio_paused && audioOutput->GetPause())
     2730    if (audioOutput && !audio_paused && audioOutput->IsPaused())
    27302731        audioOutput->Pause(false);
    27312732
    27322733    AVSync();
  • mythtv/libs/libmyth/audiooutputwin.cpp

     
    7171    }
    7272}
    7373
    74 AudioOutputWin::AudioOutputWin(
    75     QString laudio_main_device,  QString           laudio_passthru_device,
    76     int     laudio_bits,         int               laudio_channels,
    77     int     laudio_samplerate,   AudioOutputSource lsource,
    78     bool    lset_initial_vol,    bool              laudio_passthru) :
    79     AudioOutputBase(laudio_main_device, laudio_passthru_device,
    80                     laudio_bits,        laudio_channels,
    81                     laudio_samplerate,  lsource,
    82                     lset_initial_vol,   laudio_passthru),
     74AudioOutputWin::AudioOutputWin(const AudioSettings &settings) :
     75    AudioOutputBase(settings),
    8376    m_priv(new AudioOutputWinPrivate()),
    8477    m_nPkts(0),
    8578    m_CurrentPkt(0),
    8679    m_OutPkts(NULL)
    8780{
    88     Reconfigure(laudio_bits,       laudio_channels,
    89                 laudio_samplerate, laudio_passthru);
     81    Reconfigure(settings);
    9082
    9183    m_OutPkts = (unsigned char**) calloc(kPacketCnt, sizeof(unsigned char*));
    9284}
  • mythtv/libs/libmyth/audiooutputbase.h

     
    3636class AudioOutputBase : public AudioOutput
    3737{
    3838 public:
    39     AudioOutputBase(QString laudio_main_device,
    40                     QString laudio_passthru_device,
    41                     int laudio_bits,
    42                     int laudio_channels, int laudio_samplerate,
    43                     AudioOutputSource lsource,
    44                     bool lset_initial_vol, bool laudio_passthru);
     39    AudioOutputBase(const AudioSettings &settings);
    4540    virtual ~AudioOutputBase();
    4641
    4742    // reconfigure sound out for new params
    48     virtual void Reconfigure(int   audio_bits,
    49                              int   audio_channels,
    50                              int   audio_samplerate,
    51                              bool  audio_passthru,
    52                              void *audio_codec = NULL);
     43    virtual void Reconfigure(const AudioSettings &settings);
    5344   
    5445    // do AddSamples calls block?
    5546    virtual void SetBlocking(bool blocking);
     
    5849    virtual void SetEffDsp(int dsprate);
    5950
    6051    virtual void SetStretchFactor(float factor);
    61     virtual float GetStretchFactor(void);
     52    virtual float GetStretchFactor(void) const;
    6253
    6354    virtual void Reset(void);
    6455
     
    6758    virtual bool AddSamples(char *buffers[], int samples, long long timecode);
    6859
    6960    virtual void SetTimecode(long long timecode);
    70     virtual bool GetPause(void);
     61    virtual bool IsPaused(void) const { return audio_actually_paused; }
    7162    virtual void Pause(bool paused);
    7263
    7364    // Wait for all data to finish playing
    7465    virtual void Drain(void);
    7566 
    76     virtual int GetAudiotime(void);
     67    virtual int GetAudiotime(void) const;
    7768
    7869    // Send output events showing current progress
    7970    virtual void Status(void);
    8071
    8172    virtual void SetSourceBitrate(int rate);
    8273
    83     virtual void GetBufferStatus(uint &fill, uint &total);
     74    virtual void GetBufferStatus(uint &fill, uint &total) const;
    8475
    8576    //  Only really used by the AudioOutputNULL object
    8677   
     
    9586    virtual void WriteAudio(unsigned char *aubuf, int size) = 0;
    9687    virtual int getSpaceOnSoundcard(void) = 0;
    9788    virtual int getBufferedOnSoundcard(void) = 0;
    98     virtual int GetVolumeChannel(int channel) = 0; // Returns 0-100
    99     virtual void SetVolumeChannel(int channel, int volume) = 0; // range 0-100 for vol
     89    /// You need to call this from any implementation in the dtor.
     90    void KillAudio(void);
    10091
    10192    // The following functions may be overridden, but don't need to be
    10293    virtual bool StartOutputThread(void);
     
    10596    int GetAudioData(unsigned char *buffer, int buf_size, bool fill_buffer);
    10697
    10798    void _AddSamples(void *buffer, bool interleaved, int samples, long long timecode);
    108  
    109     void KillAudio();
     99
    110100    void OutputAudioLoop(void);
    111101    static void *kickoffOutputAudioLoop(void *player);
    112102    void SetAudiotime(void);
    113103    int WaitForFreeSpace(int len);
    114104
    115     int audiolen(bool use_lock); // number of valid bytes in audio buffer
    116     int audiofree(bool use_lock); // number of free bytes in audio buffer
     105    int audiolen(bool use_lock) const; // number of valid bytes in audio buffer
     106    int audiofree(bool use_lock) const; // number of free bytes in audio buffer
    117107
    118108    void UpdateVolume(void);
    119109   
     
    179169    bool audio_thread_exists;
    180170    pthread_t audio_thread;
    181171
    182     pthread_mutex_t audio_buflock; /* adjustments to audiotimecode, waud, and
    183                                       raud can only be made while holding this
    184                                       lock */
    185     pthread_cond_t audio_bufsig;  /* condition is signaled when the buffer
    186                                      gets more free space. Must be holding
    187                                      audio_buflock to use. */
     172    /** adjustments to audiotimecode, waud, and raud can only be made
     173        while holding this lock */
     174    mutable pthread_mutex_t audio_buflock;
    188175
    189     pthread_mutex_t avsync_lock; /* must hold avsync_lock to read or write
    190                                     'audiotime' and 'audiotime_updated' */
     176    /** condition is signaled when the buffer gets more free space.
     177        Must be holding audio_buflock to use. */
     178    pthread_cond_t audio_bufsig;
     179
     180    /** must hold avsync_lock to read or write 'audiotime' and
     181        'audiotime_updated' */
     182    mutable pthread_mutex_t avsync_lock;
     183
    191184    /// timecode of audio leaving the soundcard (same units as timecodes)
    192185    long long audiotime;
    193186    struct timeval audiotime_updated; // ... which was last updated at this time
  • mythtv/libs/libmyth/audiooutputalsa.cpp

     
    1313#define LOC_WARN QString("ALSA, Warning: ")
    1414#define LOC_ERR QString("ALSA, Error: ")
    1515
    16 AudioOutputALSA::AudioOutputALSA(
    17     QString laudio_main_device, QString           laudio_passthru_device,
    18     int     laudio_bits,        int               laudio_channels,
    19     int     laudio_samplerate,  AudioOutputSource lsource,
    20     bool    lset_initial_vol,   bool              laudio_passthru) :
    21     AudioOutputBase(laudio_main_device, laudio_passthru_device,
    22                     laudio_bits,        laudio_channels,
    23                     laudio_samplerate,  lsource,
    24                     lset_initial_vol,   laudio_passthru),
     16AudioOutputALSA::AudioOutputALSA(const AudioSettings &settings) :
     17    AudioOutputBase(settings),
    2518    pcm_handle(NULL),             numbadioctls(0),
    2619    killAudioLock(false),         mixer_handle(NULL),
    2720    mixer_control(QString::null), volume_range_multiplier(1.0f),
    2821    playback_vol_min(0),          playback_vol_max(1)
    2922{
    3023    // Set everything up
    31     Reconfigure(laudio_bits,       laudio_channels,
    32                 laudio_samplerate, laudio_passthru);
     24    Reconfigure(settings);
    3325}
    3426
    3527AudioOutputALSA::~AudioOutputALSA()
     
    477469}
    478470
    479471
    480 int AudioOutputALSA::GetVolumeChannel(int channel)
     472int AudioOutputALSA::GetVolumeChannel(int channel) const
    481473{
    482474    long actual_volume, volume;
    483475
     
    677669    }
    678670}
    679671
    680 void AudioOutputALSA::GetVolumeRange(snd_mixer_elem_t *elem)
     672void AudioOutputALSA::GetVolumeRange(snd_mixer_elem_t *elem) const
    681673{
    682674    snd_mixer_selem_get_playback_volume_range(elem, &playback_vol_min,
    683675                                              &playback_vol_max);
  • mythtv/libs/libmyth/volumebase.cpp

     
    55using namespace std;
    66#include "volumebase.h"
    77
    8 VolumeBase::VolumeBase()
     8VolumeBase::VolumeBase() :
     9    internal_vol(false), volume(80), current_mute_state(MUTE_OFF)
    910{
    10     volume = 80;
    11     current_mute_state=MUTE_OFF;
    12     internal_vol = false;
    13 };
     11}
    1412
    15 int VolumeBase::GetCurrentVolume(void)
     13int VolumeBase::GetCurrentVolume(void) const
    1614{
    1715    return volume;
    1816}
     
    5856    SetMute(current_mute_state == MUTE_OFF);
    5957}
    6058
    61 kMuteState VolumeBase::GetMute(void)
     59kMuteState VolumeBase::GetMute(void) const
    6260{
    6361    return current_mute_state;
    6462}
  • mythtv/libs/libmyth/volumebase.h

     
    2020    VolumeBase();   
    2121    virtual ~VolumeBase() {};
    2222
    23     virtual int GetCurrentVolume(void);
     23    virtual int  GetCurrentVolume(void) const;
    2424    virtual void SetCurrentVolume(int value);
    2525    virtual void AdjustCurrentVolume(int change);
    2626    virtual void SetMute(bool on);
    2727    virtual void ToggleMute(void);
    28     virtual kMuteState GetMute(void);
     28    virtual kMuteState GetMute(void) const;
    2929    virtual kMuteState IterateMutedChannels(void);
    3030
    3131 protected:
    3232
    33     virtual int GetVolumeChannel(int channel) = 0; // Returns 0-100
     33    virtual int GetVolumeChannel(int channel) const = 0; // Returns 0-100
    3434    virtual void SetVolumeChannel(int channel, int volume) = 0; // range 0-100 for vol
    3535
    3636    void UpdateVolume(void);
  • mythtv/libs/libmyth/audiooutputarts.cpp

     
    77#include "mythcontext.h"
    88#include "audiooutputarts.h"
    99
    10 AudioOutputARTS::AudioOutputARTS(
    11     QString laudio_main_device,     QString laudio_passthru_device,
    12     int     laudio_bits,            int     laudio_channels,
    13     int     laudio_samplerate,      AudioOutputSource lsource,
    14     bool    lset_initial_vol,       bool    laudio_passthru) :
    15     AudioOutputBase(laudio_main_device, laudio_passthru_device,
    16                     laudio_bits,        laudio_channels,
    17                     laudio_samplerate,  lsource,
    18                     lset_initial_vol,   laudio_passthru),
     10AudioOutputARTS::AudioOutputARTS(const AudioSettings &settings) :
     11    AudioOutputBase(settings),
    1912    pcm_handle(NULL), buff_size(-1), can_hw_pause(false)
    2013{
    2114    // Set everything up
    22     Reconfigure(laudio_bits,       laudio_channels,
    23                 laudio_samplerate, laudio_passthru);
     15    Reconfigure(settings);
    2416}
    2517
    2618AudioOutputARTS::~AudioOutputARTS()
     
    8880    }
    8981}
    9082
    91 inline int AudioOutputARTS::getBufferedOnSoundcard(void)
     83int AudioOutputARTS::getBufferedOnSoundcard(void)
    9284{
    9385    return buff_size - getSpaceOnSoundcard();
    9486}
    9587
    96 inline int AudioOutputARTS::getSpaceOnSoundcard(void)
     88int AudioOutputARTS::getSpaceOnSoundcard(void)
    9789{
    9890    return arts_stream_get(pcm_handle, ARTS_P_BUFFER_SIZE);
    9991}
    10092
    101 int AudioOutputARTS::GetVolumeChannel(int /*channel*/)
     93int AudioOutputARTS::GetVolumeChannel(int /*channel*/) const
    10294{
    10395    // Do nothing
    10496    return 100;
  • mythtv/libs/libmyth/volumecontrol.h

     
    1 #ifndef VOLUMECONTROL_H_
    2 #define VOLUMECONTROL_H_
    3 
    4 typedef enum { MUTE_OFF=0, MUTE_LEFT, MUTE_RIGHT, MUTE_BOTH } kMuteState;
    5 
    6 class VolumeControl
    7 {
    8   public:
    9     VolumeControl(bool setstartingvolume = true);
    10    ~VolumeControl();
    11 
    12     int GetCurrentVolume(void);
    13     void SetCurrentVolume(int value);
    14     void AdjustCurrentVolume(int change);
    15 
    16     void SetMute(bool on);
    17     void ToggleMute(void);
    18     bool GetMute(void) { return mute; }
    19     kMuteState IterateMutedChannels(void);
    20 
    21   private:
    22     int mixerfd;
    23     int volume;
    24     int internal_volume;
    25     int control;
    26 
    27     bool mute;
    28     kMuteState current_mute_state;
    29 };
    30 
    31 #endif
  • mythtv/libs/libmyth/audiooutputnull.cpp

     
    2020#include "mythcontext.h"
    2121#include "audiooutputnull.h"
    2222
    23 AudioOutputNULL::AudioOutputNULL(
    24     QString laudio_main_device, QString           laudio_passthru_device,
    25     int     laudio_bits,        int               laudio_channels,
    26     int     laudio_samplerate,  AudioOutputSource lsource,
    27     bool    lset_initial_vol,   bool              laudio_passthru) :
    28     AudioOutputBase(laudio_main_device, laudio_passthru_device,
    29                     laudio_bits,        laudio_channels,
    30                     laudio_samplerate,  lsource,
    31                     lset_initial_vol,   laudio_passthru),
     23AudioOutputNULL::AudioOutputNULL(const AudioSettings &settings) :
     24    AudioOutputBase(settings),
    3225    pcm_output_buffer_mutex(false),
    3326    current_buffer_size(0),
    34     locked_audio_channels(laudio_channels),
    35     locked_audio_bits(laudio_bits),
    36     locked_audio_samplerate(laudio_samplerate)
     27    locked_audio_channels(settings.channels),
     28    locked_audio_bits(settings.bits),
     29    locked_audio_samplerate(settings.samplerate)
    3730{
    3831    bzero(pcm_output_buffer, sizeof(char) * NULLAUDIO_OUTPUT_BUFFER_SIZE);
    3932
    40     Reconfigure(laudio_bits,       laudio_channels,
    41                 laudio_samplerate, laudio_passthru);
     33    Reconfigure(settings);
    4234}
    4335
    4436AudioOutputNULL::~AudioOutputNULL()
  • mythtv/libs/libmyth/audiooutputjack.h

     
    1212class AudioOutputJACK : public AudioOutputBase
    1313{
    1414  public:
    15     AudioOutputJACK(QString laudio_main_device,
    16                     QString laudio_passthru_device,
    17                     int laudio_bits,
    18                     int laudio_channels, int laudio_samplerate,
    19                     AudioOutputSource lsource,
    20                     bool lset_initial_vol, bool laudio_passthru);
     15    AudioOutputJACK(const AudioSettings &settings);
    2116    virtual ~AudioOutputJACK();
    2217   
    2318    // Volume control
    24     virtual int GetVolumeChannel(int channel); // Returns 0-100
     19    virtual int GetVolumeChannel(int channel) const; // Returns 0-100
    2520    virtual void SetVolumeChannel(int channel, int volume); // range 0-100 for vol
    2621 
    2722  protected:
  • mythtv/libs/libmyth/audiooutputca.cpp

     
    111111 *  \brief Implements Core Audio (Mac OS X Hardware Abstraction Layer) output.
    112112 */
    113113
    114 AudioOutputCA::AudioOutputCA(QString laudio_main_device,
    115                              QString laudio_passthru_device,
    116                              int laudio_bits, int laudio_channels,
    117                              int laudio_samplerate,
    118                              AudioOutputSource lsource,
    119                              bool lset_initial_vol, bool laudio_passthru)
    120     : AudioOutputBase(laudio_main_device, laudio_passthru_device,
    121                       laudio_bits,        laudio_channels,
    122                       laudio_samplerate,  lsource,
    123                       lset_initial_vol,   laudio_passthru),
     114AudioOutputCA::AudioOutputCA(const AudioSettings &settings)
     115    : AudioOutputBase(settings),
    124116      d(new CoreAudioData(this))
    125117{
    126     Reconfigure(laudio_bits, laudio_channels,
    127                 laudio_samplerate, laudio_passthru);
     118    Reconfigure(settings);
    128119}
    129120
    130121AudioOutputCA::~AudioOutputCA()
     
    333324/** Reimplement the base class's version of GetAudiotime()
    334325 *  so that we don't use gettimeofday or pthread mutexes.
    335326 */
    336 int AudioOutputCA::GetAudiotime(void)
     327int AudioOutputCA::GetAudiotime(void) const
    337328{
    338329    int ret;
    339330
  • mythtv/libs/libmyth/audiooutputwin.h

     
    1313{
    1414  friend class AudioOutputWinPrivate;
    1515  public:
    16     AudioOutputWin(QString laudio_main_device,
    17                    QString laudio_passthru_device,
    18                    int laudio_bits,
    19                    int laudio_channels, int laudio_samplerate,
    20                    AudioOutputSource lsource,
    21                    bool lset_initial_vol, bool laudio_passthru);
     16    AudioOutputWin(const AudioSettings &settings);
    2217    virtual ~AudioOutputWin();
    2318
    2419    // Volume control
    25     virtual int  GetVolumeChannel(int channel);
     20    virtual int  GetVolumeChannel(int channel) const;
    2621    virtual void SetVolumeChannel(int channel, int volume);
    2722
    2823  protected:
  • mythtv/libs/libmyth/volumecontrol.cpp

     
    1 #include "volumecontrol.h"
    2 #include "config.h"
    3 
    4 #ifdef USING_OSS
    5     #include <sys/ioctl.h>
    6     #ifdef HAVE_SYS_SOUNDCARD_H
    7         #include <sys/soundcard.h>
    8     #elif HAVE_SOUNDCARD_H
    9         #include <soundcard.h>
    10     #endif
    11 #endif
    12 
    13 #include <fcntl.h>
    14 #include <cstdio>
    15 #include <unistd.h>
    16 
    17 #include <iostream>
    18 using namespace std;
    19 
    20 #include "mythcontext.h"
    21 
    22 VolumeControl::VolumeControl(bool setstartingvolume)
    23 {
    24     (void) setstartingvolume;
    25 
    26     mixerfd = -1;
    27     volume = 0;
    28 
    29 #ifdef USING_OSS
    30     mute = false;
    31     current_mute_state = MUTE_OFF;
    32  
    33     QString device = gContext->GetSetting("MixerDevice", "/dev/mixer");
    34     mixerfd = open(device.ascii(), O_RDONLY);
    35 
    36     QString controlLabel = gContext->GetSetting("MixerControl", "PCM");
    37 
    38     if (controlLabel == "Master")
    39     {
    40         control = SOUND_MIXER_VOLUME;
    41     }
    42     else
    43     {
    44         control = SOUND_MIXER_PCM;
    45     }
    46 
    47     if (mixerfd < 0)
    48     {
    49         cerr << "Unable to open mixer: '" << device << "'\n";
    50         return;
    51     }
    52 
    53     int realvol;
    54 
    55     if (setstartingvolume)
    56     {
    57         volume = gContext->GetNumSetting("MasterMixerVolume", 80);
    58         realvol = (volume << 8) + volume;
    59         int ret = ioctl(mixerfd, MIXER_WRITE(SOUND_MIXER_VOLUME), &realvol);
    60         if (ret < 0)
    61             perror("Setting master volume: ");
    62 
    63         volume = gContext->GetNumSetting("PCMMixerVolume", 80);
    64         realvol = (volume << 8) + volume;
    65         ret = ioctl(mixerfd, MIXER_WRITE(SOUND_MIXER_PCM), &realvol);
    66         if (ret < 0)
    67             perror("Setting PCM volume: ");
    68     }
    69 
    70     internal_volume = GetCurrentVolume();
    71 #endif
    72 }
    73 
    74 VolumeControl::~VolumeControl()
    75 {
    76     if (mixerfd >= 0)
    77         close(mixerfd);
    78 }
    79 
    80 int VolumeControl::GetCurrentVolume(void)
    81 {
    82 #ifdef USING_OSS
    83     int realvol;
    84    
    85     if (mute)
    86     {
    87         return internal_volume;
    88     }
    89     else
    90     {
    91         int ret = ioctl(mixerfd, MIXER_READ(control), &realvol);
    92         if (ret < 0)
    93         {
    94             perror("Reading PCM volume: ");
    95         }
    96         volume = realvol & 0xff; // just use the left channel
    97         internal_volume = volume;
    98     }
    99 #endif   
    100 
    101     return volume;
    102 }
    103 
    104 void VolumeControl::SetCurrentVolume(int value)
    105 {
    106     (void) value;
    107 
    108 #ifdef USING_OSS
    109     volume = value;
    110 
    111     if (volume > 100)
    112         volume = 100;
    113     if (volume < 0)
    114         volume = 0;
    115 
    116     internal_volume = volume;
    117     if (mixerfd >= 0)
    118     {
    119         if (!mute)
    120         {
    121             int realvol = (volume << 8) + volume;
    122             int ret = ioctl(mixerfd, MIXER_WRITE(control), &realvol);
    123             if (ret < 0)
    124                 perror("Setting volume: ");
    125         }
    126     }
    127 
    128     //mute = false;
    129 
    130     QString controlLabel = gContext->GetSetting("MixerControl", "PCM");
    131     controlLabel += "MixerVolume";
    132     gContext->SaveSetting(controlLabel, volume);
    133 #endif
    134 }
    135 
    136 void VolumeControl::AdjustCurrentVolume(int change)
    137 {
    138     int newvol = GetCurrentVolume() + change;
    139 
    140     SetCurrentVolume(newvol);
    141 }
    142 
    143 void VolumeControl::SetMute(bool on)
    144 {
    145     (void) on;
    146 
    147 #ifdef USING_OSS
    148     int realvol;
    149 
    150     if (on)
    151     {
    152         realvol = 0;
    153     }
    154     else
    155     {
    156         realvol = (internal_volume << 8) + internal_volume;
    157     }
    158     if (mixerfd >= 0)
    159     {
    160         int ret = ioctl(mixerfd, MIXER_WRITE(control), &realvol);
    161         if (ret < 0)
    162             perror("Setting mute:");
    163     }
    164 
    165     mute = on;
    166 #endif
    167 }
    168 
    169 void VolumeControl::ToggleMute(void)
    170 {
    171     SetMute(!mute);
    172 }
    173 
    174 kMuteState VolumeControl::IterateMutedChannels(void)
    175 {
    176 // current_mute_state is initialized to "MUTE_OFF".  If individual muting
    177 // is enabled, each call to SetMute will advance to the next state:
    178 // MUTE_OFF -> MUTE_LEFT -> MUTE_RIGHT -> MUTE_BOTH -> MUTE_OFF
    179 #ifdef USING_OSS
    180     int realvol;
    181 
    182     switch (current_mute_state)
    183     {
    184        case MUTE_OFF:
    185            current_mute_state = MUTE_LEFT;
    186            realvol = (internal_volume << 8) + 0;
    187            break;
    188        case MUTE_LEFT:
    189            current_mute_state = MUTE_RIGHT;
    190            realvol = (0 << 8) + internal_volume;
    191            break;
    192        case MUTE_RIGHT:
    193            current_mute_state = MUTE_BOTH;
    194            realvol = 0;
    195            break;
    196        case MUTE_BOTH:
    197            current_mute_state = MUTE_OFF;
    198            realvol = (internal_volume << 8) + internal_volume;
    199            break;
    200     }
    201 
    202     if (mixerfd >= 0)
    203     {
    204         int ret = ioctl(mixerfd, MIXER_WRITE(control), &realvol);
    205         if (ret < 0)
    206             perror("IterateMutedChannels:");
    207     }
    208 #endif // USING_OSS
    209 
    210     return current_mute_state;
    211 }
  • mythtv/libs/libmyth/audiooutputjack.cpp

     
    2121#include "bio2jack.h"
    2222}
    2323
    24 AudioOutputJACK::AudioOutputJACK(
    25     QString laudio_main_device, QString           laudio_passthru_device,
    26     int     laudio_bits,        int               laudio_channels,
    27     int     laudio_samplerate,  AudioOutputSource lsource,
    28     bool    lset_initial_vol,   bool              laudio_passthru) :
    29     AudioOutputBase(laudio_main_device, laudio_passthru_device,
    30                     laudio_bits,        laudio_channels,
    31                     laudio_samplerate,  lsource,
    32                     lset_initial_vol,   laudio_passthru),
    33     audioid(-1)
     24AudioOutputJACK::AudioOutputJACK(const AudioSettings &settings) :
     25    AudioOutputBase(settings), audioid(-1)
    3426{
    3527    // Initialise the Jack output layer
    3628    JACK_Init();
    3729
    3830    // Set everything up
    39     Reconfigure(laudio_bits, laudio_channels,
    40                 laudio_samplerate, laudio_passthru);
     31    Reconfigure(settings);
    4132}
    4233
    4334AudioOutputJACK::~AudioOutputJACK()
     
    6859    audioid = -1;
    6960    while (timer.elapsed() < 2000 && audioid == -1)
    7061    {
    71         err = JACK_OpenEx(&audioid, 16, (unsigned long *) &audio_samplerate,
     62        unsigned long audio_samplerate_long = audio_samplerate;
     63        err = JACK_OpenEx(&audioid, 16, &audio_samplerate_long,
    7264                          audio_channels, audio_channels, &jack_port_name,
    7365                          jack_port_name_count, jack_port_flags);
     66        audio_samplerate = audio_samplerate_long;
    7467        if (err == 1) {
    7568            Error(QString("Error connecting to jackd:%1.  Is it running?")
    7669                  .arg(audio_main_device));
     
    7972            // need to resample
    8073            VERBOSE(VB_AUDIO, QString("Failed to open device at"
    8174                                      " requested samplerate.  Retrying"));
    82             err = JACK_OpenEx(&audioid, 16, (unsigned long *) &audio_samplerate,
     75            unsigned long audio_samplerate_long = audio_samplerate;
     76            err = JACK_OpenEx(&audioid, 16, &audio_samplerate_long,
    8377                              audio_channels, audio_channels, &jack_port_name,
    8478                              jack_port_name_count, jack_port_flags);
     79            audio_samplerate = audio_samplerate_long;
    8580        } else if (err == ERR_PORT_NOT_FOUND) {
    8681            VERBOSE(VB_IMPORTANT, QString("Error opening audio device (%1), "
    8782                    " Port not found.").arg(audio_main_device));
     
    184179    JACK_SetAllVolume(audioid, volume);
    185180}
    186181
    187 int AudioOutputJACK::GetVolumeChannel(int channel)
     182int AudioOutputJACK::GetVolumeChannel(int channel) const
    188183{
    189184    unsigned int vol = 0;
    190185   
  • mythtv/libs/libmyth/audiooutputoss.h

     
    1313class AudioOutputOSS : public AudioOutputBase
    1414{
    1515public:
    16     AudioOutputOSS(QString audiodevice, QString passthrudevice,
    17                    int laudio_bits,
    18                    int laudio_channels, int laudio_samplerate,
    19                    AudioOutputSource source, bool set_initial_vol,
    20                    bool laudio_passthru);
     16    AudioOutputOSS(const AudioSettings &settings);
    2117    virtual ~AudioOutputOSS();
    2218
    2319    // Volume control
    24     virtual int GetVolumeChannel(int channel); // Returns 0-100
     20    virtual int GetVolumeChannel(int channel) const; // Returns 0-100
    2521    virtual void SetVolumeChannel(int channel, int volume); // range 0-100 for vol
    2622
    2723protected:
  • mythtv/libs/libmyth/audiooutputbase.cpp

     
    2323#define LOC QString("AO: ")
    2424#define LOC_ERR QString("AO, ERROR: ")
    2525
    26 AudioOutputBase::AudioOutputBase(
    27     QString laudio_main_device,    QString           laudio_passthru_device,
    28     int     /*laudio_bits*/,       int               /*laudio_channels*/,
    29     int     /*laudio_samplerate*/, AudioOutputSource lsource,
    30     bool    lset_initial_vol,      bool              /*laudio_passthru*/) :
    31 
     26AudioOutputBase::AudioOutputBase(const AudioSettings &settings) :
    3227    effdsp(0),                  effdspstretched(0),
    3328    audio_channels(-1),         audio_bytes_per_sample(0),
    3429    audio_bits(-1),             audio_samplerate(-1),
    3530    audio_buffer_unused(0),
    3631    fragment_size(0),           soundcard_buffer_size(0),
    3732
    38     audio_main_device(QDeepCopy<QString>(laudio_main_device)),
    39     audio_passthru_device(QDeepCopy<QString>(laudio_passthru_device)),
     33    audio_main_device(settings.GetMainDevice()),
     34    audio_passthru_device(settings.GetPassthruDevice()),
    4035    audio_passthru(false),      audio_stretchfactor(1.0f),
    4136
    4237    audio_codec(NULL),
    43     source(lsource),            killaudio(false),
     38    source(settings.source),    killaudio(false),
    4439
    4540    pauseaudio(false),          audio_actually_paused(false),
    4641    was_paused(false),
    4742
    48     set_initial_vol(lset_initial_vol),
     43    set_initial_vol(settings.set_initial_vol),
    4944    buffer_output_data_for_use(false),
    5045    need_resampler(false),
    5146
     
    9287
    9388AudioOutputBase::~AudioOutputBase()
    9489{
    95     // Make sure you call the next line in your concrete class to ensure everything is shutdown correctly.
    96     // Cant be called here due to use of virtual functions
    97     // KillAudio();
     90    if (!killaudio)
     91    {
     92        VERBOSE(VB_IMPORTANT,
     93                "Programmer Error: "
     94                "~AudioOutputBase called, but KillAudio has not been called!");
     95    }
    9896   
    9997    pthread_mutex_destroy(&audio_buflock);
    10098    pthread_mutex_destroy(&avsync_lock);
     
    179177    pthread_mutex_unlock(&audio_buflock);
    180178}
    181179
    182 float AudioOutputBase::GetStretchFactor(void)
     180float AudioOutputBase::GetStretchFactor(void) const
    183181{
    184182    return audio_stretchfactor;
    185183}
    186184
    187 void AudioOutputBase::Reconfigure(int laudio_bits, int laudio_channels,
    188                                   int laudio_samplerate, bool laudio_passthru,
    189                                   void *laudio_codec)
     185void AudioOutputBase::Reconfigure(const AudioSettings &orig_settings)
    190186{
     187    AudioSettings settings = orig_settings;
     188
    191189    int codec_id = CODEC_ID_NONE;
    192190    int lcodec_id = CODEC_ID_NONE;
    193191    int lcchannels = 0;
    194192    int cchannels = 0;
    195     int lsource_audio_channels = laudio_channels;
     193    int lsource_audio_channels = settings.channels;
    196194    bool lneeds_upmix = false;
    197195
    198     if (laudio_codec)
     196    if (settings.codec)
    199197    {
    200         lcodec_id = ((AVCodecContext*)laudio_codec)->codec_id;
    201         laudio_bits = 16;
    202         laudio_channels = 2;
    203         lsource_audio_channels = laudio_channels;
    204         laudio_samplerate = 48000;
    205         lcchannels = ((AVCodecContext*)laudio_codec)->channels;
     198        lcodec_id = ((AVCodecContext*)settings.codec)->codec_id;
     199        settings.bits = 16;
     200        settings.channels = 2;
     201        lsource_audio_channels = settings.channels;
     202        settings.samplerate = 48000;
     203        lcchannels = ((AVCodecContext*)settings.codec)->channels;
    206204    }
    207205
    208206    if (audio_codec)
     
    212210    }
    213211
    214212    if ((configured_audio_channels == 6) &&
    215         !(laudio_codec || audio_codec))
     213        !(settings.codec || audio_codec))
    216214    {
    217         laudio_channels = configured_audio_channels;
     215        settings.channels = configured_audio_channels;
    218216        lneeds_upmix = true;
    219217        VERBOSE(VB_AUDIO,LOC + "Needs upmix");
    220218    }
    221219
    222220    ClearError();
    223     bool general_deps = (laudio_bits == audio_bits &&
    224         laudio_channels == audio_channels &&
    225         laudio_samplerate == audio_samplerate && !need_resampler &&
    226         laudio_passthru == audio_passthru &&
     221    bool general_deps = (settings.bits == audio_bits &&
     222        settings.channels == audio_channels &&
     223        settings.samplerate == audio_samplerate && !need_resampler &&
     224        settings.use_passthru == audio_passthru &&
    227225        lneeds_upmix == needs_upmix &&
    228226        lcodec_id == codec_id && lcchannels == cchannels);
    229227    bool upmix_deps =
     
    252250    waud = raud = 0;
    253251    audio_actually_paused = false;
    254252   
    255     bool redo_stretch = (pSoundStretch && audio_channels != laudio_channels);
    256     audio_channels = laudio_channels;
     253    bool redo_stretch = (pSoundStretch && audio_channels != settings.channels);
     254    audio_channels = settings.channels;
    257255    source_audio_channels = lsource_audio_channels;
    258     audio_bits = laudio_bits;
    259     audio_samplerate = laudio_samplerate;
    260     audio_codec = (AVCodecContext*)laudio_codec;
    261     audio_passthru = laudio_passthru;
     256    audio_bits = settings.bits;
     257    audio_samplerate = settings.samplerate;
     258    audio_codec = (AVCodecContext*)settings.codec;
     259    audio_passthru = settings.use_passthru;
    262260    needs_upmix = lneeds_upmix;
    263261
    264262    if (audio_bits != 8 && audio_bits != 16)
     
    316314
    317315    // NOTE: this won't do anything as above samplerate vars are set equal
    318316    // Check if we need the resampler
    319     if (audio_samplerate != laudio_samplerate)
     317    if (audio_samplerate != settings.samplerate)
    320318    {
    321319        int error;
    322320        VERBOSE(VB_GENERAL, LOC + QString("Using resampler. From: %1 to %2")
    323                                .arg(laudio_samplerate).arg(audio_samplerate));
     321                               .arg(settings.samplerate).arg(audio_samplerate));
    324322        src_ctx = src_new (SRC_SINC_BEST_QUALITY, audio_channels, &error);
    325323        if (error)
    326324        {
     
    330328            pthread_mutex_unlock(&audio_buflock);
    331329            return;
    332330        }
    333         src_data.src_ratio = (double) audio_samplerate / laudio_samplerate;
     331        src_data.src_ratio = (double) audio_samplerate / settings.samplerate;
    334332        src_data.data_in = src_in;
    335333        src_data.data_out = src_out;
    336334        src_data.output_frames = 16384*6;
     
    486484    killAudioLock.unlock();
    487485}
    488486
    489 
    490 bool AudioOutputBase::GetPause(void)
    491 {
    492     return audio_actually_paused;
    493 }
    494 
    495487void AudioOutputBase::Pause(bool paused)
    496488{
    497489    VERBOSE(VB_AUDIO, LOC + QString("Pause %0").arg(paused));
     
    540532    this->blocking = blocking;
    541533}
    542534
    543 int AudioOutputBase::audiolen(bool use_lock)
     535int AudioOutputBase::audiolen(bool use_lock) const
    544536{
    545537    /* Thread safe, returns the number of valid bytes in the audio buffer */
    546538    int ret;
     
    559551    return ret;
    560552}
    561553
    562 int AudioOutputBase::audiofree(bool use_lock)
     554int AudioOutputBase::audiofree(bool use_lock) const
    563555{
    564556    return AUDBUFSIZE - audiolen(use_lock) - 1;
    565557    /* There is one wasted byte in the buffer. The case where waud = raud is
     
    567559       be is AUDBUFSIZE - 1. */
    568560}
    569561
    570 int AudioOutputBase::GetAudiotime(void)
     562int AudioOutputBase::GetAudiotime(void) const
    571563{
    572564    /* Returns the current timecode of audio leaving the soundcard, based
    573565       on the 'audiotime' computed earlier, and the delay since it was computed.
     
    11201112    }
    11211113}
    11221114
    1123 void AudioOutputBase::GetBufferStatus(uint &fill, uint &total)
     1115void AudioOutputBase::GetBufferStatus(uint &fill, uint &total) const
    11241116{
    11251117    fill = AUDBUFSIZE - audiofree(true);
    11261118    total = AUDBUFSIZE;
  • mythtv/libs/libmyth/audiooutput.cpp

     
    1 #include <qstring.h>
    21#include <cstdio>
    32#include <cstdlib>
    43
     
    3130#include "audiooutputjack.h"
    3231#endif
    3332
    34 AudioOutput *AudioOutput::OpenAudio(QString main_device,
    35                                     QString passthru_device,
    36                                     int audio_bits,
    37                                     int audio_channels, int audio_samplerate,
    38                                     AudioOutputSource source,
    39                                     bool set_initial_vol, bool audio_passthru)
     33AudioOutput *AudioOutput::OpenAudio(
     34    const QString &main_device,
     35    const QString &passthru_device,
     36    int audio_bits, int audio_channels, int audio_samplerate,
     37    AudioOutputSource source,
     38    bool set_initial_vol, bool audio_passthru)
    4039{
    41     if (passthru_device.isEmpty() || passthru_device.lower() == "default")
    42         passthru_device = main_device;
     40    AudioSettings settings(
     41        main_device, passthru_device, audio_bits,
     42        audio_channels, audio_samplerate, source,
     43        set_initial_vol, audio_passthru);
    4344
     45    settings.FixPassThrough();
     46
    4447    if (main_device.startsWith("ALSA:"))
    4548    {
    4649#ifdef USE_ALSA
    47         return new AudioOutputALSA(main_device.remove(0, 5),
    48                                    passthru_device.remove(0, 5), audio_bits,
    49                                    audio_channels, audio_samplerate, source,
    50                                    set_initial_vol, audio_passthru);
     50        settings.TrimType();
     51        return new AudioOutputALSA(settings);
    5152#else
    5253        VERBOSE(VB_IMPORTANT, "Audio output device is set to an ALSA device "
    5354                              "but ALSA support is not compiled in!");
     
    5657    }
    5758    else if (main_device.startsWith("NULL"))
    5859    {
    59         return new AudioOutputNULL(main_device, passthru_device, audio_bits,
    60                                    audio_channels, audio_samplerate, source,
    61                                    set_initial_vol, audio_passthru);
     60        return new AudioOutputNULL(settings);
    6261    }
    6362    else if (main_device.startsWith("ARTS:"))
    6463    {
    6564#ifdef USE_ARTS
    66         return new AudioOutputARTS(main_device.remove(0, 5),
    67                                    passthru_device.remove(0, 5), audio_bits,
    68                                    audio_channels, audio_samplerate, source,
    69                                    set_initial_vol, audio_passthru);
     65        settings.TrimType();
     66        return new AudioOutputARTS(settings);
    7067#else
    7168        VERBOSE(VB_IMPORTANT, "Audio output device is set to an ARTS device "
    7269                              "but ARTS support is not compiled in!");
     
    7673    else if (main_device.startsWith("JACK:"))
    7774    {
    7875#ifdef USE_JACK
    79         return new AudioOutputJACK(main_device.remove(0, 5),
    80                                    passthru_device.remove(0, 5), audio_bits,
    81                                    audio_channels, audio_samplerate, source,
    82                                    set_initial_vol, audio_passthru);
     76        settings.TrimType();
     77        return new AudioOutputJACK(settings);
    8378#else
    8479        VERBOSE(VB_IMPORTANT, "Audio output device is set to a JACK device "
    8580                              "but JACK support is not compiled in!");
     
    8984    else if (main_device.startsWith("DirectX:"))
    9085    {
    9186#ifdef USING_DIRECTX
    92         return new AudioOutputDX(main_device, passthru_device, audio_bits,
    93                                  audio_channels, audio_samplerate, source,
    94                                  set_initial_vol, audio_passthru);
     87        return new AudioOutputDX(settings);
    9588#else
    9689        VERBOSE(VB_IMPORTANT, "Audio output device is set to DirectX device "
    9790                              "but DirectX support is not compiled in!");
     
    10194    else if (main_device.startsWith("Windows:"))
    10295    {
    10396#ifdef USING_WINAUDIO
    104         return new AudioOutputWin(main_device, passthru_device, audio_bits,
    105                                   audio_channels, audio_samplerate, source,
    106                                   set_initial_vol, audio_passthru);
     97        return new AudioOutputWin(settings);
    10798#else
    10899        VERBOSE(VB_IMPORTANT, "Audio output device is set to a Windows device "
    109100                              "but Windows support is not compiled in!");
     
    112103    }
    113104#if defined(USING_OSS)
    114105    else
    115         return new AudioOutputOSS(main_device, passthru_device, audio_bits,
    116                                   audio_channels, audio_samplerate, source,
    117                                   set_initial_vol, audio_passthru);
     106        return new AudioOutputOSS(settings);
    118107#elif defined(CONFIG_DARWIN)
    119108    else
    120         return new AudioOutputCA(main_device, passthru_device, audio_bits,
    121                                  audio_channels, audio_samplerate, source,
    122                                  set_initial_vol, audio_passthru);
     109        return new AudioOutputCA(settings);
    123110#endif
    124111
    125112    VERBOSE(VB_IMPORTANT, "No useable audio output driver found.");
     
    133120{
    134121}
    135122
     123void AudioOutput::Error(const QString &msg)
     124{
     125    lastError = QDeepCopy<QString>(msg);
     126    VERBOSE(VB_IMPORTANT, "AudioOutput Error: " + lastError);
     127}
    136128
     129void AudioOutput::Warn(const QString &msg)
     130{
     131    lastWarn = QDeepCopy<QString>(msg);
     132    VERBOSE(VB_IMPORTANT, "AudioOutput Warning: " + lastWarn);
     133}
     134
     135void AudioOutput::ClearError(void)
     136{
     137    lastError = QString::null;
     138}
     139
     140void AudioOutput::ClearWarning(void)
     141{
     142    lastWarn = QString::null;
     143}
     144
  • mythtv/libs/libmyth/libmyth.pro

     
    1111
    1212# Input
    1313HEADERS += audiooutput.h audiooutputbase.h audiooutputnull.h
    14 HEADERS += audiooutputdigitalencoder.h
     14HEADERS += audiooutputdigitalencoder.h audiosettings.cpp
    1515HEADERS += backendselect.h dbsettings.h dialogbox.h
    1616HEADERS += DisplayRes.h DisplayResScreen.h exitcodes.h
    1717HEADERS += generictree.h httpcomms.h langsettings.h lcddevice.h
     
    2323HEADERS += oldsettings.h output.h qmdcodec.h remotefile.h
    2424HEADERS += screensaver.h screensaver-null.h settings.h themeinfo.h
    2525HEADERS += uilistbtntype.h uitypes.h util.h util-x11.h
    26 HEADERS += volumebase.h volumecontrol.h virtualkeyboard.h visual.h xmlparse.h
     26HEADERS += volumebase.h virtualkeyboard.h visual.h xmlparse.h
    2727HEADERS += mythhdd.h mythcdrom.h storagegroup.h dbutil.h
    2828HEADERS += compat.h
    2929
    3030SOURCES += audiooutput.cpp audiooutputbase.cpp audiooutputnull.cpp
    31 SOURCES += audiooutputdigitalencoder.cpp
     31SOURCES += audiooutputdigitalencoder.cpp audiosettings.cpp
    3232SOURCES += backendselect.cpp dbsettings.cpp dialogbox.cpp
    3333SOURCES += DisplayRes.cpp DisplayResScreen.cpp
    3434SOURCES += generictree.cpp httpcomms.cpp langsettings.cpp lcddevice.cpp
     
    4040SOURCES += oldsettings.cpp output.cpp qmdcodec.cpp remotefile.cpp
    4141SOURCES += screensaver.cpp screensaver-null.cpp settings.cpp themeinfo.cpp
    4242SOURCES += uilistbtntype.cpp uitypes.cpp util.cpp util-x11.cpp
    43 SOURCES += volumebase.cpp volumecontrol.cpp virtualkeyboard.cpp xmlparse.cpp
     43SOURCES += volumebase.cpp virtualkeyboard.cpp xmlparse.cpp
    4444SOURCES += mythhdd.cpp mythcdrom.cpp storagegroup.cpp dbutil.cpp
    4545
    4646INCLUDEPATH += ../libmythsamplerate ../libmythsoundtouch ../libmythfreesurround
     
    7070inc.files  = dialogbox.h lcddevice.h mythcontext.h mythdbcon.h mythverbose.h
    7171inc.files += mythwidgets.h remotefile.h util.h oldsettings.h volumecontrol.h
    7272inc.files += settings.h uitypes.h xmlparse.h mythplugin.h mythdialogs.h
    73 inc.files += audiooutput.h inetcomms.h httpcomms.h mythmedia.h mythwizard.h
     73inc.files += audiooutput.h audiosettings.h
     74inc.files += inetcomms.h httpcomms.h mythmedia.h mythwizard.h
    7475inc.files += uilistbtntype.h generictree.h managedlist.h mythmediamonitor.h
    7576inc.files += visual.h volumebase.h output.h langsettings.h qmdcodec.h
    7677inc.files += exitcodes.h mythconfig.h mythconfig.mak virtualkeyboard.h
  • mythtv/libs/libmyth/audiooutputca.h

     
    1818class AudioOutputCA : public AudioOutputBase
    1919{
    2020public:
    21     AudioOutputCA(QString laudio_main_device,
    22                   QString laudio_passthru_device,
    23                   int laudio_bits,
    24                   int laudio_channels, int laudio_samplerate,
    25                   AudioOutputSource lsource,
    26                   bool lset_initial_vol, bool laudio_passthru);
     21    AudioOutputCA(const AudioSettings &settings);
    2722    virtual ~AudioOutputCA();
    2823   
    29     virtual int GetAudiotime(void);
     24    virtual int GetAudiotime(void) const;
    3025    void        SetAudiotime(void);
    3126
    3227    // callback for delivering audio to output device
  • mythtv/libs/libmyth/audiooutputoss.cpp

     
    2525#include "audiooutputoss.h"
    2626#include "util.h"
    2727
    28 AudioOutputOSS::AudioOutputOSS(
    29     QString laudio_main_device, QString           laudio_passthru_device,
    30     int     laudio_bits,        int               laudio_channels,
    31     int     laudio_samplerate,  AudioOutputSource lsource,
    32     bool    lset_initial_vol,   bool              laudio_passthru) :
    33     AudioOutputBase(laudio_main_device, laudio_passthru_device,
    34                     laudio_bits,        laudio_channels,
    35                     laudio_samplerate,  lsource,
    36                     lset_initial_vol,   laudio_passthru),
     28AudioOutputOSS::AudioOutputOSS(const AudioSettings &settings) :
     29    AudioOutputBase(settings),
    3730    audiofd(-1), numbadioctls(0),
    3831    mixerfd(-1), control(SOUND_MIXER_VOLUME)
    3932{
    4033    // Set everything up
    41     Reconfigure(laudio_bits,       laudio_channels,
    42                 laudio_samplerate, laudio_passthru);
     34    Reconfigure(settings);
    4335}
    4436
    4537AudioOutputOSS::~AudioOutputOSS()
     
    340332    }
    341333}
    342334
    343 int AudioOutputOSS::GetVolumeChannel(int channel)
     335int AudioOutputOSS::GetVolumeChannel(int channel) const
    344336{
    345337    int volume=0;
    346338    int tmpVol=0;
  • mythtv/libs/libmyth/audiooutputdx.cpp

     
    287287    effdsp = dsprate / 100;
    288288}
    289289
    290 bool AudioOutputDX::GetPause(void)
    291 {
    292     return paused;
    293 }
    294 
    295290void AudioOutputDX::Pause(bool pause)
    296291{
    297292    HRESULT dsresult;
     
    326321    paused = pause;
    327322}
    328323
    329 int AudioOutputDX::GetAudiotime(void)
     324int AudioOutputDX::GetAudiotime(void) const
    330325{
    331326    DWORD play_pos;
    332327    HRESULT dsresult;
     
    746741
    747742}
    748743
    749 int AudioOutputDX::GetVolumeChannel(int channel)
     744int AudioOutputDX::GetVolumeChannel(int channel) const
    750745{
    751746    // Do nothing
    752747    return 100;
  • mythtv/libs/libmyth/audiooutputnull.h

     
    2323
    2424class AudioOutputNULL : public AudioOutputBase
    2525{
    26 public:
    27     AudioOutputNULL(QString laudio_main_device,
    28                     QString laudio_passthru_device,
    29                     int laudio_bits,
    30                     int laudio_channels, int laudio_samplerate,
    31                     AudioOutputSource lsource,
    32                     bool lset_initial_vol, bool laudio_passthru);
     26  public:
     27    AudioOutputNULL(const AudioSettings &settings);
     28
    3329    virtual ~AudioOutputNULL();
    3430
    3531    virtual void Reset(void);
    3632
    3733
    3834    // Volume control
    39     virtual int GetVolumeChannel(int /* channel */){ return 100; }
    40     virtual void SetVolumeChannel(int /* channel */, int /* volume */){ return; }
     35    virtual int GetVolumeChannel(int /* channel */) const { return 100; }
     36    virtual void SetVolumeChannel(int /* channel */, int /* volume */){return;}
    4137
    4238    virtual int readOutputData(unsigned char *read_buffer, int max_length);
    4339
    44 protected:
    45     // You need to implement the following functions
     40  protected:
     41    // AudioOutputBase
    4642    virtual bool OpenDevice(void);
    4743    virtual void CloseDevice(void);
    4844    virtual void WriteAudio(unsigned char *aubuf, int size);
    49     virtual inline int getSpaceOnSoundcard(void);
    50     virtual inline int getBufferedOnSoundcard(void);
     45    virtual int getSpaceOnSoundcard(void);
     46    virtual int getBufferedOnSoundcard(void);
    5147
    52 private:
    53 
     48  private:
    5449    QMutex        pcm_output_buffer_mutex;
    5550    unsigned char pcm_output_buffer[NULLAUDIO_OUTPUT_BUFFER_SIZE];
    5651    int           current_buffer_size;
  • mythtv/libs/libmyth/audiooutput.h

     
    11#ifndef AUDIOOUTPUT
    22#define AUDIOOUTPUT
    33
    4 #include <iostream>
    5 using namespace std;
     4#include <qstring.h>
    65
     6#include "audiosettings.h"
    77#include "mythcontext.h"
    88#include "volumebase.h"
    99#include "output.h"
    1010
    11 typedef enum {
    12     AUDIOOUTPUT_VIDEO,
    13     AUDIOOUTPUT_MUSIC,
    14     AUDIOOUTPUT_TELEPHONY
    15 } AudioOutputSource;
    16 
    1711class MPUBLIC AudioOutput : public VolumeBase, public OutputListeners
    1812{
    1913 public:
    2014    // opens one of the concrete subclasses
    21     static AudioOutput *OpenAudio(QString audiodevice, QString passthrudevice,
    22                                   int audio_bits,
    23                                   int audio_channels, int audio_samplerate,
    24                                   AudioOutputSource source,
    25                                   bool set_initial_vol, bool audio_passthru);
     15    static AudioOutput *OpenAudio(
     16        const QString &audiodevice,
     17        const QString &passthrudevice,
     18        int audio_bits, int audio_channels, int audio_samplerate,
     19        AudioOutputSource source,
     20        bool set_initial_vol, bool audio_passthru);
    2621
    2722    AudioOutput() :
    2823        VolumeBase(),             OutputListeners(),
     
    3126    virtual ~AudioOutput() { };
    3227
    3328    // reconfigure sound out for new params
    34     virtual void Reconfigure(int audio_bits,
    35                              int audio_channels,
    36                              int audio_samplerate,
    37                              bool audio_passthru,
    38                              void* audio_codec = NULL) = 0;
     29    virtual void Reconfigure(const AudioSettings &settings) = 0;
    3930   
    4031    virtual void SetStretchFactor(float factor);
    41     virtual float GetStretchFactor(void) { return 1.0f; }
     32    virtual float GetStretchFactor(void) const { return 1.0f; }
    4233
    4334    // do AddSamples calls block?
    4435    virtual void SetBlocking(bool blocking) = 0;
     
    5445    virtual bool AddSamples(char *buffers[], int samples, long long timecode) = 0;
    5546
    5647    virtual void SetTimecode(long long timecode) = 0;
    57     virtual bool GetPause(void) = 0;
     48    virtual bool IsPaused(void) const = 0;
    5849    virtual void Pause(bool paused) = 0;
    5950 
    6051    // Wait for all data to finish playing
    6152    virtual void Drain(void) = 0;
    6253
    63     virtual int GetAudiotime(void) = 0;
     54    virtual int GetAudiotime(void) const = 0;
    6455
    6556    virtual void SetSourceBitrate(int ) { }
    6657
    6758    QString GetError(void)   const { return lastError; }
    6859    QString GetWarning(void) const { return lastWarn; }
    6960
    70     virtual void GetBufferStatus(uint &fill, uint &total) { fill = total = 0; }
     61    virtual void GetBufferStatus(uint &fill, uint &total) const
     62        { fill = total = 0; }
    7163
    7264    //  Only really used by the AudioOutputNULL object
    7365   
     
    7567    virtual int readOutputData(unsigned char *read_buffer, int max_length) = 0;
    7668
    7769  protected:
    78     void Error(QString msg)
    79     {
    80         lastError = msg;
    81         VERBOSE(VB_IMPORTANT, "AudioOutput Error: " + lastError);
    82     }
    83     void ClearError(void) { lastError = QString::null; }
     70    void Error(const QString &msg);
     71    void Warn(const QString &msg);
     72    void ClearError(void);
     73    void ClearWarning(void);
    8474
    85     void Warn(QString msg)
    86     {
    87         lastWarn  = msg;
    88         VERBOSE(VB_IMPORTANT, "AudioOutput Warning: " + lastWarn);
    89     }
    90 
    9175  protected:
    9276    QString lastError;
    9377    QString lastWarn;
  • mythtv/libs/libmyth/audiooutputarts.h

     
    1414class AudioOutputARTS : public AudioOutputBase
    1515{
    1616  public:
    17      AudioOutputARTS(QString main_device, QString passthru_device,
    18                      int audio_bits,
    19                      int audio_channels, int audio_samplerate,
    20                      AudioOutputSource source,
    21                      bool set_initial_vol, bool laudio_passthru);
     17     AudioOutputARTS(const AudioSettings &settings);
    2218     virtual ~AudioOutputARTS();
    2319
    2420    // Volume control
    25     virtual int GetVolumeChannel(int channel); // Returns 0-100
     21    virtual int GetVolumeChannel(int channel) const; // Returns 0-100
    2622    virtual void SetVolumeChannel(int channel, int volume); // range 0-100 for vol
    2723
    2824  protected:
  • mythtv/libs/libmyth/audiooutputdx.h

     
    1717class AudioOutputDX : public AudioOutputBase
    1818{
    1919public:
    20     AudioOutputDX(QString laudio_main_device,
    21                   QString laudio_passthru_device,
    22                   int laudio_bits,
    23                   int laudio_channels, int laudio_samplerate,
    24                   AudioOutputSource lsource,
    25                   bool lset_initial_vol, bool laudio_passthru);
     20    AudioOutputDX(const AudioSettings &settings);
    2621    virtual ~AudioOutputDX();
    2722
    2823    /// BEGIN HACK HACK HACK HACK These need to actually be implemented!
     
    3530    /// END HACK HACK HACK HACK
    3631       
    3732    virtual void Reset(void);
    38     virtual void Reconfigure(int audio_bits,
    39                              int audio_channels,
    40                              int audio_samplerate,
    41                              bool audio_passthru);
     33    virtual void Reconfigure(const AudioSettings &settings);
    4234    virtual void SetBlocking(bool blocking);
    4335
    4436    virtual bool AddSamples(char *buffer, int samples, long long timecode);
     
    4638    virtual void SetEffDsp(int dsprate);
    4739    virtual void SetTimecode(long long timecode);
    4840
    49     virtual bool GetPause(void);
     41    virtual bool IsPaused(void) const { return paused; }
    5042    virtual void Pause(bool paused);
    5143
    5244    virtual void Drain(void);
    5345
    54     virtual int GetAudiotime(void);
     46    virtual int GetAudiotime(void) const;
    5547
    5648    // Volume control
    5749    virtual int GetVolumeChannel(int channel); // Returns 0-100
  • mythtv/libs/libmyth/audiooutputalsa.h

     
    1616class AudioOutputALSA : public AudioOutputBase
    1717{
    1818  public:
    19     AudioOutputALSA(QString laudio_main_device, QString laudio_passthru_device,
    20                     int laudio_bits,
    21                     int laudio_channels, int laudio_samplerate,
    22                     AudioOutputSource source,
    23                     bool set_initial_vol, bool laudio_passthru);
     19    AudioOutputALSA(const AudioSettings &settings);
    2420    virtual ~AudioOutputALSA();
    2521
    2622    // Volume control
    27     virtual int GetVolumeChannel(int channel); // Returns 0-100
     23    virtual int GetVolumeChannel(int channel) const; // Returns 0-100
    2824    virtual void SetVolumeChannel(int channel, int volume); // range 0-100 for vol
    2925
    3026   
     
    4844    void OpenMixer(bool setstartingvolume);
    4945    void CloseMixer(void);
    5046    void SetupMixer(void);
    51     void GetVolumeRange(snd_mixer_elem_t *elem);
     47    void GetVolumeRange(snd_mixer_elem_t *elem) const;
    5248
    5349  private:
    5450    snd_pcm_t   *pcm_handle;
     
    5652    QMutex       killAudioLock;
    5753    snd_mixer_t *mixer_handle;
    5854    QString      mixer_control; // e.g. "PCM"
    59     float        volume_range_multiplier;
    60     long        playback_vol_min;
    61     long        playback_vol_max;
     55    mutable float volume_range_multiplier;
     56    mutable long playback_vol_min;
     57    mutable long playback_vol_max;
    6258    snd_pcm_sframes_t (*pcm_write_func)(
    6359        snd_pcm_t*, const void*, snd_pcm_uframes_t);
    6460};
  • mythtv/programs/mythtranscode/transcode.cpp

     
    4141    AudioReencodeBuffer(int audio_bits, int audio_channels)
    4242    {
    4343        Reset();
    44         Reconfigure(audio_bits, audio_channels, 0, 0);
     44        const AudioSettings settings(audio_bits, audio_channels, 0, false);
     45        Reconfigure(settings);
    4546        bufsize = 512000;
    4647        audiobuffer = new unsigned char[bufsize];
    4748
     
    5758    }
    5859
    5960    // reconfigure sound out for new params
    60     virtual void Reconfigure(int audio_bits, int audio_channels,
    61                              int audio_samplerate, bool audio_passthru,
    62                              void *audio_codec = NULL)
     61    virtual void Reconfigure(const AudioSettings &settings)
    6362    {
    64         (void)audio_samplerate;
    65         (void)audio_passthru;
    66         (void)audio_codec;
    67 
    6863        ClearError();
    69         bits = audio_bits;
    70         channels = audio_channels;
     64        bits = settings.bits;
     65        channels = settings.channels;
    7166        bytes_per_sample = bits * channels / 8;
    72         if ((uint)audio_channels > 2)
     67        if ((uint)settings.channels > 2)
    7368            Error(QString("Invalid channel count %1").arg(channels));
    7469    }
    7570
     
    156151    {
    157152        last_audiotime = timecode;
    158153    }
    159     virtual bool GetPause(void)
     154    virtual bool IsPaused(void) const
    160155    {
    161156        return false;
    162157    }
     
    170165        return;
    171166    }
    172167
    173     virtual int GetAudiotime(void)
     168    virtual int GetAudiotime(void) const
    174169    {
    175170        return last_audiotime;
    176171    }
    177172
    178     virtual int GetVolumeChannel(int)
     173    virtual int GetVolumeChannel(int) const
    179174    {
    180175        // Do nothing
    181176        return 100;
     
    190185    }
    191186   
    192187
    193     virtual int GetCurrentVolume(void)
     188    virtual int GetCurrentVolume(void) const
    194189    {
    195190        // Do nothing
    196191        return 100;
     
    211206    {
    212207        // Do nothing
    213208    }
    214     virtual kMuteState GetMute(void)
     209    virtual kMuteState GetMute(void) const
    215210    {
    216211        // Do nothing
    217212        return MUTE_OFF;