~ubuntu-branches/ubuntu/dapper/kdemultimedia/dapper

« back to all changes in this revision

Viewing changes to kscd/kcompactdisc.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2006-01-23 14:26:07 UTC
  • mfrom: (1.2.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20060123142607-4cj5fiu4gef3wypf
Tags: 4:3.5.1-0ubuntu1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
70
70
#include "libwm/include/wm_cdtext.h"
71
71
#include "libwm/include/wm_config.h"
72
72
#include "libwm/include/wm_cdinfo.h"
 
73
#include "libwm/include/wm_helpers.h"
73
74
 
74
75
// Sun, Ultrix etc. have a canonical CD device specified in the
75
76
// respective plat_xxx.c file. On those platforms you need not
109
110
    m_infoMode(infoMode)
110
111
{
111
112
    // Debug.
112
 
    // wm_cd_set_verbosity(0xffff);
 
113
    // wm_cd_set_verbosity(WM_MSG_LEVEL_DEBUG | WM_MSG_CLASS_ALL );
113
114
    m_trackArtists.clear();
114
115
    m_trackTitles.clear();
115
116
    m_trackStartFrames.clear();
134
135
{
135
136
    if (NO_DISC || !m_tracks)
136
137
        return 0;
137
 
    return FRAMES_TO_MS(m_trackStartFrames[m_tracks - 1] - m_trackStartFrames[0]);
 
138
    return FRAMES_TO_MS(m_trackStartFrames[m_tracks+1] - m_trackStartFrames[0]);
138
139
}
139
140
 
140
141
unsigned KCompactDisc::discPosition() const
141
142
{
142
 
    return cur_pos_abs * 1000;
 
143
    return cur_pos_abs * 1000 - FRAMES_TO_MS(m_trackStartFrames[0]);
143
144
}
144
145
 
145
146
QString KCompactDisc::discStatus(int status)
217
218
 
218
219
bool KCompactDisc::isPlaying() const
219
220
{
220
 
    return WM_CDS_DISC_PLAYING(m_status) && (m_status != WM_CDM_PAUSED);
 
221
    return WM_CDS_DISC_PLAYING(m_status) && (m_status != WM_CDM_PAUSED) && (m_status != WM_CDM_TRACK_DONE);
221
222
}
222
223
 
223
224
void KCompactDisc::pause()
243
244
        if (!reply.isValid() || properties.count() < 6)
244
245
        {
245
246
            kdError() << "Invalid reply from mediamanager" << endl;
246
 
            return defaultDevice;
 
247
            return defaultDevice;
247
248
        }
248
249
        else
249
250
        {
250
251
            kdDebug() << "Reply from mediamanager " << properties[5] << endl;
251
 
            return properties[5];
 
252
            return properties[5];
252
253
        }
253
254
    }
254
255
 
293
294
        // Init CD-ROM and display.
294
295
        setVolume(volume);
295
296
    }
 
297
 
 
298
    m_previousStatus = m_status = wm_cd_status();
 
299
    
296
300
    if (m_infoMode == Asynchronous)
297
301
        timerExpired();
298
302
    else
299
 
        timer.start(1000, true);
 
303
        timer.start(1000, true);
300
304
    return m_device != QString::null;
301
305
}
302
306
 
373
377
void KCompactDisc::timerExpired()
374
378
{
375
379
    m_status = wm_cd_status();
 
380
 
376
381
    if (WM_CDS_NO_DISC(m_status) || (m_device == QString::null))
377
382
    {
378
383
        if (m_previousStatus != m_status)
445
450
        }
446
451
        if (isPlaying())
447
452
        {
 
453
            m_previousStatus = m_status;
448
454
            // Update the current playing position.
449
455
            emit trackPlaying(m_track, trackPosition());
450
456
        }
451
457
        else
452
458
        if (m_previousStatus != m_status)
453
459
        {
454
 
            m_previousStatus = m_status;
455
 
 
456
460
            // If we are not playing, then we are either paused, or stopped.
457
461
            switch (m_status)
458
462
            {
463
467
                emit trayOpening();
464
468
                break;
465
469
            default:
466
 
                emit discStopped();
 
470
                if (m_previousStatus == WM_CDM_PLAYING || m_previousStatus == WM_CDM_PAUSED
 
471
                      && m_status == WM_CDM_STOPPED)
 
472
                {
 
473
                    emit discStopped();
 
474
                }
467
475
                break;
468
476
            }
 
477
 
 
478
            m_previousStatus = m_status;
469
479
        }
470
480
    }
471
481