• R/O
  • SSH
  • HTTPS

qrobosdk: コミット


コミットメタ情報

リビジョン13 (tree)
日時2008-05-11 20:14:58
作者satofumi

ログメッセージ

add CD player demo

変更サマリ

差分

--- trunk/libs/sound/CdromPlay.cpp (revision 12)
+++ trunk/libs/sound/CdromPlay.cpp (revision 13)
@@ -111,16 +111,26 @@
111111
112112 bool getCurrentFrame(size_t* frame, size_t* min, size_t* sec) {
113113
114- //FRAMES_TO_MSF(cdrom->cur_frame, &min, &sec, &frame);
115- //printf("現在位置: %d 分, %d 秒, %d フレーム\n", min, sec, frame);
116-
117114 if (! checkDrive(track_list_)) {
118115 return false;
119116 }
120117
118+ // 値の取得
119+ size_t frame_length = 0;
120+ size_t min_length = 0;
121+ size_t sec_length = 0;
122+ FRAMES_TO_MSF(cdrom_->cur_frame, &min_length, &sec_length, &frame_length);
123+
124+ // 代入
121125 if (frame) {
122- *frame = cdrom_->cur_frame;
126+ *frame = frame_length;
123127 }
128+ if (min) {
129+ *min = min_length;
130+ }
131+ if (sec) {
132+ *sec = sec_length;
133+ }
124134 return true;
125135 }
126136 };
@@ -161,15 +171,10 @@
161171 return -1;
162172 }
163173
164- size_t play_msec = 0;
165- if (play_frame != 0) {
166- play_msec = 1000 * play_frame / CD_FPS;
174+ size_t play_frame_length = (play_frame == 0) ?
175+ pimpl->track_list_[track_id].frame_length - start_frame : play_frame;
167176
168- } else {
169- size_t play_frame_ =
170- pimpl->track_list_[track_id].frame_length - start_frame;
171- play_msec = 1000 * play_frame_ / CD_FPS;
172- }
177+ size_t play_msec = 1000 * play_frame_length / CD_FPS;
173178 return play_msec;
174179 }
175180
--- trunk/libs/sound/Makefile (revision 12)
+++ trunk/libs/sound/Makefile (revision 13)
@@ -5,7 +5,7 @@
55 # Compile options
66 CC = ${CXX}
77 CXXFLAGS = -g -O0 -Wall -Werror ${INCLUDES} `sdl-config --cflags`
8-INCLUDES = -I../system
8+INCLUDES = -I../system/sdl -I../system
99
1010 # Target
1111 SOUND_LIB = sound.a
--- trunk/programs/CdPlayer/main.cpp (revision 12)
+++ trunk/programs/CdPlayer/main.cpp (revision 13)
@@ -8,11 +8,16 @@
88 */
99
1010 #include <QApplication>
11+#include "CdPlayerWidget.h"
1112
13+using namespace qrk;
1214
15+
1316 int main(int argc, char *argv[]) {
1417
1518 QApplication app(argc, argv);
19+ CdPlayerWidget widget;
20+ widget.show();
1621
1722 return app.exec();
1823 }
--- trunk/programs/CdPlayer/CdPlayerWidget.cpp (revision 12)
+++ trunk/programs/CdPlayer/CdPlayerWidget.cpp (revision 13)
@@ -7,4 +7,60 @@
77 $Id$
88 */
99
10+#include <QShortcut>
1011 #include "CdPlayerWidget.h"
12+#include "CdromPlay.h"
13+
14+using namespace qrk;
15+
16+
17+struct CdPlayerWidget::pImpl {
18+ CdromPlay cdrom_;
19+
20+ void initForm(CdPlayerWidget* parent) {
21+
22+ // Track テーブルの初期化
23+ QStringList labels;
24+ labels << "Track" << "Length";
25+ parent->track_table_->setHorizontalHeaderLabels(labels);
26+
27+ // LCD を初期化
28+ parent->frame_lcd_->display(" 00:00");
29+
30+ // 初期ボリューム値の取得
31+ // !!! CdromPlay から受け取った値で初期化すべき
32+
33+ // Ctrl-q で終了できるようにする
34+ (void) new QShortcut(Qt::CTRL + Qt::Key_Q, parent, SLOT(close()));
35+
36+#if 0
37+ // ボタンイベントの登録
38+ connect(parent->eject_button_, SIGNAL(clicked()),
39+ parent, SLOT(eject()));
40+ // !!!
41+#endif
42+
43+ // 定期的に CD-ROM があるかをチェックする
44+ // !!!
45+ }
46+};
47+
48+
49+CdPlayerWidget::CdPlayerWidget(void)
50+ : QWidget(0), pimpl(new pImpl) {
51+ setupUi(this);
52+
53+ pimpl->initForm(this);
54+}
55+
56+
57+CdPlayerWidget::CdPlayerWidget(QWidget* parent)
58+ : QWidget(parent), pimpl(new pImpl) {
59+ setupUi(this);
60+
61+ pimpl->initForm(this);
62+}
63+
64+
65+CdPlayerWidget::~CdPlayerWidget(void) {
66+}
--- trunk/programs/CdPlayer/CdPlayerWidget.h (revision 12)
+++ trunk/programs/CdPlayer/CdPlayerWidget.h (revision 13)
@@ -12,8 +12,21 @@
1212
1313 #include "ui_CdPlayerForm.h"
1414
15+
1516 namespace qrk {
16- class CdPlayerWidget : public Ui::CdPlayerForm {
17+ class CdPlayerWidget : public QWidget, private Ui::CdPlayerForm {
18+ Q_OBJECT;
19+
20+ CdPlayerWidget(const CdPlayerWidget& rhs);
21+ CdPlayerWidget& operator = (const CdPlayerWidget& rhs);
22+
23+ struct pImpl;
24+ const std::auto_ptr<pImpl> pimpl;
25+
26+ public:
27+ CdPlayerWidget(void);
28+ CdPlayerWidget(QWidget* parent);
29+ ~CdPlayerWidget(void);
1730 };
1831 };
1932
--- trunk/programs/Makefile (revision 12)
+++ trunk/programs/Makefile (revision 13)
@@ -2,6 +2,12 @@
22 # Satofumi KAMIMURA
33 # $Id$
44
5-include ../handover.mk
5+#include ../handover.mk
6+#TARGET_DIR = hyakutyping/ qtmclock/
67
7-TARGET_DIR = hyakutyping/ qtmclock/
8+all :
9+
10+clean :
11+ cd hyakutyping/ && ${MAKE} clean
12+ cd qtmclock/ && ${MAKE} clean
13+ cd CdPlayer/ && (if test -f Makefile; then ${MAKE} distclean; fi)
旧リポジトリブラウザで表示