~ubuntu-branches/ubuntu/breezy/muse/breezy

« back to all changes in this revision

Viewing changes to audioprefetch.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Kobras
  • Date: 2004-02-07 15:18:22 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20040207151822-es27xxkzbcxkebjm
Tags: 0.6.3-1
* New upstream version.
* Added patches:
  + [10_alsa_init_fix] New, from upstream CVS.
    Initialize direction variable when setting Alsa parameters.
  + [10_canvas_translation_fix] New, from upstream CVS.
    Do not translate tooltips twice in canvas popup.
  + [10_checkbox_fix] New, from upstream CVS.
    Use proper set/test methods on metronome checkboxes.
  + [10_html_doc_cleanup] New.
    Fix links and HTML errors in documentation.
  + [20_allow_system_timer] New.
    The new upstream version fails by default if the real-time clock
    could not be accessed (usually the case when not running suid-root).
    This patch reverts the old behaviour of falling back to the more
    inaccurate system timer.
* Updated patches:
  + [11_PIC_fixes_fixup] Rediffed.
* Removed patches:
  + [20_no_atomic_asm] Merged upstream.
* debian/compat: Splice out debhelper compatibility level from rules file.
* debian/control: Build-depend on latest jack release by default.
  Closes: #228788
* debian/control: Bump standards version.
* debian/control: Use auto-generated debconf dependency via misc:Depends.
* debian/control: Minor tweaks to the long description.
* debian/control: Tighten fluidsynth build dependency to sane version.
* debian/muse.doc-base: New. Register HTML documentation with doc-base.
* debian/templates: Tiny rewording, and typo fix.
* debian/templates, debian/po/*: Switch to po-debconf for translations.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
//=========================================================
2
2
//  MusE
3
3
//  Linux Music Editor
4
 
//  $Id: audioprefetch.cpp,v 1.2 2002/02/27 11:52:58 muse Exp $
 
4
//  $Id: audioprefetch.cpp,v 1.1.1.1 2003/10/29 10:05:00 wschweer Exp $
5
5
//
6
6
//  (C) Copyright 2001 Werner Schweer (ws@seh.de)
7
7
//=========================================================
14
14
#include "globals.h"
15
15
#include "track.h"
16
16
#include "song.h"
 
17
#include "audio.h"
 
18
 
 
19
AudioPrefetch* audioPrefetch;
17
20
 
18
21
//---------------------------------------------------------
19
22
//   AudioPrefetch
20
23
//---------------------------------------------------------
21
24
 
22
 
AudioPrefetch::AudioPrefetch(bool rt=true, int prio=50, bool ml = true)
23
 
   : Thread(rt, prio, ml)
 
25
AudioPrefetch::AudioPrefetch(int prio, const char* name)
 
26
   : Thread(prio,name)
24
27
      {
25
 
      currentFrameSize = 0;
 
28
      readSamplePos = 0;
 
29
      seekpos = -1;
26
30
      }
27
31
 
28
32
//---------------------------------------------------------
63
67
      const PrefetchMsg* msg = (PrefetchMsg*)m;
64
68
      switch(msg->id) {
65
69
            case PREFETCH_TICK:
66
 
                  prefetch(msg->pos, msg->bufferNo);
67
 
                  break;
 
70
                  prefetch();
 
71
                  break;
 
72
            case PREFETCH_SEEK:
 
73
                  seek(msg->pos);
 
74
                  {
 
75
                  int rv = write(fromThreadFdw, m, 4);
 
76
                  if (rv != 4)
 
77
                        perror("Thread::readMessage(): write pipe failed");
 
78
                  }
 
79
                  break;
 
80
            default:
 
81
                  printf("AudioPrefetch::processMsg1: unknown message\n");
68
82
            }
69
83
      }
70
84
 
72
86
//   msgTick
73
87
//---------------------------------------------------------
74
88
 
75
 
void AudioPrefetch::msgTick(int samplePos, int bufferNo)
76
 
      {
77
 
      if (noAudio)
78
 
            return;
79
 
      PrefetchMsg msg;
80
 
      msg.id = PREFETCH_TICK;
 
89
void AudioPrefetch::msgTick()
 
90
      {
 
91
      if (noAudio)
 
92
            return;
 
93
      PrefetchMsg msg;
 
94
      msg.id  = PREFETCH_TICK;
 
95
      while (sendMsg1(&msg, sizeof(msg))) {
 
96
            printf("AudioPrefetch::msgTick::sleep(1)\n");
 
97
            sleep(1);
 
98
            }
 
99
      }
 
100
 
 
101
//---------------------------------------------------------
 
102
//   msgSeek
 
103
//---------------------------------------------------------
 
104
 
 
105
void AudioPrefetch::msgSeek(int samplePos)
 
106
      {
 
107
      if (noAudio)
 
108
            return;
 
109
      PrefetchMsg msg;
 
110
      msg.id  = PREFETCH_SEEK;
81
111
      msg.pos = samplePos;
82
 
      msg.bufferNo = bufferNo;
83
112
      while (sendMsg1(&msg, sizeof(msg)))
84
113
            sleep(1);
 
114
      // wait for answer
 
115
      int rv = read(fromThreadFdr, &msg, 4);
 
116
      if (rv != 4) {
 
117
            perror("AudioPrefetch:: read pipe failed");
 
118
            }
85
119
      }
86
120
 
87
121
//---------------------------------------------------------
88
122
//   prefetch
89
123
//---------------------------------------------------------
90
124
 
91
 
void AudioPrefetch::prefetch(int pos, int bufferNo)
92
 
      {
93
 
      bool realloc = currentFrameSize != segmentSize;
94
 
      TrackList* tl = song->tracks();
95
 
      for (iTrack it = tl->begin(); it != tl->end(); ++it) {
96
 
            if ((*it)->type() != Track::WAVE)
97
 
                  continue;
98
 
            WaveTrack* track = (WaveTrack*)(*it);
99
 
            track->fetchData(bufferNo, pos, realloc);
100
 
            }
101
 
      currentFrameSize = segmentSize;
 
125
void AudioPrefetch::prefetch()
 
126
      {
 
127
      seekpos = -1;
 
128
      if (song->record())
 
129
            audio->writeTick();
 
130
      TrackList* tl = song->tracks();
 
131
      for (iTrack it = tl->begin(); it != tl->end(); ++it) {
 
132
            if ((*it)->type() != Track::WAVE)
 
133
                  continue;
 
134
            WaveTrack* track = (WaveTrack*)(*it);
 
135
// printf("prefetch %d\n", readSamplePos);
 
136
            track->fetchData(readSamplePos, segmentSize);
 
137
            }
 
138
      readSamplePos += segmentSize;
 
139
      }
 
140
 
 
141
//---------------------------------------------------------
 
142
//   seek
 
143
//---------------------------------------------------------
 
144
 
 
145
void AudioPrefetch::seek(int pos)
 
146
      {
 
147
      if (pos == seekpos)
 
148
            return;
 
149
      readSamplePos = pos;
 
150
      TrackList* tl = song->tracks();
 
151
// printf("AudioPrefetch::seek(%d)\n", pos);
 
152
      for (iTrack it = tl->begin(); it != tl->end(); ++it) {
 
153
            if ((*it)->type() != Track::WAVE)
 
154
                  continue;
 
155
            WaveTrack* track = (WaveTrack*)(*it);
 
156
            track->clearPrefetchFifo();
 
157
            for (int i = 0; i < FIFO_BUFFER; ++i) {
 
158
                  track->fetchData(readSamplePos + i * segmentSize, segmentSize);
 
159
                  }
 
160
            }
 
161
      seekpos = pos;
 
162
      readSamplePos += FIFO_BUFFER * segmentSize;
102
163
      }
103
164