Ticket #429: mythfm.diff

File mythfm.diff, 19.2 KB (added by jacques.facquet@…, 19 years ago)

mythfm.diff

  • configure

     
    2121fftw_lib="no"
    2222sdl="no"
    2323aac="no"
     24radio="no"
    2425transcode="no"
    2526vcdsupport="no"
    2627exif="no"
     
    8081  ;;
    8182  --disable-aac) aac="no"
    8283  ;;
     84  --enable-radio) radio="yes"
     85  ;;
     86  --disable-radio) radio="no"
     87  ;;
    8388  --enable-transcode) transcode="yes"
    8489  ;;
    8590  --disable-transcode) transcode="no"
     
    109114                 opengl="yes";
    110115                 fftw_lib="yes";
    111116                 aac="yes";
     117                 radio="yes";
    112118                 vcdsupport="yes";
    113119                 transcode="yes";
    114120                 exif="yes";
     
    126132                 sdl="no"; 
    127133                 opengl="no";
    128134                 fftw_lib="no";
    129                  aac="no";
     135                 aac="no";
     136                 radio="no";
    130137                 vcdsupport="no";
    131138                 transcode="no";
    132139                 exif="no";
     
    166173  --enable-fftw            enable fftw visualizers [default=no]
    167174  --enable-sdl             use SDL for the synaesthesia output [default=no]
    168175  --enable-aac             enable AAC/MP4 audio file decompression [default=no]
    169 
     176  --enable-radio           enable V4L Radio decoder [default=no]
     177 
    170178MythNews related options:
    171179  --enable-mythnews        build the mythnews plugin [default=yes]
    172180
     
    453461    fi
    454462fi
    455463
     464if test "$radio" = "yes" ; then
     465  echo "        V4L Radio     support will be included in MythMusic"
     466  echo "#define RADIO_SUPPORT 1" >> ./mythmusic/mythmusic/config.h
     467  echo "HEADERS += radiodecoder.h metaioradiocomment.h v4lradio.h stationsimporter.h" >> ./mythmusic/mythmusic/config.pro
     468  echo "SOURCES += radiodecoder.cpp metaioradiocomment.cpp v4lradio.cpp stationsimporter.cpp" >> ./mythmusic/mythmusic/config.pro
     469fi
     470if test "$radio" = "no" ; then
     471  echo "        V4L Radio     support will not be included in MythMusic"
     472fi
     473
    456474###########################################################
    457475#                                                         #
    458476#   MythPhone related configuration options               #
  • mythmusic/mythmusic/playbackbox.cpp

     
    5050    curMeta = NULL;
    5151    curSmartPlaylistCategory = "";
    5252    curSmartPlaylistName = "";
     53
     54#ifdef RADIO_SUPPORT
     55    // read radio decoder settings, even radio decoder not activate???
     56    radio_lock_device = gContext->GetNumSetting("RadioLockDevice", 0);
     57    radio_max_freq = gContext->GetNumSetting("RadioFMaxOverride", 108000);
     58    radio_min_freq = gContext->GetNumSetting("RadioFMinOverride", 87500);
     59    radio_freq_step = gContext->GetNumSetting("RadioScanStep", 50);
     60#endif
    5361   
    5462    // Set our pointers the playlists and the metadata containers
    5563
     
    936944
    937945void PlaybackBoxMusic::pause(void)
    938946{
     947#ifdef RADIO_SUPPORT
     948    // sometimes radio decoder can't stop from pause state
     949    // sets pause key act as mute key :(
     950    if (decoder && decoder->factory()->extension() == ".fmd")
     951    {
     952        if (output)
     953            output->ToggleMute();
     954        return;
     955    }
     956#endif
     957
    939958    if (output)
    940959    {
    941960        isplaying = !isplaying;
     
    10181037        info_text->SetText("");
    10191038
    10201039    isplaying = false;
     1040
     1041#ifdef RADIO_SUPPORT
     1042    // restore rating image
     1043    if (showrating && curMeta)
     1044    {
     1045        if (ratings_image)
     1046            ratings_image->setRepeat(curMeta->Rating());
     1047    }
     1048    else
     1049    {
     1050        if (ratings_image)
     1051            ratings_image->setRepeat(0);
     1052    }
     1053#endif
    10211054}
    10221055
    10231056void PlaybackBoxMusic::stopAll()
     
    10871120
    10881121void PlaybackBoxMusic::seekforward()
    10891122{
     1123#ifdef RADIO_SUPPORT
     1124    if (decoder && decoder->factory()->extension() == ".fmd")
     1125    {
     1126        // seek only available if radio device in lock mode
     1127        if (artist_text && radio_lock_device)
     1128        {
     1129            QString sfreq = (artist_text->GetText().left(6)).stripWhiteSpace();
     1130            int ifreq = (int) (sfreq.toFloat() * 1000.0);
     1131
     1132            ifreq = ifreq + radio_freq_step;
     1133            if (ifreq > radio_max_freq) ifreq = radio_max_freq;
     1134
     1135            seek(ifreq);
     1136        }
     1137        return;
     1138    }
     1139#endif
    10901140    int nextTime = currentTime + 5;
    10911141    if (nextTime > maxTime)
    10921142        nextTime = maxTime;
     
    10951145
    10961146void PlaybackBoxMusic::seekback()
    10971147{
     1148#ifdef RADIO_SUPPORT
     1149    if (decoder && decoder->factory()->extension() == ".fmd")
     1150    {
     1151        // seek only available if radio device in lock mode
     1152        if (artist_text && radio_lock_device)
     1153        {
     1154            QString sfreq = (artist_text->GetText().left(6)).stripWhiteSpace();
     1155            int ifreq = (int) (sfreq.toFloat() * 1000.0);
     1156
     1157            ifreq = ifreq - radio_freq_step;
     1158            if (ifreq < radio_min_freq) ifreq = radio_min_freq;
     1159
     1160            seek(ifreq);
     1161        }
     1162        return;
     1163    }
     1164#endif
    10981165    int nextTime = currentTime - 5;
    10991166    if (nextTime < 0)
    11001167        nextTime = 0;
     
    11061173    if (output)
    11071174    {
    11081175        output->Reset();
     1176#ifdef RADIO_SUPPORT
     1177        if (decoder && decoder->factory()->extension() == ".fmd" && decoder->running())
     1178        {
     1179            if (artist_text)
     1180                artist_text->SetText(QString().setNum((float) pos / 1000.0, 'f', 2) + " " + tr("MHz"));
     1181        }
     1182        else
     1183#endif
    11091184        output->SetTimecode(pos*1000);
    11101185
    11111186        if (decoder && decoder->running())
     
    14191494                }
    14201495            }
    14211496
     1497#ifdef RADIO_SUPPORT
     1498            // signal viewer only available if radio device in lock mode
     1499            if (radio_lock_device && decoder && decoder->factory()->extension() == ".fmd")
     1500            {
     1501                if (ratings_image)
     1502                {
     1503                    decoder->mutex()->lock();
     1504                    ratings_image->setRepeat((int) (decoder->radioSignalQuality() * 10.0));
     1505                    decoder->mutex()->unlock();
     1506                }
     1507            }
     1508#endif
     1509
    14221510            break;
    14231511        }
    14241512        case OutputEvent::Error:
  • mythmusic/mythmusic/decoder.h

     
    8181
    8282    virtual Metadata *getMetadata() = 0;
    8383    virtual void commitMetadata(Metadata *mdata) = 0;
     84   
     85#ifdef RADIO_SUPPORT   
     86    virtual float radioSignalQuality() const { return 0; }
     87#endif
    8488
    8589    static void SetLocationFormatUseTags(void);
    8690
     
    177181};
    178182#endif
    179183
     184#ifdef RADIO_SUPPORT
     185class RadioDecoderFactory : public DecoderFactory
     186{
     187public:
     188    bool supports(const QString &) const;
     189    const QString &extension() const;
     190    const QString &description() const;
     191    Decoder *create(const QString &, QIODevice *, AudioOutput *, bool);
     192};
    180193#endif
     194
     195#endif
  • mythmusic/mythmusic/globalsettings.cpp

     
    11#include "mythtv/mythcontext.h"
    2 
     2#include "config.h"
    33#include <unistd.h>
    44
    55#include "globalsettings.h"
     
    1212#include <qprocess.h>
    1313#include <qapplication.h>
    1414
     15#ifdef RADIO_SUPPORT
     16#include "stationsimporter.h"
     17#endif
     18
    1519// General Settings
    1620
    1721static HostLineEdit *SetMusicDirectory()
     
    297301    return gc;
    298302};
    299303
     304
     305#ifdef RADIO_SUPPORT
     306static HostComboBox *RadioDevice()
     307{
     308    HostComboBox *gc = new HostComboBox("RadioDevice", true);
     309    gc->setLabel(QObject::tr("Radio device"));
     310    QDir dev("/dev", "radio*", QDir::Name, QDir::System);
     311    gc->fillSelectionsFromDir(dev);
     312
     313    dev.setNameFilter("radio*");
     314    dev.setPath("/dev/v4l");
     315    gc->fillSelectionsFromDir(dev);
     316    //gc->setHelpText(QObject::tr("Radio device used for playback."));
     317    return gc;
     318};
     319
     320static HostSpinBox *RadioFMinOverride()
     321{
     322    HostSpinBox *gc = new HostSpinBox("RadioFMinOverride", 65000, 108000, 500);
     323    gc->setLabel(QObject::tr("Minimum frequency [kHz]"));
     324    gc->setValue(87500);
     325    gc->setHelpText(QObject::tr("Override radio device minimum frequency to this value."));
     326    return gc;
     327};
     328
     329static HostSpinBox *RadioFMaxOverride()
     330{
     331    HostSpinBox *gc = new HostSpinBox("RadioFMaxOverride", 65000, 108000, 500);
     332    gc->setLabel(QObject::tr("Maximum frequency [kHz]"));
     333    gc->setValue(108000);
     334    gc->setHelpText(QObject::tr("Override radio device maximum frequency to this value."));
     335    return gc;
     336};
     337
     338static HostSpinBox *RadioScanStep()
     339{
     340    HostSpinBox *gc = new HostSpinBox("RadioScanStep", 5, 500, 5);
     341    gc->setLabel(QObject::tr("Frequency step (kHz)"));
     342    gc->setValue(50);
     343    gc->setHelpText(QObject::tr("Sets radio frequency to this value multiplication."));
     344    return gc;
     345};
     346
     347static HostSpinBox *RadioSignalMinQuality()
     348{
     349    HostSpinBox *gc = new HostSpinBox("RadioSignalMinQuality", 10, 100, 1);
     350    gc->setLabel(QObject::tr("Minimum signal quality [%]"));
     351    gc->setValue(60);
     352    gc->setHelpText(QObject::tr("Minimum signal for frequency good quality."));
     353    return gc;
     354};
     355
     356static HostLineEdit *RadioDirectory()
     357{
     358    HostLineEdit *gc = new HostLineEdit("RadioLocation");
     359    gc->setLabel(QObject::tr("Directory to hold radio file"));
     360    gc->setValue("/mnt/store/music/radio");
     361    gc->setHelpText(QObject::tr("This directory must exist, and the user "
     362                    "running MythMusic needs to have write permission "
     363                    "to the directory. Sets under MythMusic directory."));
     364    return gc;
     365};
     366
     367static TransButtonSetting *ButtonImport()
     368{
     369    TransButtonSetting *gc = new TransButtonSetting();
     370    gc->setLabel(QObject::tr("Import MythFM Station Database"));
     371    gc->setHelpText(QObject::tr("Import all MythFM station database and save it to .fmd file."));
     372    return gc;
     373}
     374
     375static TransButtonSetting *ButtonScan()
     376{
     377    TransButtonSetting *gc = new TransButtonSetting();
     378    gc->setLabel(QObject::tr("Scan Radio Stations"));
     379    gc->setHelpText(QObject::tr("Scan all radio stations and save it to .fmd file."));
     380    return gc;
     381}
     382
     383static HostCheckBox *RadioUseOldV4L2Calls()
     384{
     385    HostCheckBox *gc = new HostCheckBox("RadioUseOldV4L2Calls");
     386    gc->setLabel(QObject::tr("Use old V4L2 calls"));
     387    gc->setValue(true);
     388    gc->setHelpText(QObject::tr("Sets this value to figure out old version V4L2 calls. "
     389                    "MythMusic will try the other version of the call in case this set "
     390                    "did not work."));
     391    return gc;
     392};
     393
     394static HostCheckBox *RadioIVTVPassthrough()
     395{
     396    HostCheckBox *gc = new HostCheckBox("RadioIVTVPassthrough");
     397    gc->setLabel(QObject::tr("Activate ivtv passthrough mode"));
     398    gc->setValue(false);
     399    gc->setHelpText(QObject::tr("Sets this value to enable ivtv passthrough mode in "
     400                    "case ivtv driver activate. (experimental)"));
     401    return gc;
     402};
     403
     404static HostCheckBox *RadioLockDevice()
     405{
     406    HostCheckBox *gc = new HostCheckBox("RadioLockDevice");
     407    gc->setLabel(QObject::tr("Lock radio device while playing"));
     408    gc->setValue(false);
     409    gc->setHelpText(QObject::tr("Note that activate this setting can be  "
     410                    "disturb your tv recording schedule. Be carefull. "
     411                    "Frequency seeker and signal viewer only available "
     412                    "in lock mode."));
     413    return gc;
     414};
     415
     416static HostComboBox *RadioAudioDevice()
     417{
     418    HostComboBox *gc = new HostComboBox("RadioAudioDevice", true);
     419    gc->setLabel(QObject::tr("Radio audio device"));
     420    QDir dev("/dev", "dsp*", QDir::Name, QDir::System);
     421    gc->fillSelectionsFromDir(dev);
     422    dev.setNameFilter("video*");
     423    gc->fillSelectionsFromDir(dev);
     424
     425    dev.setNameFilter("dsp*");
     426    dev.setPath("/dev/sound");
     427    gc->fillSelectionsFromDir(dev);
     428    gc->setHelpText(QObject::tr("Audio device used as audio input for audio playback."));
     429    return gc;
     430};
     431
     432static HostComboBox *RadioAudioRate()
     433{
     434    HostComboBox *gc = new HostComboBox("RadioAudioRate", true);
     435    gc->setLabel(QObject::tr("Audio sampling rate"));
     436    gc->addSelection("32000"); // prepare for bttv audio
     437    gc->addSelection("44100"); // prepare for audio pass-through
     438    gc->addSelection("48000"); // prepare for ivtv audio
     439    gc->setHelpText(QObject::tr("Sets the audio sampling rate for your DSP. "
     440                    "Ensure that you choose a sampling rate appropriate "
     441                    "for your device.  btaudio may only allow 32000, "
     442                    "ivtv may only allow 48000."));
     443    return gc;
     444};
     445
     446static HostSlider *RadioVolume()
     447{
     448    HostSlider *gc = new HostSlider("RadioVolume", 0, 100, 5);
     449    gc->setLabel(QObject::tr("Radio device volume"));
     450    gc->setValue(100);
     451    gc->setHelpText(QObject::tr("Volume position for radio device."));
     452    return gc;
     453};
     454
     455static HostSlider *RadioTreble()
     456{
     457    HostSlider *gc = new HostSlider("RadioTreble", 0, 100, 5);
     458    gc->setLabel(QObject::tr("Radio device treble"));
     459    gc->setValue(50);
     460    gc->setHelpText(QObject::tr("Treble position for radio device."));
     461    return gc;
     462};
     463
     464static HostSlider *RadioBass()
     465{
     466    HostSlider *gc = new HostSlider("RadioBass", 0, 100, 5);
     467    gc->setLabel(QObject::tr("Radio device bass"));
     468    gc->setValue(50);
     469    gc->setHelpText(QObject::tr("Bass position for radio device."));
     470    return gc;
     471};
     472
     473static HostSlider *RadioBalance()
     474{
     475    HostSlider *gc = new HostSlider("RadioBalance", -100, 100, 5);
     476    gc->setLabel(QObject::tr("Radio device balance"));
     477    gc->setValue(0);
     478    gc->setHelpText(QObject::tr("Balance position for radio device."));
     479    return gc;
     480};
     481
     482static HostCheckBox *RadioAudioAsFile()
     483{
     484    HostCheckBox *gc = new HostCheckBox("RadioAudioAsFile");
     485    gc->setLabel(QObject::tr("Open audio device as file"));
     486    gc->setValue(false);
     487    gc->setHelpText(QObject::tr("Open audio device as raw PCM stream file. "
     488                    "Activate this setting to enable ivtv radio audio support."));
     489    return gc;
     490};
     491#endif
     492
    300493//Player Settings
    301494
    302495static HostComboBox *PlayMode()
     
    510703    general2->addChild(CDWriteSpeed());
    511704    general2->addChild(CDBlankType());
    512705    addChild(general2);
     706   
     707#ifdef RADIO_SUPPORT   
     708    VerticalConfigurationGroup* general3 = new VerticalConfigurationGroup(false);
     709    general3->setLabel(QObject::tr("Radio Settings"));
     710    general3->addChild(RadioDevice());
     711    general3->addChild(RadioLockDevice());
     712    general3->addChild(RadioFMinOverride());
     713    general3->addChild(RadioFMaxOverride());
     714    general3->addChild(RadioScanStep());
     715    general3->addChild(RadioSignalMinQuality());
     716    general3->addChild(RadioDirectory());
     717   
     718    HorizontalConfigurationGroup* buttonImporter =
     719            new HorizontalConfigurationGroup(false, false);
     720   
     721    StationsImporter* importer = new StationsImporter();
     722   
     723    TransButtonSetting* buttonImport = ButtonImport();
     724    buttonImporter->addChild(buttonImport);
     725    QObject::connect(buttonImport, SIGNAL(pressed()), importer, SLOT(importStations()));
     726   
     727    TransButtonSetting* buttonScan = ButtonScan();
     728    buttonImporter->addChild(buttonScan);
     729    QObject::connect(buttonScan, SIGNAL(pressed()), importer, SLOT(scanStations()));
     730   
     731    general3->addChild(buttonImporter);
     732   
     733    addChild(general3);
     734   
     735    VerticalConfigurationGroup* general4 = new VerticalConfigurationGroup(false);
     736    general4->setLabel(QObject::tr("Radio Settings (part 2)"));
     737    general4->addChild(RadioAudioDevice());
     738    general4->addChild(RadioAudioAsFile());
     739    general4->addChild(RadioAudioRate());
     740    general4->addChild(RadioVolume());
     741    general4->addChild(RadioTreble());
     742    general4->addChild(RadioBass());
     743    general4->addChild(RadioBalance());
     744   
     745    general4->addChild(RadioUseOldV4L2Calls());
     746    general4->addChild(RadioIVTVPassthrough());
     747   
     748    addChild(general4);
     749#endif
    513750}
    514751
    515752MusicPlayerSettings::MusicPlayerSettings()
  • mythmusic/mythmusic/decoder.cpp

     
    121121#ifdef AAC_SUPPORT
    122122        Decoder::registerFactory(new aacDecoderFactory);
    123123#endif
     124#ifdef RADIO_SUPPORT
     125        Decoder::registerFactory(new RadioDecoderFactory);
     126#endif
    124127    }
    125128}
    126129
  • mythmusic/mythmusic/editmetadata.cpp

     
    55#include "decoder.h"
    66#include "genres.c"
    77
     8#include "config.h"
     9
     10#include <math.h>
     11
     12#ifdef RADIO_SUPPORT
     13int intFrequency(int freq)
     14{
     15    int step = gContext->GetNumSetting("RadioScanStep",         50);
     16    int minf = gContext->GetNumSetting("RadioFMinOverride",  87500);
     17    int maxf = gContext->GetNumSetting("RadioFMaxOverride", 108000);
     18   
     19    if (freq < minf || freq > maxf) freq = 87500;
     20     
     21    // rounding frequency to step
     22    freq = (int)(rint(freq / step) * step);
     23
     24    return freq;
     25}
     26
     27QString strFrequency(int freq)
     28{
     29    float ffreq = (float) intFrequency(freq) / 1000.0;
     30
     31    QString s = QString().setNum(ffreq, 'f', 2) + " " + QObject::tr("MHz");
     32
     33    return s;
     34}
     35#endif
     36
    837EditMetadataDialog::EditMetadataDialog(Metadata *source_metadata,
    938                                 MythMainWindow *parent,
    1039                                 QString window_name,
     
    487516void EditMetadataDialog::saveToDatabase()
    488517{
    489518    cancelPopup();
     519   
     520#ifdef RADIO_SUPPORT
     521    Decoder *decoder = Decoder::create(m_metadata->Filename(), NULL, NULL, true);
     522    if (decoder)
     523    {
     524        if (decoder->factory()->extension() == ".fmd")
     525        {
     526            int i     = m_metadata->Track();
    490527
     528            m_metadata->setArtist(strFrequency(i));
     529            m_metadata->setAlbum(tr("Radio Stations"));
     530            m_metadata->setTrack(intFrequency(i));
     531        }
     532        delete decoder;
     533    }
     534#endif
     535
    491536    m_metadata->updateDatabase(QString::null);
    492537    *m_sourceMetadata = m_metadata;
    493538    done(1);
     
    509554    Decoder *decoder = Decoder::create(m_metadata->Filename(), NULL, NULL, true);
    510555    if (decoder)
    511556    {
     557#ifdef RADIO_SUPPORT
     558        if (decoder->factory()->extension() == ".fmd")
     559        {
     560            int i     = m_metadata->Track();
     561
     562            m_metadata->setArtist(strFrequency(i));
     563            m_metadata->setAlbum(tr("Radio Stations"));
     564            m_metadata->setTrack(intFrequency(i));
     565        }
     566#endif
    512567        decoder->commitMetadata(m_metadata);
    513568        delete decoder;
    514569    }
  • mythmusic/mythmusic/playbackbox.h

     
    99#include <mythtv/dialogbox.h>
    1010#include <mythtv/audiooutput.h>
    1111
     12#include "config.h"
     13
    1214#include "mainvisual.h"
    1315#include "metadata.h"
    1416#include "playlist.h"
     
    153155    bool show_whole_tree;
    154156    bool keyboard_accelerators;
    155157    bool volume_control;
     158   
     159#ifdef RADIO_SUPPORT   
     160    bool radio_lock_device;   
     161    int radio_max_freq;
     162    int radio_min_freq;
     163    int radio_freq_step;
     164#endif
    156165
    157166    MythPopupBox *playlist_popup;
    158167