Skip to content

Commit 52c7f0c

Browse files
committed
Metadata: bool begin()
1 parent a3fffa3 commit 52c7f0c

File tree

4 files changed

+24
-10
lines changed

4 files changed

+24
-10
lines changed

src/AudioTools/CoreAudio/AudioMetaData/AbstractMetaData.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class AbstractMetaData {
3838
// defines the callback which provides the metadata information
3939
virtual void setCallback(void (*fn)(MetaDataType info, const char* str, int len)) = 0 ;
4040
// starts the processing
41-
virtual void begin() = 0;
41+
virtual bool begin() = 0;
4242
// ends the processing
4343
virtual void end() = 0;
4444
// provide audio data which contains the metadata to be extracted

src/AudioTools/CoreAudio/AudioMetaData/MetaDataICY.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,10 @@ class MetaDataICY : public AbstractMetaData {
5454
}
5555

5656
/// Resets all counters and restarts the prcessing
57-
virtual void begin() override {
57+
virtual bool begin() override {
5858
clear();
5959
LOGI("mp3_blocksize: %d", mp3_blocksize);
60+
return true;
6061
}
6162

6263
/// Resets all counters and restarts the prcessing

src/AudioTools/CoreAudio/AudioMetaData/MetaDataID3.h

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -119,11 +119,12 @@ class MetaDataID3V1 : public MetaDataID3Base {
119119
MetaDataID3V1() = default;
120120

121121
/// (re)starts the processing
122-
void begin() {
122+
bool begin() {
123123
end();
124124
status = TagNotFound;
125125
use_bytes_of_next_write = 0;
126126
memset(tag_str, 0, 5);
127+
return true;
127128
}
128129

129130
/// Ends the processing and releases the memory
@@ -340,13 +341,14 @@ class MetaDataID3V2 : public MetaDataID3Base {
340341
MetaDataID3V2() = default;
341342

342343
/// (re)starts the processing
343-
void begin() {
344+
bool begin() {
344345
status = TagNotFound;
345346
use_bytes_of_next_write = 0;
346347
actual_tag = nullptr;
347348
tag_active = false;
348349
tag_processed = false;
349350
result.resize(result_size);
351+
return true;
350352
}
351353

352354
/// Ends the processing and releases the memory
@@ -582,10 +584,11 @@ class MetaDataID3 : public AbstractMetaData {
582584
this->filter = sel;
583585
}
584586

585-
void begin() {
587+
bool begin() {
586588
TRACEI();
587-
id3v1.begin();
588-
id3v2.begin();
589+
if (!id3v1.begin()) return false;
590+
if (!id3v2.begin()) return false;
591+
return true;
589592
}
590593

591594
void end() {

src/AudioTools/CoreAudio/AudioPlayer.h

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,19 @@ class AudioPlayer : public AudioInfoSupport, public VolumeSupport {
164164

165165
// start dependent objects
166166
out_decoding.begin();
167-
p_source->begin();
168-
meta_out.begin();
169-
volume_out.begin();
167+
168+
if (!p_source->begin()){
169+
LOGE("Could not start audio source");
170+
return false;
171+
}
172+
if (!meta_out.begin()){
173+
LOGE("Could not start metadata output");
174+
return false;
175+
}
176+
if (!volume_out.begin()){
177+
LOGE("Could not start volume control");
178+
return false;
179+
}
170180

171181
if (index >= 0) {
172182
setStream(p_source->selectStream(index));

0 commit comments

Comments
 (0)