~ubuntu-branches/ubuntu/feisty/ecasound2.2/feisty

« back to all changes in this revision

Viewing changes to libecasound/audio-stamp.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Junichi Uekawa
  • Date: 2005-04-14 09:15:48 UTC
  • Revision ID: james.westby@ubuntu.com-20050414091548-o7kgb47z0tcunh0s
Tags: upstream-2.4.1
ImportĀ upstreamĀ versionĀ 2.4.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// ------------------------------------------------------------------------
 
2
// audio-stamp.cpp: Classes for handling audio stamps and their clients
 
3
// Copyright (C) 2000 Kai Vehmanen
 
4
//
 
5
// This program is free software; you can redistribute it and/or modify
 
6
// it under the terms of the GNU General Public License as published by
 
7
// the Free Software Foundation; either version 2 of the License, or
 
8
// (at your option) any later version.
 
9
// 
 
10
// This program is distributed in the hope that it will be useful,
 
11
// but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
13
// GNU General Public License for more details.
 
14
// 
 
15
// You should have received a copy of the GNU General Public License
 
16
// along with this program; if not, write to the Free Software
 
17
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
 
18
// ------------------------------------------------------------------------
 
19
 
 
20
#include "audio-stamp.h"
 
21
 
 
22
AUDIO_STAMP::AUDIO_STAMP(void) 
 
23
  : id_rep(0),
 
24
    id_set_rep(false) { }
 
25
 
 
26
int AUDIO_STAMP::id(void) const { return(id_rep); }
 
27
 
 
28
void AUDIO_STAMP::set_id(int n) {
 
29
  id_rep = n;
 
30
  id_set_rep = true;
 
31
}
 
32
 
 
33
void AUDIO_STAMP::store(const SAMPLE_BUFFER* x) {
 
34
  buffer_rep.length_in_samples(x->length_in_samples());
 
35
  buffer_rep.number_of_channels(x->number_of_channels());
 
36
  buffer_rep.copy(*x);
 
37
}
 
38
 
 
39
void AUDIO_STAMP::fetch_stamp(SAMPLE_BUFFER* x) {
 
40
  x->length_in_samples(buffer_rep.length_in_samples());
 
41
  x->number_of_channels(buffer_rep.number_of_channels());
 
42
  x->copy(buffer_rep);
 
43
}
 
44
 
 
45
void AUDIO_STAMP_SERVER::register_stamp(AUDIO_STAMP* stamp) {
 
46
  stamp_map_rep[stamp->id()] = stamp;
 
47
}
 
48
 
 
49
void AUDIO_STAMP_SERVER::fetch_stamp(int id, SAMPLE_BUFFER* x) {
 
50
  if (stamp_map_rep.find(id) == stamp_map_rep.end()) {
 
51
    x->make_silent();
 
52
    // std::cerr << "(as-server) Making silent!" << std::endl;
 
53
  }
 
54
  else {
 
55
    AUDIO_STAMP* p = stamp_map_rep[id];
 
56
    p->fetch_stamp(x);
 
57
//      cerr << "(as-server) fetch stamp from id " << p->id() << "." << endl;
 
58
  }
 
59
}
 
60
 
 
61
AUDIO_STAMP_CLIENT::AUDIO_STAMP_CLIENT(void) 
 
62
  : id_rep(0),
 
63
    id_set_rep(false),
 
64
    server_repp(0) { }
 
65
 
 
66
int AUDIO_STAMP_CLIENT::id(void) const { return(id_rep); }
 
67
 
 
68
void AUDIO_STAMP_CLIENT::set_id(int n) {
 
69
  id_rep = n;
 
70
  id_set_rep = true;
 
71
}
 
72
 
 
73
void AUDIO_STAMP_CLIENT::fetch_stamp(SAMPLE_BUFFER* x) {
 
74
  if (server_repp != 0) {
 
75
    server_repp->fetch_stamp(id(), x);
 
76
//      cerr << "(as-client) fetch stamp id " << id() << "." << endl;
 
77
  }
 
78
  else {
 
79
//      cerr << "(as-client) Making silent!" << endl;
 
80
    x->make_silent();
 
81
  }
 
82
}
 
83
 
 
84
void AUDIO_STAMP_CLIENT::register_server(AUDIO_STAMP_SERVER* server) {
 
85
  server_repp = server;
 
86
}