Debian Codegraph @

include/engine/worker.h

raw symbols SCIP
1 /* fre:ac - free audio converter
2 * Copyright (C) 2001-2021 Robert Kausch <[email protected]>
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation, either version 2 of
7 * the License, or (at your option) any later version.
8 *
9 * THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
10 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
11 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. */
12
13 #ifndef H_FREAC_CONVERT_WORKER
14 #define H_FREAC_CONVERT_WORKER
15
16 #include <smooth.h>
17 #include <boca.h>
18
19 #include "converter.h"
20
21 namespace freac
22 {
23 class Decoder;
24 class Verifier;
25 class Processor;
26 class Encoder;
27
28 class ConvertWorker : public Threads::Thread
29 {
30 protected:
31 const BoCA::Config *configuration;
32
33 Int conversionID;
34
35 String logName;
36
37 Int numThreads;
38
39 BoCA::Track trackToConvert;
40 UnsignedInt64 trackStartTicks;
41 Int64 trackPosition;
42
43 String decoderName;
44 String encoderName;
45 ConversionStep conversionStep;
46
47 Bool idle;
48 Bool waiting;
49 Bool error;
50
51 Bool pause;
52 Bool cancel;
53 Bool quit;
54
55 Threads::Semaphore workSignal;
56
57 Int Perform();
58 Int64 Loop(Decoder *, Verifier *, BoCA::FormatConverter *, Processor *, Encoder *);
59
60 Void VerifyInput(const String &, Verifier *);
61
62 Void LogConversionStart(Decoder *, const String &, const String & = NIL, Bool = False) const;
63 Void LogConversionEnd(const String &, Int64, UnsignedInt32, const String &, const String &);
64
65 virtual Int Convert();
66 public:
67 ConvertWorker(const BoCA::Config *, Int);
68 virtual ~ConvertWorker();
69
70 Int Pause(Bool);
71 Int Cancel();
72 Int Quit();
73 accessors:
74 Bool IsIdle() { return Threads::Access::Value(idle); }
75 Bool IsWaiting() { return Threads::Access::Value(waiting); }
76 Bool IsError() { return Threads::Access::Value(error); }
77
78 Void SetLogName(const String &nLogName) { logName = nLogName; }
79
80 Void SetNumberOfThreads(Int nNumThreads) { numThreads = nNumThreads; }
81
82 const BoCA::Track &GetTrackToConvert() const { return trackToConvert; }
83 Void SetTrackToConvert(const BoCA::Track &);
84
85 const String &GetDecoderName() const { return decoderName; }
86 const String &GetEncoderName() const { return encoderName; }
87 ConversionStep GetConversionStep() const { return conversionStep; }
88
89 UnsignedInt64 GetTrackStartTicks() const { return trackStartTicks; }
90 Int64 GetTrackPosition() const { return trackPosition; }
91 signals:
92 Signal2<Void, const BoCA::Track &, Bool> onFinishTrack;
93 Signal2<Void, const BoCA::Track &,
94 const BoCA::Track &> onFixTotalSamples;
95
96 Signal1<Void, const String &> onReportError;
97 Signal1<Void, const String &> onReportWarning;
98 };
99 };
100
101 #endif