diff --git a/gambatte_qt/src/gambattesource.cpp b/gambatte_qt/src/gambattesource.cpp index 627b367..67bba3a 100644 --- a/gambatte_qt/src/gambattesource.cpp +++ b/gambatte_qt/src/gambattesource.cpp @@ -44,18 +44,6 @@ const std::vector GambatteSource::generateVideoSou return v; } -const MediaSource::SampleRateInfo GambatteSource::generateSampleRateInfo() { - SampleRateInfo srinfo; - - srinfo.rates.push_back(48000); - srinfo.rates.push_back(44100); - srinfo.defaultRateIndex = 0; - srinfo.minCustomRate = 8000; - srinfo.maxCustomRate = 192000; - - return srinfo; -} - enum { UP_BUTTON, DOWN_BUTTON, LEFT_BUTTON, RIGHT_BUTTON, A_BUTTON, B_BUTTON, START_BUTTON, SELECT_BUTTON, diff --git a/gambatte_qt/src/gambattesource.h b/gambatte_qt/src/gambattesource.h index af0e5fa..16ecfa3 100644 --- a/gambatte_qt/src/gambattesource.h +++ b/gambatte_qt/src/gambattesource.h @@ -54,7 +54,6 @@ public: static const std::vector generateButtonInfos(); const std::vector generateVideoSourceInfos(); - static const SampleRateInfo generateSampleRateInfo(); void emitBlit() { emit blit(); } diff --git a/gambatte_qt/src/main.cpp b/gambatte_qt/src/main.cpp index a32485a..3def817 100644 --- a/gambatte_qt/src/main.cpp +++ b/gambatte_qt/src/main.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2007 by Sindre Aamås * + * Copyright (C) 2007 by Sindre Aam�s * * aamas@stud.ntnu.no * * * * This program is free software; you can redistribute it and/or modify * @@ -33,8 +33,7 @@ int main(int argc, char *argv[]) { source.generateButtonInfos(), source.generateVideoSourceInfos(), MainWindow::tr("Video filter:"), - QSize(160, 144), - source.generateSampleRateInfo()); + QSize(160, 144)); GambatteMenuHandler mh(mw, &source, argc, argv); mw->show(); return app.exec(); diff --git a/gambatte_qt/src/mainwindow.cpp b/gambatte_qt/src/mainwindow.cpp index f77cbc4..4e8d390 100644 --- a/gambatte_qt/src/mainwindow.cpp +++ b/gambatte_qt/src/mainwindow.cpp @@ -132,8 +132,7 @@ MainWindow::MainWindow(MediaSource *source, const std::vector &buttonInfos, const std::vector &videoSourceInfos, const QString &videoSourceLabel, - const QSize &aspectRatio, - const MediaSource::SampleRateInfo &sampleRateInfo) : + const QSize &aspectRatio) : source(source), buttonHandlers(buttonInfos.size(), ButtonHandler(0, 0)), blitter(NULL), @@ -170,7 +169,7 @@ MainWindow::MainWindow(MediaSource *source, addAudioEngines(audioEngines, winId()); audioEngines.push_back(new NullAudioEngine); - soundDialog = new SoundDialog(audioEngines, sampleRateInfo, this); + soundDialog = new SoundDialog(audioEngines, this); connect(soundDialog, SIGNAL(accepted()), this, SLOT(soundSettingsChange())); inputDialog = new InputDialog(buttonInfos, this); @@ -445,10 +444,6 @@ void MainWindow::setAspectRatio(const QSize &aspectRatio) { videoDialog->setAspectRatio(aspectRatio); } -void MainWindow::setSampleRates(const MediaSource::SampleRateInfo &sampleRateInfo) { - soundDialog->setRates(sampleRateInfo); -} - void MainWindow::setVideoSources(const std::vector &sourceInfos) { videoDialog->setVideoSources(sourceInfos); } diff --git a/gambatte_qt/src/mainwindow.h b/gambatte_qt/src/mainwindow.h index ce7a038..5aebef3 100644 --- a/gambatte_qt/src/mainwindow.h +++ b/gambatte_qt/src/mainwindow.h @@ -166,16 +166,12 @@ public: * listed are multiples of the base size. Use bigger width and height values * to get fewer window sizes listed. Can be changed later with the setAspectRatio * method. - * - * @param sampleRateInfo Information about sample rates selectable in the sound dialog. - * Can be changed later with the setSampleRates method. */ MainWindow(MediaSource *source, const std::vector &buttonInfos, const std::vector &videoSourceInfos, const QString &videoSourceLabel, - const QSize &aspectRatio, - const MediaSource::SampleRateInfo &sampleRateInfo); + const QSize &aspectRatio); ~MainWindow(); const QSize& aspectRatio() const; @@ -209,7 +205,6 @@ public: * from MainWindow, and unpaused when the dialog is closed. pauseOnDialogExec is on by default. */ void setPauseOnDialogExec(bool enable) { pauseOnDialogExec = enable; } - void setSampleRates(const MediaSource::SampleRateInfo &sampleRateInfo); void setVideoSources(const std::vector &sourceInfos); /** diff --git a/gambatte_qt/src/mediasource.h b/gambatte_qt/src/mediasource.h index 8bbcb0d..3848e90 100644 --- a/gambatte_qt/src/mediasource.h +++ b/gambatte_qt/src/mediasource.h @@ -77,21 +77,6 @@ public: int defaultAltKey; }; - struct SampleRateInfo { - enum { NOT_SUPPORTED = -1 }; - - // Distinct sample rate (stereo samples per second) alternatives selectable in the sound settings dialog. - std::vector rates; - - // The index of the rate in the rates list to be selected by default. - std::size_t defaultRateIndex; - - // Minimum and maximum custom sample rates selectable in the sound settings dialog. - // Set to NOT_SUPPORTED if you don't want to allow custom sample rates. - int minCustomRate; - int maxCustomRate; - }; - const unsigned overupdate; /** diff --git a/gambatte_qt/src/sounddialog.cpp b/gambatte_qt/src/sounddialog.cpp index 22c5a1b..8939deb 100644 --- a/gambatte_qt/src/sounddialog.cpp +++ b/gambatte_qt/src/sounddialog.cpp @@ -31,6 +31,33 @@ #include "audioengine.h" +struct SampleRateInfo { + enum { NOT_SUPPORTED = -1 }; + + // Distinct sample rate (stereo samples per second) alternatives selectable in the sound settings dialog. + std::vector rates; + + // The index of the rate in the rates list to be selected by default. + std::size_t defaultRateIndex; + + // Minimum and maximum custom sample rates selectable in the sound settings dialog. + // Set to NOT_SUPPORTED if you don't want to allow custom sample rates. + int minCustomRate; + int maxCustomRate; +}; + +static SampleRateInfo generateSampleRateInfo() { + SampleRateInfo srinfo; + + srinfo.rates.push_back(48000); + srinfo.rates.push_back(44100); + srinfo.defaultRateIndex = 0; + srinfo.minCustomRate = 8000; + srinfo.maxCustomRate = 192000; + + return srinfo; +} + static int filterValue(const int value, const int upper, const int lower = 0, const int fallback = 0) { if (value >= upper || value < lower) return fallback; @@ -38,7 +65,7 @@ static int filterValue(const int value, const int upper, const int lower = 0, co return value; } -static void populateRateSelector(QComboBox *rateSelector, const MediaSource::SampleRateInfo &rateInfo) { +static void populateRateSelector(QComboBox *rateSelector, const SampleRateInfo &rateInfo) { assert(!rateInfo.rates.empty()); assert(rateInfo.defaultRateIndex < rateInfo.rates.size()); @@ -78,7 +105,7 @@ static void setRate(QComboBox *rateSelector, const int r) { rateSelector->setCurrentIndex(newIndex); } -SoundDialog::SoundDialog(const std::vector &engines, const MediaSource::SampleRateInfo &rateInfo, QWidget *parent) : +SoundDialog::SoundDialog(const std::vector &engines, QWidget *parent) : QDialog(parent), engines(engines), topLayout(new QVBoxLayout), @@ -122,7 +149,7 @@ SoundDialog::SoundDialog(const std::vector &engines, const MediaSo QHBoxLayout *const hLayout = new QHBoxLayout; hLayout->addWidget(new QLabel(tr("Sample rate:"))); - populateRateSelector(rateSelector, rateInfo); + populateRateSelector(rateSelector, generateSampleRateInfo()); hLayout->addWidget(rateSelector); topLayout->addLayout(hLayout); @@ -229,17 +256,6 @@ void SoundDialog::restore() { latencySelector->setValue(latency); } -void SoundDialog::setRates(const MediaSource::SampleRateInfo &rateInfo) { - restore(); - - rateSelector->clear(); - populateRateSelector(rateSelector, rateInfo); - setRate(rateSelector, rate); - - store(); - emit accepted(); -} - void SoundDialog::accept() { store(); QDialog::accept(); diff --git a/gambatte_qt/src/sounddialog.h b/gambatte_qt/src/sounddialog.h index aa5efa1..8a34ed6 100644 --- a/gambatte_qt/src/sounddialog.h +++ b/gambatte_qt/src/sounddialog.h @@ -51,13 +51,12 @@ private slots: void rateIndexChange(int index); public: - SoundDialog(const std::vector &engines, const MediaSource::SampleRateInfo &rateInfo, QWidget *parent = 0); + SoundDialog(const std::vector &engines, QWidget *parent = 0); ~SoundDialog(); int getEngineIndex() const { return engineIndex; } int getResamplerNum() const { return resamplerNum; } int getRate() const { return rate; } int getLatency() const { return latency; }; - void setRates(const MediaSource::SampleRateInfo &rateInfo); public slots: void accept();