Ticket #5477: toggleupmixer_clean.diff

File toggleupmixer_clean.diff, 8.4 KB (added by Markus Schulz <msc@…>, 16 years ago)

now a working version, OSD menu entry included

  • libs/libmythtv/NuppelVideoPlayer.cpp

     
    37243724    audio_codec = ac;
    37253725}
    37263726
     3727bool NuppelVideoPlayer::ToggleUpmixer()
     3728{
     3729    if (audioOutput)
     3730    {
     3731        const AudioSettings settings(
     3732                audio_bits, audio_channels, audio_samplerate,
     3733                audio_passthru, audio_codec);
     3734        return audioOutput->ToggleUpmixer(settings);
     3735    }
     3736    return false;
     3737}
     3738
    37273739void NuppelVideoPlayer::SetEffDsp(int dsprate)
    37283740{
    37293741    if (audioOutput)
  • libs/libmythtv/tv_play.h

     
    239239    // Used by EPG
    240240    void ChangeVolume(bool up);
    241241    void ToggleMute(void);
     242    void ToggleUpmixer(void);
    242243
    243244  public slots:
    244245    void HandleOSDClosed(int osdType);
  • libs/libmythtv/NuppelVideoPlayer.h

     
    128128    void SetAudioParams(int bits, int channels, int samplerate, bool passthru);
    129129    void SetEffDsp(int dsprate);
    130130    void SetAudioCodec(void *ac);
     131    bool ToggleUpmixer();
    131132
    132133    // Sets
    133134    void SetParentWidget(QWidget *widget)     { parentWidget = widget; }
  • libs/libmythtv/tv_play.cpp

     
    379379    REG_KEY("TV Playback", "VOLUMEDOWN", "Volume down", "[,{,F10,Volume Down");
    380380    REG_KEY("TV Playback", "VOLUMEUP",   "Volume up",   "],},F11,Volume Up");
    381381    REG_KEY("TV Playback", "MUTE",       "Mute",        "|,\\,F9,Volume Mute");
     382    REG_KEY("TV Playback", "TOGGLEUPMIXER",       "Toggle Upmixer",        "F12,Toggle Upmixer");
    382383    REG_KEY("TV Playback", "TOGGLEPIPMODE", "Toggle Picture-in-Picture mode",
    383384            "V");
    384385    REG_KEY("TV Playback", "TOGGLEPIPWINDOW", "Toggle active PiP window", "B");
     
    27422743            else if (action == "VOLUMEDOWN" || action == "VOLUMEUP" ||
    27432744                     action == "STRETCHINC" || action == "STRETCHDEC" ||
    27442745                     action == "MUTE"       || action == "TOGGLEASPECT" ||
    2745                      action == "TOGGLEFILL" )
     2746                     action == "TOGGLEFILL" || action == "TOGGLEUPMIXER")
    27462747            {
    27472748                passThru = 1;
    27482749                handled = false;
     
    27972798            else if (action == "VOLUMEDOWN" || action == "VOLUMEUP" ||
    27982799                     action == "STRETCHINC" || action == "STRETCHDEC" ||
    27992800                     action == "MUTE" || action == "PAUSE" ||
    2800                      action == "CLEAROSD")
     2801                     action == "CLEAROSD" || action == "TOGGLEUPMIXER")
    28012802            {
    28022803                passThru = 1;
    28032804                handled = false;
     
    33643365            ChangeVolume(true);
    33653366        else if (action == "MUTE")
    33663367            ToggleMute();
     3368        else if (action == "TOGGLEUPMIXER")
     3369            ToggleUpmixer();
    33673370        else if (action == "STRETCHINC")
    33683371            ChangeTimeStretch(1);
    33693372        else if (action == "STRETCHDEC")
     
    61436146        GetOSD()->SetSettingsText(text, 5);
    61446147}
    61456148
     6149void TV::ToggleUpmixer(void)
     6150{
     6151    bool state=nvp->ToggleUpmixer();
     6152
     6153    QString text;
     6154
     6155    if(state)
     6156        text = tr("Upmixer enabled");
     6157    else
     6158        text = tr("Upmixer disabled");
     6159
     6160    if (GetOSD() && !browsemode)
     6161        GetOSD()->SetSettingsText(text, 5);
     6162}
     6163
    61466164void TV::ToggleSleepTimer(void)
    61476165{
    61486166    QString text;
     
    73177335
    73187336    if (HandleTrackAction(action))
    73197337        ;
     7338    else if (action == "TOGGLEUPMIXER")
     7339        ToggleUpmixer();
    73207340    else if (action == "TOGGLEMANUALZOOM")
    73217341        SetManualZoom(true);
    73227342    else if (action == "TOGGLESTRETCH")
     
    75587578        }
    75597579    }
    75607580
     7581    new OSDGenericTree(treeMenu, tr("Toggle Upmixer"), "TOGGLEUPMIXER");
     7582
    75617583    new OSDGenericTree(treeMenu, tr("Manual Zoom Mode"), "TOGGLEMANUALZOOM");
    75627584
    75637585    new OSDGenericTree(treeMenu, tr("Adjust Audio Sync"), "TOGGLEAUDIOSYNC");
  • libs/libmyth/audiooutputbase.h

     
    7676    /// Audio Buffer Size -- should be divisible by 12,10,8,6,4,2..
    7777    static const uint kAudioRingBufferSize   = 1536000;
    7878
     79    virtual bool ToggleUpmixer(const AudioSettings&);
    7980 protected:
    8081    // You need to implement the following functions
    8182    virtual bool OpenDevice(void) = 0;
     
    153154    int source_audio_channels;
    154155    int source_audio_bytes_per_sample;
    155156    bool needs_upmix;
     157    bool upmixer_enabled;
    156158    int surround_mode;
    157159
    158160    bool blocking; // do AddSamples calls block?
  • libs/libmyth/audiooutputbase.cpp

     
    5353    source_audio_channels(-1),
    5454    source_audio_bytes_per_sample(0),
    5555    needs_upmix(false),
     56    upmixer_enabled(false),
    5657    surround_mode(FreeSurround::SurroundModePassive),
    5758
    5859    blocking(false),
     
    223224    }
    224225
    225226    if ((configured_audio_channels == 6) &&
    226         !(settings.codec || audio_codec))
     227        !(settings.codec || audio_codec) && upmixer_enabled)
    227228    {
    228229        settings.channels = configured_audio_channels;
    229230        lneeds_upmix = true;
     
    245246        return;
    246247    }
    247248
    248     if (general_deps && !upmix_deps && lneeds_upmix && upmixer)
     249    if (general_deps && !upmix_deps && lneeds_upmix && upmixer && upmixer_enabled)
    249250    {
    250251        upmixer->flush();
    251252        source_audio_channels = lsource_audio_channels;
     
    654655                              audio_bytes_per_sample) / audio_stretchfactor);
    655656    }
    656657
    657     if (upmixer && needs_upmix)
     658    if (upmixer && needs_upmix && upmixer_enabled)
    658659    {
    659660        totalbuffer += upmixer->sampleLatency() * audio_bytes_per_sample;
    660661    }
     
    700701        len = (int)ceilf(float(len) * src_data.src_ratio);
    701702
    702703    // include samples in upmix buffer that may be flushed
    703     if (needs_upmix && upmixer)
     704    if (needs_upmix && upmixer && upmixer_enabled)
    704705        len += upmixer->numUnprocessedSamples() * abps;
    705706
    706707    if (pSoundStretch)
     
    767768        len = (int)ceilf(float(len) * src_data.src_ratio);
    768769
    769770    // include samples in upmix buffer that may be flushed
    770     if (needs_upmix && upmixer)
     771    if (needs_upmix && upmixer && upmixer_enabled)
    771772        len += upmixer->numUnprocessedSamples() * abps;
    772773
    773774    if (pSoundStretch)
     
    854855    return len;
    855856}
    856857
     858bool AudioOutputBase::ToggleUpmixer(const AudioSettings& settings)
     859{
     860    upmixer_enabled = !upmixer_enabled;
     861    this->Reconfigure(settings);
     862    return upmixer_enabled;
     863}
     864
    857865void AudioOutputBase::_AddSamples(void *buffer, bool interleaved, int samples,
    858866                                  long long timecode)
    859867{
     
    870878
    871879    VERBOSE(VB_AUDIO+VB_TIMESTAMP,
    872880            LOC + QString("_AddSamples samples=%1 bytes=%2, used=%3, "
    873                           "free=%4, timecode=%5 needsupmix %6")
     881                          "free=%4, timecode=%5 needsupmix %6 upmixer enabled %7")
    874882            .arg(samples)
    875883            .arg(samples * abps)
    876884            .arg(kAudioRingBufferSize-afree).arg(afree).arg(timecode)
    877             .arg(needs_upmix));
     885            .arg(needs_upmix).arg(upmixer_enabled));
    878886
    879     if (upmixer && needs_upmix)
     887    if (upmixer && needs_upmix && upmixer_enabled)
    880888    {
    881889        int out_samples = 0;
    882890        int step = (interleaved)?source_audio_channels:1;
  • libs/libmyth/audiooutput.h

     
    6969    virtual void bufferOutputData(bool y) = 0;
    7070    virtual int readOutputData(unsigned char *read_buffer, int max_length) = 0;
    7171
     72    virtual bool ToggleUpmixer(const AudioSettings&) = 0;
     73
    7274  protected:
    7375    void Error(const QString &msg);
    7476    void Warn(const QString &msg);