Ticket #4981: 4981-v1.patch
File 4981-v1.patch, 62.7 KB (added by , 16 years ago) |
---|
-
mythplugins/mythmusic/mythmusic/playbackbox.cpp
1286 1286 return; 1287 1287 } 1288 1288 1289 if (gPlayer->getOutput() && gPlayer->getOutput()-> GetPause())1289 if (gPlayer->getOutput() && gPlayer->getOutput()->IsPaused()) 1290 1290 { 1291 1291 gPlayer->pause(); 1292 1292 return; … … 2134 2134 2135 2135 QString time_string = getTimeString(maxTime, 0); 2136 2136 2137 if (gPlayer->getOutput() && gPlayer->getOutput()-> GetPause())2137 if (gPlayer->getOutput() && gPlayer->getOutput()->IsPaused()) 2138 2138 { 2139 2139 gPlayer->stop(); 2140 2140 } -
mythplugins/mythmusic/mythmusic/miniplayer.cpp
181 181 if (gPlayer->isPlaying()) 182 182 return; 183 183 184 if (gPlayer->getOutput() && gPlayer->getOutput()-> GetPause())184 if (gPlayer->getOutput() && gPlayer->getOutput()->IsPaused()) 185 185 { 186 186 gPlayer->pause(); 187 187 return; … … 198 198 if (gPlayer->isPlaying()) 199 199 gPlayer->stop(); 200 200 201 if (gPlayer->getOutput() && gPlayer->getOutput()->GetPause()) 201 if (gPlayer->getOutput() && 202 gPlayer->getOutput()->IsPaused()) 202 203 { 203 204 gPlayer->pause(); 204 205 return; -
mythplugins/mythmusic/mythmusic/vorbisdecoder.cpp
187 187 188 188 if (output()) 189 189 { 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); 191 193 output()->SetSourceBitrate(bitrate); 192 194 } 193 195 -
mythplugins/mythmusic/mythmusic/avfdecoder.cpp
184 184 185 185 if (output()) 186 186 { 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); 189 191 output()->SetSourceBitrate(audio_dec->bit_rate); 190 192 } 191 193 -
mythplugins/mythmusic/mythmusic/flacdecoder.cpp
150 150 151 151 if (output()) 152 152 { 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); 155 156 output()->SetSourceBitrate(44100 * 2 * 16); 156 157 } 157 158 } -
mythplugins/mythmusic/mythmusic/musicplayer.cpp
184 184 185 185 if (m_output) 186 186 { 187 if (m_output-> GetPause())187 if (m_output->IsPaused()) 188 188 { 189 189 pause(); 190 190 } -
mythplugins/mythmusic/mythmusic/cddecoder.cpp
136 136 137 137 if (output()) 138 138 { 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); 140 142 output()->SetSourceBitrate(44100 * 2 * 16); 141 143 } 142 144 -
mythplugins/mythmusic/mythmusic/maddecoder.cpp
111 111 112 112 if (output()) 113 113 { 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); 115 117 output()->SetSourceBitrate(bitrate); 116 118 } 117 119 … … 479 481 { 480 482 freq = newfreq; 481 483 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); 483 487 } 484 488 if (newbitrate != bitrate) 485 489 { -
mythtv/libs/libmythtv/NuppelVideoPlayer.cpp
481 481 bool NuppelVideoPlayer::IsPaused(bool *is_pause_still_possible) const 482 482 { 483 483 bool rbf_playing = (ringBuffer != NULL) && !ringBuffer->isPaused(); 484 bool aud_playing = (audioOutput != NULL) && !audioOutput-> GetPause();484 bool aud_playing = (audioOutput != NULL) && !audioOutput->IsPaused(); 485 485 if (is_pause_still_possible) 486 486 { 487 487 bool decoder_pausing = (0.0f == next_play_speed) && !next_normal_speed; … … 798 798 799 799 if (audioOutput) 800 800 { 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); 804 805 errMsg = audioOutput->GetError(); 805 806 if (!errMsg.isEmpty()) 806 807 audioOutput->SetStretchFactor(audio_stretchfactor); … … 2726 2727 videoOutput->ProcessFrame(frame, osd, videoFilters, pipplayer); 2727 2728 videofiltersLock.unlock(); 2728 2729 2729 if (audioOutput && !audio_paused && audioOutput-> GetPause())2730 if (audioOutput && !audio_paused && audioOutput->IsPaused()) 2730 2731 audioOutput->Pause(false); 2731 2732 2732 2733 AVSync(); -
mythtv/libs/libmyth/audiooutputwin.cpp
71 71 } 72 72 } 73 73 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), 74 AudioOutputWin::AudioOutputWin(const AudioSettings &settings) : 75 AudioOutputBase(settings), 83 76 m_priv(new AudioOutputWinPrivate()), 84 77 m_nPkts(0), 85 78 m_CurrentPkt(0), 86 79 m_OutPkts(NULL) 87 80 { 88 Reconfigure(laudio_bits, laudio_channels, 89 laudio_samplerate, laudio_passthru); 81 Reconfigure(settings); 90 82 91 83 m_OutPkts = (unsigned char**) calloc(kPacketCnt, sizeof(unsigned char*)); 92 84 } -
mythtv/libs/libmyth/audiooutputbase.h
36 36 class AudioOutputBase : public AudioOutput 37 37 { 38 38 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); 45 40 virtual ~AudioOutputBase(); 46 41 47 42 // 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); 53 44 54 45 // do AddSamples calls block? 55 46 virtual void SetBlocking(bool blocking); … … 58 49 virtual void SetEffDsp(int dsprate); 59 50 60 51 virtual void SetStretchFactor(float factor); 61 virtual float GetStretchFactor(void) ;52 virtual float GetStretchFactor(void) const; 62 53 63 54 virtual void Reset(void); 64 55 … … 67 58 virtual bool AddSamples(char *buffers[], int samples, long long timecode); 68 59 69 60 virtual void SetTimecode(long long timecode); 70 virtual bool GetPause(void);61 virtual bool IsPaused(void) const { return audio_actually_paused; } 71 62 virtual void Pause(bool paused); 72 63 73 64 // Wait for all data to finish playing 74 65 virtual void Drain(void); 75 66 76 virtual int GetAudiotime(void) ;67 virtual int GetAudiotime(void) const; 77 68 78 69 // Send output events showing current progress 79 70 virtual void Status(void); 80 71 81 72 virtual void SetSourceBitrate(int rate); 82 73 83 virtual void GetBufferStatus(uint &fill, uint &total) ;74 virtual void GetBufferStatus(uint &fill, uint &total) const; 84 75 85 76 // Only really used by the AudioOutputNULL object 86 77 … … 95 86 virtual void WriteAudio(unsigned char *aubuf, int size) = 0; 96 87 virtual int getSpaceOnSoundcard(void) = 0; 97 88 virtual int getBufferedOnSoundcard(void) = 0; 98 virtual int GetVolumeChannel(int channel) = 0; // Returns 0-10099 v irtual void SetVolumeChannel(int channel, int volume) = 0; // range 0-100 for vol89 /// You need to call this from any implementation in the dtor. 90 void KillAudio(void); 100 91 101 92 // The following functions may be overridden, but don't need to be 102 93 virtual bool StartOutputThread(void); … … 105 96 int GetAudioData(unsigned char *buffer, int buf_size, bool fill_buffer); 106 97 107 98 void _AddSamples(void *buffer, bool interleaved, int samples, long long timecode); 108 109 void KillAudio(); 99 110 100 void OutputAudioLoop(void); 111 101 static void *kickoffOutputAudioLoop(void *player); 112 102 void SetAudiotime(void); 113 103 int WaitForFreeSpace(int len); 114 104 115 int audiolen(bool use_lock) ; // number of valid bytes in audio buffer116 int audiofree(bool use_lock) ; // number of free bytes in audio buffer105 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 117 107 118 108 void UpdateVolume(void); 119 109 … … 179 169 bool audio_thread_exists; 180 170 pthread_t audio_thread; 181 171 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; 188 175 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 191 184 /// timecode of audio leaving the soundcard (same units as timecodes) 192 185 long long audiotime; 193 186 struct timeval audiotime_updated; // ... which was last updated at this time -
mythtv/libs/libmyth/audiooutputalsa.cpp
13 13 #define LOC_WARN QString("ALSA, Warning: ") 14 14 #define LOC_ERR QString("ALSA, Error: ") 15 15 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), 16 AudioOutputALSA::AudioOutputALSA(const AudioSettings &settings) : 17 AudioOutputBase(settings), 25 18 pcm_handle(NULL), numbadioctls(0), 26 19 killAudioLock(false), mixer_handle(NULL), 27 20 mixer_control(QString::null), volume_range_multiplier(1.0f), 28 21 playback_vol_min(0), playback_vol_max(1) 29 22 { 30 23 // Set everything up 31 Reconfigure(laudio_bits, laudio_channels, 32 laudio_samplerate, laudio_passthru); 24 Reconfigure(settings); 33 25 } 34 26 35 27 AudioOutputALSA::~AudioOutputALSA() … … 477 469 } 478 470 479 471 480 int AudioOutputALSA::GetVolumeChannel(int channel) 472 int AudioOutputALSA::GetVolumeChannel(int channel) const 481 473 { 482 474 long actual_volume, volume; 483 475 … … 677 669 } 678 670 } 679 671 680 void AudioOutputALSA::GetVolumeRange(snd_mixer_elem_t *elem) 672 void AudioOutputALSA::GetVolumeRange(snd_mixer_elem_t *elem) const 681 673 { 682 674 snd_mixer_selem_get_playback_volume_range(elem, &playback_vol_min, 683 675 &playback_vol_max); -
mythtv/libs/libmyth/volumebase.cpp
5 5 using namespace std; 6 6 #include "volumebase.h" 7 7 8 VolumeBase::VolumeBase() 8 VolumeBase::VolumeBase() : 9 internal_vol(false), volume(80), current_mute_state(MUTE_OFF) 9 10 { 10 volume = 80; 11 current_mute_state=MUTE_OFF; 12 internal_vol = false; 13 }; 11 } 14 12 15 int VolumeBase::GetCurrentVolume(void) 13 int VolumeBase::GetCurrentVolume(void) const 16 14 { 17 15 return volume; 18 16 } … … 58 56 SetMute(current_mute_state == MUTE_OFF); 59 57 } 60 58 61 kMuteState VolumeBase::GetMute(void) 59 kMuteState VolumeBase::GetMute(void) const 62 60 { 63 61 return current_mute_state; 64 62 } -
mythtv/libs/libmyth/volumebase.h
20 20 VolumeBase(); 21 21 virtual ~VolumeBase() {}; 22 22 23 virtual int GetCurrentVolume(void);23 virtual int GetCurrentVolume(void) const; 24 24 virtual void SetCurrentVolume(int value); 25 25 virtual void AdjustCurrentVolume(int change); 26 26 virtual void SetMute(bool on); 27 27 virtual void ToggleMute(void); 28 virtual kMuteState GetMute(void) ;28 virtual kMuteState GetMute(void) const; 29 29 virtual kMuteState IterateMutedChannels(void); 30 30 31 31 protected: 32 32 33 virtual int GetVolumeChannel(int channel) = 0; // Returns 0-10033 virtual int GetVolumeChannel(int channel) const = 0; // Returns 0-100 34 34 virtual void SetVolumeChannel(int channel, int volume) = 0; // range 0-100 for vol 35 35 36 36 void UpdateVolume(void); -
mythtv/libs/libmyth/audiooutputarts.cpp
7 7 #include "mythcontext.h" 8 8 #include "audiooutputarts.h" 9 9 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), 10 AudioOutputARTS::AudioOutputARTS(const AudioSettings &settings) : 11 AudioOutputBase(settings), 19 12 pcm_handle(NULL), buff_size(-1), can_hw_pause(false) 20 13 { 21 14 // Set everything up 22 Reconfigure(laudio_bits, laudio_channels, 23 laudio_samplerate, laudio_passthru); 15 Reconfigure(settings); 24 16 } 25 17 26 18 AudioOutputARTS::~AudioOutputARTS() … … 88 80 } 89 81 } 90 82 91 in line int AudioOutputARTS::getBufferedOnSoundcard(void)83 int AudioOutputARTS::getBufferedOnSoundcard(void) 92 84 { 93 85 return buff_size - getSpaceOnSoundcard(); 94 86 } 95 87 96 in line int AudioOutputARTS::getSpaceOnSoundcard(void)88 int AudioOutputARTS::getSpaceOnSoundcard(void) 97 89 { 98 90 return arts_stream_get(pcm_handle, ARTS_P_BUFFER_SIZE); 99 91 } 100 92 101 int AudioOutputARTS::GetVolumeChannel(int /*channel*/) 93 int AudioOutputARTS::GetVolumeChannel(int /*channel*/) const 102 94 { 103 95 // Do nothing 104 96 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 VolumeControl7 {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
20 20 #include "mythcontext.h" 21 21 #include "audiooutputnull.h" 22 22 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), 23 AudioOutputNULL::AudioOutputNULL(const AudioSettings &settings) : 24 AudioOutputBase(settings), 32 25 pcm_output_buffer_mutex(false), 33 26 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) 37 30 { 38 31 bzero(pcm_output_buffer, sizeof(char) * NULLAUDIO_OUTPUT_BUFFER_SIZE); 39 32 40 Reconfigure(laudio_bits, laudio_channels, 41 laudio_samplerate, laudio_passthru); 33 Reconfigure(settings); 42 34 } 43 35 44 36 AudioOutputNULL::~AudioOutputNULL() -
mythtv/libs/libmyth/audiooutputjack.h
12 12 class AudioOutputJACK : public AudioOutputBase 13 13 { 14 14 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); 21 16 virtual ~AudioOutputJACK(); 22 17 23 18 // Volume control 24 virtual int GetVolumeChannel(int channel) ; // Returns 0-10019 virtual int GetVolumeChannel(int channel) const; // Returns 0-100 25 20 virtual void SetVolumeChannel(int channel, int volume); // range 0-100 for vol 26 21 27 22 protected: -
mythtv/libs/libmyth/audiooutputca.cpp
111 111 * \brief Implements Core Audio (Mac OS X Hardware Abstraction Layer) output. 112 112 */ 113 113 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), 114 AudioOutputCA::AudioOutputCA(const AudioSettings &settings) 115 : AudioOutputBase(settings), 124 116 d(new CoreAudioData(this)) 125 117 { 126 Reconfigure(laudio_bits, laudio_channels, 127 laudio_samplerate, laudio_passthru); 118 Reconfigure(settings); 128 119 } 129 120 130 121 AudioOutputCA::~AudioOutputCA() … … 333 324 /** Reimplement the base class's version of GetAudiotime() 334 325 * so that we don't use gettimeofday or pthread mutexes. 335 326 */ 336 int AudioOutputCA::GetAudiotime(void) 327 int AudioOutputCA::GetAudiotime(void) const 337 328 { 338 329 int ret; 339 330 -
mythtv/libs/libmyth/audiooutputwin.h
13 13 { 14 14 friend class AudioOutputWinPrivate; 15 15 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); 22 17 virtual ~AudioOutputWin(); 23 18 24 19 // Volume control 25 virtual int GetVolumeChannel(int channel) ;20 virtual int GetVolumeChannel(int channel) const; 26 21 virtual void SetVolumeChannel(int channel, int volume); 27 22 28 23 protected: -
mythtv/libs/libmyth/volumecontrol.cpp
1 #include "volumecontrol.h"2 #include "config.h"3 4 #ifdef USING_OSS5 #include <sys/ioctl.h>6 #ifdef HAVE_SYS_SOUNDCARD_H7 #include <sys/soundcard.h>8 #elif HAVE_SOUNDCARD_H9 #include <soundcard.h>10 #endif11 #endif12 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_OSS30 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 else43 {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 #endif72 }73 74 VolumeControl::~VolumeControl()75 {76 if (mixerfd >= 0)77 close(mixerfd);78 }79 80 int VolumeControl::GetCurrentVolume(void)81 {82 #ifdef USING_OSS83 int realvol;84 85 if (mute)86 {87 return internal_volume;88 }89 else90 {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 channel97 internal_volume = volume;98 }99 #endif100 101 return volume;102 }103 104 void VolumeControl::SetCurrentVolume(int value)105 {106 (void) value;107 108 #ifdef USING_OSS109 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 #endif134 }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_OSS148 int realvol;149 150 if (on)151 {152 realvol = 0;153 }154 else155 {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 #endif167 }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 muting177 // is enabled, each call to SetMute will advance to the next state:178 // MUTE_OFF -> MUTE_LEFT -> MUTE_RIGHT -> MUTE_BOTH -> MUTE_OFF179 #ifdef USING_OSS180 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_OSS209 210 return current_mute_state;211 } -
mythtv/libs/libmyth/audiooutputjack.cpp
21 21 #include "bio2jack.h" 22 22 } 23 23 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) 24 AudioOutputJACK::AudioOutputJACK(const AudioSettings &settings) : 25 AudioOutputBase(settings), audioid(-1) 34 26 { 35 27 // Initialise the Jack output layer 36 28 JACK_Init(); 37 29 38 30 // Set everything up 39 Reconfigure(laudio_bits, laudio_channels, 40 laudio_samplerate, laudio_passthru); 31 Reconfigure(settings); 41 32 } 42 33 43 34 AudioOutputJACK::~AudioOutputJACK() … … 68 59 audioid = -1; 69 60 while (timer.elapsed() < 2000 && audioid == -1) 70 61 { 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, 72 64 audio_channels, audio_channels, &jack_port_name, 73 65 jack_port_name_count, jack_port_flags); 66 audio_samplerate = audio_samplerate_long; 74 67 if (err == 1) { 75 68 Error(QString("Error connecting to jackd:%1. Is it running?") 76 69 .arg(audio_main_device)); … … 79 72 // need to resample 80 73 VERBOSE(VB_AUDIO, QString("Failed to open device at" 81 74 " 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, 83 77 audio_channels, audio_channels, &jack_port_name, 84 78 jack_port_name_count, jack_port_flags); 79 audio_samplerate = audio_samplerate_long; 85 80 } else if (err == ERR_PORT_NOT_FOUND) { 86 81 VERBOSE(VB_IMPORTANT, QString("Error opening audio device (%1), " 87 82 " Port not found.").arg(audio_main_device)); … … 184 179 JACK_SetAllVolume(audioid, volume); 185 180 } 186 181 187 int AudioOutputJACK::GetVolumeChannel(int channel) 182 int AudioOutputJACK::GetVolumeChannel(int channel) const 188 183 { 189 184 unsigned int vol = 0; 190 185 -
mythtv/libs/libmyth/audiooutputoss.h
13 13 class AudioOutputOSS : public AudioOutputBase 14 14 { 15 15 public: 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); 21 17 virtual ~AudioOutputOSS(); 22 18 23 19 // Volume control 24 virtual int GetVolumeChannel(int channel) ; // Returns 0-10020 virtual int GetVolumeChannel(int channel) const; // Returns 0-100 25 21 virtual void SetVolumeChannel(int channel, int volume); // range 0-100 for vol 26 22 27 23 protected: -
mythtv/libs/libmyth/audiooutputbase.cpp
23 23 #define LOC QString("AO: ") 24 24 #define LOC_ERR QString("AO, ERROR: ") 25 25 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 26 AudioOutputBase::AudioOutputBase(const AudioSettings &settings) : 32 27 effdsp(0), effdspstretched(0), 33 28 audio_channels(-1), audio_bytes_per_sample(0), 34 29 audio_bits(-1), audio_samplerate(-1), 35 30 audio_buffer_unused(0), 36 31 fragment_size(0), soundcard_buffer_size(0), 37 32 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()), 40 35 audio_passthru(false), audio_stretchfactor(1.0f), 41 36 42 37 audio_codec(NULL), 43 source( lsource),killaudio(false),38 source(settings.source), killaudio(false), 44 39 45 40 pauseaudio(false), audio_actually_paused(false), 46 41 was_paused(false), 47 42 48 set_initial_vol( lset_initial_vol),43 set_initial_vol(settings.set_initial_vol), 49 44 buffer_output_data_for_use(false), 50 45 need_resampler(false), 51 46 … … 92 87 93 88 AudioOutputBase::~AudioOutputBase() 94 89 { 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 } 98 96 99 97 pthread_mutex_destroy(&audio_buflock); 100 98 pthread_mutex_destroy(&avsync_lock); … … 179 177 pthread_mutex_unlock(&audio_buflock); 180 178 } 181 179 182 float AudioOutputBase::GetStretchFactor(void) 180 float AudioOutputBase::GetStretchFactor(void) const 183 181 { 184 182 return audio_stretchfactor; 185 183 } 186 184 187 void AudioOutputBase::Reconfigure(int laudio_bits, int laudio_channels, 188 int laudio_samplerate, bool laudio_passthru, 189 void *laudio_codec) 185 void AudioOutputBase::Reconfigure(const AudioSettings &orig_settings) 190 186 { 187 AudioSettings settings = orig_settings; 188 191 189 int codec_id = CODEC_ID_NONE; 192 190 int lcodec_id = CODEC_ID_NONE; 193 191 int lcchannels = 0; 194 192 int cchannels = 0; 195 int lsource_audio_channels = laudio_channels;193 int lsource_audio_channels = settings.channels; 196 194 bool lneeds_upmix = false; 197 195 198 if ( laudio_codec)196 if (settings.codec) 199 197 { 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; 206 204 } 207 205 208 206 if (audio_codec) … … 212 210 } 213 211 214 212 if ((configured_audio_channels == 6) && 215 !( laudio_codec || audio_codec))213 !(settings.codec || audio_codec)) 216 214 { 217 laudio_channels = configured_audio_channels;215 settings.channels = configured_audio_channels; 218 216 lneeds_upmix = true; 219 217 VERBOSE(VB_AUDIO,LOC + "Needs upmix"); 220 218 } 221 219 222 220 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 && 227 225 lneeds_upmix == needs_upmix && 228 226 lcodec_id == codec_id && lcchannels == cchannels); 229 227 bool upmix_deps = … … 252 250 waud = raud = 0; 253 251 audio_actually_paused = false; 254 252 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; 257 255 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; 262 260 needs_upmix = lneeds_upmix; 263 261 264 262 if (audio_bits != 8 && audio_bits != 16) … … 316 314 317 315 // NOTE: this won't do anything as above samplerate vars are set equal 318 316 // Check if we need the resampler 319 if (audio_samplerate != laudio_samplerate)317 if (audio_samplerate != settings.samplerate) 320 318 { 321 319 int error; 322 320 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)); 324 322 src_ctx = src_new (SRC_SINC_BEST_QUALITY, audio_channels, &error); 325 323 if (error) 326 324 { … … 330 328 pthread_mutex_unlock(&audio_buflock); 331 329 return; 332 330 } 333 src_data.src_ratio = (double) audio_samplerate / laudio_samplerate;331 src_data.src_ratio = (double) audio_samplerate / settings.samplerate; 334 332 src_data.data_in = src_in; 335 333 src_data.data_out = src_out; 336 334 src_data.output_frames = 16384*6; … … 486 484 killAudioLock.unlock(); 487 485 } 488 486 489 490 bool AudioOutputBase::GetPause(void)491 {492 return audio_actually_paused;493 }494 495 487 void AudioOutputBase::Pause(bool paused) 496 488 { 497 489 VERBOSE(VB_AUDIO, LOC + QString("Pause %0").arg(paused)); … … 540 532 this->blocking = blocking; 541 533 } 542 534 543 int AudioOutputBase::audiolen(bool use_lock) 535 int AudioOutputBase::audiolen(bool use_lock) const 544 536 { 545 537 /* Thread safe, returns the number of valid bytes in the audio buffer */ 546 538 int ret; … … 559 551 return ret; 560 552 } 561 553 562 int AudioOutputBase::audiofree(bool use_lock) 554 int AudioOutputBase::audiofree(bool use_lock) const 563 555 { 564 556 return AUDBUFSIZE - audiolen(use_lock) - 1; 565 557 /* There is one wasted byte in the buffer. The case where waud = raud is … … 567 559 be is AUDBUFSIZE - 1. */ 568 560 } 569 561 570 int AudioOutputBase::GetAudiotime(void) 562 int AudioOutputBase::GetAudiotime(void) const 571 563 { 572 564 /* Returns the current timecode of audio leaving the soundcard, based 573 565 on the 'audiotime' computed earlier, and the delay since it was computed. … … 1120 1112 } 1121 1113 } 1122 1114 1123 void AudioOutputBase::GetBufferStatus(uint &fill, uint &total) 1115 void AudioOutputBase::GetBufferStatus(uint &fill, uint &total) const 1124 1116 { 1125 1117 fill = AUDBUFSIZE - audiofree(true); 1126 1118 total = AUDBUFSIZE; -
mythtv/libs/libmyth/audiooutput.cpp
1 #include <qstring.h>2 1 #include <cstdio> 3 2 #include <cstdlib> 4 3 … … 31 30 #include "audiooutputjack.h" 32 31 #endif 33 32 34 AudioOutput *AudioOutput::OpenAudio( QString main_device,35 QString passthru_device,36 int audio_bits,37 38 39 33 AudioOutput *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) 40 39 { 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); 43 44 45 settings.FixPassThrough(); 46 44 47 if (main_device.startsWith("ALSA:")) 45 48 { 46 49 #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); 51 52 #else 52 53 VERBOSE(VB_IMPORTANT, "Audio output device is set to an ALSA device " 53 54 "but ALSA support is not compiled in!"); … … 56 57 } 57 58 else if (main_device.startsWith("NULL")) 58 59 { 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); 62 61 } 63 62 else if (main_device.startsWith("ARTS:")) 64 63 { 65 64 #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); 70 67 #else 71 68 VERBOSE(VB_IMPORTANT, "Audio output device is set to an ARTS device " 72 69 "but ARTS support is not compiled in!"); … … 76 73 else if (main_device.startsWith("JACK:")) 77 74 { 78 75 #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); 83 78 #else 84 79 VERBOSE(VB_IMPORTANT, "Audio output device is set to a JACK device " 85 80 "but JACK support is not compiled in!"); … … 89 84 else if (main_device.startsWith("DirectX:")) 90 85 { 91 86 #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); 95 88 #else 96 89 VERBOSE(VB_IMPORTANT, "Audio output device is set to DirectX device " 97 90 "but DirectX support is not compiled in!"); … … 101 94 else if (main_device.startsWith("Windows:")) 102 95 { 103 96 #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); 107 98 #else 108 99 VERBOSE(VB_IMPORTANT, "Audio output device is set to a Windows device " 109 100 "but Windows support is not compiled in!"); … … 112 103 } 113 104 #if defined(USING_OSS) 114 105 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); 118 107 #elif defined(CONFIG_DARWIN) 119 108 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); 123 110 #endif 124 111 125 112 VERBOSE(VB_IMPORTANT, "No useable audio output driver found."); … … 133 120 { 134 121 } 135 122 123 void AudioOutput::Error(const QString &msg) 124 { 125 lastError = QDeepCopy<QString>(msg); 126 VERBOSE(VB_IMPORTANT, "AudioOutput Error: " + lastError); 127 } 136 128 129 void AudioOutput::Warn(const QString &msg) 130 { 131 lastWarn = QDeepCopy<QString>(msg); 132 VERBOSE(VB_IMPORTANT, "AudioOutput Warning: " + lastWarn); 133 } 134 135 void AudioOutput::ClearError(void) 136 { 137 lastError = QString::null; 138 } 139 140 void AudioOutput::ClearWarning(void) 141 { 142 lastWarn = QString::null; 143 } 144 -
mythtv/libs/libmyth/libmyth.pro
11 11 12 12 # Input 13 13 HEADERS += audiooutput.h audiooutputbase.h audiooutputnull.h 14 HEADERS += audiooutputdigitalencoder.h 14 HEADERS += audiooutputdigitalencoder.h audiosettings.cpp 15 15 HEADERS += backendselect.h dbsettings.h dialogbox.h 16 16 HEADERS += DisplayRes.h DisplayResScreen.h exitcodes.h 17 17 HEADERS += generictree.h httpcomms.h langsettings.h lcddevice.h … … 23 23 HEADERS += oldsettings.h output.h qmdcodec.h remotefile.h 24 24 HEADERS += screensaver.h screensaver-null.h settings.h themeinfo.h 25 25 HEADERS += uilistbtntype.h uitypes.h util.h util-x11.h 26 HEADERS += volumebase.h v olumecontrol.h virtualkeyboard.h visual.h xmlparse.h26 HEADERS += volumebase.h virtualkeyboard.h visual.h xmlparse.h 27 27 HEADERS += mythhdd.h mythcdrom.h storagegroup.h dbutil.h 28 28 HEADERS += compat.h 29 29 30 30 SOURCES += audiooutput.cpp audiooutputbase.cpp audiooutputnull.cpp 31 SOURCES += audiooutputdigitalencoder.cpp 31 SOURCES += audiooutputdigitalencoder.cpp audiosettings.cpp 32 32 SOURCES += backendselect.cpp dbsettings.cpp dialogbox.cpp 33 33 SOURCES += DisplayRes.cpp DisplayResScreen.cpp 34 34 SOURCES += generictree.cpp httpcomms.cpp langsettings.cpp lcddevice.cpp … … 40 40 SOURCES += oldsettings.cpp output.cpp qmdcodec.cpp remotefile.cpp 41 41 SOURCES += screensaver.cpp screensaver-null.cpp settings.cpp themeinfo.cpp 42 42 SOURCES += uilistbtntype.cpp uitypes.cpp util.cpp util-x11.cpp 43 SOURCES += volumebase.cpp v olumecontrol.cpp virtualkeyboard.cpp xmlparse.cpp43 SOURCES += volumebase.cpp virtualkeyboard.cpp xmlparse.cpp 44 44 SOURCES += mythhdd.cpp mythcdrom.cpp storagegroup.cpp dbutil.cpp 45 45 46 46 INCLUDEPATH += ../libmythsamplerate ../libmythsoundtouch ../libmythfreesurround … … 70 70 inc.files = dialogbox.h lcddevice.h mythcontext.h mythdbcon.h mythverbose.h 71 71 inc.files += mythwidgets.h remotefile.h util.h oldsettings.h volumecontrol.h 72 72 inc.files += settings.h uitypes.h xmlparse.h mythplugin.h mythdialogs.h 73 inc.files += audiooutput.h inetcomms.h httpcomms.h mythmedia.h mythwizard.h 73 inc.files += audiooutput.h audiosettings.h 74 inc.files += inetcomms.h httpcomms.h mythmedia.h mythwizard.h 74 75 inc.files += uilistbtntype.h generictree.h managedlist.h mythmediamonitor.h 75 76 inc.files += visual.h volumebase.h output.h langsettings.h qmdcodec.h 76 77 inc.files += exitcodes.h mythconfig.h mythconfig.mak virtualkeyboard.h -
mythtv/libs/libmyth/audiooutputca.h
18 18 class AudioOutputCA : public AudioOutputBase 19 19 { 20 20 public: 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); 27 22 virtual ~AudioOutputCA(); 28 23 29 virtual int GetAudiotime(void) ;24 virtual int GetAudiotime(void) const; 30 25 void SetAudiotime(void); 31 26 32 27 // callback for delivering audio to output device -
mythtv/libs/libmyth/audiooutputoss.cpp
25 25 #include "audiooutputoss.h" 26 26 #include "util.h" 27 27 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), 28 AudioOutputOSS::AudioOutputOSS(const AudioSettings &settings) : 29 AudioOutputBase(settings), 37 30 audiofd(-1), numbadioctls(0), 38 31 mixerfd(-1), control(SOUND_MIXER_VOLUME) 39 32 { 40 33 // Set everything up 41 Reconfigure(laudio_bits, laudio_channels, 42 laudio_samplerate, laudio_passthru); 34 Reconfigure(settings); 43 35 } 44 36 45 37 AudioOutputOSS::~AudioOutputOSS() … … 340 332 } 341 333 } 342 334 343 int AudioOutputOSS::GetVolumeChannel(int channel) 335 int AudioOutputOSS::GetVolumeChannel(int channel) const 344 336 { 345 337 int volume=0; 346 338 int tmpVol=0; -
mythtv/libs/libmyth/audiooutputdx.cpp
287 287 effdsp = dsprate / 100; 288 288 } 289 289 290 bool AudioOutputDX::GetPause(void)291 {292 return paused;293 }294 295 290 void AudioOutputDX::Pause(bool pause) 296 291 { 297 292 HRESULT dsresult; … … 326 321 paused = pause; 327 322 } 328 323 329 int AudioOutputDX::GetAudiotime(void) 324 int AudioOutputDX::GetAudiotime(void) const 330 325 { 331 326 DWORD play_pos; 332 327 HRESULT dsresult; … … 746 741 747 742 } 748 743 749 int AudioOutputDX::GetVolumeChannel(int channel) 744 int AudioOutputDX::GetVolumeChannel(int channel) const 750 745 { 751 746 // Do nothing 752 747 return 100; -
mythtv/libs/libmyth/audiooutputnull.h
23 23 24 24 class AudioOutputNULL : public AudioOutputBase 25 25 { 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 33 29 virtual ~AudioOutputNULL(); 34 30 35 31 virtual void Reset(void); 36 32 37 33 38 34 // 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;} 41 37 42 38 virtual int readOutputData(unsigned char *read_buffer, int max_length); 43 39 44 protected:45 // You need to implement the following functions40 protected: 41 // AudioOutputBase 46 42 virtual bool OpenDevice(void); 47 43 virtual void CloseDevice(void); 48 44 virtual void WriteAudio(unsigned char *aubuf, int size); 49 virtual in line int getSpaceOnSoundcard(void);50 virtual in line int getBufferedOnSoundcard(void);45 virtual int getSpaceOnSoundcard(void); 46 virtual int getBufferedOnSoundcard(void); 51 47 52 private: 53 48 private: 54 49 QMutex pcm_output_buffer_mutex; 55 50 unsigned char pcm_output_buffer[NULLAUDIO_OUTPUT_BUFFER_SIZE]; 56 51 int current_buffer_size; -
mythtv/libs/libmyth/audiooutput.h
1 1 #ifndef AUDIOOUTPUT 2 2 #define AUDIOOUTPUT 3 3 4 #include <iostream> 5 using namespace std; 4 #include <qstring.h> 6 5 6 #include "audiosettings.h" 7 7 #include "mythcontext.h" 8 8 #include "volumebase.h" 9 9 #include "output.h" 10 10 11 typedef enum {12 AUDIOOUTPUT_VIDEO,13 AUDIOOUTPUT_MUSIC,14 AUDIOOUTPUT_TELEPHONY15 } AudioOutputSource;16 17 11 class MPUBLIC AudioOutput : public VolumeBase, public OutputListeners 18 12 { 19 13 public: 20 14 // 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); 26 21 27 22 AudioOutput() : 28 23 VolumeBase(), OutputListeners(), … … 31 26 virtual ~AudioOutput() { }; 32 27 33 28 // 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; 39 30 40 31 virtual void SetStretchFactor(float factor); 41 virtual float GetStretchFactor(void) { return 1.0f; }32 virtual float GetStretchFactor(void) const { return 1.0f; } 42 33 43 34 // do AddSamples calls block? 44 35 virtual void SetBlocking(bool blocking) = 0; … … 54 45 virtual bool AddSamples(char *buffers[], int samples, long long timecode) = 0; 55 46 56 47 virtual void SetTimecode(long long timecode) = 0; 57 virtual bool GetPause(void)= 0;48 virtual bool IsPaused(void) const = 0; 58 49 virtual void Pause(bool paused) = 0; 59 50 60 51 // Wait for all data to finish playing 61 52 virtual void Drain(void) = 0; 62 53 63 virtual int GetAudiotime(void) = 0;54 virtual int GetAudiotime(void) const = 0; 64 55 65 56 virtual void SetSourceBitrate(int ) { } 66 57 67 58 QString GetError(void) const { return lastError; } 68 59 QString GetWarning(void) const { return lastWarn; } 69 60 70 virtual void GetBufferStatus(uint &fill, uint &total) { fill = total = 0; } 61 virtual void GetBufferStatus(uint &fill, uint &total) const 62 { fill = total = 0; } 71 63 72 64 // Only really used by the AudioOutputNULL object 73 65 … … 75 67 virtual int readOutputData(unsigned char *read_buffer, int max_length) = 0; 76 68 77 69 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); 84 74 85 void Warn(QString msg)86 {87 lastWarn = msg;88 VERBOSE(VB_IMPORTANT, "AudioOutput Warning: " + lastWarn);89 }90 91 75 protected: 92 76 QString lastError; 93 77 QString lastWarn; -
mythtv/libs/libmyth/audiooutputarts.h
14 14 class AudioOutputARTS : public AudioOutputBase 15 15 { 16 16 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); 22 18 virtual ~AudioOutputARTS(); 23 19 24 20 // Volume control 25 virtual int GetVolumeChannel(int channel) ; // Returns 0-10021 virtual int GetVolumeChannel(int channel) const; // Returns 0-100 26 22 virtual void SetVolumeChannel(int channel, int volume); // range 0-100 for vol 27 23 28 24 protected: -
mythtv/libs/libmyth/audiooutputdx.h
17 17 class AudioOutputDX : public AudioOutputBase 18 18 { 19 19 public: 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); 26 21 virtual ~AudioOutputDX(); 27 22 28 23 /// BEGIN HACK HACK HACK HACK These need to actually be implemented! … … 35 30 /// END HACK HACK HACK HACK 36 31 37 32 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); 42 34 virtual void SetBlocking(bool blocking); 43 35 44 36 virtual bool AddSamples(char *buffer, int samples, long long timecode); … … 46 38 virtual void SetEffDsp(int dsprate); 47 39 virtual void SetTimecode(long long timecode); 48 40 49 virtual bool GetPause(void);41 virtual bool IsPaused(void) const { return paused; } 50 42 virtual void Pause(bool paused); 51 43 52 44 virtual void Drain(void); 53 45 54 virtual int GetAudiotime(void) ;46 virtual int GetAudiotime(void) const; 55 47 56 48 // Volume control 57 49 virtual int GetVolumeChannel(int channel); // Returns 0-100 -
mythtv/libs/libmyth/audiooutputalsa.h
16 16 class AudioOutputALSA : public AudioOutputBase 17 17 { 18 18 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); 24 20 virtual ~AudioOutputALSA(); 25 21 26 22 // Volume control 27 virtual int GetVolumeChannel(int channel) ; // Returns 0-10023 virtual int GetVolumeChannel(int channel) const; // Returns 0-100 28 24 virtual void SetVolumeChannel(int channel, int volume); // range 0-100 for vol 29 25 30 26 … … 48 44 void OpenMixer(bool setstartingvolume); 49 45 void CloseMixer(void); 50 46 void SetupMixer(void); 51 void GetVolumeRange(snd_mixer_elem_t *elem) ;47 void GetVolumeRange(snd_mixer_elem_t *elem) const; 52 48 53 49 private: 54 50 snd_pcm_t *pcm_handle; … … 56 52 QMutex killAudioLock; 57 53 snd_mixer_t *mixer_handle; 58 54 QString mixer_control; // e.g. "PCM" 59 floatvolume_range_multiplier;60 longplayback_vol_min;61 longplayback_vol_max;55 mutable float volume_range_multiplier; 56 mutable long playback_vol_min; 57 mutable long playback_vol_max; 62 58 snd_pcm_sframes_t (*pcm_write_func)( 63 59 snd_pcm_t*, const void*, snd_pcm_uframes_t); 64 60 }; -
mythtv/programs/mythtranscode/transcode.cpp
41 41 AudioReencodeBuffer(int audio_bits, int audio_channels) 42 42 { 43 43 Reset(); 44 Reconfigure(audio_bits, audio_channels, 0, 0); 44 const AudioSettings settings(audio_bits, audio_channels, 0, false); 45 Reconfigure(settings); 45 46 bufsize = 512000; 46 47 audiobuffer = new unsigned char[bufsize]; 47 48 … … 57 58 } 58 59 59 60 // 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) 63 62 { 64 (void)audio_samplerate;65 (void)audio_passthru;66 (void)audio_codec;67 68 63 ClearError(); 69 bits = audio_bits;70 channels = audio_channels;64 bits = settings.bits; 65 channels = settings.channels; 71 66 bytes_per_sample = bits * channels / 8; 72 if ((uint) audio_channels > 2)67 if ((uint)settings.channels > 2) 73 68 Error(QString("Invalid channel count %1").arg(channels)); 74 69 } 75 70 … … 156 151 { 157 152 last_audiotime = timecode; 158 153 } 159 virtual bool GetPause(void)154 virtual bool IsPaused(void) const 160 155 { 161 156 return false; 162 157 } … … 170 165 return; 171 166 } 172 167 173 virtual int GetAudiotime(void) 168 virtual int GetAudiotime(void) const 174 169 { 175 170 return last_audiotime; 176 171 } 177 172 178 virtual int GetVolumeChannel(int) 173 virtual int GetVolumeChannel(int) const 179 174 { 180 175 // Do nothing 181 176 return 100; … … 190 185 } 191 186 192 187 193 virtual int GetCurrentVolume(void) 188 virtual int GetCurrentVolume(void) const 194 189 { 195 190 // Do nothing 196 191 return 100; … … 211 206 { 212 207 // Do nothing 213 208 } 214 virtual kMuteState GetMute(void) 209 virtual kMuteState GetMute(void) const 215 210 { 216 211 // Do nothing 217 212 return MUTE_OFF;