~ubuntu-branches/ubuntu/trusty/teeworlds/trusty-updates

« back to all changes in this revision

Viewing changes to .pc/system-libs.patch/src/engine/client/sound.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Felix Geyer
  • Date: 2011-08-05 15:02:49 UTC
  • mfrom: (1.2.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20110805150249-1kai5j7v29m13dl3
Tags: 0.6.1+dfsg-1
* New upstream release.
* Repackage upstream tarball to remove pre-compiled libraries.
* Update watch file.
* Refresh patches.
* Drop patches that have been applied upstream: fix-ftbfs-hurd.patch,
  fix-ftbfs-kfreebsd.patch and gcc-endianness.patch.
* Use dh_link to create the DejaVuSans.ttf symlink.
* Query dpkg-buildflags instead of relying on dpkg-buildpackage to set the
  environment variables.

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
        int m_Channels;
32
32
        int m_LoopStart;
33
33
        int m_LoopEnd;
 
34
        int m_PausedAt;
34
35
};
35
36
 
36
37
struct CChannel
54
55
static CChannel m_aChannels[NUM_CHANNELS] = { {255, 0} };
55
56
 
56
57
static LOCK m_SoundLock = 0;
57
 
static int m_SoundEnabled = 0;
58
58
 
59
59
static int m_CenterX = 0;
60
60
static int m_CenterY = 0;
157
157
                        
158
158
                        // free voice if not used any more
159
159
                        if(v->m_Tick == v->m_pSample->m_NumFrames)
160
 
                                v->m_pSample = 0;
161
 
                        
 
160
                        {
 
161
                                if(v->m_Flags&ISound::FLAG_LOOP)
 
162
                                        v->m_Tick = 0;
 
163
                                else
 
164
                                        v->m_pSample = 0;
 
165
                        }
162
166
                }
163
167
        }
164
168
        
194
198
 
195
199
int CSound::Init()
196
200
{
 
201
        m_SoundEnabled = 0;
197
202
        m_pGraphics = Kernel()->RequestInterface<IEngineGraphics>();
198
203
        m_pStorage = Kernel()->RequestInterface<IStorage>();
199
204
        
389
394
                pSample->m_NumFrames = m_aSamples;
390
395
                pSample->m_LoopStart = -1;
391
396
                pSample->m_LoopEnd = -1;
 
397
                pSample->m_PausedAt = 0;
392
398
        }
393
399
        else
394
400
        {
410
416
        m_CenterX = (int)x;
411
417
        m_CenterY = (int)y;
412
418
}
413
 
        
 
419
 
414
420
 
415
421
void CSound::SetChannel(int ChannelID, float Vol, float Pan)
416
422
{
442
448
        {
443
449
                m_aVoices[VoiceID].m_pSample = &m_aSamples[SampleID];
444
450
                m_aVoices[VoiceID].m_pChannel = &m_aChannels[ChannelID];
445
 
                m_aVoices[VoiceID].m_Tick = 0;
 
451
                if(Flags & FLAG_LOOP)
 
452
                        m_aVoices[VoiceID].m_Tick = m_aSamples[SampleID].m_PausedAt;
 
453
                else
 
454
                        m_aVoices[VoiceID].m_Tick = 0;
446
455
                m_aVoices[VoiceID].m_Vol = 255;
447
456
                m_aVoices[VoiceID].m_Flags = Flags;
448
457
                m_aVoices[VoiceID].m_X = (int)x;
463
472
        return Play(ChannelID, SampleID, Flags, 0, 0);
464
473
}
465
474
 
466
 
void CSound::Stop(int VoiceID)
 
475
void CSound::Stop(int SampleID)
467
476
{
468
477
        // TODO: a nice fade out
469
478
        lock_wait(m_SoundLock);
470
 
        m_aVoices[VoiceID].m_pSample = 0;
 
479
        CSample *pSample = &m_aSamples[SampleID];
 
480
        for(int i = 0; i < NUM_VOICES; i++)
 
481
        {
 
482
                if(m_aVoices[i].m_pSample == pSample)
 
483
                {
 
484
                        if(m_aVoices[i].m_Flags & FLAG_LOOP)
 
485
                                m_aVoices[i].m_pSample->m_PausedAt = m_aVoices[i].m_Tick;
 
486
                        else
 
487
                                m_aVoices[i].m_pSample->m_PausedAt = 0;
 
488
                        m_aVoices[i].m_pSample = 0;
 
489
                }
 
490
        }
471
491
        lock_release(m_SoundLock);
472
492
}
473
493
 
477
497
        lock_wait(m_SoundLock);
478
498
        for(int i = 0; i < NUM_VOICES; i++)
479
499
        {
 
500
                if(m_aVoices[i].m_pSample)
 
501
                {
 
502
                        if(m_aVoices[i].m_Flags & FLAG_LOOP)
 
503
                                m_aVoices[i].m_pSample->m_PausedAt = m_aVoices[i].m_Tick;
 
504
                        else
 
505
                                m_aVoices[i].m_pSample->m_PausedAt = 0;
 
506
                }
480
507
                m_aVoices[i].m_pSample = 0;
481
508
        }
482
509
        lock_release(m_SoundLock);