root/branches/transport_redesign_2/libs/hydrogen/src/transport/H2Transport.cpp @ 1082

Revision 1082, 2.4 KB (checked in by gabriel@…, 4 years ago)

Removed EVENT_STATE/STATE_PLAYING, replaced with EVENT_TRANSPORT.

Hydrogen's STATE now just indicates the health of the audio engine,
and no longer indicates if we are playing. This is done by checking
the transport. All of the code is converted to equivalent calls,
and a new EventListener::transportEvent() callback has been added.
However, hydrogen.cpp is still a bit messy since a lot of the
scheduling code was looking at this state.

Line 
1/*
2 * Hydrogen
3 * Copyright(c) 2002-2008 by Alex >Comix< Cominu [comix@users.sourceforge.net]
4 *
5 * http://www.hydrogen-music.org
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY, without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20 *
21 */
22
23#include <hydrogen/event_queue.h>
24#include "H2Transport.h"
25#include "SimpleTransportMaster.h"
26
27using namespace H2Core;
28
29class H2Core::H2TransportPrivate
30{
31public:
32    Transport* xport;
33};
34
35H2Transport::H2Transport() :
36    d(0)   
37{
38    d = new H2TransportPrivate;
39    d->xport = new SimpleTransportMaster;
40}
41
42H2Transport::~H2Transport()
43{
44    delete d->xport;
45    delete d;
46}
47
48int H2Transport::locate(uint32_t frame)
49{
50    if(d->xport) return d->xport->locate(frame);
51    return -1;
52}
53
54int H2Transport::locate(uint32_t bar, uint32_t beat, uint32_t tick)
55{
56    if(d->xport) return d->xport->locate(bar, beat, tick);
57    return -1;
58}
59
60void H2Transport::start(void)
61{
62    EventQueue::get_instance()->push_event( EVENT_TRANSPORT, (int)TransportPosition::ROLLING );
63    if(d->xport) d->xport->start();
64}
65
66void H2Transport::stop(void)
67{
68    EventQueue::get_instance()->push_event( EVENT_TRANSPORT, (int)TransportPosition::STOPPED );
69    if(d->xport) d->xport->stop();
70}
71
72void H2Transport::get_position(TransportPosition* pos)
73{
74    if(d->xport) d->xport->get_position(pos);
75}
76
77void H2Transport::processed_frames(uint32_t nFrames)
78{
79    if(d->xport) d->xport->processed_frames(nFrames);
80}
81
82void H2Transport::set_current_song(Song* s)
83{
84    if(d->xport) d->xport->set_current_song(s);
85}
86
87uint32_t H2Transport::get_current_frame()
88{
89    if(d->xport) {
90        return d->xport->get_current_frame();
91    }
92    return (uint32_t)-1;
93}
94
95TransportPosition::State H2Transport::get_state()
96{
97    if(d->xport) {
98        return d->xport->get_state();
99    }
100    return TransportPosition::STOPPED;
101}
Note: See TracBrowser for help on using the browser.